Try:
p = Persona.objects.get(user__username='foo') On Thu, Apr 2, 2015 at 12:24 PM, <somenxavier@gmail.com> wrote:
I have this--
class Persona(models.Model): 7 """Person class: 8 * user: a user 9 * presentation: some paragraph for other knowing you 10 * availability: the availability of user for knowing new people. See 'AVAILABILITY' tuples explanation 11 """ 12 # 'Available' means you want to meet new people now 13 # and 'Unavailable' means you don't want to meet new people. 14 # Useful for not anoying you new users. 15 AVAILABILITY = ( 16 ('Y', 'Available'), 17 ('N', 'Unavailable'), 18 ) 19 20 21 user = models.OneToOneField(User) 22 presentation = models.CharField(max_length=254, blank=True) 23 availability = models.CharField(max_length=1, choices=AVAILABILITY, default='Y') 24 25 def __str__(self): 26 return self.user.username 27 28 def username(self): 29 return self.user.username 30 31 def full_name(self): 32 return "{0}, {1}".format(self.user.last_name, self.user.first_name) 33
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+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/599f61a6-6f87-4dd7-a3f2-7a4b3693a185%40googlegroups.com.
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+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/CAA-QWB1yVcigp4%3D0xX5KD4-F_dW4P%2Bp3BmamWjHHnNe_cyNA5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment