Hi!
Personna.objects.get(user__username='foo') should do.
Simon
Le jeudi 2 avril 2015 11:24:48 UTC-4, somen...@gmail.com a écrit :
-- Personna.objects.get(user__username='foo') should do.
Simon
Le jeudi 2 avril 2015 11:24:48 UTC-4, somen...@gmail.com a écrit :
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=25 4 , 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/30164044-6f56-433d-9372-75f77169a4d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment