Python django.contrib.admin.helpers.AdminErrorList() Examples
The following are 2
code examples of django.contrib.admin.helpers.AdminErrorList().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.contrib.admin.helpers
, or try the search function
.
Example #1
Source File: admin.py From django-usersettings2 with BSD 3-Clause "New" or "Revised" License | 4 votes |
def select_site_view(self, request, form_url=''): """ Display a choice form to select which site to add settings. """ if not self.has_add_permission(request): raise PermissionDenied extra_qs = '' if request.META['QUERY_STRING']: extra_qs = '&' + request.META['QUERY_STRING'] site_choices = self.get_site_choices() if len(site_choices) == 1: return HttpResponseRedirect('?site_id={0}{1}'.format(site_choices[0][0], extra_qs)) # Create form form = self.select_site_form( data=request.POST if request.method == 'POST' else None, initial={'site': site_choices[0][0]} ) form.fields['site'].choices = site_choices if form.is_valid(): return HttpResponseRedirect( '?site_id={0}{1}'.format(form.cleaned_data['site'], extra_qs)) # Wrap in all admin layout fieldsets = ((None, {'fields': ('site',)}),) adminForm = AdminForm(form, fieldsets, {}, model_admin=self) media = self.media + adminForm.media context = { 'title': _('Add %s') % force_text(self.opts.verbose_name), 'adminform': adminForm, 'is_popup': '_popup' in request.GET, 'media': mark_safe(media), 'errors': AdminErrorList(form, ()), 'app_label': self.opts.app_label, } return self.render_select_site_form(request, context, form_url)
Example #2
Source File: admin.py From django-connected with BSD 3-Clause "New" or "Revised" License | 4 votes |
def add_view(self, request, form_url='', extra_context=None): if not self.has_add_permission(request): raise PermissionDenied data = None changelist_filters = request.GET.get('_changelist_filters') if request.method == 'GET' and changelist_filters is not None: changelist_filters = dict(parse_qsl(changelist_filters)) if 'provider' in changelist_filters: data = { 'provider': changelist_filters['provider'] } form = AccountCreationForm(data=request.POST if request.method == 'POST' else data) if form.is_valid(): info = self.model._meta.app_label, self.model._meta.model_name preserved_filters = self.get_preserved_filters(request) request.session[PRESERVED_FILTERS_SESSION_KEY] = preserved_filters redirect_url = reverse('admin:%s_%s_login' % info, kwargs={'provider': form.cleaned_data['provider']}) return redirect(redirect_url) fieldsets = ( (None, { 'fields': ('provider', ) }), ) adminForm = helpers.AdminForm(form, list(fieldsets), {}, model_admin=self) media = self.media + adminForm.media context = dict( adminform=adminForm, is_popup=IS_POPUP_VAR in request.GET, media=media, errors=helpers.AdminErrorList(form, ()), preserved_filters=self.get_preserved_filters(request), ) context.update(extra_context or {}) return self.render_change_form(request, context, add=True, change=False, form_url=form_url)