- 新建一个django项目
- 配置项目的运行环境,Python解释器:
- settings:Language & Frameworks->Django->Django project root;Settings
- Project:******->Project Interpreter->Project Interpreter:选择相应的python解释器
- Run->Edit configurations->"+"Python->Name:**;Script path:项目目录\manage.py;Parameters:runserver;Python interpreter:Python解释器
- 新建app: Terminal:python manage.py app_name:
- 配置主目录settings.py:INSTALLED_APPS中添加 ‘app_name’,;
- 配置主目录urls.py:urlpatterns中添加:url(r'',include('app_name.urls')),
- 连接redis:
- 定义redis集群:redis_node=[{},{},{}];密码:redis_password
- 添加rediscluster框架:redis-py-cluster
- 连接redis:
try: redisconn = RedisCluster(startup_nodes=redis_nodes,decode_responses=True, password=pd, max_connections=150) except Exception: print("Connect Redis Error")
- 针对每一个功能的app:
- 新建serializers.py:(类似于form表单)(待编辑。。。。。。。。。。。。。)
- 编辑views.py:编写功能对应视图函数:
-
class RecSingleView(APIView): def post(self, request,format=None): pass
- 编辑urls.py:定义视图函数对应的urls
-
urlpatterns=[ url(r'^rec-single/',RecSingleView.as_view()) ]
开发一个Django项目流程
猜你喜欢
转载自www.cnblogs.com/yujiebingqing/p/9634616.html
今日推荐
周排行