Category "django-models"

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

django manytomany - get value from through

I have a manytomany field between 2 models: class userProfile(models.Model): boughtCoupons = models.ManyToManyField(Coupon, through='UserCoupons') class U

How to make a query on related_name field?

I have to models connected by a ForeignKey class User(AbstractUser): ... and class PrivateMessage(models.Model): user_from = models.ForeignKey(

Create several instances out of a related model in Django

In university as a part of a project we have to develop a liga system with Django. I have my basic app running and also my models are already set up. from djang

How to get the objects from child model to a django template?

I have created child ('Bid') model related to a parent(Post) model in my Django project. I also created a BidForm which I have added in my B_Bid.view so that ty

Can I make a django model object immutable?

There are places in my code where I want to temporarily change some of the attributes on a model object without changing the data in the database. Obviously Dja

Django Rest framework, how to include '__all__' fields and a related field in ModelSerializer ?

I have two models, one with M2M relation and a related name. I want to include all fields in the serializer and the related field. models.py: class Pizza(mode