Category "django-models"

Django dumpdata serializing an int as string

I've been trying to make a custom class/type, defined in a separate db.py file, to be properly serialized as an int when doing a manage.py dumpdata command, but

The response content must be rendered before it can be iterated over. Django Rest Framework

I have a Cart model and Cartserializers. I am trying to do that is if cart defects exist in the cart and then update the cart by increasing the quantity of cart

How to get foreign key detailed values based on id in html template in django

In Models.py class Interview(models.Model): Current_Date = models.DateField(auto_now_add=True ) User = models.ForeignKey(User,

How to have multiple Auth models in django

I have an application where I've two models both models have same fields client buyer I'm using separate models because client can also signs up as a buyer usin

How to mention users using @ in django

I have been working on a project on django and it is very similar to instagram and twitter, one of the functions it needs to have is to mention users using "@"

ValueError: Field 'id' expected a number but got 'Abidjan'

Hello I'm new to django and I don't understand the following error: ValueError: Field 'id' expected a number but got 'Abidjan'. Here is the model code for more

Using CreateView with 2 Models at the same time

should I be building a function to achieve what I am trying to do?

When django load data to memory?

Lets have simple model: class NewModel(models.Model): json_data = models.JSONField(default=dict) Then lets get it: model = NewModel.objects.get(pk=1)

Django can't login the superuser in admin page

So , I am trying to make an register and login system . I want to customize it using the custom user model , where I can save my data and extend the model. I am

Django model default value in response

I want to have a default value in my django model response value Sample model query myModel.objects.filter().values("username", "user_gender") I want to have a

How to create a persigned url for a private s3 bucket using django rest framework

models.py def upload_org_logo(instance, filename): ts = calendar.timegm(time.gmtime()) filepath = f"Timesheet/org_logo/{ts}" if instance: b

Why does Django use `Meta` inner class in models?

If I want to describe some information such as ordering, if the model is proxy or abstract, which fields must be unique together, then I need to put this inform

Django throws AttributeError: 'str' object has no attribute '_meta' when I register my Model

Im novice and I didnt find solution for this problem. Im writing code for a blog. I have a model Post where I want to create field author which is ForeighKey to

Django Assigning or saving value to Foreign Key field

can any one help me with assigning value to a foreign key field. Im trying to create user profile where user can add there countries. when creating the models,

Any way to update a ManyToMany field via a queryset?

Suppose I have an object: survey = Survey.objects.all().first() and I want to create a relationship between it and a group of objects: respondents = Respond

How to restrict a Django model to a single one-to-one relation?

I am currently building a Django app that requires two different user types and I know that storing authentication information across multiple models/tables is

unique=True gives already exist! Even if interchanging the values of two objects

To display objects (members) in particular order, I have made a field, order: order = models.IntegerField(unique=True,null=True,blank=True) so that I can do an

from Model.AGCRNCell import AGCRNCell ModuleNotFoundError: No module named 'model'

I'm trying to replicate this model from here: https://github.com/Davidham3/ASTGCN/tree/master/model but when I try to run the model code in my colab import torc

Default value in Django Model

I have a model named "Product" and it has an attribute like price, quantity, and remarks. Thru the models.py, if remarks has a property of "null=True", it will

How to extract Data from Django Queryset

How to retrieve the data from Django queryset for use in a variable When an output is received in below form after running the query <QuerySet [{'name': 'J