42👍
✅
update
If you have overridden save()
method of Activity
or some other Models that get saved in meanwhile, but forgotten to accept force_insert
as keyword argument, this error could happen:
def save(self):
...
# should be
def save(self, force_insert=False, force_update=False, using=None):
...
# or at least
def save(self, **kwargs):
...
Check the trackback to locate the failed save
Your code does not fully follow the code from b-list.org, try:
def save_model(self, request, obj, form, change):
if not change:
obj.cruser = request.user
obj.save()
👤okm
4👍
As a general rule, you should only override the save()
method in the model itself, not in some model admin.
When overriding the save() method in a model, you should always use (*args, **kwargs)
to be safe. You have no way of knowing which specific parameters are being used when a specific model is being saved.
Your Activity
model should contain a method like this:
def save(self, *args, **kwargs):
'''do your custom stuff here'''
return super(Activity, self).save(*args, **kwargs)
- Why do I get a "auth_user does not exist"error when running "migrate" on a newly created django project with "registration redux" app installed?
- How to give initial value in modelform
- How to solve the circular import error in django?
- How do I install Mezzanine as a Django app?
- Image Conversion – Cannot write mode RGBA as JPEG
Source:stackexchange.com