request.get_full_path == "/"
home_url == "/?page=2"
def home_view(request):
where_i_am = 'home_page'
....
# html
{% if where_i_am == "home_page" %}...
{% if request.user.is_staff %}
<li>
<a href="{% url "staff"%}">Admin Panel</a>
</li>
{% endif%}
{% if request.user.is_superuser %}
<li>
<a href="{% url "admin"%}">Admin Panel</a>
</li>
{% endif%}
class AuthorCreate(SuccessMessageMixin, ListView):
model = Author
template_name = "example.html"
def get_context_data(self, **kwargs):
context = super(AuthorCreate, self).get_context_data(**kwargs)
context['some_text_to_tpl'] = "Hello world"
return context
#html
{{ some_text_to_tpl }}
def my_context(request):
# do what you want
return my_context
def view1(request):
context = my_context(request)
#do what you need
return render('tpl1.html', context)
Видимо, процент пользователей, у которых не включена поддержка настолько мал, что все ими пренебрегают?
class Meta:
verbose_name = _('user')
verbose_name_plural = _('users')
# abstract = False
class LoginView(FormView):
success_url = '/blog/edit/'
form_class = AuthenticationForm
template_name = 'blog/login.html'
@method_decorator(sensitive_post_parameters('password'))
@method_decorator(never_cache)<code></code>
@method_decorator(requires_csrf_token)
def dispatch(self, request, *args, **kwargs):
return super(LoginView, self).dispatch(request, *args, **kwargs)
class UserCreate(View):
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super(UserCreate, self).dispatch(request, *args, **kwargs)
def post():
....
есть поле номер договора,