How to do it...

To release your likes app, follow these steps:

  1. Start a new Django app project, as follows:
(myapp_env)$ cookiecutter 
> https://github.com/pydanny/cookiecutter-djangopackage.git

Or, since this is a GitHub-hosted cookiecutter template, we can use a shorthand syntax, as follows:

(myapp_env)$ cookiecutter gh:pydanny/cookiecutter-djangopackage
  1. Answer the questions to create the app template, as follows:
full_name [Your full name here]: Your Name
email [[email protected]]: [email protected]
github_username [yourname]: githubuser
project_name [Django Package]: Django Likes
repo_name [dj-package]: django-likes
app_name [django_likes]: likes
app_config_name [LikesConfig]:
project_short_description [Your project description goes here]: Django-likes allows your website users to like any object.
models [Comma-separated list of models]: Like
django_versions [1.11,2.0]: 2.0
version [0.1.0]:
create_example_project [N]:
Select open_source_license:
1 - MIT
2 - BSD
3 - ISCL
4 - Apache Software License 2.0
5 - Not open source
Choose from 1, 2, 3, 4, 5 (1, 2, 3, 4, 5) [1]: 2

This will create a basic file structure for the releasable Django package, similar to the following screenshot:

└── django-likes/
├── docs/
│ ├── Makefile
│ ├── authors.rst
│ ├── conf.py
│ ├── contributing.rst
│ ├── history.rst
│ ├── index.rst
│ ├── installation.rst
│ ├── make.bat
│ ├── readme.rst
│ └── usage.rst
├── likes/
│ ├── static/
│ │ ├── css/
│ │ │ └── likes.css
│ │ ├── img/
│ │ └── js/
│ │ └── likes.js
│ ├── templates/
│ │ ├── static/
│ │ └── views.py
│ ├── __init__.py
│ ├── apps.py
│ ├── models.py
│ ├── urls.py
│ └── views.py
├── tests/
│ ├── __init.py
│ ├── settings.py
│ ├── test_models.py
│ └── urls.py
├── AUTHORS.rst
├── CONTRIBUTING.rst
├── HISTORY.rst
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README.rst
├── manage.py
├── requirements.txt
├── requirements_dev.txt
├── requirements_test.txt
├── runtests.py
├── setup.cfg
├── setup.py*
└── tox.ini
  1. Copy the files in the likes app from the Django project where you are using it to the django-likes/likes directory. In cases where the cookiecutter created the same files, the content will need to be merged, rather than overwritten. For instance, the likes/__init__.py file will need to contain a version string to work properly with setup.py in later steps, as follows:
__version__ = "0.1.0"
  1. In the likes app, we have a dependency upon the utils app, so that also needs to be made available. The ideal option would be to release the utils app itself (in the same manner as likes), and then change the imports in the likes app to draw from the new package location instead. We could also simply copy the utils code directly into the files in the likes app, but then we would have to maintain the code separately, in at least two places. In this case, let's simply add utils to the django-likes/utils directory, which is something of a compromise between the two approaches.
  2. Add the reusable app project to the Git repository in GitHub, using the repo_name that was entered previously.
  3. Explore the different files and complete the license, README, documentation, configuration, and other files.
  4. Make sure that the app passes the cookiecutter template tests:
(myapp_env)$ pip3 install -r requirements-test.txt
(myapp_env)$ python3 runtests.py
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
.
----------------------------------------------------------------------
Ran 1 test in 0.001s

OK
Destroying test database for alias 'default'...
  1. If your package is closed source, create a shareable release as a ZIP archive, as follows:
(myapp_env)$ python3 setup.py sdist
running sdist
running egg_info
# ...intermediary steps here...
creating dist
Creating tar archive
removing 'django-likes-0.1.0' (and everything under it)

This will create a django-likes/dist/django-likes-0.1.0.tar.gz file that can then be installed or uninstalled with pip, as follows:

(myproject_env)$ pip3 install django-likes-0.1.0.tar.gz
(myproject_env)$ pip3 uninstall django-likes
  1. If your package is open source, you can register and publish your app in the Python Package Index (PyPI):
(myapp_env)$ python3 setup.py register
(myapp_env)$ python3 setup.py publish
  1. Also, to spread the word, add your app to the Django packages by submitting a form at https://www.djangopackages.com/packages/add/.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.195.225