Monday, September 30, 2013

How to Query account/profile information for multiple account and allowing user edit or update acount

I have two problems

1. How can i populate the account
   information of each user, this
   what i have done but only info on
   user models populates, the info on extended
   field does not show on my template

    # models.py
   class Student(Models.model):
          user = foreignkey(user)
          sex= models.charfied()
         ......

     class Teacher(Models.model):
          user = foreignkey(user)
          sex= models.charfied()
          salary models.charfield()
         ......


  
   # views.py
  
 @login_required(login_url='/
login/')
def account(request, template_name="account.html"):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login/')
    regis = property(lambda u: Candidate.objects.get(User=u)[0])
    context = {'regis': regis}
    return render_to_response('account.html', context, context_instance=RequestContext(request))
   
    #account.html
   
{% extends "base.html" %}

{% block wrapper %}
<h3> welcome  {{ user.username }}</h3>
<p>Email: {{ user.email }}</p>
<p>Name: {{ regis.u.first_name }}</p>
<p>Sex: {{ regis.sex }}</p>
<p>surname: {{ regis.last_name }}</p>
<p>Date of birth: {{ regis.dob }}</p>
<p>Marital status: {{ regis.marital_status }}</p>
<p>passport: {{ regis.passport }}</p>
<img src="{{ regis.passport.url }}" />

{% endblock %}

{{user.username}}, {{ user.email }} shows but
the rest does not show

2. i Have the profile form to enable user
    edit their account anytime they want,
    but i can't figure the code around it
   
any solution to this problem
thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/50bfe62a-556b-4b29-8ba9-50d58006c2c1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment