Category "django-models"

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

How to fix " TypeError: post_details() got an unexpected keyword argument 'slug' "

I'm creating my blog with django, and trying to make posts urls in slug way, after I created the models and called it in views it showed me this error: [TypeErr

Need to do POST method for the Nested serializers using django

models.py class Organisation(models.Model): """ Organisation model """ org_id = models.AutoField(unique=True, primary_key=True) org_name = m

How can I display data from django model and save at the same time using class based views?

I am creating a quiz app using Django. The requirements are: I need to first display all the topics available for the quiz on the homepage. Clicking on a partic

TypeError: 'BasePermissionMetaclass' object is not iterable in django rest framework

i looked at other questions regarding this issue and their problems were in the REST_FRAMEWORK = ... values in settings.py file . is there any error in mine ? I

how to make custom form without database - DJANGO

So i want to upload file but only sent to locals storage NOT DATABASE too. But i don't know how to make custom forms. suddenly, here's my models.py : from djang

TypeError: SET_NULL() missing 4 required positional arguments: 'collector', 'field', 'sub_objs', and 'using'

How do i solve the above error which shows up not during the makemigrations but during migrate in Django. class Comment(models.Model): #comment_id=models.I

How to filter in a table column contains list in django

I have a table column A=['1','2','3'] and I want filter from the table if the filter value is exist in the list. eg: id='1' Models.objects.filter(A=id)

Create model with a link to static-file when created

I have a model class myModel(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete = models.CASCADE,null=True) start_price = model

In django after deleting the posts the post images are still in the directory

In django my posts are deleted but the files are not. I have a image field in the model which i want to deelete whenever the author deletes it. I'm using generi

Unit Testing Django Model Save Function

I'm creating tests to check that a custom calibration model save function updates an asset record (foreign key) if it is the latest calibration record for the a

file extentions in Django

I have created a file upload website where I want to allow users to upload files in pdf, ppt, doc, txt, and zip format. I am using the HTML form to upload files

django.db.utils.IntegrityError: NOT NULL constraint failed after reseting migrations

I need to save an object that contains a file and some other data. Although the file is stored on the /media folder, the entity is not saved in the database sin

Django How to Upload an Image to Form

This is my code associated with the form: # models class Date(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, null=True) place

Serializing reverse relationship of a ForeignKey with a DRF ModelSerializer

I'm trying to generate a data structure following this sample: [ { "name": "groupname", "key": "grouping1", "base_templates": [ { "i

button function doesn't work without any error - django

So i want to make models form to upload file mp3. I was copy the code from website, but suddenly it's not work. there's no error message in terminal or console

Django: How to enforce UniqueConstraint with parent and child models

Say I have the following models: class ParentModel(models.Model): parent_field_1 = models.CharField(max_length=10) parent_field_2 = models.CharField(max