url(r'^(?P<category_slug>[-\w]+)/$', views.BookList, name='BookListByCategory')category = get_object_or_404(Category, slug=category_slug)urlpatterns = [
url(r'^contacts/$', views.ContactsPage, name='ContactsPage'),
url(r'^$', views.BookList, name='BookList'),
url(r'^(?P<category_slug>[-\w]+)/$', views.BookList, name='BookListByCategory'),
url(r'^(?P<id>\d+)/(?P<slug>[-\w]+)/$', views.BookDetail, name='BookDetail')
] class PersonAdmin(admin.ModelAdmin):
list_filter = ('is_active', 'company')class EngineerTypeFilter(SimpleListFilter):
title = u'инженеры'
parameter_name = 'engineer'
#engineer__id__exact
def lookups(self, request, model_admin):
return (
(None, u"Активные"),
('rejected', u"Уволенные"),
)
def queryset(self, request, queryset):
if self.value() is None:
records = queryset.filter(is_active=True)
else:
records = queryset.filter(is_active=False)
return records head_id = get_object_or_404(Heading, heading_alies=alies)head_id = get_object_or_404(Heading, heading_alies=alies)heading = get_object_or_404(Heading, heading_alies=alies) def set_unusable_password(self):
# Создает "ниюзабельный" пароль, который при вызове метода check_password будет возвращать False
self.password = make_password(None)
def has_usable_password(self):
return is_password_usable(self.password) template = get_template("%s/base.html" % request.domain)"domain_base_template": "%s/base.html" % request.domain{% extends domain_base_template %} from games.models import Game
def most_popular_games(request):
return { "MOST_POPULAR_GAMES": Game.objects.filter(active=True).order_by("-rating", "-id")[:5] }TEMPLATE_CONTEXT_PROCESSORS = (
...
"download_games.context_processors.most_popular_games",
...
}{% for game in MOST_POPULAR_GAMES %}
...
{% endfor %}