EXPT 5 and 6
EXPT 5 and 6
Experiment 5
Theory:
Django App:
● D jango is a high-level Python web framework that encourages rapid development and
clean, pragmatic design.
● It follows the Model-View-Template (MVT) architectural pattern.
Project Structure:
●
manage.py
: Command-line utility for administrativetasks.
●
settings.py
: Configuration settings for the Djangoproject.
●
urls.py
: URL declarations for the project.
●
wsgi.py
: Entry point for WSGI-compatible web servers.
U
● python manage.py startapp appnameto create anew app.
se
● Apps should be modular and reusable components within the project.
settings.pyfile.
● Register the app in the project’s
URL Routing:
D
● urls.pyusing the
efine URL patterns in pathand
re_pathfunctions.
● Use include() to reference URL patterns from apps, promoting modularity.
U
● se Django’s built-in authentication system for user management.
● Implement login, logout, and registration views.
● Use decorators and mixins for access control.
staticdirectory.
● Manage static files (CSS, JavaScript, images) in the
MEDIA_ROOTand
● Configure media files (user-uploaded content) in MEDIA_URL
.
Testing:
W
● rite unit tests for models, views, and forms using Django’s test framework.
● Run tests with python manage.py testto ensure codereliability.
Deployment:
● P repare the app for deployment with settings adjustments (DEBUG=False,
ALLOWED_HOSTS, etc.).
● Use WSGI servers like Gunicorn for running Django applications.
Experiment List & Theory
● Configure web servers (e.g., Nginx, Apache) to serve the application.
P
● rotect against common threats like XSS, CSRF, and SQL injection.
● Use Django’s security middleware and settings to enhance protection.
Performance Optimization:
Scalability:
D
● esign the application to scale horizontally by adding more instances.
● Use load balancers to distribute traffic.
● Implement database replication and sharding for data scalability.
Experiment List & Theory
Experiment 6
Theory: