Category "django-models"

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

What does "IntegrityError. NOT NULL constraint failed: blog_comment.post_id " stands for?

I've added a Comment model to my application, but when the form is submitted, this error pops: NOT NULL constraint failed: blog_comment.post_id Here's models

psycopg2 installing error in cPanel while hosting Django Website with PostgreSQL

Collecting psycopg2 Using cached psycopg2-2.9.3.tar.gz (380 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup

How to display Foreign key Data in Django view page?

i have relation between Project and ProjectFloorPlan, and i want to display ProjectFloorPlan data in my template. Please let me know how i can display the Forei

How to display Foreign key Data in Django view page?

i have relation between Project and ProjectFloorPlan, and i want to display ProjectFloorPlan data in my template. Please let me know how i can display the Forei