星期日, 6月 21, 2015

Django Class Base View Examples

https://docs.djangoproject.com/en/1.8/ref/class-based-views/

Generic display views
Model Name as suffix name, e.g., author_xxx.html
DetailView
_detail.html
ListView
_list.html


Generic editing views

FormView

CreateView
_form.html
UpdateView
_form.html
DeleteView
_confirm_delete.html









Reference:

好投影片
Django class-based views: survival guide for novices
http://www.slideshare.net/giordanileonardo/django-cb-vssurvivalguidefornovicesv2

Best Practices for Class-Based Views
http://www.slideshare.net/starwilly/two-scoopsofdjangocbv


好範例,很小很容易理解

Django 1.8 Tutorial - 1. A Minimal Application Made Using Generic Class Based Views
http://riceball.com/d/content/django-18-minimal-application-using-generic-class-based-views

Notes:
練習中少了一些命令
settings.py -->'comment'
python manage.py makemigration
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

Pycharm note:
把專案根目錄Make Directory as sources root 可以避免urls.py找不到相對import 檔提示問題
https://www.jetbrains.com/pycharm/help/configuring-folders-within-a-content-root.html


Getting started with Generic Class Based Views in Django
http://www.onespacemedia.com/news/2014/feb/5/getting-started-generic-class-based-views-django/

沒有留言: