I think this is preferable because it looks cleaner in code. You can also read in underscores too much, since the advantage or difference is not so great. However, when implementing things, I use the proposed approach.
Consider the following model (purely for illustrative purposes):
class Vehicle(models.Model): wheels = models.IntegerField() color = models.CharField(max_length=100)
In your application you often need to get all the cars, or all the motorcycles, or some type of vehicle. To hold DRY stuff, you need a standard form for retrieving this data. Using class methods, you get the following:
class Vehicle(models.Model):
If you create a manager, you will get something like this:
class CarManager(models.Manager): def get_query_set(self): return super(CarManager, self).get_query_set().filter(wheels=4) class Vehicle(models.Model):
In my opinion, the latter looks cleaner, especially when the situation becomes more complicated. It saves clutter from your model definitions and saves something similar to using the objects manager by default.
source share