Perfect.

El dijous, 2 abril de 2015 17:29:46 UTC+2, Filipe Ximenes va escriure:
>
> Try:
>
> p = Persona.objects.get(user__username='foo')
>
> ​
>
> On Thu, Apr 2, 2015 at 12:24 PM, <somen...@gmail.com <javascript:>> wrote:
>
>> I have this
>> class Persona(models.Model):7 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L7> 
>>        """Person class:8 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L8> 
>>             * user: a user9 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L9> 
>>             * presentation: some paragraph for other knowing you10 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L10> 
>>             * availability: the availability of user for knowing new 
>> people. See 'AVAILABILITY' tuples explanation11 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L11> 
>>        """12 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L12> 
>>        # 'Available' means you want to meet new people now13 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L13> 
>>        # and 'Unavailable' means you don't want to meet new people.14 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L14> 
>>        # Useful for not anoying you new users.15 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L15> 
>>        AVAILABILITY = (16 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L16> 
>>                ('Y', 'Available'),17 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L17> 
>>                ('N', 'Unavailable'),18 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L18> 
>>        )19 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L19>
>> 20 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L20>
>> 21 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L21> 
>>        user = models.OneToOneField(User)22 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L22> 
>>        presentation = models.CharField(max_length=254, blank=True)23 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L23> 
>>        availability = models.CharField(max_length=1, choices=AVAILABILITY
>> , default='Y')24 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L24>
>> 25 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L25> 
>>        def __str__(self):26 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L26> 
>>                return self.user.username27 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L27>
>> 28 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L28> 
>>        def username(self):29 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L29> 
>>                return self.user.username30 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L30>
>> 31 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L31> 
>>        def full_name(self):32 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L32> 
>>                return "{0}, {1}".format(self.user.last_name, self.user.
>> first_name)33 
>> <http://178.79.181.191/openbouches/browser/gargamella/quedar/models.py#L33>
>>
>>
>> How can I do to acces to Persona which has user.username=='foo'?
>>
>> Thanks in advance,
>>
>>  -- 
>> 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 <javascript:>.
>> To post to this group, send email to django...@googlegroups.com 
>> <javascript:>.
>> 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/599f61a6-6f87-4dd7-a3f2-7a4b3693a185%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/599f61a6-6f87-4dd7-a3f2-7a4b3693a185%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>   
>
> *Filipe Ximenes*+55 (81) 8245-9204
>
> *Vinta Software Studio*http://www.vinta.com.br
>  

-- 
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+unsubscr...@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/5fca2f82-7bdf-4eff-abc6-e6aab45ab41e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to