Answer the question
In order to leave comments, you need to log in
How to reference id in model in new versions of django?
Just started learning Django.
For this piece of code, Django throws an error during migration.
class DescriptionLinks(models.Model):
class Meta:
db_table = "description_link"
name = models.CharField(max_length = 100)
description = models.TextField()
class SpecificLinks(models.Model):
class Meta:
db_table = "specific_link"
link = models.SlugField(max_length = 200)
description = models.ForeignKey(DescriptionLinks)
def contact_default():
return {"email": "[email protected]"}
contact_info = JSONField("ContactInfo", default=contact_default)
Answer the question
In order to leave comments, you need to log in
Add the following to the project field: null=True, blank=True
Or after migrating, select 1, and then specify 1 too :)
class Meta:
db_table = "....."
You can press 1. You will be prompted to fill in an existing table with data
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question