Category "django-models"

Django form with dropdown list using Database returns empty fields

I'm discovering Django and I'm trying to develop a simple application. I have three tables in my database : One big table to report all the information to users

in Django : Why nothing happens when I try to Create new note with the html form in the notes.html page

I've just started my first app with Django by following a video on YouTube. The app is a students dashboard with 8 tools and features to help the student to mak

How to separate tables based on the model using FSM and FSM-Log?

I'm currently logging status changes to several models in my Django REST API using the django-fsm and django-fsm-log packages. However, all of the logs are stor

Django: How to run a celery task only on start up?

I have a django app that uses celery to run tasks. Sometimes, I have a "hard shutdown" and a bunch of models aren't cleaned up. I created a task called clean_up

django create a field that hold array of tupels or array of array

I want to add a field in my models that hold value like this field = [(1,2,3),(6,5,4),(5,6,7)] or field = [[1,2,3],[6,5,4],[5,6,7]] I am using po

Optimize Django generated SQL query

I have the these models: class Person(models.Model): firstname = models.CharField(max_length=20) lastname = models.CharField(max_length=20, blank=True,

how to display models.full_clean() ValidationError in django admin?

https://docs.djangoproject.com/en/4.0/ref/models/instances/#validating-objects from django.core.exceptions import ValidationError try: article.full_clean()

Need to override save method for image field and save it as base64 string using django

models.py class Organisation(models.Model): org_id = models.CharField(max_length=50,default=uuid.uuid4, editable=False, unique=True, primary_key=True)

Selectively hit the update signal for a model

I have a model called as nodes: class node(models.Model): name = models.CharField(max_length=200) status = models.CharField( max_length=32,

Django Queryset with multiple joins and filtering

I need a list of jobs joined with houses joined with owners Results row should contain: job_id, job_worker_role1, job_worker_role2, job_worker_role3, house_id,

Getting Django migration error "sequence must have same owner as table it is linked to", but all tables and sequences have the same owner

I'm trying to run a migration in a Django project. (Django 3.1, Python 3.9.9) I'm in my virtual environment. I keep getting a puzzling error. python manage.py

Django models in admin return TypeError: bad operand type for unary -: 'str'

I'm working on a project using Django(3) and Python(3) in which I have added few models and added those models in admin.py, but when I open the admin panel and

How to prevent N+1 queries when fetching ancestors with Django Treebeard?

We are using Django Treebeard's materialized path to model an organizational hierarchy as follows: Now each node in the organizational tree can have multiple t

Is there a Django library that automatically display local currency based on a visitors country IP address

I'm trying to integrate a functionality on an Ecommerce website in Django, Where visitors are automatically shown local currency base on their country IP addres

Django says that model has no ForeignKey to another model but it really does

Will you help me to figure out why Django raises this error? SolutionsForLanguagesApp.LanguageLevel: (fields.E336) The model is used as an in termediate

I would like to run for loop to each of li tag and want to add content dynamically from django backend admin

I have created a navbar and content can be added from the backend but only the home nav bar shows the icon and the other navbar name is with the same icon. I wa

Configuring PostgreSQL schema for default Django DB working with PgBouncer connection pool

I need to set the default DB schema for a Django project, so that all tables of all apps (including 3rd party apps) store their tables in the configured Postgre

How to print multiple object from table def __str__(self):return self.title

I created a article models below models.py class Article(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True) is_deleted

Detect when user register/Login on Context Proccessor Django

I have to do some checks all the time with the context proccessor.The value must be 'True' as soon as the user logs in.But when navigating the site after loggin

How can we add more than 3 authors field for a single magzine? in Django models

I created a magzine model in django. But their are more than three authors of a magzine. I have written below code for three authors. If I write the code of two