All Questions
Tagged with django django-models
41,804
questions
1
vote
0
answers
19
views
Custom email validation in django form
In my django Account app I have a model for Account
class Account(AbstractBaseUser):
wallet_value = models.DecimalField(max_digits=10, decimal_places=2, default=0.00)
first_name = models....
0
votes
0
answers
12
views
Django errorlist in form Select Valid Choice
The situation is as follows: I am building a form where I fetch data for some fields from an API. I have tried debugging in every possible way, but I cannot understand why the data is not being ...
1
vote
2
answers
24
views
How to make Django to increase a field by db value?
For example, I have model:
class CacheMetaData(models.Model):
count = models.IntegerField(default=0)
def inc(self):
self.count += 1
self.save()
If I define method inc() like above, then ...
0
votes
0
answers
29
views
Django REST framework serializer.is_valid() saves files to MEDIA_ROOT although .is_valid() is False
I have a project which supports file uploads via Django forms and also Django REST framework, these files are used are stored in a model 'Document'. The issue is that when a file that fails validation ...
0
votes
2
answers
22
views
forms.ModelMultipleChoiceField with widget=FilteredSelectMultiple not working on custom new Django Admin
I am trying to show the forms.ModelMultipleChoiceField on custom new admin form page but it doesn't seem to show it the way it is showing on the Django page that was already made e.g. model product ...
0
votes
1
answer
14
views
Django Profile Page Not Displaying Related Worker Information with Djoser
I'm working on a Django application where users can be either normal app users or workers with additional details. I'm using Djoser for user authentication and registration. I'm having trouble with my ...
1
vote
1
answer
37
views
prefetch_related within model method
So I have a Django model which is a foreign key for several other models. I want to add a method to my model and see if my instance of the model actually has any related objects. Two questions:
I'd ...
0
votes
1
answer
23
views
How can I have a different method instead of user.is_authenticated? [duplicate]
I have an academy website , which has 3 different kinds of users. The first one is the staff that I handle with the admin panel. The second one is parents or people who are going to get some ...
0
votes
1
answer
16
views
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'api.User' that has not been installed
I just create Django project and get this error
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'api.User' that has not been installed
this my files
settings
...
-1
votes
0
answers
67
views
Django for loop not working in HTML in Django 4.2
HELP: There is some issue with for loop in my code. I cannot find the problem. This problem is not displaying data from backend. Can you help me with it? Whole code and process is given below.
Models:
...
-1
votes
0
answers
30
views
How to remove all clear Django_migrations table WITHOUT losing out on any data in PROD?
Very mainstream problem :-
I've a production database in postgres that's connected with my django projects which has multiple apps.
I've 2 aspects to look at :-
2.1. I need to delete the migrations ...
0
votes
1
answer
19
views
Filtered reverse of a one to many relation in Django
I have a model called Item and another called ItemSynonym with a one to many relation like so:
from django.db import models
from django.conf import settings
from project.utils.models import UUIDModel ...
0
votes
0
answers
28
views
ValueError:The field admin.LogEntry.user was declared with a lazy reference to 'recipes.customuser',but app'recipes'doesn't provide model 'customuser'
This is the Custom user model
I also declared in settings
AUTH_USER_MODEL="recipes.CustomUser"
still I face this error
ValueError:The field admin.LogEntry.user was declared with a lazy ...
0
votes
1
answer
25
views
Resize readonly fields in Django Admi
In my Django admin im currently displaying JSONField as readonly, the JSON data is quite large and takes up about 80-90% of the page. I was able to find an answer for how one might resize a not ...
0
votes
1
answer
54
views
How to write a Case() SQL expression with an aggregated field (Sum) using Django's query builder
I am trying to recreate this SQL statement using Django's query builder:
CASE
WHEN sum(imps) = 0 THEN NULL
ELSE SUM(total_expenses) / (sum(imps) / 1000)
END as "cpm"
I have tried:
...