Questions tagged [django-models]
For questions concerning use of the model class from the web framework Django.
django-models
43,827
questions
-1
votes
0
answers
22
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
14
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
19
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
20
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
43
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:
...
1
vote
0
answers
41
views
Postgresql SELECT optimisation into Django ORM [closed]
Please see below a PostgreSQL SELECT statement. This presently returns around 300k rows, which is the grouped result of several million underlying rows. The dataset is only going to get larger. Using ...
0
votes
0
answers
20
views
How to access set of objects in reverse Foreign Key in Django
I have 2 tables defined like this:
class Optimization(BaseModel):
name = models.TextField(unique=True, null=False)
is_active = models.BooleanField(null=False, default=True)
class Meta:
...
1
vote
1
answer
16
views
models.ManyToManyField Necessity
I can't understand, what benefits we get when adding models.ManyToManyField if using intermediary model? Is it necessary?
I want to use base (not custom) user model in my project. Should I redefine ...
0
votes
1
answer
26
views
custom delete action admin class in django
I want to custom delete action admin class with overwrite function delete in admin.py , but it dosn't work !
this is the error : Post with ID “<django.db.models.query_utils.DeferredAttribute object ...
0
votes
1
answer
14
views
Adding a filter to a Django Module
I'm working in a Django project. I've created a model to save the last 50 errors that happen.
models.py
class Error(models.Model):
ERROR_TYPE_CHOICES = [
('ERROR', 'ERROR'),
('...
0
votes
0
answers
30
views
Introducing custom-role in my Django based E-commerce application
I completed finish my Django E-commerce web-application. And now I want to add the facility of customer roles(admin,staff,merchant,customer). I'm having problems configuring this with my project. I'd ...
0
votes
1
answer
45
views
How to Avoid Duplicate Validation When Creating Django Model Instances Manually and via Forms?
When I create new instances using forms, I know that calling is_valid on the form automatically runs the full_clean method for validation. After that, I just call save on the form.
But when I create ...
0
votes
0
answers
14
views
Enter a valid date. at BC/AD field in django framework
In Django framework with PostgreSql I need to store BC date.
So, Here is the code I'm using:
class BCEDateField(models.DateField):
def __init__(self, *args, **kwargs):
super().__init__(*...
1
vote
1
answer
25
views
DRF error serializing many to many relation
The error occurs after inserting the DetallePedido record, the serializer is looking for the fields 'producto' and 'cantidad'. And it receives a Producto object and an integer (cantidad) and it is ...
1
vote
0
answers
30
views
how to use a foreingkey field in a Multi-table inheritance?
Currently the code is working for me, however in admin panel it is not displaying the information in the fields. I assumed that the information that had been entered in the parent table would be seen ...