I want to extend the User model. I followed the steps mentioned in this doc. I made a new app extended_user
whose models.py reads as :
from django.db import models
from oscar.apps.customer.abstract_models import AbstractUser
from django.utils.translation import ugettext_lazy as _
class User(AbstractUser):
nickname = models.CharField(_("nick_name"), max_length=50, null=True, blank=True)
def get_full_name(self):
full_name = '%s %s' % (self.last_name.upper(), self.first_name)
return full_name.strip()
In settings.py I mention
AUTH_USER_MODEL = "extended_user.User"
I make and run migrations. In profile view I can see nickname
field but in Profile Edit view I don't. What do I have to do to see the newly added field in the Profile Edit form ?
I assume that you do not use a separate rofile class. In that case Oscar sets
ProfileForm
to point to theUserForm
class.That class in turn has a more-or-less hardcoded list of
fields
. (In reality it says "whichever fields exist out of this list".)The easiest way to go forward from here is to override
customer.forms.ProfileForm
with your own class that uses your newly definedUser
model and the list of fields that better suits your usecase. (Create ayour_app.customer.forms
module and define aProfileForm
inside.)python3 manage.py oscar_fork_app customer
customer/forms.py
:ProfileForm
var as Oscar use it for render form of profile to point to your new form.