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
p = Persona.objects.get(user__username='foo')
--
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.
To post to this group, send email to django...@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 |