0
0
Djangoframework~30 mins

Creating a Django project - Try It Yourself

Choose your learning style9 modes available
Creating a Django Project
📖 Scenario: You want to start a new website project using Django, a popular web framework in Python. This project will guide you through creating the basic Django project setup step-by-step.
🎯 Goal: Build a new Django project named mywebsite with the default settings and a basic app called main.
📋 What You'll Learn
Create a new Django project named mywebsite
Create a new Django app named main inside the project
Add the main app to the project’s INSTALLED_APPS list
Create a simple view in main/views.py that returns a plain text response
Configure the project’s urls.py to route the home page to the main app’s view
💡 Why This Matters
🌍 Real World
Starting a Django project is the first step to building websites and web apps with Python. This setup is the foundation for adding pages, data, and user features.
💼 Career
Many web developer jobs require knowledge of Django project structure, app creation, and URL routing to build maintainable web applications.
Progress0 / 4 steps
1
Create the Django project
Run the command django-admin startproject mywebsite in your terminal to create a new Django project folder named mywebsite.
Django
Need a hint?

Open your terminal or command prompt and type exactly django-admin startproject mywebsite then press Enter.

2
Create the Django app
Inside the mywebsite folder, run the command python manage.py startapp main to create a new app called main.
Django
Need a hint?

Change directory into mywebsite and run python manage.py startapp main.

3
Add the app to INSTALLED_APPS
Open mywebsite/settings.py and add the string 'main' to the INSTALLED_APPS list.
Django
Need a hint?

Find the INSTALLED_APPS list in settings.py and add 'main' as a new item.

4
Create a view and route the home page
In main/views.py, create a function home that returns HttpResponse("Hello, Django!"). Then, in mywebsite/urls.py, import home and add a URL pattern for the root path '' to call home.
Django
Need a hint?

Define the home function in main/views.py and return a simple HttpResponse. Then update urls.py to route the root URL to this view.