Hello together,
I have overriden the models.Model.save method and added a parameter called 'user', so that each save-call of an object will store the creation date/author and update date/user: class Model(models.Model): class Meta: abstract = True def save(self, user, force_insert=False, force_update=False): now = datetime.datetime.now() if not self.id: self.created = now self.created_by = user self.updated = now self.updated_by = user super(Model, self).save(user) In our projects, we always have these four timestamp fields, and I want them to be filled out automatically. That works fine so far, but when I use a TabularInline view for an object's ModelAdmin, a save causes the following traceback: File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/contrib/admin/options.py" in wrapper 226. return self.admin_site.admin_view(view)(*args, **kwargs) File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/views/decorators/cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/contrib/admin/sites.py" in inner 186. return view(request, *args, **kwargs) File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/db/transaction.py" in _commit_on_success 240. res = func(*args, **kw) File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/contrib/admin/options.py" in add_view 737. self.save_formset(request, form, formset, change=False) File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/contrib/admin/options.py" in save_formset 563. formset.save() File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/forms/models.py" in save 522. return self.save_existing_objects(commit) + self.save_new_objects(commit) File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/forms/models.py" in save_new_objects 657. self.new_objects.append(self.save_new(form, commit=commit)) File "/storage/virtualenvs/teagarden/lib/python2.6/site-packages/ Django-1.1.1-py2.6.egg/django/forms/models.py" in save_new 760. obj.save() Exception Type: TypeError at /admin/teagarden/group/add/ Exception Value: save() takes at least 2 arguments (1 given) Well that's quite clear: the TabularInline model calls a save_formset method which itself triggers save_new, which I cannot override or at last, will not be overriden by my models.Model abstract class. I guess I should'nt alter the methods header by adding parameters, so is there another way to automatically save such timestap fields? I searched a long time for other solutions, but most of them use similar mechanisms as far as I can see it. Thanks in advance, Henning -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.