2

I have one class in core folder as below:

class AbstractLine(models.Model):
    basket = models.ForeignKey('basket.Basket', related_name='lines',
                           verbose_name=_("Basket"))

    quantity = models.PositiveIntegerField(_('Quantity'), default=1)

Now I want to override this class in order to change the quantity PositiveIntegerField to DecimalField as below:

from django.db import models
from django.utils.translation import ugettext_lazy as _
from oscar.apps.basket.abstract_models import AbstractLine as ModelLine

class Line(ModelLine):
    quantity = models.DecimalField(_('Quantity'), default=0.25, decimal_places=2, max_digits=3)

How can I achieve this?

Reuben Mallaby
  • 5,740
  • 4
  • 47
  • 45

1 Answers1

1

Actually, it's not possible. See this question: In Django - Model Inheritance - Does it allow you to override a parent model's attribute?

The same applies to abstract base classes also, see this discussion on the Django user's group.

Your best bet is to simply delete the field from the base class.

Community
  • 1
  • 1
michaelb
  • 747
  • 3
  • 9