Category "django"

How to add data to ManyToMany field using Django Rest Framework?

I'm relatively new to DJango and I am looking to add data to a many-to-many field using serializers from rest framework. My Model: class IngFamily(models.Mode

How to debug Django custom management command using VS Code

I am trying to debug a custom management command using Visual Studio Code. For this I have gone through the official VS Code tutorials for working with Python

How do I use django rest framework to send a file in response?

I need to send a pdf file and some other parameters in response to a get API call using django rest framework. How can I do it? I tried this but it gives an er

OperationalError in Django app: models.py

There's an OperationalError in my models.py code. Can anyone pinpoint the problem? I have tried deleting the cache (along with previous migrations) and doing th

How can I make a Django REST framework /me/ call?

Suppose I have a ViewSet: class ProfileViewSet(viewsets.ModelViewSet): """ API endpoint that allows a user's profile to be viewed or edited. """

AssertionError: database connection isn't set to UTC

I have done server setup multiple times with the same settings but this time, I am seeing the error message. It is not even allowing to migrate the database. Sy

Django ModelTranslation

Hello guys i need a help for translating models values. I use django-modeltranslation package. I have managed to register my models. class Institution(models.Mo

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 media files not showing with Debug = False on production - Django 1.10

I currently have two kind of files static files and media files.The static files contain my css,js and other static content. The media files contain stuff that

django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')

My model: class Course(models.Model): language = models.ForeignKey(Language) name = models.CharField(max_length=50, unique=True, default='course')

how to pass extra custom attribute in Django template from "select option" form to a view

I have an html form include a select input in Django template, and the option has an extra attribute value called "testvalue". I want to pass the "testvalue" at

Only accept 2 digits integer array in django model form

How to make a form field that accept 2 digit numeric array in frontend. if someone enter more then 2 digit or string then The input value is automatically valid

How to stop the Django development server on windows

I found here answers how to stop the Django Server on Linux but not on windows. Do I really need to restart my machine ?

Django - How to delete a object directly from a button in a table

(sorry for my bad english) I need to delete an object, but directly from a list of the objects that y have in my template. I have a work orders, that have spa

Django DEBUG=False won't upload files to STATIC_ROOT

I'm trying to give the user the ability to upload images on a website I created with Django and the images are uploaded fine when running with DEBIG=True but th

ValueError: Missing staticfiles manifest entry for 'favicon.ico'

I'm getting a ValueError when running python manage.py test. My project is named fellow_go, and I'm currently working on an App called pickup. Please note that

Limit Django users to one single group

I'm rather surprised that this hasn't been asked before, but I need to limit my Users in Django to only belong to one single Group. How would I do this?

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

Can't import rest_framework in Django

I'm trying to stand up a Django site and I am attempting to setup Report_builder with that. I just got the front end of report builder to work but it is not ret