Category "django"

How can I show the StringRelatedField instead of the Primary Key while still being able to write-to that field using Django Rest Framework?

Models: class CrewMember(models.Model): DEPARTMENT_CHOICES = [ ("deck", "Deck"), ("engineering", "Engineering"), ("interior", "Inte

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding, when trying to start uwsgi

I am trying to start my uwsgi server in my virtual environment, but after I added plugin python3 option I get this error every time: !!! Python Home is not a di

django errno 104 Connection reset by peer

I am trying to run my django server on an Ubuntu instance on AWS EC2. I am using gunicorn to run the server like this : gunicorn --workers 4 --bind 127.0.0.1:8

Django is not sending e-mails

guys! I have an issue with my Django project. About project: Django version: 3.0.7 Django hosting provider: Digitalocean E-mail hosting provider: Beget.com OS:

Django Nested Inline Formsets to Populate Multilevel Nested Form

I'm trying to solve a problem. I have a model hierarchy like this: class Task(models.Model): name = models.CharField(max_length=255) number_of_steps = m

django update_or_create gets "duplicate key value violates unique constraint "

Maybe I misunderstand the purpose of Django's update_or_create Model method. Here is my Model: from django.db import models import datetime from vc.models imp

Django model doesn't get saved to database inside Celery Task

I've hit a really nasty situation. I have the following setup. I have a django model representing an FSM with a django FSM field I have a celery task that sen

What's the difference between staff, admin, superuser in django?

Django has superuser, staff, admin… superuser and staff are in django.contib.auth.models.UserManager. Then there is the createsuperuser command of djan

Django 3.2+: implementing case-sensitive string comparisons within MySQL tables

Django documentation (3.2 to 4.0) states: In MySQL, a database table’s collation determines whether string comparisons (such as the expression and substr

ModelSerializer field validation for empty string

I'm having a problem with django rest framework. My front is posting data to drf, and one of the fields could be null or an empty string "". # models.py class

Django channels testing with HttpCommunicator

I have a DRF application, which also has a single websocket consumer Now I'm trying to make a test case, which inherits from a Djano 3.1 TestCase. Said test cas

Image Not displaying in django getting 404 error

I followed official django documentation for image field.I am able to store the image in the database but when I try to display it in browser I am getting 404 e

VSCode breaks Django template tags with newline

Problem: {% extends 'base.html' %} {% block title %} Dashboard {% endblock %} {% block pagetitle %} becomes {% extends 'base.html' %} {% block title %} Dashboa

Python Django Web application not able to deploy on Heroku using Waitress server

I have tried to deployed my django application several times on Heroku and then i finally succeeded . It is working fine on localhost ,however, when i use the l

Reverse for `view` with arguments '('',)' not found. 1 pattern(s) tried: `[u'bms/update/(?P<id>[0-9]+)/$']`

This is my update view which I'm using to get pre-populated form. Although this is also not working. def update(request, id): item = get_object_or_404(Book

how can i make the field looks mandatory using HTML and CSS

I want to make a field mandatory but the *required in red color is coming below the field name which i want just beside to field name here is the HTML code &l

Django: list all reverse relations of a model

I would like my django application to serve a list of any model's fields (this will help the GUI build itself). Imagine the classes (ignore the fact that all f

Django pagination - nice urls

I did pagination in my django projet. Everything works just perfect, but my urls looks terrible, like host:8000/?page=1 How to create nice urls like host

Default value for foreign key in Django migrations.AddField

Using migrations, I need to add a new field (a foreign key) to a model. I know it can be done with: migrations.AddField( model_name='MyModel',

Register custom user model with admin auth

In a Django project, I have a custom user model that adds one extra field: class User(AbstractUser): company = models.ForeignKey(Company, null=True, blank