Hi all,

I'm still quite new to django coding and am trying to learn to work
inline with Django's DRY and other principles.

In this case I'm having trouble deciding what is the more Django way
of counting the number of times an object has been open.

I know that the code will be executed in the View for the object but
should the .increase_hits() method be defined in the Model or in the
models manager?

class Post(model.Model)
    ...
    hits = PositiveInteger(default=0)

def increase_hits(self):
    ....
    self.hits += 1
    self.save()

or have a manager method to perform this?

Cheers

Goran
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to