































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
We do need to run python manage.py syncdb to get our default tables set up. ... <a class=navbar-brand href=#>PyCon Survival Guide</a>.
Typology: Summaries
1 / 39
This page cannot be seen from the preview
Don't miss anything!
































export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh
< html > < head > < title >{% block title %}PyCon Survival Guide{% endblock title %}</ title > < link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/ ˓→bootstrap.min.css"> < style > body { padding-bottom : 20 px ; padding-top : 70 px ; }
. messages { list-style : none ; } </ style > {% block css %}{% endblock css %} </ head > < body > < div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> < div class="container"> < div class="navbar-header"> < button type="button" class="navbar-toggle" data-toggle="collapse" data- ˓→target=".navbar-collapse"> < span class="sr-only">Toggle navigation</ span > < span class="icon-bar"></ span > < span class="icon-bar"></ span > < span class="icon-bar"></ span > </ button > < a class="navbar-brand" href="#">PyCon Survival Guide</ a > </ div > < div class="navbar-collapse collapse"> </ div > </ div > </ div > < div class="jumbotron"> < div class="container">{% block headline %}{% endblock headline %}</ div > </ div > < div class="container"> {% block content %}{% endblock content %} </ div > < script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></ ˓→ script > {% block js %}{% endblock js %} </ body > </ html >
Auth views
from django.views import generic
class HomePageView (generic.TemplateView): template_name = 'home.html'
{% extends '_layouts/base.html' %}
{% block headline %}< h1 >Welcome to the PyCon Survival Guide!</ h1 >{% endblock headline ˓→%}
{% block content %} < p >Howdy{% if user.is_authenticated %} {{ user.username }}{% endif %}!</ p > {% endblock %}
from .views import HomePageView [...]
url('^$', HomePageView.as_view(), name='home'),
from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User
class SignUpView (generic.CreateView): form_class = UserCreationForm model = User template_name = 'accounts/signup.html'
from django.contrib.auth.forms import UserCreationForm
from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, ButtonHolder, Submit
class RegistrationForm (UserCreationForm): def init(self, *args, *kwargs): super(RegistrationForm, self).init(args, **kwargs)
self.helper = FormHelper() self.helper.layout = Layout( 'username', 'password1', 'password2', ButtonHolder( Submit('register', 'Register', css_class='btn-primary') ) )
from django.contrib.auth.forms import UserCreationForm
from .forms import RegistrationForm
from future import absolute_import