Here, We will be creating a django E-commerce project named "myEcommerceSite" with 2 apps named "shop" and "blog" within it.
Django Apps :
- Apps in Django are pluggable web applications.
- Django apps are the self-sufficient sub module of a project. A project can contain more than one apps, and an app can be used in more than one project.
Follow the below steps:
Step 1: Click on File and then select New Project.
Step 2: After clicking on New Project, a pop-up window will appear. Select the location(PycharmProjects folder recommended) and name the file as myEcommerceSite
Step3: Start the project
C:\Users\Srinanda\Desktop\python\djangoCodeSource\myEcommerceSite>django-admin startproject mes
Step 4: Run the command in following format to create the app.
python manage.py startapp name_of_the_app
C:\Users\Srinanda\Desktop\python\djangoCodeSource\myEcommerceSite\mes>python manage.py startapp blog
C:\Users\Srinanda\Desktop\python\djangoCodeSource\myEcommerceSite\mes>python manage.py startapp shop
from django.urls import pathfrom . import viewsurlpatterns = [path('', views.index, name="ShopHome"),]
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name="blogHome"),
]
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("index shop")
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("index blog")
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('shop/', include('shop.urls')),
path('blog/', include('blog.urls'))
]