django-8,写高复用的app
2018-01-24 00:00
169 查看
摘要: 讲应用打包,开源,使用pip安装使用
就像再setting里面调用app和url里面使用include方便,我们可以做更多
讲polls 复制到新建文件夹django-polls(尽量避免重复)
Create a file
django-polls/README.rst
Create a
django-polls/setup.py
create a
django-polls/MANIFEST.in
Note that the
Try building your package with
使用
开源并上传
注册账号
https://pypi.python.org/pypi?%3Aaction=register_form
pip install twine
上传成功之后便可以用pip安装使用了
就像再setting里面调用app和url里面使用include方便,我们可以做更多
讲polls 复制到新建文件夹django-polls(尽量避免重复)
Create a file
django-polls/README.rstwith the following contents:
django-polls/README.rst
===== Polls ===== Polls is a simple Django app to conduct Web-based polls. For each question, visitors can choose between a fixed number of answers. Detailed documentation is in the "docs" directory. Quick start ----------- 1. Add "polls" to your INSTALLED_APPS setting like this:: INSTALLED_APPS = [ ... 'polls', ] 2. Include the polls URLconf in your project urls.py like this:: path('polls/', include('polls.urls')), 3. Run `python manage.py migrate` to create the polls models. 4. Start the development server and visit http://127.0.0.1:8000/admin/ to create a poll (you'll need the Admin app enabled). 5. Visit http://127.0.0.1:8000/polls/ to participate in the poll.
Create a
django-polls/LICENSEfil
django-polls/setup.py
import os from setuptools import find_packages, setup with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme: README = readme.read() # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( name='django-polls-fuan', version='0.1', packages=find_packages(), include_package_data=True, license='BSD License', # example license description='A simple Django app to conduct Web-based polls.', long_description=README, url='https://www.example.com/', author='Your Name', author_email='yourname@example.com', classifiers=[ 'Environment :: Web Environment', 'Framework :: Django', 'Framework :: Django :: 2.0, # replace "X.Y" as appropriate 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', # example license 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ], )
create a
MANIFEST.infile.
django-polls/MANIFEST.in
include LICENSE include README.rst recursive-include polls/static * recursive-include polls/templates *
Note that the
docsdirectory won’t be included in your package unless you add some files to it. Many Django apps also provide their documentation online through sites like readthedocs.org.
recursive-include docs *
Try building your package with
python setup.py sdist(run from inside
django-polls). This creates a directory called
distand builds your new package,
django-polls-fuhan-0.1.tar.gz.
使用
pip install --user django-polls/dist/django-polls-fuhan-0.1.tar.gz
pip uninstall django-polls
开源并上传
注册账号
https://pypi.python.org/pypi?%3Aaction=register_form
pip install twine
twine upload dist/*
上传成功之后便可以用pip安装使用了
相关文章推荐
- Django Hello World app
- django新建app以及model的创建
- django多个app组织形式
- django 2.0 创建新应用 app 要做什么 怎么做 速记
- pycharm的django工程中再建一个app
- Django之第一个app<15>
- pycharm django 再建一个app
- 创建Django的App
- 看完了Writing your first Django app, part 1,我的笔记(1)
- [转]使用Google App Engine Helper for Django
- Django 官方文档write your first Django app --6
- Django(二)创建app,设置相关后台
- Django 2 创建app
- 【译】自己动手写Django app,第一部分【完】
- Django1.3添加app提示模块不存在的解决方法
- 在pycharm中如何将django中多个app放到同个文件夹apps处理
- pycharm 运行django服务器端 以及创建app方法
- Django-1.8.3新建一个简单的News app——安装django
- Django-1.8.3新建一个简单的News app——01初探urls views
- Django之第一个app<13>