Category "django-models"

Django does not create foreign key in sqlite table [closed]

I use sqlite in a Django project. I created a model called Employee, and then Education, but I forgot to add a foreign key to Employee. When I

Django-How can I upload image to a Model, without that field being present in the ModelForm

I am trying to build an image steganography application and for the encoding part I have a form with two fields, one for image and one for the message that is t

find top performing list of category which have highest number of orders in django

models.py class Line_items(models.Model): id = models.AutoField(primary_key=True) product = models.ForeignKey('Products' , on_delete=models.DO_NOTHING ) cl

Django models - how to assign as ForeignKey

My lab has a models.py as below: class Book(models.Model): isbn = models.CharField(max_length=10, unique=True) name = models.CharField(max_length=100)

Is it possible to link multiple models to one fiel in django?

Let's say I have these models: class Material(models.Model): name = models.CharField([...]) class Consumable(models.Model): name = models.CharField([..

How can i filter parents that has at least one active child on parent child relationship model

I have "Category" model which has multiple parent/child relationship. class Category(models.Model): pass class CategoryParent(models.Model): parent_cat

Django Admin dependent DropDown HTML field

I have a Region and SubRegion ForeignKey in the Country Model. My SubRegion model also has a Region ForeignKey for the Region Model. I am having a hard time dis

How can i multiselect in django admin dropdown on foreignkey data just like manytomanyfield?

models.py from django.db import models class Images(models.Model): def upload_path(instance, filename): return '/images/'.join([filename]) im

InvalidCursorName : Django Admin error referencing wrong column in ForeignKey

I've setup a relationship using django's ForeignKey against 2 unmanaged tables like so: class Product(BaseModel): publish_name = models.CharField(unique=Tru

Separating files based on file extension?

I want to separate the files in my models based on extension type. Right now I am able to print all the files but now I want to separate them based on extension

How we can access and save object value of foregn model as default value, if the field is empty while saving the related object model?

class ObjectSEO(models.Model): object= models.ForeignKey(Objects, related_name='seo', on_delete=models.CASCADE) meta_description = models.CharField(max_

Python Django error "Select a valid choice. That choice is not one of the available choices."

I am relatively new to Django so I am likely doing something obviously wrong but I cant seem to figure out what exactly. I have a model called Report and this h

Django - profile creation based on is_staff

I am currently working on a job portal project, where I need to create 2 profiles based on is_staff field of default user model of django. one for job seekers a

Filtering in Django which depends on first field

Suppose I have 3 fields of a Car Shop. those are Condition, Brand, Model . class Car(models.Model): ConditionType=(('1','New'),('2','Used'),('3','Reco

Django - query Grand Children with Autofield as Primay Key

I have this model: class AnlieferungKopf(models.Model): kopfNr = models.AutoField(primary_key=True) firma = models.ForeignKey( Firma,

How to change the database local to be in a cloud (Django)

I wrote a project in django framework and I use the local DataBase SQLite, and I now want to upload it to the cloud so other people who work with me can access

Django processing form input name

I have changed the input's name attribute to some custom name, but the view calls form_invalid method. Why my Form isn't saving (validating)? html: <tr>

send template data from signal in django

As soon as the django user_logged_in signal works, I want to send data to my template at that moment.I need to check if my signal is working. from django.contri

Representing Django M2M data export in a CSV

The problem I am trying to solve is to export all the entries of a Django model as CSV. The field names are supposed to be headers, with each row having an appr

What is if 'admin' in request.path

I followed YouTube Django E-commerce video, I did exactly the same as the tutorial. But I found some difficulty in certain code. CONTEXT_PROCESSORS.PY from .mod