Model Inheritance and AttributeError in Django base.py

June 11, 2009...... at 12:23 pm | Posted in geek | Leave a comment

Spent 2 hours last night debugging an inability to create an instance of a particular model because of an attribute error. The problem turned out to be that I had a read-only attribute on the child, fullname = property(_get_full_name), which had the same name as a field on the parent model. Another interesting discovery was that you don’t seem to be able to override fields using inheritance. Define a field called location on the on the parent as a charfield and define a field called location on the child as a foreignkey. If you define a modelForm on the child you get a charfield rather than a select field. So basically always ensure that there are no common field names between your parent and child models it’ll save you hours 🙂

Advertisements

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: