Skip to content Skip to sidebar Skip to footer

"object Has No Attribute" In Custom Django Model Field

I am trying to create a Django model field that represents a duration with days, hours, minutes and seconds text input fields in the HTML, and stores the duration in the db using t

Solution 1:

I was stupid. The problem was that I named the file where the model was defined duration.py, so there was a naming conflict with the "duration" field. I renamed the file and it worked.

Solution 2:

Did you run ./manage syncdb after you changed your model?

If you decide to change your model it won't update the current database. The only way is to reset it and then run syncdb.

If you're using SQLite - just delete the db file, run syncdb and it will generate a database with your updated model. Note, it will delete all existing records!

Post a Comment for ""object Has No Attribute" In Custom Django Model Field"