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

36 views
Skip to first unread message

Okorie Emmanuel

unread,
Sep 30, 2013, 2:33:31 PM9/30/13
to django...@googlegroups.com
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

Frank Bieniek

unread,
Sep 30, 2013, 2:52:24 PM9/30/13
to django...@googlegroups.com
Please try, django-userena, or django-registration,
both deal with userdetails.

Thx
Frank


Am 30.09.13 20:33, schrieb Okorie Emmanuel:
--
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...@googlegroups.com.
To post to this group, send email to django...@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.

Daniel Roseman

unread,
Sep 30, 2013, 4:16:54 PM9/30/13
to django...@googlegroups.com
What is that property/lambda stuff supposed to be doing? You *seem* to be trying to define something that will get a Candidate from a user, but I don't understand why you're wrapping it in 'property', and then of course you don't ever call it or pass it a User. If you did call it, you'd no doubt get multiple errors, for example `get` only returns a single object so indexing it with [0] is bound to raise an exception.

Also, you might want to explain the relationship between a Candidate and the Student/Teacher models you've shown above. 
--
DR.

Okorie Emmanuel

unread,
Oct 8, 2013, 1:24:16 PM10/8/13
to django...@googlegroups.com
Thanks for your response

This is what i want to do,
I want to create an app that have two different users
that is teachers(one type of user) and student(another type of user)
the problem is how to create them without using
AUTH_USER_MODEL = 'myapp.MyUser'
since it is for one kind of user only.

I have created the model as shown in last post
but how to query individual details in their
respective profile is the problem.

Any way out. thanks
Reply all
Reply to author
Forward
0 new messages