0

Let's say I have a model Message. In admin, I need to add a message by submitting/uploading a message file, not by posting message fields as normally would. The process is, I get the file uploaded, send it to a processing program which parse the file, do some further processing and then add an entry into database.

So I create a custom form for ModelAdmin(assign form = CustomForm) with one FileField and override save_model() to not to save anything. However, this isn't a proper way as the doc clearly mention ModelAdmin's save_model() method is not for veto purpose. So what would be the proper way for this?

Some suggest an extra button pointed to a custom view, while it's surelly possible but logically I'm still adding a message so an extra view doesn't seem nature.

Tianwei Chen
  • 148
  • 11
  • you may override the `save_model` function and not write `obj.save` sentence. https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model – WeizhongTu Oct 22 '14 at 08:37
  • Maybe `object = form.save(commit=False)` doing some things and then `object.save()`http://stackoverflow.com/a/12848678/3033586 – madzohan Oct 22 '14 at 10:17

0 Answers0