python - Django registration-profile - next step to a user profile -


i have installed django-registration app project. after successful log in step, redirecting user localhost:8000/ - default testing host , port. , displaying somewhere on page, username of logged in user.

what want when click username options edit profile or change password appear. questions following:

  1. should create model (inside new app) containing fields profile photo, gender, birthday etc , add foreign key user model django.contrib.auth.models ? or should modify model django-registration add additional fields not ask @ registration phase , update them later?

  2. if want profile edit feature @ /accounts/edit, best practice it? edit urlconf of project , add line (r'^accounts/edit$',.....) before (r'^accounts/', include('registration.backends.default.urls')), ?

i hope made myself clear. i'm trying figure out best approach before coding, new django... thanks

i find it's easier decouple profile table auth table. mentioned can use foreign key relationship link profile user. can apply lambda inside of profile table automatically create profile when new user object created.

inside template can link profile page dynamically based on current authenticated party using

{% if request.user.is_authenticated %} <a href="/user_profile/{{ request.user.id }}">update profile</a> {% endif %} 

user_profile being name of app holds user_profile table. way when request made use regular expression current user id (similar polls example provided django) id number of logged in user inside views query database particular user.

views.py

def myview(request, user_id):     userprofile = userprofile.objects.get(user.pk=user_id) 

this high level example give idea of 1 way accomplish it.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -