Monday, September 30, 2013

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

On Monday, 30 September 2013 19:33:31 UTC+1, Okorie Emmanuel wrote:
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))
 

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.

--
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/beedfe13-35a8-4def-a0e4-72dc478775fb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment