1 2 3 4 5 6 7 8 9 10 | from django.contrib.auth.models import User
class OwnerField(User):
def get_internal_type(self):
return User.__name__
def pre_save(self, model_instance, add):
if model_instance.id is None:
return get_current_user()
else:
return getattr(model_instance, self.attname)
|
More like this
- Username form field by sma 3 years, 6 months ago
- Update Related Object Fields by johnboxall 3 years, 5 months ago
- User manager by diverman 2 years, 10 months ago
- Email on new comments by nikolaj 4 years, 9 months ago
- Duplicate related objects of model instance by johnboxall 3 years, 4 months ago
Comments