<?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>DEV Community: Shan Ndanu</title>
    <description>The latest articles on DEV Community by Shan Ndanu (@shan_ndanu_45aad2aad3f128).</description>
    <link>https://dev.to/shan_ndanu_45aad2aad3f128</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%2F3289821%2F18fe367d-8f1d-4730-b9a5-41e9855177b0.png</url>
      <title>DEV Community: Shan Ndanu</title>
      <link>https://dev.to/shan_ndanu_45aad2aad3f128</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shan_ndanu_45aad2aad3f128"/>
    <language>en</language>
    <item>
      <title>DAY 4: How I Structured My Django Project with Two Apps</title>
      <dc:creator>Shan Ndanu</dc:creator>
      <pubDate>Mon, 30 Jun 2025 19:07:35 +0000</pubDate>
      <link>https://dev.to/shan_ndanu_45aad2aad3f128/day-4-how-i-structured-my-django-project-with-two-apps-493c</link>
      <guid>https://dev.to/shan_ndanu_45aad2aad3f128/day-4-how-i-structured-my-django-project-with-two-apps-493c</guid>
      <description>&lt;p&gt;hello again. I actually find it interesting learning new things in django day by day.so proud of myself. Recently, I embarked on a new Django project which i named it Shannels, and i structured it with two distinct apps  . I wanted to share my experience, the thought process behind it, and the tools I used to achieve this modularity. &lt;/p&gt;

&lt;p&gt;i actually found out that idea behind Django's "app" concept is to promote the "single responsibility principle." Each app should do one thing and do it well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Setup: Creating the Project and Apps&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, I created the main Django project, Shannels. I like to name my project's root directory the same as the project itself, to keep things clean.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;django-admin startproject shannels&lt;br&gt;
cd shannels&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, I created my two apps within the &lt;code&gt;shannels&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python manage.py startapp users&lt;br&gt;
python manage.py startapp content&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;At this point, my project directory structure looked something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;shannels/&lt;br&gt;
├── manage.py&lt;br&gt;
├── shannels/&lt;br&gt;
│   ├── __init__.py&lt;br&gt;
│   ├── settings.py&lt;br&gt;
│   ├── urls.py&lt;br&gt;
│   ├── wsgi.py&lt;br&gt;
│   └── asgi.py&lt;br&gt;
├── users/&lt;br&gt;
│   ├── migrations/&lt;br&gt;
│   ├── __init__.py&lt;br&gt;
│   ├── admin.py&lt;br&gt;
│   ├── apps.py&lt;br&gt;
│   ├── models.py&lt;br&gt;
│   ├── tests.py&lt;br&gt;
│   └── views.py&lt;br&gt;
└── content/&lt;br&gt;
    ├── migrations/&lt;br&gt;
    ├── __init__.py&lt;br&gt;
    ├── admin.py&lt;br&gt;
    ├── apps.py&lt;br&gt;
    ├── models.py&lt;br&gt;
    ├── tests.py&lt;br&gt;
    └── views.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Wiring It All Together: &lt;code&gt;settings.py&lt;/code&gt; and &lt;code&gt;urls.py&lt;/code&gt;&lt;br&gt;
i saw that the best and easier way to make Django aware of your new apps is to register them in &lt;code&gt;settings.py.&lt;/code&gt; and that what i tried.&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;shannels/settings.py&lt;/code&gt;, I added my apps to the &lt;code&gt;INSTALLED_APPS&lt;/code&gt; list:&lt;/p&gt;

&lt;p&gt;shannels/settings.py&lt;/p&gt;

&lt;p&gt;INSTALLED_APPS = [&lt;br&gt;
    'django.contrib.admin',&lt;br&gt;
    'django.contrib.auth',&lt;br&gt;
    'django.contrib.contenttypes',&lt;br&gt;
    'django.contrib.sessions',&lt;br&gt;
    'django.contrib.messages',&lt;br&gt;
    'django.contrib.staticfiles',&lt;br&gt;
    # My apps&lt;br&gt;
    'users',&lt;br&gt;
    'content',&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;Next, I needed to define the URL routing. Each app has its own &lt;code&gt;urls.py&lt;/code&gt; file to manage its specific routes. Then, the main project's &lt;code&gt;urls.py&lt;/code&gt; includes these app-specific URLs. for sure i had trouble at first but i tried.&lt;/p&gt;

&lt;p&gt;First, create&lt;code&gt;urls.py&lt;/code&gt; files within each app's directory &lt;/p&gt;

&lt;p&gt;`from django.urls import path&lt;br&gt;&lt;br&gt;
from . import views&lt;/p&gt;

&lt;p&gt;urlpatterns = [&lt;br&gt;
    path('', views.home, name='home'),&lt;br&gt;
    path('about/', views.about, name='about')&lt;br&gt;
]&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;Almost there. In the main project's &lt;code&gt;shannels/urls.py&lt;/code&gt;, I included these app-specific URL configurations:&lt;br&gt;
 `shannels/urls.py&lt;/p&gt;

&lt;p&gt;from django.contrib import admin&lt;br&gt;
from django.urls import path, include&lt;/p&gt;

&lt;p&gt;urlpatterns = [&lt;br&gt;
    path('admin/', admin.site.urls),&lt;br&gt;
    path('accounts/', include('users.urls')), # URLs for user management&lt;br&gt;
    path('blog/', include('content.urls')),   # URLs for content management&lt;br&gt;
]&lt;br&gt;
&lt;code&gt;&lt;br&gt;
Now, URLs like &lt;/code&gt;/accounts/register/ &lt;code&gt;would be handled by the &lt;/code&gt;users&lt;code&gt; app, and &lt;/code&gt;/blog/articles/&lt;code&gt; by the &lt;/code&gt;content` app&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shared Resources&lt;/strong&gt;&lt;br&gt;
While designing the app i saw it was common for them to share resources . Here's how I managed that:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Templates&lt;/strong&gt;: I set up a project-level templates directory in shannels/templates for base templates (e.g., base.html, navbar.html) that are shared across all apps. Each app could then have its own templates subdirectory (e.g., users/templates/users/, content/templates/content/) for app-specific templates that often extend the base templates. This is configured in settings.py by adding BASE_DIR / 'templates' to TEMPLATES['DIRS'].&lt;/p&gt;

&lt;p&gt;Model Relationships: If a model in one app needs to relate to a model in another i saw that Django handles this easily. i simply imported my model&lt;/p&gt;

&lt;h1&gt;
  
  
  content/models.py
&lt;/h1&gt;

&lt;p&gt;from django.db import models&lt;br&gt;
from users.models import CustomUser # Assuming you have a CustomUser model&lt;/p&gt;

&lt;p&gt;&lt;code&gt;class Article(models.Model):&lt;br&gt;
    title = models.CharField(max_length=200)&lt;br&gt;
    content = models.TextField()&lt;br&gt;
    author = models.ForeignKey(CustomUser, on_delete=models.CASCADE)&lt;br&gt;
    published_date = models.DateTimeField(auto_now_add=True)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I Used Beyond Django Itself&lt;/strong&gt;&lt;br&gt;
While the core functionality of structuring multiple apps is built into Django, here are some tools and practices that made the process smoother:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(Python venv)&lt;/strong&gt;: Absolutely essential for isolating project dependencies. I always start by creating a virtual environment: &lt;code&gt;python -m venv venv&lt;/code&gt; and activating it.&lt;br&gt;
&lt;strong&gt;Git for Version Control&lt;/strong&gt;: Indispensable for tracking changes, experimenting with features, and collaborating.&lt;br&gt;
sensible Naming Conventions&lt;br&gt;
&lt;strong&gt;Django Admin&lt;/strong&gt;: Once the models are defined in each app, registering them with&lt;code&gt;admin.py&lt;/code&gt; in their respective apps immediately gives you a powerful interface for managing your data&lt;/p&gt;

&lt;p&gt;What i learnt&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it is not always hard when you try and learn from mistakes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-if you anticipate growth or distinct functionalities, consider starting with multiple app&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;don't split your project into apps that are too granular.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;**To finish up **i can tell that Creating a Django project with multiple apps isn't just about doing it to best practices; it's about building and maintainable. By dividing my project's concerns into &lt;code&gt;users&lt;/code&gt; and &lt;code&gt;content&lt;/code&gt; apps within Shannels, I've laid a strong foundation for future development and collaboration. I recommend this approach for my next Django endeavor!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How I Set Up My Python Dev Environment</title>
      <dc:creator>Shan Ndanu</dc:creator>
      <pubDate>Tue, 24 Jun 2025 19:10:05 +0000</pubDate>
      <link>https://dev.to/shan_ndanu_45aad2aad3f128/how-i-set-up-my-python-dev-environment-3lo3</link>
      <guid>https://dev.to/shan_ndanu_45aad2aad3f128/how-i-set-up-my-python-dev-environment-3lo3</guid>
      <description>&lt;p&gt;Hello everyone, I’m Shan. I’m not an expert in this yet, but I’m eager to learn more.&lt;br&gt;&lt;br&gt;
I decided to start with Python and explore the interesting things it can do.&lt;/p&gt;




&lt;p&gt;Here’s What I Installed&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git
&lt;/li&gt;
&lt;li&gt;Python 3.13
&lt;/li&gt;
&lt;li&gt;VS Code
&lt;/li&gt;
&lt;li&gt;WSL (for Linux on Windows)
&lt;/li&gt;
&lt;li&gt;Docker
&lt;/li&gt;
&lt;li&gt;GitHub SSH&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;How I Installed Everything&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I used "Google Chrome" to download Git, Python, VS Code, and Docker.&lt;br&gt;&lt;br&gt;
I used "Windows PowerShell" to install WSL.&lt;/p&gt;




&lt;p&gt;** Git**&lt;/p&gt;

&lt;p&gt;Downloaded from &lt;a href="https://git-scm.com" rel="noopener noreferrer"&gt;git-scm.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To test:i applied used below to check&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
git --version&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python 3.13&lt;/strong&gt;&lt;br&gt;
Downloaded from python.org&lt;br&gt;
i clicked on Windows installer (64-bit)&lt;br&gt;
i then added python to path and clicked install&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VS Code&lt;/strong&gt;&lt;br&gt;
Installed from code.visualstudio.com&lt;br&gt;
i saw it was the easiest method to download&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WSL&lt;/strong&gt;&lt;br&gt;
In PowerShell, I ran: wsl --install and it installed not taking much time&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker&lt;/strong&gt;&lt;br&gt;
i Installed Docker Desktop and followed the instructions. i enabled wsl2 backened when prompted&lt;br&gt;
After installation:&lt;br&gt;
docker --version&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub SSH&lt;/strong&gt;&lt;br&gt;
i then Set up SSH using ssh-keygen -t ed25519 -C "&lt;a href="mailto:ndanushan31@gmail.com"&gt;ndanushan31@gmail.com&lt;/a&gt;" this is an example&lt;br&gt;
I then copied the public key to GitHub under Settings → SSH and GPG keys.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;what i learnt&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it needs patience. install one tool at a time&lt;/li&gt;
&lt;li&gt;SSH setup is worth doing — saves you from typing passwords&lt;/li&gt;
&lt;li&gt;do it with interest&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My Conclusion&lt;br&gt;
Now I’m ready to continue coding in Python with all the tools I need!&lt;br&gt;
DO NOT HESITATE....Start now and experience the best&lt;br&gt;
Happy coding!!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
