Category "django-models"

Getting TypeError: __init__() missing 1 required positional argument: 'on_delete' when trying to add parent table after child table with entries

I have two classes in my sqlite database, a parent table named Categorie and the child table called Article. I created first the child table class and addes ent

Not able to migrate changes to mysql database from Django

I have added foreign keys to some of the models in a Django application but the changes are not being reflected in the MySQL database even after migrating them.

Django: ProtectedError exception handling is not working

I am trying to handle ProtectedError exception and try to post a custom error message in my template. def delete(self, request, *args, **kwargs): obj = sel

Forbidden (CSRF token missing or incorrect.): /

So i want to make models form to upload file mp3. I was copy the code from website, but suddenly it goes error. Here's error message on the website : Forbidden

Possible race condition between Django post_save signal and celery task

In a django 2.0 app I have a model, called Document, that uploads and saves an image to the file system. That part works. I am performing some facial recognitio

ManyToMany Relationship between two models in Django

I am trying to build a website that users can add the courses they are taking. I want to know how should I add the ManyToMany relationship. Such that we can ge

Model.clean() vs Model.clean_fields()

What is the difference between the Model.clean() method and the Model.clean_fields() method?. When should I use one or the other?. According to the Model.clean

I keep getting RelatedObjectDoesNotExist at /admin/login/. How do I successfully create user profiles in Django via a one to one relationship?

I'm trying to extend the built-in user and add some more information to it. I have two apps in my django project- general and user_details. Inside my user_detai

Django ValueError for deleted fields when running migrations

My models.py file is as follows: from django.db import models from django.utils import timezone from random import randint # Create your models here. class Fil

Nested Category In django

how do I use nested categories in django as Im nwe to django and doing this and find some solutions but didnt work anything class MainCategory(models.Model)

How to get django queryset results with formatted datetime field

I've Django model which has foreign keys associated with other models. Each model is having same field names(attributes) created_at and updated_at In every dja

Why should I set max_length when using Choices in a Django model?

In the official Django 2 tutorial I found this: from django.db import models class Student(models.Model): FRESHMAN = 'FR' SOPHOMORE = 'SO' JUNIOR

Understanding ManyToMany fields in Django with a through model

I'm having trouble understanding the use of ManyToMany models fields with a through model. I can easily achieve the same without the ManyToMany field. Consideri

How to upload multiple files in Django using Dropzone js?

Info: I want to upload multiple files using Dropzone js in Django project. I have two models. One for the Post and the other would be for the File. My files mod

Django model fields not appearing in admin

I have a relatively simple model in my Django project (I should note that the wording is weird in that the app itself is called 'games' and within it the model

'ProgrammingError: function avg(character varying) does not exist' - Django project

I have recently deployed a Django project to Heroku. While testing out the functionality in the browser, I've come across a new error when attempting to render

How to add username to the filefield?

I am making use of file fields in my model and I want it to be saved as username_field.jpeg (or whatever format it is in), for example for rent_agreement I want

Django 3.2: AttributeError: 'NoneType' object has no attribute 'attname'

I am working with Django 3.2, and have come across a problem that seems to have answers here and here also, and I have tried the solutions offered in the accept

This QueryDict instance is immutable

I have a Branch model with a foreign key to account (the owner of the branch): class Branch(SafeDeleteModel): _safedelete_policy = SOFT_DELETE_CASCADE

django.db.utils.IntegrityError: UNIQUE constraint failed: rango_category__new.slug

I'm learning Django from Tango with Django but I keep getting this error when I type: python manage.py makemigrations rango python manage.py migrate This is