DEV Community

Yusra Muktar
Yusra Muktar

Posted on

Getting started with Django: Beginner summary with PyCharm

FIRST PART:
make sure you have pycharm installed in your machine,open pycharm and start a new project give the folder a name and a location that you know you can easily find

Image description

One big advantage of PyCharm is that it creates a virtual environment (venv) automatically when you make a new project — you just choose the Python version and PyCharm sets up everything for you.

Image description

im gonna activate venv, pycharm comes w a venv automatically as stated above:)

Image description
i have activated venv and started my project i called it config
under the project you created it should show you the following
init_.py
asgi.py
settings.py
urls.py
wsgi.py

Image description

so next step is creating an app
An app is a web application that has a specific meaning in your project, like a home page, a contact form, or a members database.

Image description
i decided to call my app "arusha" you can call it whatever...

Image description
went ahead and created another app named it "devcode"
we are gonna then register the apps,Open config/settings.py
Find INSTALLED_APPS and add your app there

Image description

built a basic Django project with two separate apps (arusha and devcode).
Each app has its own view (Python function) and its own HTML template (web page).we created the separate templates,check the structure its clean and not confusing at all.
When you have more than one app, Django can get confused if multiple apps have a template called index.html.

Solution: use app-named subfolders in templates:

Image description

next is creating views.py for each template
first template
Image description

second template for devcode

Image description

and adding urls.py for each app,later on we will hook both apps into main projects urls
i ran into a problem regarding urls but managed to fix it...small issue like where you place the url might be the reason your server does not run so be careful.
You connected them using URLs, so you can visit each page in your browser.

Image description

Image description

Image description

this is gonna drive you crazy if you are not careful..

Image description

ran server works
pro tip though
Remember: In Django, your views.py lives in the app folder, and your HTML files live in the templates folder. Keep your structure clean to avoid errors!
In this mini project, I set up a Django project with two separate apps. Each app has its own view and its own template. I linked them with URL paths so I can open each page in the browser. This is how Django helps you organize big websites into smaller, reusable pieces
And just like that, my first Django project with multiple apps runs in the browser! I learned how to create apps, views, templates, and connect everything step by step — all inside PyCharm, which made setup smooth and beginner-friendly.

Top comments (0)