It's even easier than that: try user_profile.name

if you need a specific variable field, remember it is just python so:
>> from Model.models import Profile
>> user_profile = Profile.objects.get(pk=1)
>> attribute = 'name'
>> getattr(user_profile, attribute)
John

Hope that helps, Mn


On Oct 2, 10:47 am, WillF <[EMAIL PROTECTED]> wrote:
> Hi I'm new to django. Is there way to get a specific column from a specific
> table in a database when using Models. Say for instance I wanted just a list
> of user's firstnames or something.
>
> Also, with a instance of a Model, say for instance, UserProfile, is there a
> way to get an arbitrary attribute. Soemthing along the lines of
>
> user_profile.get('name') or user_profile.get(attribute)
>
> ??
>
> Thanks!
> --
> View this message in 
> context:http://www.nabble.com/Models---getting-specific-attributes-question-t...
> Sent from the django-users mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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