Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django_pazdziernikowe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
django_pazdziernikowe
Commits
da6990b1
Commit
da6990b1
authored
Oct 17, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dodanie szablonu i wodoków dla aplikacji sklep
parent
13221ab0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
+51
-0
towary.html
sklep/templates/towary.html
+24
-0
views.py
sklep/views.py
+21
-0
urls.py
webowy/urls.py
+6
-0
No files found.
sklep/templates/towary.html
0 → 100644
View file @
da6990b1
<!DOCTYPE html>
<html
lang=
"pl"
>
<head>
<meta
charset=
"utf-8"
>
<title>
Produkty naszego sklepu
</title>
</head>
<body>
<h1>
Lista towarów
</h1>
<ul>
{% for p in products %}
<li>
towar: {{ p.name }} - cena {{ p.price }} zł, {{ p.vat_jako_calkowita }}% VAT
{% if p.valid_to %}
<br/>
(termin ważności {{p.valid_to}})
{% endif %}
{% if not p.available %}
<br/><strong>
Produkt niedostępny
</strong>
{% endif %}
</li>
{% endfor %}
</ul>
</body>
</html>
sklep/views.py
View file @
da6990b1
from
django.http
import
HttpRequest
,
HttpResponse
from
django.shortcuts
import
render
from
.models
import
*
# Create your views here.
def
lista_produktow
(
request
:
HttpRequest
)
->
HttpResponse
:
produkty
=
Product
.
objects
.
all
()
return
HttpResponse
(
str
(
produkty
),
content_type
=
'text/plain'
)
def
lista_produktow_txt
(
request
:
HttpRequest
)
->
HttpResponse
:
products
=
Product
.
objects
.
all
()
wynik
=
'Produkty naszego sklepu:'
for
product
in
products
:
wynik
+=
f
'
\n
- {product.name} za {product.price} zł'
if
product
.
valid_to
is
not
None
:
wynik
+=
f
', termin ważności: {product.valid_to}'
return
HttpResponse
(
wynik
,
content_type
=
'text/plain;charset=utf-8'
)
def
lista_produktow_html
(
request
:
HttpRequest
)
->
HttpResponse
:
products
=
Product
.
objects
.
all
()
return
render
(
request
,
'towary.html'
,
context
=
{
'products'
:
products
})
webowy/urls.py
View file @
da6990b1
...
...
@@ -17,7 +17,10 @@ Including another URLconf
from
django.contrib
import
admin
from
django.urls
import
path
# dwa style importowania do wyboru:
from
aplikacja.views
import
*
import
sklep.views
urlpatterns
=
[
path
(
"admin/"
,
admin
.
site
.
urls
),
...
...
@@ -30,4 +33,7 @@ urlpatterns = [
path
(
"kalkulator"
,
kalkulator
),
path
(
"kalkulator_post"
,
kalkulator_post
),
path
(
"formularz"
,
formularz
),
path
(
"sklep"
,
sklep
.
views
.
lista_produktow
),
path
(
"sklep.txt"
,
sklep
.
views
.
lista_produktow_txt
),
path
(
"sklep.html"
,
sklep
.
views
.
lista_produktow_html
)
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment