Skip to content

Instantly share code, notes, and snippets.

View justachamp's full-sized avatar

Ayubkhon Abbosov justachamp

  • Uzbekistan
View GitHub Profile
{% extends 'base.html' %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
<!-- as_p для того, чтобы каждый элемент формы был с новой строки -->
{{ form.as_p }}
<button type="submit">Регистрация</button>
</form>
{% endblock %}
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,
}
@justachamp
justachamp / views.py
Created September 26, 2020 11:38 — forked from bsurajbh/views.py
django-default-auth-model views.py
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):
@justachamp
justachamp / logging_example.py
Created September 18, 2020 12:09 — forked from mbrengel/logging_example.py
Python Logging Setup
#!/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()
@justachamp
justachamp / logging_example.py
Created September 18, 2020 12:07 — forked from robdmc/logging_example.py
Python Logging Example
#! /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__)