Django-Oscar: UserAddressForm override in oscar fork doesn't work
I need to override UserAddress model.
My Steps:
- Make address app fork
python manage.py oscar_fork_app address oscar_fork
- Override model
from django.db import models
from django.conf import settings
from django.utils.translation import gettext_lazy as _
AUTH_USER_MODEL = getattr(settings, "AUTH_USER_MODEL", "auth.User")
class Address(models.Model):
city = models.CharField("city ", max_length=255, blank=False)
street = models.CharField("street ", max_length=255, blank=False)
house = models.CharField("house ", max_length=30, blank=False)
apartment = models.CharField("apartment ", max_length=30, blank=True)
comment = models.CharField("comment ", max_length=255, blank=True)
class UserAddress(Address):
user = models.ForeignKey(
AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="addresses",
verbose_name=_("User"),
)
from oscar.apps.address.models import *
But I came across an error during makemigrations:
django.core.exceptions.FieldError: Unknown field(s) (line1, phone_number, line4, notes, state, postcode, last_name, line2, country, line3, first_name) specified for UserAddress
I tried to override UserAddressForm too:
from django import forms
from .models import UserAddress
class UserAddressForm(forms.ModelForm):
class Meta:
model = UserAddress
fields = [
"city",
"street",
"house",
"apartment",
"comment",
]
But it doesn't work. What am I doing wrong?