Hi guys,

I´m using newforms-admin and I have a suggestion on newforms-admin
that I want you look at. I have a news application and each entry has
an author, the superuser can add entries choosing an author on the
author list but when a staff user adds an entry, I want the author
field be autofilled with the current logged user.

In this case I will need to hook save_add and save_change:

def save_change(self, request, model, form, formsets,
post_url_continue):
      ...
      new_object = form.save(commit=False)
      new_object.author = request.user
      new_object.save()
      ...

But, to change this small piece of code, I need to change all the
save_change method and maybe copy some parts of codes. So, what about
a method called save_form_add and another save_form_change to do only
the form save and formsets save operations?

def save_change( ... ):
      self.save_form_change( ... )
      ...

This way I will keep the logs and another stuff. But if you can
suggests me another way to set the author for the entry, I can use if
instead of this idea ;)

Best regards!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to