Hi,

How do I display an exception's argument as a message in Django's
admin?

I want the exception's argument to be displayed as an error message at
the top of the add stage - instead of having the exception argument
displayed at the debug page. Furthermore, I would like to add an error
message to the field that causes the exception.

Can anyone give me clue how to accomplish this?

Currently, I have this (but it doesn't work):
+++
# models.py
def save(self):
    (...)
    # Ma.gnolia
    if not self.magnolia_id:
        import pymagnolia
        from pymagnolia import PyMagnoliaError
        api = pymagnolia.MagnoliaApi(settings.MAGNOLIA_API_KEY)
        try:
            b = api.bookmark_add(title=self.name,
description=self.description_html, url=self.url, private=False,
tags=tags, rating=self.rating)
        except PyMagnoliaError, e:
            raise validators.ValidationError, "Bookmark exists: %s" % e
+++

For example: In case Ma.gnolia's bookmark collection already has an
entry for self.url, Pymagnolia raises PyMagnoliaError "[1160] Bookmark
URL already in collection. (...)". Subsequently, I want part of this
message to be displayed as an error message at the top of the add
stage, and a specific field-related error message added to the field
that caused the exception.

I don't know if there's a preferred way to handle this issue. Should I
use a custom validator? The problem is that I can only validate against
the response from the Ma.gnolia API.

How do I achieve this? Any thoughts?

Any help is greatly appreciated!

Regards,
bin


--~--~---------~--~----~------------~-------~--~----~
 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