<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sreethul</title>
    <description>The latest articles on Forem by Sreethul (@ksreethul).</description>
    <link>https://forem.com/ksreethul</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3572587%2Fe7f5c02b-47a4-46cb-b0cf-6c94025909f5.jpeg</url>
      <title>Forem: Sreethul</title>
      <link>https://forem.com/ksreethul</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ksreethul"/>
    <language>en</language>
    <item>
      <title>How to Convert a Django App into a Pip-Installable Package</title>
      <dc:creator>Sreethul</dc:creator>
      <pubDate>Wed, 22 Oct 2025 11:43:34 +0000</pubDate>
      <link>https://forem.com/ksreethul/how-to-convert-a-django-app-into-a-pip-installable-package-5c2</link>
      <guid>https://forem.com/ksreethul/how-to-convert-a-django-app-into-a-pip-installable-package-5c2</guid>
      <description>&lt;p&gt;Sometimes you develop a reusable Django app in your project and want to share it across multiple projects—or even publicly via PyPI. Here’s a step-by-step guide on how to convert your Django app into a pip-installable package.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Create a Dedicated Django App
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Inside your Django project, create a new app for your reusable functionality:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python manage.py startapp your_app_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Do &lt;strong&gt;all your coding only inside this app&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Outside the app, only update &lt;code&gt;settings.py&lt;/code&gt; → &lt;code&gt;INSTALLED_APPS&lt;/code&gt; if needed.&lt;/li&gt;
&lt;li&gt;Keep the app self-contained so that it can work independently when installed in other projects.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Step 2: Prepare Your App for Packaging
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Once your app is ready, &lt;strong&gt;create a new folder outside your Django project&lt;/strong&gt; with the same name as your app:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;your_app_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Copy your Django app into this folder.&lt;/li&gt;
&lt;li&gt;Add the following files to the folder:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;LICENSE&lt;/code&gt; – your license file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;README.md&lt;/code&gt; – a brief description of your app&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MANIFEST.in&lt;/code&gt; – to include non-Python files&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setup.py&lt;/code&gt; – packaging script&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pyproject.toml&lt;/code&gt; – build configuration&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Example &lt;code&gt;setup.py&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;setuptools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;find_packages&lt;/span&gt;

&lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;your_app_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;0.1.0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;find_packages&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;include_package_data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;install_requires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Django&amp;gt;=4.2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# specify dependencies
&lt;/span&gt;    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;license&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;MIT&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;A reusable Django app&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;long_description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;README.md&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="n"&gt;long_description_content_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text/markdown&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://github.com/yourusername/your_app_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Build the Package
&lt;/h2&gt;

&lt;p&gt;Run the following command in your app folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a &lt;code&gt;dist/&lt;/code&gt; folder containing &lt;code&gt;.whl&lt;/code&gt; and &lt;code&gt;.tar.gz&lt;/code&gt; files.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Install Locally
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go back to your Django project.&lt;/li&gt;
&lt;li&gt;Remove the old app from your project.&lt;/li&gt;
&lt;li&gt;Install the package from the &lt;code&gt;dist&lt;/code&gt; folder:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; ../your_app_name/dist/your_app_name-0.1.0-py3-none-any.whl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4.Now your app is installed into your virtual environment and can be used like any other installed package.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5: Publish to PyPI
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go back to your django app standalone folder,Same folder that you run python -m build.&lt;/li&gt;
&lt;li&gt;Upload to PyPI using Twine:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; twine upload dist/&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;It will prompt for your &lt;strong&gt;PyPI API token&lt;/strong&gt;. Generate one from your PyPI account.&lt;/li&gt;
&lt;li&gt;After a successful upload, your app is publicly available! Anyone can install it with:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;your_app_name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;ul&gt;
&lt;li&gt;Build and test locally before uploading to PyPI.&lt;/li&gt;
&lt;li&gt;After publishing, your app can be reused across projects or shared with the community.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>programming</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
