Skip to content
Advertisement

Tag: django-models

Date filter binned data

I have a model in django that contains a start and end date for a financial year and a value for demand volume. I would like to filter this data on a given date range that may not coincide with the date ranges of the data, taking a proportion of the demand from each data point that may fall somewhere

Django is_active field is not changing

I’m using django 4.0 when i change the is_active to False from django admin, it doesn’t make any changes to the object, I have override the save method in models. models.py admin.py Can anyone advise ? The problem started when i added the save() in models.py Answer The .save() method should always call the super method, regardless whether pk is

Django upload multiple images per post

I want to let the user upload multiple images per post. Similarly to an e-commerce platform with multiple images per product. But till now the images are not sent to the database. That’s my code so far: models.py: forms.py: views.py: project_form.html: settings.py: project urls.py app urls.py Answer Issue: You have made ProjectForm which relates to Project model, but the image

django FieldError: Cannot resolve keyword ‘category_name_contains’ into field. Choices are: category, description, id, image, name, order, price

I want to build a food delivering app, but facing this error. “FieldError: Cannot resolve keyword ‘category_name_contains’ into field. Choices are: catego ry, description, id, image, name, order, price”. This is the query.py: This is the views.py This is my models.py: Here’s the traceback: So this my problem I have tried many solutions still not getting the problem here. As

type object ‘PizzaMenu’ has no attribute ‘_default_manager’

I have following error while i try to reach PizzaDetailView on template: AttributeError at /pizza/6/ type object ‘PizzaMenu’ has no attribute ‘_default_manager’. Where is the problem? models.py views.py urls.py Answer Don’t name your view PizzaMenu, it will override the reference to the PizzaMenu for the other views. Usually class-based views have a …View suffix, so:

Change boolean data when adding new registration

In this piece of code l want to change the boolean data of room when adding new registration For example: when l add new registration in django admin the boolean data of room should change to False Answer You should use Django’s signals for that. Just create signals.py in your app’s folder and do that: and add to your apps.py

Advertisement