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
623cb3f8
Commit
623cb3f8
authored
Oct 16, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Przykład rozmowa
parent
a4498b77
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
2 deletions
+60
-2
index.html
aplikacja/templates/index.html
+1
-1
rozmowa.html
aplikacja/templates/rozmowa.html
+23
-0
views.py
aplikacja/views.py
+12
-1
notatki.txt
notatki.txt
+23
-0
urls.py
webowy/urls.py
+1
-0
No files found.
aplikacja/templates/index.html
View file @
623cb3f8
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<h1>
Witaj w Django
</h1>
<h1>
Witaj w Django
</h1>
<ul>
<ul>
<li><a
href=
"hello"
>
Hello / Hello
</a></li>
<li><a
href=
"hello"
>
Hello / Hello
</a></li>
<li><a
href=
"czas1"
>
czas
</a>
- wersja tekstowa
</li>
<li><a
href=
"czas1"
>
czas
1
</a>
- wersja tekstowa
</li>
<li><a
href=
"czas2"
>
czas2
</a>
- HTML tworzony w funkcji
</li>
<li><a
href=
"czas2"
>
czas2
</a>
- HTML tworzony w funkcji
</li>
<li><a
href=
"czas3"
>
czas3
</a>
- HTML tworzony szablonem
</li>
<li><a
href=
"czas3"
>
czas3
</a>
- HTML tworzony szablonem
</li>
<li><a
href=
"rozmowa"
>
rozmowa
</a>
- przykład formularza
</li>
<li><a
href=
"rozmowa"
>
rozmowa
</a>
- przykład formularza
</li>
...
...
aplikacja/templates/rozmowa.html
0 → 100644
View file @
623cb3f8
<!DOCTYPE html>
{% load static %}
<html
lang=
"pl"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Rozmowa z Django
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'styl.css'%}"
>
</head>
<body>
<h1>
Rozmowa z Django
</h1>
<form>
<label
for=
"imie"
>
Jak masz na imię?
</label>
<input
id=
"imie"
name=
"imie"
>
<button>
Wyślij
</button>
</form>
<div
class=
"wynik"
>
{{powitanie}}
</div>
</body>
</html>
aplikacja/views.py
View file @
623cb3f8
from
django.http
import
HttpResponse
from
django.http
import
HttpRe
quest
,
HttpRe
sponse
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
datetime
import
datetime
from
datetime
import
datetime
...
@@ -29,3 +29,14 @@ def czas_html(request):
...
@@ -29,3 +29,14 @@ def czas_html(request):
def
czas_szablon
(
request
):
def
czas_szablon
(
request
):
return
render
(
request
,
'szablon_czasu.html'
,
{
'now'
:
datetime
.
now
()})
return
render
(
request
,
'szablon_czasu.html'
,
{
'now'
:
datetime
.
now
()})
def
rozmowa
(
request
:
HttpRequest
)
->
HttpResponse
:
# to jest słownik i można odczytać wartość z klucza za pomocą []
# ale w razie braku parametru o tej nazwie będzie KeyError
# imie = request.GET['imie']
# gdy użyjemy meody get, możmy uniknąć błędu i podstawić domyślną wartość
imie
=
request
.
GET
.
get
(
'imie'
,
''
)
powitanie
=
f
'Witaj {imie}!'
if
imie
else
'Witaj nieznana osobo...'
return
render
(
request
,
'rozmowa.html'
,
context
=
{
'powitanie'
:
powitanie
})
notatki.txt
0 → 100644
View file @
623cb3f8
https://gitlab.alx.pl/pczarnik/django_pazdziernikowe
- utworzenie projektu
- instalacja Django - w Pycharm poprzez File > Settings > Python Interpreter
- wybraliśmy konkretną wersję 5.2.7, bo wersja 6 jest jeszcze niestabilna
django-admin startproject webowy .
python manage.py startapp aplikacja
python manage.py migrate
python manage.py runserver
- funkcje widoku i mapowanie urls
- szablony
- parametry i formularze
- model
webowy/urls.py
View file @
623cb3f8
...
@@ -26,4 +26,5 @@ urlpatterns = [
...
@@ -26,4 +26,5 @@ urlpatterns = [
path
(
"czas1"
,
daj_czas
),
path
(
"czas1"
,
daj_czas
),
path
(
"czas2"
,
czas_html
),
path
(
"czas2"
,
czas_html
),
path
(
"czas3"
,
czas_szablon
),
path
(
"czas3"
,
czas_szablon
),
path
(
"rozmowa"
,
rozmowa
),
]
]
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