Django
Django
Install Django
Make sure you have Django installed. Use the following command:
1.
2.
Create an Application
Navigate to your project directory and create an app:
cd myproject
3.
Code Structure
1. settings.py
...
'myapp',
class Article(models.Model):
title = models.CharField(max_length=100) # Title of the article
def __str__(self):
def article_list(request):
urlpatterns = [
]
Include your app’s urls.py in the project’s urls.py:
from django.contrib import admin
urlpatterns = [
path('admin/', admin.site.urls),
<!DOCTYPE html>
<html>
<head>
<title>Article List</title>
</head>
<body>
<h1>Articles</h1>
<ul>
{% endfor %}
</ul>
</body>
</html>
1. models.py
○ Handles the logic for fetching data from the database and passing it to the template.
3. urls.py
This setup is a foundational Django application demonstrating the MVC (Model-View-Controller) pattern.
Let me know if you'd like more details or want to extend this project!