return self.render(request, {self.realm.name: category, 'item': category, 'realms_links': realms_links}) class VersionDetailsView(DetailsView): """Представление с детальной информацией о версии Питона.""" def update_context(self, context, request): version = context['item'] context['added'] = version.reference_added.order_by('title') context['deprecated'] = version.reference_deprecated.order_by('title') context['peps'] = version.peps.order_by('num') # Наши страницы ошибок. permission_denied = lambda request, exception: dj_permission_denied(request, exception, template_name='static/403.html') page_not_found = lambda request, exception: dj_page_not_found(request, exception, template_name='static/404.html') server_error = lambda request: dj_server_error(request, template_name='static/500.html') @cache_page(1800) # 30 минут @csrf_protect def index(request): """Индексная страница.""" from .realms import get_realms realms_data = [] realms_registry = get_realms() externals = ExternalResource.objects.filter(realm_name__in=realms_registry.keys()) externals = {k: list(v) for k, v in groupby(externals, attrgetter('realm_name'))}
def page_not_found(request: HttpRequest, exception: Exception) -> HttpResponse: return dj_page_not_found(request, exception, template_name='static/404.html')
def page_not_found(request, exception=None, template='wcoa_404.html'): return dj_page_not_found(request, exception, template)
realm_list = [] for realm in get_realms(): if hasattr(realm.model, 'categories'): # ModelWithCategory objs = realm.model.get_objects_in_category(category)[:5] if objs: realm_list.append({ 'objects': objs, 'url': reverse(realm.get_tags_urlname(), args=[category.id]), 'realm': realm }) return self.render(request, {self.realm.name: category, 'item': category, 'realm_list': realm_list}) # Наши страницы ошибок. permission_denied = lambda request: dj_permission_denied(request, template_name='static/403.html') page_not_found = lambda request: dj_page_not_found(request, template_name='static/404.html') server_error = lambda request: dj_server_error(request, template_name='static/500.html') def index(request): from .realms import get_realms return render(request, 'index.html', {'realms': get_realms()}) @redirect_signedin @signin_view(widget_attrs={'class': 'form-control', 'placeholder': lambda f: f.label}, template='form_bootstrap3') @signup_view(widget_attrs={'class': 'form-control', 'placeholder': lambda f: f.label}, template='form_bootstrap3', flow=SimpleClassicWithEmailSignup, verify_email=True) def login(request): return render(request, 'static/login.html')