Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eldondagdag_reading
Project
Project
Details
Activity
Releases
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
Eldon Dagdag
eldondagdag_reading
Commits
ee782a7a
Commit
ee782a7a
authored
Mar 28, 2023
by
Eldon Dagdag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Populated Author and Book models
parent
914ac61a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
7 deletions
+43
-7
admin.py
eldondagdag_reading/bookshelf/admin.py
+4
-4
0002_rename_books_book.py
...ag_reading/bookshelf/migrations/0002_rename_books_book.py
+17
-0
0003_alter_book_isbn.py
...gdag_reading/bookshelf/migrations/0003_alter_book_isbn.py
+19
-0
models.py
eldondagdag_reading/bookshelf/models.py
+3
-3
No files found.
eldondagdag_reading/bookshelf/admin.py
View file @
ee782a7a
from
django.contrib
import
admin
from
django.contrib
import
admin
from
.models
import
Author
,
Book
s
from
.models
import
Author
,
Book
class
AuthorAdmin
(
admin
.
ModelAdmin
):
class
AuthorAdmin
(
admin
.
ModelAdmin
):
model
=
Author
model
=
Author
class
Book
s
Admin
(
admin
.
ModelAdmin
):
class
BookAdmin
(
admin
.
ModelAdmin
):
model
=
Book
s
model
=
Book
admin
.
site
.
register
(
Author
,
AuthorAdmin
)
admin
.
site
.
register
(
Author
,
AuthorAdmin
)
admin
.
site
.
register
(
Book
s
,
Books
Admin
)
admin
.
site
.
register
(
Book
,
Book
Admin
)
eldondagdag_reading/bookshelf/migrations/0002_rename_books_book.py
0 → 100644
View file @
ee782a7a
# Generated by Django 4.1.7 on 2023-03-28 07:50
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0001_initial'
),
]
operations
=
[
migrations
.
RenameModel
(
old_name
=
'Books'
,
new_name
=
'Book'
,
),
]
eldondagdag_reading/bookshelf/migrations/0003_alter_book_isbn.py
0 → 100644
View file @
ee782a7a
# Generated by Django 4.1.7 on 2023-03-28 08:11
import
django.core.validators
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0002_rename_books_book'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'book'
,
name
=
'ISBN'
,
field
=
models
.
PositiveBigIntegerField
(
validators
=
[
django
.
core
.
validators
.
MinValueValidator
(
1000000000000
),
django
.
core
.
validators
.
MaxValueValidator
(
9999999999999
)]),
),
]
eldondagdag_reading/bookshelf/models.py
View file @
ee782a7a
from
django.db
import
models
from
django.db
import
models
from
django.core.validators
import
Min
Length
Validator
,
MaxValueValidator
from
django.core.validators
import
Min
Value
Validator
,
MaxValueValidator
class
Author
(
models
.
Model
):
class
Author
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
255
,
default
=
''
)
first_name
=
models
.
CharField
(
max_length
=
255
,
default
=
''
)
...
@@ -11,12 +11,12 @@ class Author(models.Model):
...
@@ -11,12 +11,12 @@ class Author(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
'{} {}'
.
format
(
self
.
first_name
,
self
.
last_name
)
return
'{} {}'
.
format
(
self
.
first_name
,
self
.
last_name
)
class
Book
s
(
models
.
Model
):
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
255
,
default
=
''
)
title
=
models
.
CharField
(
max_length
=
255
,
default
=
''
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
publisher
=
models
.
CharField
(
max_length
=
255
,
default
=
''
)
publisher
=
models
.
CharField
(
max_length
=
255
,
default
=
''
)
year_published
=
models
.
PositiveIntegerField
()
year_published
=
models
.
PositiveIntegerField
()
ISBN
=
models
.
PositiveBigIntegerField
(
validators
=
[
Min
Length
Validator
(
1000000000000
),
MaxValueValidator
(
9999999999999
)])
ISBN
=
models
.
PositiveBigIntegerField
(
validators
=
[
Min
Value
Validator
(
1000000000000
),
MaxValueValidator
(
9999999999999
)])
blurb
=
models
.
TextField
(
max_length
=
1000
,
default
=
''
)
blurb
=
models
.
TextField
(
max_length
=
1000
,
default
=
''
)
def
__str__
(
self
):
def
__str__
(
self
):
...
...
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