Category "django-models"

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):

How to get a model's last access date in Django?

I'm building a Django application, and in it I would like to track whenever a particular model was last accessed. I'm opting for this in order to build a user

'NOT NULL constraint failed' after adding to models.py

I'm using userena and after adding the following line to my models.py zipcode = models.IntegerField(_('zipcode'), max_length

Django CheckConstraint: Elements of reverse ForeignKey lookup must not be empty

I've got these models: class Container(models.Model): ... class Meta: constraints = [ models.CheckConstraint( chec

How to change the validation error color and position in Django?

I am new to Django. I am trying to make a simple form to match the password. However, when I enter different passwords and press the Save button I get a black v

Django-admin: show multi select field for JSONField

I have a model with a field channel (JSONField). I'm strong an array of string in db with channel. By default, a JSONField is shown as a textarea in django-admi

Does Django cache related ForeignKey and ManyToManyField fields once they're accessed?

Given the following model, does Django cache the related objects after the first time they're accessed? class Post(models.Model): authors = models.ManyToMa

How to add custom views or overide views for Django Admin index?

urls.py -> ''''from django.contrib import admin from django.urls import path from Administrator import views admin.site.index_template = 'admi