0

I'm trying to change the attribute date of my Product Attributes because it is a DateField and I need a DateTimeField (I want to implement a countdown on my website). I found out that the app responsible for it is oscar.apps.catalogue and the attribute that I want to modify (date) is located inside abstract_models.py in the catalogue app folder (AbstractProductAttributeValue class).

I forked the project and created a ProductAttributeValue class inheriting from AbstractProductAttributeValue but Python doesn't allow to modify a parent class attribute so I can't just modify that attribute.

Is there a way to modify that attribute or will I have to modify the original Django-Oscar file (abstract_models.py)?

EDIT: I'm trying to modify the Django-oscar behaviour by inheriting a class. Using AbstractProductAttributeValue._meta.get_field('value_date').default = models.DateTimeField(_('Date and Time'), blank=True, null=True) to change the parent class attribute doesn't work and shows me an error when I try to use python manage.py migrate: "AttributeError: 'DateField' object has no attribute 'model'"

Alexandre Lara
  • 2,464
  • 1
  • 28
  • 35
  • possible duplicate of [How to override the default value of a Model Field from an Abstract Base Class](http://stackoverflow.com/questions/6377631/how-to-override-the-default-value-of-a-model-field-from-an-abstract-base-class) – rnevius May 10 '15 at 13:48
  • 1
    @rnevius It is not duplicated because I'm dealing with a core file from Django-oscar project (oscar/apps/abstract_models.py). Anyways, I tried the solution posted in your link, and it shows me an error. I edited my original post providing more information about what occurs. Thanks. – Alexandre Lara May 10 '15 at 14:34

0 Answers0