Answer the question
In order to leave comments, you need to log in
In what there can be a problem with a DB? Didn't create additional tables?
The database contains the following models:
class Musician(models.Model):
id_musician = models.AutoField(primary_key=True)
pseudonym = models.CharField(max_length=30)
class Genre(models.Model):
id_genre = models.AutoField(primary_key=True)
name_genre = models.CharField("genre's name", max_length=30)
class Song(models.Model):
id_song = models.AutoField(primary_key=True)
name_song = models.CharField("song's name", max_length=30)
album = models.CharField(max_length=30)
release_date = models.DateField
text = models.TextField
musician = models.ManyToManyField(Musician)
genre = models.ManyToManyField(Genre)
Answer the question
In order to leave comments, you need to log in
Let me sum up a few answers and add a little of my own.
- release_date = models.DateField()
- brackets are missing, and also in some similar fields. I also suspect that it should blank=True, null=True
.
- Explicit setting of primary keys is not necessary. id_song, id_genre, ...
- superfluous. Django itself creates a named primary key id
for each table.
- It seems to me that many of your fields should have blank=True
, otherwise they are all mandatory.
- Album
as it seems to me, it should be a separate table linked by foreign key.
After fixing this, makemigrations and migrate should be done as mentioned above.
To create the necessary tables from models, migrations are used, which can be created and applied with the following commands:
manage.py makemigrations
manage.py migrate
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question