Category : django

I have 2 Lists of dictionaries, example below: list one = [ {‘day’: ‘2021-09-05 00:00:00+02:00’, ‘airtime_total_for_day’: ‘650.00’, ‘data_total_for_day’: ‘0’}, {‘day’: ‘2021-09-16 00:00:00+02:00’, ‘airtime_total_for_day’: ‘124.20’, ‘data_total_for_day’: ‘20.00’}, ] list_two = [ {‘day’: ‘2021-09-10 00:00:00+02:00’, ‘data_bundle_total_for_day’: ‘100.00’}, {‘day’: ‘2021-09-16 00:00:00+02:00’, ‘data_bundle_total_for_day’: ‘50.00’}, {‘day’: ‘2021-09-18 00:00:00+02:00’, ‘data_bundle_total_for_day’: ‘45.00’}, ] I would like to merge the two lists together ..

Read more

i have two models : 1—– class Account(AbstractBaseUser, PermissionsMixin): email = models.EmailField(unique=True) name = models.CharField(max_length=150) phone = models.CharField(max_length=50) picture = models.ImageField(blank=True, null=True , upload_to=’profile’ ) profession = models.ManyToManyField(Profession) 2—– class Profession(models.Model): profession = models.CharField(max_length=50) i want to display all the profession that i have and in the same time i want to display the number ..

Read more

Trying to load static files but it is showing following error. ERROR GET http://127.0.0.1:8000/static/css/user/style.css net::ERR_ABORTED 404 (Not Found) – home:25 GET http://127.0.0.1:8000/static/css/user/style.css 404 (Not Found) – home:25 GET http://127.0.0.1:8000/static/img/logo.png 404 (Not Found) – home:149 GET http://127.0.0.1:8000/static/img/logo.png 404 (Not Found) – home:1 Click here to see error image. CODE -ADMIN settings.py STATIC_URL = ‘/static/’ STATIC_ROOT = ..

Read more

I currently have an app that generates financial documents based on user-set settings These settings look something like this: Trial Balance ☐ Use main accounts ☐ Include Opening Balances ☐ Print Null Values ☐ Print Account Number All these settings are boolean variables and can easily be checked with if UseMainAccount == True : However, ..

Read more

Trying to loop over a many to many relationship where I want all the fields. My Models: class Recipe(models.Model): title = models.CharField(max_length=200) slug = AutoSlugField(populate_from="title") category = models.ForeignKey(RecipeTopic, on_delete=models.CASCADE) image = models.ImageField() description = models.TextField() ingredients = models.ManyToManyField(Ingredient, through="IngredientList") directions = models.TextField() servings = models.IntegerField() time = models.IntegerField() cuisine = models.ForeignKey(Cuisine, on_delete=models.CASCADE) def __str__(self): return ..

Read more

I’m working on a form where few field inputs depend on each other. I implemented custom validation and added error messages to it but, although custom validation works, error messages don’t get shown in templates. form.py class NewCalculationForm(forms.ModelForm): def clean(self): cleaned_data = super(NewCalculationForm, self).clean() if self.cleaned_data.get(‘Tsrcin’) <= self.cleaned_data.get(‘Tsrcout’): raise forms.ValidationError({"Tsrcout": "Source outlet temperature has to ..

Read more