On 7/16/07, Eratothene <[EMAIL PROTECTED]> wrote:
>
> I need to make dictionary out of django.auth.model.User instance in
> such format:
>
> {'username':'val1', 'password':'val2', 'email':'',
> 'first_name':'val3', 'last_name':'val4' ...}
>
> In order to populate this data in to the custom form. I have read all
> documentation available in order to resolve this simple task, how to
> make it?

The __dict__ option described elsewhere will work, but could introduce
some interesting name clashes (depending on the exact names in use).

Another option is to use the values() clause on a queryset. This
modifies a query set to return a dictionary of values, rather than a
list of objects (or a single object, in the case of get):

>>> User.objects.values('username','email').get(pk=1)
{'username': u'freakboy', 'email': u'[EMAIL PROTECTED]'}

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to