Reputation: 81
I have table with name of column "call-limit".
When create field in django models:
call-limit = models.IntegerField(default=1,verbose_name='call-limit')
I have error.
Thank you for help
Upvotes: 1
Views: 1511
Reputation: 25560
You can set or refer to the name of the column in your relational database from the model with the db_column
argument:
call_limit = models.IntegerField(default=1, db_column='call-limit',
verbose_name='call-limit')
But the model name in your Python code must be a valid Python identifier, so cannot contain the hyphen. Why not use call_limit
instead?
See the docs for more information.
Upvotes: 4