Why define create_foo() in a Django models.Manager instead of overriding create()? Why define create_foo() in a Django models.Manager instead of overriding create()? django django

Why define create_foo() in a Django models.Manager instead of overriding create()?


Yes, obviously, you can do that. But if you look closer to the example you are quoting from documentation, it is not about whether you should override create or not, it is about

If you do so, however, take care not to change the calling signature as any change may prevent the model instance from being saved.

preserving the calling signature. Because interfaces available for you may also be used by django internally. If you modify them, things may not break for you but for Django.

In this example, they are not suggesting this for create but model constructor.

Secondly, even standard interface for create is only taking keyword arguments

def create(self, **kwargs):

But if you modify it to take positional arguments, def create(self, title): it will break wherever it is used inside Django or in standard way. So you should extend existing functionality not modify and most probably break it.