Category "django-models"

How to upload multiple files in Django using Dropzone js?

Info: I want to upload multiple files using Dropzone js in Django project. I have two models. One for the Post and the other would be for the File. My files mod

Django model fields not appearing in admin

I have a relatively simple model in my Django project (I should note that the wording is weird in that the app itself is called 'games' and within it the model

'ProgrammingError: function avg(character varying) does not exist' - Django project

I have recently deployed a Django project to Heroku. While testing out the functionality in the browser, I've come across a new error when attempting to render

How to add username to the filefield?

I am making use of file fields in my model and I want it to be saved as username_field.jpeg (or whatever format it is in), for example for rent_agreement I want

Django 3.2: AttributeError: 'NoneType' object has no attribute 'attname'

I am working with Django 3.2, and have come across a problem that seems to have answers here and here also, and I have tried the solutions offered in the accept

This QueryDict instance is immutable

I have a Branch model with a foreign key to account (the owner of the branch): class Branch(SafeDeleteModel): _safedelete_policy = SOFT_DELETE_CASCADE

django.db.utils.IntegrityError: UNIQUE constraint failed: rango_category__new.slug

I'm learning Django from Tango with Django but I keep getting this error when I type: python manage.py makemigrations rango python manage.py migrate This is

Python(Django) :I want the payment form(code) triggered whenever a user clicks the submit button and only saved into DB if payment is succesful

I am currently using DJANGO How can I make the payment form(code) triggered when a user clickn submit and also make it saved into DB after successful payment. P

django permissions: new permission is inserted after all other migrations

I added a new permission to my model, and than used manage.py makemigrations. it created a migration that alters the model options (specificly the permisions..)

"Local variable referenced before assignment" Django error

I have no idea what may cause this issue. The only change I've made was add the loginquiredmixins to my class-based views. Once I started stylising the login pa

Add field to AbstractUser admin page

I have an AbstractUser class in models.py file in order to extend the django user default class, class Profile(AbstractUser): address = models.CharField('A

Create a save data using Django post_save() Signal

Here I want to create a heatmap when a Lead is created, it'll create an example api for the particular API. This is my lead model and another model for the api,

Django model validator not working on create

I have model with a field validator from django.db import models from django.core.validators import MinValueValidator, MaxValueValidator class MyModel(model.

Database relationship between a match and its players

I'm trying to design a database that would save matches and players in a 3v3 game. So far my models look like this : class Player(models.Model): user = mode

Django ORM returns non-iterable object

The model is class WeeklyStrMst(BaseModel): StoreId = models.AutoField(primary_key=True) TDLinx_No = models.IntegerField(blank=True, null=True, default=

Django models: dynamic inheritance from classes defined in standalone app

I am using Django 3.2 I have written a standalone app social that has models defined like this: from abc import abstractmethod class ActionableModel: # Th

django update_or_create gets "duplicate key value violates unique constraint "

Maybe I misunderstand the purpose of Django's update_or_create Model method. Here is my Model: from django.db import models import datetime from vc.models imp

Django 3.2+: implementing case-sensitive string comparisons within MySQL tables

Django documentation (3.2 to 4.0) states: In MySQL, a database table’s collation determines whether string comparisons (such as the expression and substr

Image Not displaying in django getting 404 error

I followed official django documentation for image field.I am able to store the image in the database but when I try to display it in browser I am getting 404 e

If "null=True", which is stored in DB "NULL" or "empty values"?

I created the django model "User" with "null=True" as shown below: # "myapp/models.py" from django.db import models class User(models.Model):