Lesson 37-2

parent b9755297
from django.urls import path
from article.views import article_create_view
from article.views import article_create_view, article_list_view
urlpatterns = [
path('add/', article_create_view, name='add_article')
path('add/', article_create_view, name='add_article'),
path('list/', article_list_view, name='article_list')
]
\ No newline at end of file
......@@ -20,3 +20,10 @@ def article_create_view(request):
return render(request, 'article/list.html', context={
'articles': articles_list
})
def article_list_view(request):
articles_list = Article.objects.all()
return render(request, 'article/list.html', context={
'articles': articles_list
})
\ No newline at end of file
......@@ -121,6 +121,10 @@ USE_TZ = True
STATIC_URL = '/static/'
# STATICFILES_DIRS = [
# [BASE_DIR / "static"]
# ]
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
......
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<div class="container">
{% extends 'base.html' %}
{% block content %}
<div class="row">
<div class="col-md-6">
<form action="{% url 'add_article' %}" method="post">
......@@ -30,6 +21,4 @@
</form>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
{% endblock %}
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<div class="container">
{% extends 'base.html' %}
{% block content %}
<h4>{{ message }}</h4>
<div class="row">
<div class="col-md-6">
......@@ -19,6 +10,4 @@
<p>{{ article.content }}</p>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
{% endblock %}
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<div class="container">
<div class="row">
{% extends 'base.html' %}
{% block content %}
<div class="row">
<div class="col-md-6">
<ul>
{% for article in articles %}
......@@ -18,7 +9,5 @@
{% endfor %}
</ul>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
</div>
{% endblock %}
{#{% load static %}#}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
{# <link rel="stylesheet" href="{% url 'css/style.css' %}">#}
<title>Document</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
{% block content %}
{% endblock %}
</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment