1π
β
It is a requirement to apply the filter to the User model? Why donβt you try to subclass this model instead?, and code a manager for this one.
class CustomUserManager(UserManager):
def get_query_set(self):
return super(CustomUserManager, self).get_query_set().
filter(is_active=True)
class MyUser(User):
objects = CustomUserManager()
# get an active user which username is 'foo'
MyUser.objects.get(username='foo')
or use a proxy model
π€trinchet
0π
Found the answer in this post. Since his question is specific and mine is general, I donβt consider them duplicates, but the answer to his question also answers mine.
π€Clay Wardell
- [Django]-How do I programmatically create a user with django_social_auth?
- [Django]-Django List deserialization in rest-framework
- [Django]-Allowing basic html markup in django
- [Django]-How to return most popular items in a table, but where each item is unique?
- [Django]-Is there an easy way reverse a template render?
Source:stackexchange.com