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
13221ab0
Commit
13221ab0
authored
Oct 17, 2025
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utworzenie modelu Product
parent
f9d8bb91
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
1 deletions
+56
-1
notatki.txt
notatki.txt
+1
-1
admin.py
sklep/admin.py
+2
-0
0001_initial.py
sklep/migrations/0001_initial.py
+32
-0
models.py
sklep/models.py
+20
-0
settings.py
webowy/settings.py
+1
-0
No files found.
notatki.txt
View file @
13221ab0
...
...
@@ -43,7 +43,7 @@ python manage.py startapp sklep
Dopisanie aplikacji do settings.py
Dopisanie klasy do models.py
Dopisanie rejestracji do admin.py
Dopisanie rejestracji
klas
do admin.py
Dopisanie funkcji widoku do views.py w aplikacji
Ewentualnie dodanie templates z plikami html i static z plikiem css
...
...
sklep/admin.py
View file @
13221ab0
from
django.contrib
import
admin
from
.models
import
*
# Register your models here.
admin
.
site
.
register
(
Product
)
sklep/migrations/0001_initial.py
0 → 100644
View file @
13221ab0
# Generated by Django 5.2.7 on 2025-10-17 08:14
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[]
operations
=
[
migrations
.
CreateModel
(
name
=
"Product"
,
fields
=
[
(
"id"
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
"ID"
,
),
),
(
"name"
,
models
.
CharField
(
max_length
=
100
)),
(
"price"
,
models
.
DecimalField
(
decimal_places
=
2
,
max_digits
=
10
)),
(
"vat"
,
models
.
DecimalField
(
decimal_places
=
2
,
max_digits
=
2
)),
(
"valid_to"
,
models
.
DateField
(
blank
=
True
,
null
=
True
)),
(
"available"
,
models
.
BooleanField
(
default
=
True
)),
],
),
]
sklep/models.py
View file @
13221ab0
from
django.db
import
models
# Create your models here.
class
Product
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
)
price
=
models
.
DecimalField
(
max_digits
=
10
,
decimal_places
=
2
)
vat
=
models
.
DecimalField
(
max_digits
=
2
,
decimal_places
=
2
)
valid_to
=
models
.
DateField
(
blank
=
True
,
null
=
True
)
available
=
models
.
BooleanField
(
default
=
True
)
def
vat_jako_calkowita
(
self
):
return
int
(
100
*
self
.
vat
)
def
__str__
(
self
):
return
f
'{self.name} za {self.price} zł'
def
__repr__
(
self
):
return
(
f
'Product(name={repr(self.name)}'
f
', price={repr(self.price)}'
f
', vat={repr(self.vat)}'
f
', valid_to={repr(self.valid_to)}'
f
', available={repr(self.available)})'
)
webowy/settings.py
View file @
13221ab0
...
...
@@ -38,6 +38,7 @@ INSTALLED_APPS = [
"django.contrib.messages"
,
"django.contrib.staticfiles"
,
"aplikacja"
,
"sklep"
,
]
MIDDLEWARE
=
[
...
...
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