How to publish a Django package to PyPi?

PyPI · The Python Package Index


pip install django-package-by-me

How do you do this?


  1. How can I make a django package
  2. How to upload it to PyPi

Making a django package

  1. Create a parent directory named django-polls and create another directory named polls
  2. Copy the django app directories you want to package into the polls directory.
  3. Create a file django-polls/README.rstand add following content django-polls/README.rst with the following contents (This is for documentation purpose):
Description hereDetailed documentation is in the "docs" directory.Quick start
1. Add "polls" to your INSTALLED_APPS setting like this::INSTALLED_APPS = [
2. Include the polls URLconf in your project like this::url(r'^polls/', include('polls.urls')),3. Run `python migrate` to create the polls models.4. Start the development server and visit
to create a poll (you'll need the Admin app enabled).
5. Visit to participate in the poll.

4 . Also create a LICENSE file in the same directory

5. Create a setup.cfgfile

name = django-polls
version = 0.1
description = A Django app to conduct Web-based polls.
long_description = file: README.rst
url =
author = Your Name
author_email =
license = BSD-3-Clause # Example license
classifiers =
Environment :: Web Environment
Framework :: Django
Framework :: Django :: X.Y # Replace "X.Y" as appropriate
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Topic :: Internet :: WWW/HTTP
Topic :: Internet :: WWW/HTTP :: Dynamic Content

include_package_data = true
packages = find:

6. Create a setup.pyfile

from setuptools import setup


7. Create

include LICENSE
include README.rst
recursive-include polls/static *
recursive-include polls/templates *
recursive-include docs *

The directory structure will be like

— README.rst [file]
— LICENSE [file]
— setup.cfg [file]
— [file]
— [file]

— polls [dir]
— — [app directories]
— — ..
— — ..

8. python sdistto build the package
Now you may see some changes in the directory

9. Install twine pip install twine

10. Create an account on PyPi

11. twine upload dist/*

Enter PyPi username and password

Now you’re done with uploading the package. You can now install the package using pip install


  1. Packaging Python Projects
  2. Video Guide



Entrepreneur | Storyteller |

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store