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

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

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

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. 

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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment