How to restrict save function in Django admin

58 views
Skip to first unread message

Akshay Mukadam

unread,
Dec 3, 2014, 12:03:56 AM12/3/14
to django...@googlegroups.com
Hi,
I have developed application that loads CSV file, if the input received while parsing the CSV file in Django admin is wrong, it throws a stacktrace, to avoid stacktrace I have handled the exception and I am able to show the error message using the Message framework in django.
But the problem is that when I save the data it shows the error that CSV data is incorrect, but it also show save message, how could I override this.???
Thank You

pjotr

unread,
Dec 3, 2014, 10:17:02 AM12/3/14
to django...@googlegroups.com
Maybe you could show the code to clearly see what you are doing?

Ezequiel

unread,
Dec 3, 2014, 5:30:49 PM12/3/14
to django...@googlegroups.com
in admin.py

class MyModelAdmin(admin.ModelAdmin):
    def has_change_permission(self, request, obj=None):
        return False 


Ezequiel

Collin Anderson

unread,
Dec 5, 2014, 8:55:33 AM12/5/14
to django...@googlegroups.com
Hi,

Would it work to validate the CSV in the form? Maybe start processing it, but if there's an error, raise a forms.ValidationError?

Collin
Reply all
Reply to author
Forward
0 new messages