django - Extending the User to add a profile_pic -


in older versions of django extends user model , create userprofile. seems in django 1.8 not same anymore. im looking examples in django 1.8.

here example found somewhere on net, not extend anything. want extend user can still use user object in tempaltes etc.

class myuser(abstractbaseuser):     """     custom user class.     """      gender_choices = (         ('m', 'male'),         ('f', 'female'),     )     email = models.emailfield('email address', unique=true, db_index=true)     is_staff = models.booleanfield('is staff', default=false)     first_name = models.textfield('first name', default=none, null=true)     last_name = models.textfield('last name', default=none, null=true)     date_of_birth = models.datefield('date of birth', null=true)     avatar = models.imagefield('profile picture', upload_to='static/media/images/avatars/', null=true, blank=true)     has_picture = models.booleanfield('has profile picture', default=false)     adult = models.booleanfield('is adult', default=false)     gender = models.charfield('gender', max_length=1, choices=gender_choices)      objects = myusermanager()      required_fields = ['date_of_birth', 'gender']      username_field = 'email'      # insert lot of methods here      def set_avatar(self):        self.has_picture = true 

useing followin decoumentation: https://docs.djangoproject.com/en/1.6/topics/auth/customizing/#extending-django-s-default-user

gives me these errors:

  rendering model states...traceback (most recent call last):   file "manage.py", line 10, in <module>     execute_from_command_line(sys.argv)   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line     utility.execute()   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute     self.fetch_command(subcommand).run_from_argv(self.argv)   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv     self.execute(*args, **cmd_options)   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute     output = self.handle(*args, **options)   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 221, in handle     executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 100, in migrate     state.apps  # render real_apps -- performance critical   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/utils/functional.py", line 60, in __get__     res = instance.__dict__[self.name] = self.func(instance)   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/db/migrations/state.py", line 166, in apps     return stateapps(self.real_apps, self.models)   file "/users/hermanstander/apps/afriapps/stem/env/lib/python2.7/site-packages/django/db/migrations/state.py", line 248, in __init__     raise valueerror(msg.format(field=operations[0][1], model=lookup_model)) valueerror: lookup failed model referenced field admin.logentry.user: app.userprofile 


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -