On Wed, May 20, 2009 at 10:09 AM, Felipe Martinez <ugtgali...@gmail.com>wrote:
> > > > Sorry, but I got lost somewhere in formsets. I'm using actions from > change_list.html, so I suppose I should use cl.formset.errors: > > {% if cl.formset.errors %} > <p class="errornote"> > {% blocktrans count cl.formset.errors|length as counter %} > Please correct the error below.{% plural %}Please correct the errors > below.{% endblocktrans %} > </p> > <ul class="errorlist">{% for error in > cl.formset.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul> > {% endif %} > > But I don't know how to access such formset from a function in my_app/ > admin.py function. > > Here's my class: > > class SomemodelAdmin(admin.ModelAdmin): > actions = ['myfunction'] > def myfunction(self, request, queryset): > for obj in queryset: > if <things_are_ok>: > self.message_user(request, "OK message") > else: > < here I want to access cl.formset.errors to display > my error messages > > > > Thank you > > On 20 mayo, 16:29, Alex Gaynor <alex.gay...@gmail.com> wrote: > > On Wed, May 20, 2009 at 6:24 AM, Felipe Martinez <ugtgali...@gmail.com > >wrote: > > > > > > > > > > > > > Hi, everybody > > > > > I've done a simple app using admin actions in django's admin site. > > > Everytime somebody executes an action some checks are made and > > > messages are delivered informing about actions result (ok, error, > > > warnig...etc) > > > > > I'm using message_user for that, but that always returns a green check > > > mark on yellow background. I would like to use class errornote defined > > > in admin's stylesheet to acomplish that. > > > > > That sounds easy, but surprisingly I haven't figured out how to do it > > > yet > > > > > Has anybody found a workaround for this? > > > > > Thank you > > > > Django doesn't use the user.message_set for displaying those errors. It > > just uses this: > http://code.djangoproject.com/browser/django/trunk/django/contrib/adm... > > snippet of HTML. You should be able to just use that. > > > > Alex > > > > -- > > "I disapprove of what you say, but I will defend to the death your right > to > > say it." --Voltaire > > "The people's good is the highest law."--Cicero > > > There is no cl.formset there, that's just where Django get's the error text from in that parciular case, you should put whatever text *you* want there for the error message. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---