Django Error: Field ‘id’ expected a number but got ‘list’

I have an app with 2 models and I’m trying to create a List View and a Detail View. The list view worked fine, but when I created the detail view the list view stopped working and it’s prompting me …

How can I get a value from other model, based in other value from that same other model?

How can I get the proper “sumvalue” in the example? (which I only know how to represent in SQL): class Addition(models.Model): location = models.ForeignKey(Place, …) a = models….

Django: How to use data from a function as a field in Meta class

I’ve created a function in my serializers.py that call an external API and give me a dict back. How can I use the output from return downloads in the get_all_files as a field in class Meta? After the …

Django: How do I get referenced objects in a symmetric ManyToMany relationship?

I’ve created a Many-to-Many relationship for the model UserProfile, to enable users to grant access to a particular feature to one another. The relationship works as expected with the use of …

Import django models to custom python script

I am trying to create a custom python script within my Django application. This script requires the use of my app models. I am unable to figure out how to import the models appropriately to be used …

How to make a “create-only” non-editable field in django admin

im looking for some solution about make a “create-only” field on django admin using models. I saw some questions before, but no one can answer the core question: the field should appear when …

Update a field of a Django Object

I’m trying to update an object field in django. Usually I would do something like this: # MODEL — class MyObj(models.model): name: models.CharField(max_length=10) surname: models.CharField(…

How should I improve my styling here (python class, Django models)?

My main model class looks like this: class Article(models.Model): title = models.CharField(max_length=120) content = models.TextField() authors = models.TextField(max_length=200) year =…

Registration form refreshes after submitting instead of sending post request in django

I’m trying to register a user but the page refreshes instead of submitting the data. At the initial stage of my project, it was working properly but when I added some more models and form it’s not …

Django inspectdb omitted integer primary key

I have a legacy MySQL db, and I am trying to create Django models from it so I can use the legacy tables in my Django application. I ran inspectdb on the MySQL db and it seemed to import most fields …