Where IT meets innovation, IT-INFO lights the path to technological brilliance
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design.
To get started with Django, you need to have Python installed. You can install Django using pip
.
pip install django
Let's create a new Django project. Run the following command to create a new project named myproject
:
django-admin startproject myproject
Navigate to your project directory and start the development server:
cd myproject python manage.py runserver
Open your browser and go to http://127.0.0.1:8000. You should see the Django welcome page.
Inside your project directory, create a new app named myapp
:
python manage.py startapp myapp
Edit the views.py
file in your myapp
directory to define a simple view:
from django.http import HttpResponse def index(request): return HttpResponse("Hello, world!")
Edit the urls.py
file in your project directory to include the URL configuration for your app:
from django.contrib import admin from django.urls import include, path urlpatterns = [ path('myapp/', include('myapp.urls')), path('admin/', admin.site.urls), ]
Then, create a urls.py
file inside the myapp
directory:
from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), ]
In this guide, you've learned how to install Django, create a new project, and define a simple view. Django provides many built-in features to help you develop complex web applications quickly and efficiently. For more detailed information, refer to the official Django documentation.
Created on Aug. 7, 2024, 12:29 p.m.