Model methods are custom methods that add custom row level
functionality to your objects.

For example, if your model has a first_name field and a last_name
field, and you wanted to return the full name, your custom model
method could be:

class Person(models.Model):
     first_name = models.CharField(max_length=50)
     last_name = models.CharField(max_length=50)

     def full_name(self):
          return u'{0} {1}'.format (self.first_name, self.last_name)

In your view:

p = Person.objects.get(first_name='Mike', last_name='Smith')

To get the full name

p.full_name

Which returns:

u'Mike Smith'

On Sat, Jul 23, 2011 at 9:59 AM, Eyad Al-Sibai <eyad.alsi...@gmail.com> wrote:
>
> I am a little bit confused... what functions should I write it in the Manager 
> and what should be within the Model itself... Also what functions do you 
> think should be written inside the class Admin within the Model?
>
> Regards,
> Eyad
>
> --
> 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 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to