This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block content %} | |
<form action="" method="post"> | |
{% csrf_token %} | |
<!-- as_p для того, чтобы каждый элемент формы был с новой строки --> | |
{{ form.as_p }} | |
<button type="submit">Регистрация</button> | |
</form> | |
{% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FeedbackFormView(FormView): | |
form_class = FeedbackForm | |
template_name = 'ecoke/feedback.html' | |
def get_initial(self): | |
if self.request.user.is_authenticated(): | |
return { | |
'name': self.request.user.profile.get_screen_name, | |
'email': self.request.user.email, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render, redirect | |
from .forms import SignupForm, LoginForm | |
from django.views.generic.edit import FormView | |
from django.contrib.auth import login, authenticate, logout | |
from django.urls import reverse_lazy | |
from django.http import HttpResponseRedirect | |
from django.contrib import messages | |
class SignupView(FormView): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import logging | |
from logging.handlers import RotatingFileHandler | |
import sys | |
import colorama | |
def configure_logging(): | |
# enable cross-platform colored output | |
colorama.init() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import logging | |
""" | |
I never remember all the steps for setting up logging in python. | |
This gist goes through the steps so I can copy and paste what I need. | |
""" | |
# create logger on the current module and set its level | |
logger = logging.getLogger(__file__) |