Simple blogApp in Django Django by Ravinder Nath Rajotiya - January 4, 2022January 5, 20220 Steps in creating blogProject Starting virtual environment E:\project\webAppProjects>python –m venv venv E:\project\webAppProjects>venv\Scripts\activate Creating Project (venv) E:\project\webAppProjects>django-admin startproject blogProject (venv) E:\project\webAppProjects>cd blogProj (venv) E:\project\webAppProjects\blogProject>django-admin startapp blogApp Run the Server (venv) E:\project\webAppProjects\blogProj>python manage.py runserver Watching for file changes with StatReloader Performing system checks... January 04, 2022 - 09:31:14 Django version 4.0, using settings 'blogProj.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. now the server is ready, you can test by typing the url http://127.0.0.1:8000/ in the browser Developing Project in Atom Open the Project folder in Atom, your window will look as: Now modify urls.py and settings.py in blogProj folder Now create url.py in blogApp and update url.py and views.py as shown below: Create a folder template in blogApp and create a index.html
Multi Page Website in Django Django by Ravinder Nath Rajotiya - December 30, 20210 Project – Multi page website We will following steps in creating a multi-page website in Django Steps-1: Create views.html Step-2: create path in urls.py Step-3: create a template folder in external folder Step-4: create html file index.html and contact.html files in the template folder Step-5 : run the project in the browser Steps-1: Create views.html From django.shortcuts import render def home(request): return render(request,’index.html’) def contact(request): return render(request,’contact.html’) Step-2: create path in urls.py from . import views urlpatterns = [ path(‘admin/’, admin.site.urls), path(‘ ‘, views.home), path(‘about/’, views.contact, name=’contact’), #check name=’anyname’ ] Step-3: create a template folder in external folder Right click external folder and right click to create folder, name it as template Step-4: create html file index.html and contact.html files in the template folder <!DOCTYPE html> <html lang=”en” dir=”ltr”> <head> <meta charset=”utf-8”> <title> home </title> </head> </body> <h1> This is my first page</h1> <h3> list </h3> <ul> <li>
Starting Django Computer Engineering Django by Ravinder Nath Rajotiya - December 29, 20210 Checking if Django is installed and working: Type the following on the command prompt to check whether Django is installed or not C:\Users\ECE>django-admin C:\Users\ECE>'django-admin' is not recognized as an internal or external command, operable program or batch file. It simply is an indication that Django is not installed on your systems. So first of all create a python virtual environment so that you can install Django and start working on the Django environment. Steps for creating virtual environment Example: Go to the Project Folder:- E:\project\webAppProjects Set virtualEnv as : E:\project\webAppProjects>python -m venv venv Activate environment : E:\project\webAppProjects>venv\Scripts\activate Install Django Then install Django in that environment (venv) E:\project\webAppProjects\webProject1>cd \ (venv) E:\>pip install django Now you are ready to start Django for creating web applications Working with Django:- here is the example of