Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django models sqlmigrate - too few arguments

Tags:

python

django

Here are my Django models, which have multiple many to many relationships.

class Theme(models.Model):
        theme_name = Models.CharField(max_length=20)
        theme_ind = Models.CharField(max_length=1)

class Topics(models.Model):
        topic_name = Models.CharField(max_length=20)

class Language(models.Model):
        lang_name = models.CharField(max_length=10)


class Article(models.Model):
        name = Models.CharField(max_length=10)
        url = Models.CharField(max_length=50)
        lang_id = models.ManyToManyField(Language, related_name='theme')
        theme_id = models.OneToOneField(Theme, related_name='theme')
        topic_id = models.ManyToManyField(Topics, related_name='topic')

Question: When I run:

python  manage.py sqlmigrate polls

I get this error:

manage.py sqlmigrate: error: too few arguements.
like image 293
user1050619 Avatar asked Sep 22 '15 16:09

user1050619


2 Answers

From the docs, sqlmigrate also requires the migration name:

python manage.py sqlmigrate polls <migration_name>
like image 35
Ivan Avatar answered Sep 20 '22 11:09

Ivan


You forgot the prefix of makemigrations command output file.

When you run:

python manage.py makemigrations polls

You will see in output 0001_any_name.py.

Here, 0001 is used in sqlmigrate for creating the database that you forgot to add in your command.

So, write:

python manage.py sqlmigrate polls 0001
like image 154
Neeraj Kumar Avatar answered Sep 24 '22 11:09

Neeraj Kumar