3π
β
In your case specifically, you should go with the non-manager version, if you go with the custom manager youβll be adding a method as well (not working over the manager QuerySet), and also you will have to provide the user parameter.
Using a method left the user instance the responsibility of finding users nears to itself.
And not to mention you have to write more code using the first option and it would be slower too.
user.user_in_radiuos.find_users_in_radius(user) # Two attribute lookpus, redundance: calling object == parameter.
user.users_in_search_radius() # Clean, no redundance.
π€Raydel Miranda
3π
You only need to define a custom manager when you want to modify the default manager ( objects
) or add extra manager methods (which are not present in default manager).
So, if you can use the default manager without having to modify it then why reinventing the wheel.
π€Ahtisham
- [Django]-Example Cron with Django
- [Django]-How install a extension in postgresql before creating the models in django?
- [Django]-Count how many fields a model has
- [Django]-Does Neomodel support modelform? If so, why isn't it picking up default meta attributes / how do I set them?
- [Django]-Django β Admin custom field display & behavior
Source:stackexchange.com