Some prerequisites, I am developing a user profile for our Django database system, and I am currently trying to create a view page so that the user can edit their account settings (outside the admin page). I searched for a lot of sources, most of which recommend using .get_profile (), but this did not work in my program no matter what approach I try (as far as I know and what has been done). So far I have used the django main pages for .get_profile () to see how to use .get_profile () correctly and find the AUTH_PROFILE_MODULE parameter (I will specify my settings a bit).
Using this site:
http://www.turnkeylinux.org/blog/django-profileI found some other methods of using .get_profile (), but still nothing worked. (I will not add the rest of the links I tried, as I could continue for some time)
Back to the question, can anyone recommend a method that will work, so that I can get information about users, to set some default values, to maintain their current settings, if they prefer not to edit them and update only new values.
So far I: (hope all relevant parts)
file directory: ~ / Documents / project1
settings.py
AUTH_PROFILE_MODULE = "accounts.Account"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `
File Location: Project1 / Account
models.py
class Account(models.Model):
userLink = models.OneToOneField(User)
birthdate = models.DateField(blank = True)
gender = models.CharField(max_length = 1, choices = GENDER_CHOICE, null = True)
def __unicode__(self):
return u'%s %s' % (self.userLink.first_name, self.userLink.last_name)
class EditAccountForm(forms.Form):
gender = forms.CharField(max_length = 1)
birthdate = forms.DateField(widget = SelectDateWidget())
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
views.py
@login_required
def AccountSettings(request):
sluggedSettingError = request.GET.get('error', '')
settingError = sluggedSettingError.replace('-', ' ')
settingForm = AdditionalForm(request.POST or None)
userSettings = Account.objects.filter(userLink=request.user)
print "userLink = %s" % userSettings
if request.method == 'POST':
return HttpResponseRedirect('/')
return render_to_response("user_settings.html", {'settingForm': settingForm, 'settingError': settingError}, context_instance = RequestContext(request))
.get_profile() , userLink, "userSettings". , , , userSettings.gender, userSettings.birthdate .. , , ( if Django).
, , get_profile(). get_profile() ( ), "" . : , , id, userLink
, userLink, "", , , - django.docs, , . : :
https://bitbucket.org/filmaster/filmaster-test/src/1618b18003ed/film20/userprofile/views.py
, .
, .get_profile() , , , . , , , , . - , . , - , , , , .
!