[Django]-Error in a class when trying to syncDB (Python Django)

4๐Ÿ‘

โœ…

I can see two issues with your model.

You didnโ€™t create an instance of the IntegerField; you need to call it:

id = models.IntegerField()
#                       ^^

You are creating tuples for the other fields, because you end each field with a comma:

title = models.CharField(max_length=40),
#                                      ^

Remove those commas.

You donโ€™t really have to specify your own id field; models are by default given an id field automatically. See Automatic primary fields in the Django models documentation:

By default, Django gives each model the following field:

id = models.AutoField(primary_key=True)

This is an auto-incrementing primary key.

Since your specified your own id field that doesnโ€™t use primary_key=True, your model is probably going to run into problems with that too.

๐Ÿ‘คMartijn Pieters

1๐Ÿ‘

Below line of code is missing

id = models.IntegerField(primary_key= True)
๐Ÿ‘คYashraj

0๐Ÿ‘

You are missing two () for your id integerfield.

id = models.IntegerField()
๐Ÿ‘คJimmy Bernljung

Leave a comment