全栈增长工程师实战
http://growth-in-action.phodal.com/
https://my.oschina.net/liuxinquan/blog/551341
https://github.com/piyushthegamer/python-projects
https://github.com/dongqifan/forum
生成的代码和示例不一样,static 也要加上
from django.conf.urls import url
from django.contrib import admin
from blogpost import views as blogpostViews urlpatterns = [
url(r'^$', blogpostViews.index, name='main'),
url(r'^blog/(?P<slug>[^\.]+).html', blogpostViews.view_post, name='view_blog_post'),
url(r'^admin/', admin.site.urls),
]
STATIC_URL = '/static/' STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static/'),
'/static/js/',
'/static/css/',
)
django-rest-framework tutorial
https://github.com/tomchristie/django-rest-framework/blob/bb56ca46ed6c07db0146dbdc61c672ff25f127de/docs/tutorial/6-viewsets-and-routers.md
>>> def submission_to_json(submission):
... return {
... 'title':submission.title+"ddtt"
... }
... >>> class LL:
... title = 'a'
...
>>> ll = LL()
>>> ll
<__main__.LL instance at 0x102345488>
>>> submissions = [ll]
>>> list(submissions)
[<__main__.LL instance at 0x102345488>]
>>> map(submission_to_json,submissions)
[{'title': 'addtt'}]
http://localhost:8000/api/posts/?format=json
命令:
安装选版本
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple django==1.10.0
pip install django==1.10.0
pip freeze
这是Django版本的问题,1.10之前,中间件的key为MIDDLEWARE_CLASSES, 1.10之后,为MIDDLEWARE。
https://blog.****.net/xiongjiezk/article/details/53220302
python manage.py runserver
pip install -r requirements.txt
virtualenv命令
virtualenv .
virtualenv -p /anaconda3/bin/python3 shop01
cd shop01/
source bin/activate
MySQL-python
sudo chown -R $USER /Library/Python/
brew remove mysql
brew install mysql@5.7
brew link --force mysql@5.7
pip install MySQL-python
https://github.com/farcepest/MySQLdb1/issues/119
资料
https://github.com/zaxlct/python-django-learning
Blog-API-with-Django-Rest-Framework
https://www.bilibili.com/video/av11744508/
https://github.com/codingforentrepreneurs/Blog-API-with-Django-Rest-Framework