Skip to content

Commit

Permalink
learning about class-based views
Browse files Browse the repository at this point in the history
  • Loading branch information
kherin committed Jan 26, 2024
1 parent dd38640 commit f038922
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 65 deletions.
24 changes: 10 additions & 14 deletions project1/myapp/templates/about.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
</head>

<body>
<body>
<!-- Add heading code -->
<h1 style="color: #495E57">
About
</h1>
<h1 style="color: #495e57">About</h1>

<!-- Add paragraph code -->
<p>{{content.about}}</p>

<!-- Add image code -->

</body>

</html>
{% extends "base.html" %}
</body>
</html>
1 change: 1 addition & 0 deletions project1/myapp/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Hello from index!</h1>
14 changes: 14 additions & 0 deletions project1/myapp/templates/partials/_header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Add code to load static content-->

{% load static %}
<header>
<img src="{% static 'img/logo.png' %}" />
</header>
<nav>
<ul>
<li><a href="{% url 'home' %}">Home</a></li>
<li><a href="{% url 'about' %}">About</a></li>
<li><a href="{% url 'menu' %}">Menu</a></li>
<li><a href="{% url 'book' %}">Book</a></li>
</ul>
</nav>
17 changes: 10 additions & 7 deletions project1/myapp/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from django.urls import path
from . import views

from myapp.views.index import IndexView

urlpatterns = [
path('', views.home, name='home'),
path('hello/<name>/<id>', views.pathview, name='pathview'),
path('showform/', views.showform, name='showform'),
path('getform/', views.getform, name='getform'),
path("drinks/<str:drink_name>", views.drinks, name="drink_name"),
path('menu', views.menu, name='menu'),
path('about', views.about, name='about'),
# path('', views.home, name='home'),
# path('hello/<name>/<id>', views.pathview, name='pathview'),
# path('showform/', views.showform, name='showform'),
# path('getform/', views.getform, name='getform'),
# path("drinks/<str:drink_name>", views.drinks, name="drink_name"),
# path('menu', views.menu, name='menu'),
# path('about', views.about, name='about'),
path('index', IndexView.as_view(), name='index'),
]
44 changes: 0 additions & 44 deletions project1/myapp/views.py

This file was deleted.

Empty file.
5 changes: 5 additions & 0 deletions project1/myapp/views/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.views.generic.base import TemplateView


class IndexView(TemplateView):
template_name = 'index.html'

0 comments on commit f038922

Please sign in to comment.