from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth import views as auth_views from accounts import views as accounts_views
from boards import views urlpatterns = [
url(r'^$', views.home, name='home'),
url(r'^signup/$', accounts_views.signup, name='signup'),
url(r'^login/$', auth_views.LoginView.as_view(template_name='login.html'), name='login'),
url(r'^logout/$', auth_views.LogoutView.as_view(), name='logout'), url(r'^reset/$',
auth_views.PasswordResetView.as_view(
template_name='password_reset.html',
email_template_name='password_reset_email.html',
subject_template_name='password_reset_subject.txt'
),
name='password_reset'),
url(r'^reset/done/$',
auth_views.PasswordResetDoneView.as_view(template_name='password_reset_done.html'),
name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html'),
name='password_reset_confirm'),
url(r'^reset/complete/$',
auth_views.PasswordResetCompleteView.as_view(template_name='password_reset_complete.html'),
name='password_reset_complete'), url(r'^settings/password/$', auth_views.PasswordChangeView.as_view(template_name='password_change.html'),
name='password_change'),
url(r'^settings/password/done/$', auth_views.PasswordChangeDoneView.as_view(template_name='password_change_done.html'),
name='password_change_done'), url(r'^boards/(?P<pk>\d+)/$', views.board_topics, name='board_topics'),
url(r'^boards/(?P<pk>\d+)/new/$', views.new_topic, name='new_topic'),
url(r'^admin/', admin.site.urls),
]
python manage.py makemigrations
python manage.py sqlmigrate boards 0001
python manage.py migrate python manage.py shell from boards.models import Board
board = Board.objects.create(name='Django', description='This is a board about Django.')
board = Board.objects.create(name='Python', description='General discussion about Python.')
board = Board.objects.create(name='Random', description='Here you can discuss about anything.') boards_list = Board.objects.all()
for board in boards_list:
print(board.description)
#accounts/forms.py
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User class SignUpForm(UserCreationForm):
email = forms.CharField(max_length=254, required=True, widget=forms.EmailInput()) class Meta:
model = User
fields = ('username', 'email', 'password1', 'password2')
#boards/templatetags/form_tags.py
from django import template register = template.Library() @register.filter
def field_type(bound_field):
return bound_field.field.widget.__class__.__name__ @register.filter
def input_class(bound_field):
css_class = ''
if bound_field.form.is_bound:
if bound_field.errors:
css_class = 'is-invalid'
elif field_type(bound_field) != 'PasswordInput':
css_class = 'is-valid'
return 'form-control {}'.format(css_class)

Part 4 - Authentication(14-16)的更多相关文章

  1. (2.16)Mysql之SQL基础——函数

    (2.16)Mysql之SQL基础——函数 关键词:mysql函数,mysql自定义函数,mysql聚合函数,mysql字符串函数,mysql数值函数 1.自定义函数 -- (1)一般形式 creat ...

  2. (Problem 16)Power digit sum

    215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of th ...

  3. (1.16)mysql server优化之buffer pool

    (1.16)mysql server优化之buffer pool 1.innodb buffer pool 查看 show status like  'Innodb_buffer_pool_%'; 该 ...

  4. (3.16)mysql基础深入——mysql字符集

    (3.16)mysql基础深入——mysql字符集 关键字:mysql字符集,mysql编码 目录 1.概念 2.常用的字符编码 3.查看mysql字符集 [3.1]查看服务器支持的字符集 [3.2] ...

  5. 【每日Scrum】第六天(4.16) TD学生助手Sprint1阶段性成果

    TD学生助手Sprint1阶段性成果(4.16) 任务看板 站立会议内容 组员 昨天 今天 困难 签到 刘铸辉 (组长) 和叶姐,静姐修改页面布局和图片显示,保证界面的亲切. 和大家一起做演示PPT, ...

  6. SQL Server2012 T-SQL基础教程--读书笔记(1-4章)

    SQL Server2012 T-SQL基础教程--读书笔记(1-4章) SqlServer T-SQL 示例数据库:点我 Chapter 01 T-SQL 查询和编程背景 1.3 创建表和定义数据的 ...

  7. (4)Linux命令分类汇总(13~16)

    Linux命令分类汇总(13~16) (十三)系统管理与性能监视命令(9个) 79       chkconfig 管理Linux系统开机启动项. 80       vmstat 虚拟内存统计. 81 ...

  8. Http authentication(BASIC, DIGEST)

    Http authentication....BASIC: In the context of an HTTP transaction, basic access authentication is ...

  9. (4.16)sql server迁移DB文件(同一DB内)

    SQL Server 修改数据库物理文件存在位置 关键词:迁移文件,迁移temp库(这怎么迁移呢,用方法2即可,需要重启实例) 三种均需要离线: 一共分为(1)脱机迁移和(2)在线迁移. (1)迁移方 ...

  10. Kubuntu(14.04)共享wifi(热点)

    笔记本(kubuntu14.04)通过有线上网,共享本机无线给手机.平板及其他通过wifi上网的设备. 曾经在网上找过各种方法.下载了非常多软件都不能在本机上实现wifi共享,以下这样的方法眼下相对简 ...

随机推荐

  1. 去除android手机浏览器中, 按住链接出现border的情况

    body{ -moz-user-select:none; -webkit-user-select:none; -webkit-tap-highlight-color:transparent; }

  2. Mysql 索引优化 - 2

    永远小表驱动大表(小数据驱动大数据) in exists区别, SELECT * FROM A WHERE A.id in (SELECT id FORM B) 若A表数据大于B表数据用in SELE ...

  3. UI5-文档-4.33-Routing Back and History

    现在我们可以导航到细节页面并显示发票,但是还不能回到概览页面.我们将向细节页面添加一个back按钮,并实现一个函数,再次显示概述页面. Preview A back button is now dis ...

  4. spring boot 测试类

    import org.junit.Test;import org.junit.runner.RunWith;import org.slf4j.Logger;import org.slf4j.Logge ...

  5. mysql之MMM高可用方案简介

    MMM(Master-Master Replication Manager for MySQL) MySQL主主复制管理器,提供了MySQL主主复制配置的监控.故障转移和管理的一套可伸缩的脚本套件.在 ...

  6. 全屏幕显示AVI

    uses Unit2; procedure TForm1.Button1Click(Sender: TObject);begin  Form2.Show;  Form2.WindowState := ...

  7. python的读写和写读操作

    # 读写操作 (读写操作是正常的)f = open('log',mode='r+',encoding='utf-8') # log是文件名 print(f.read()) f.write(" ...

  8. Mycat入门及简单规则

    以下都来自网络: 官网: http://www.mycat.io/ 官网配置文件解析: https://github.com/MyCATApache/Mycat-Server/wiki/9.0-%E6 ...

  9. T分布(T-Distribution)

    1.What is the T Distribution? T分布(也叫Student 's T分布)是一组与正态分布曲线几乎相同的分布,只是更短更胖一点.当有小样本时,使用t分布而不是正态分布.样本 ...

  10. 9-最短路径(dijkstra)

    参考博客:http://www.wutianqi.com/?p=1890 #include <iostream>using namespace std;#define  max 1< ...