django-inheritance

How to provide a default value for base class attribute from subclass in Django?

Scenario: class BaseClass(models.Model): base_field = models.CharField(max_length=15, default=None) class SubClass(BaseClass): # TODO set default value if base_field's value is None ... ie. I need to be able to load a fixture into the database, providing a default value only if the base_field is None. Any help greatly app...

In Django - Model Inheritance - Does it allow you to override a parent model's attribute?

I'm looking to do this: class Place(models.Model): name = models.CharField(max_length=20) rating = models.DecimalField() class LongNamedRestaurant(Place): # Subclassing `Place`. name = models.CharField(max_length=255) # Notice, I'm overriding `Place.name` to give it a longer length. food_type = models.CharField(max_length=25) T...

Help a Python newbie with a Django model inheritance problem

I'm working on my first real Django project after years of PHP programming, and I am running into a problem with my models. First, I noticed that I was copying and pasting code between the models, and being a diligent OO programmer I decided to make a parent class that the other models could inherit from: class Common(model.Model): ...