Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nicsdevega_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
Nics De Vega
nicsdevega_reading
Commits
6dbbe2d7
Commit
6dbbe2d7
authored
Mar 28, 2023
by
Nics De Vega
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed admin panel, modified and populated models for bookshelf
parent
d19136ea
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
12 deletions
+108
-12
admin.py
nicsdevega_reading/bookshelf/admin.py
+7
-6
0002_alter_author_age_alter_books_isbn_alter_books_blurb_and_more.py
...author_age_alter_books_isbn_alter_books_blurb_and_more.py
+34
-0
0003_rename_books_book.py
...ga_reading/bookshelf/migrations/0003_rename_books_book.py
+17
-0
0004_alter_book_isbn_alter_book_year_published.py
...rations/0004_alter_book_isbn_alter_book_year_published.py
+24
-0
0005_alter_book_isbn.py
...vega_reading/bookshelf/migrations/0005_alter_book_isbn.py
+19
-0
models.py
nicsdevega_reading/bookshelf/models.py
+7
-6
No files found.
nicsdevega_reading/bookshelf/admin.py
View file @
6dbbe2d7
from
django.contrib
import
admin
from
.models
import
Author
,
Books
from
.models
import
Author
,
Book
class
AuthorAdmin
(
admin
.
ModelAdmin
):
model
=
Author
list_d
si
play
=
(
"first_name"
,
"last_name"
,
"age"
,
"nationality"
,
"bio"
)
search_fields
=
(
"first_name"
,
"last_name
s
"
)
list_d
is
play
=
(
"first_name"
,
"last_name"
,
"age"
,
"nationality"
,
"bio"
)
search_fields
=
(
"first_name"
,
"last_name"
)
list_filter
=
(
"first_name"
,
"last_name"
,
"nationality"
)
class
Book
s
Admin
(
admin
.
ModelAdmin
):
model
=
Book
s
class
BookAdmin
(
admin
.
ModelAdmin
):
model
=
Book
list_display
=
(
"title"
,
"author"
,
"publisher"
,
"year_published"
,
"ISBN"
,
"blurb"
)
search_fields
=
(
"title"
,
"author"
,
"publisher"
,
"year_published"
,
"ISBN"
)
list_filter
=
(
"author"
,
"publisher"
,
"year_published"
)
admin
.
site
.
register
(
Author
,
AuthorAdmin
)
admin
.
site
.
register
(
Book
s
,
Books
Admin
)
admin
.
site
.
register
(
Book
,
Book
Admin
)
nicsdevega_reading/bookshelf/migrations/0002_alter_author_age_alter_books_isbn_alter_books_blurb_and_more.py
0 → 100644
View file @
6dbbe2d7
# Generated by Django 4.1.7 on 2023-03-28 06:19
import
django.core.validators
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'author'
,
name
=
'age'
,
field
=
models
.
PositiveIntegerField
(),
),
migrations
.
AlterField
(
model_name
=
'books'
,
name
=
'ISBN'
,
field
=
models
.
IntegerField
(
default
=
0
,
validators
=
[
django
.
core
.
validators
.
MaxValueValidator
(
9999999999999
)]),
),
migrations
.
AlterField
(
model_name
=
'books'
,
name
=
'blurb'
,
field
=
models
.
TextField
(
default
=
''
,
max_length
=
700
,
validators
=
[
django
.
core
.
validators
.
MinLengthValidator
(
100
)]),
),
migrations
.
AlterField
(
model_name
=
'books'
,
name
=
'year_published'
,
field
=
models
.
IntegerField
(
validators
=
[
django
.
core
.
validators
.
MaxValueValidator
(
2023
)]),
),
]
nicsdevega_reading/bookshelf/migrations/0003_rename_books_book.py
0 → 100644
View file @
6dbbe2d7
# Generated by Django 4.1.7 on 2023-03-28 06:37
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0002_alter_author_age_alter_books_isbn_alter_books_blurb_and_more'
),
]
operations
=
[
migrations
.
RenameModel
(
old_name
=
'Books'
,
new_name
=
'Book'
,
),
]
nicsdevega_reading/bookshelf/migrations/0004_alter_book_isbn_alter_book_year_published.py
0 → 100644
View file @
6dbbe2d7
# Generated by Django 4.1.7 on 2023-03-28 07:47
import
django.core.validators
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0003_rename_books_book'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'book'
,
name
=
'ISBN'
,
field
=
models
.
IntegerField
(
validators
=
[
django
.
core
.
validators
.
MaxValueValidator
(
9999999999999
),
django
.
core
.
validators
.
MinValueValidator
(
1000000000000
)]),
),
migrations
.
AlterField
(
model_name
=
'book'
,
name
=
'year_published'
,
field
=
models
.
PositiveIntegerField
(
validators
=
[
django
.
core
.
validators
.
MaxValueValidator
(
2023
)]),
),
]
nicsdevega_reading/bookshelf/migrations/0005_alter_book_isbn.py
0 → 100644
View file @
6dbbe2d7
# Generated by Django 4.1.7 on 2023-03-28 07:51
import
django.core.validators
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0004_alter_book_isbn_alter_book_year_published'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'book'
,
name
=
'ISBN'
,
field
=
models
.
IntegerField
(
unique
=
True
,
validators
=
[
django
.
core
.
validators
.
MaxValueValidator
(
9999999999999
),
django
.
core
.
validators
.
MinValueValidator
(
1000000000000
)]),
),
]
nicsdevega_reading/bookshelf/models.py
View file @
6dbbe2d7
from
django.db
import
models
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
,
MinLengthValidator
class
Author
(
models
.
Model
):
class
Author
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
last_name
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
age
=
models
.
IntegerField
()
age
=
models
.
Positive
IntegerField
()
nationality
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
bio
=
models
.
TextField
(
max_length
=
700
,
default
=
""
)
def
__str__
(
self
):
return
'{} {}'
.
format
(
self
.
first_name
,
self
.
last_name
)
class
Book
s
(
models
.
Model
):
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
publisher
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
year_published
=
models
.
IntegerField
(
default
=
0
)
ISBN
=
models
.
IntegerField
(
default
=
0
)
blurb
=
models
.
TextField
(
max_length
=
700
,
default
=
""
)
year_published
=
models
.
PositiveIntegerField
(
validators
=
[
MaxValueValidator
(
2023
)]
)
ISBN
=
models
.
IntegerField
(
unique
=
True
,
validators
=
[
MaxValueValidator
(
9999999999999
),
MinValueValidator
(
1000000000000
)]
)
blurb
=
models
.
TextField
(
validators
=
[
MinLengthValidator
(
100
)],
max_length
=
700
,
default
=
""
)
def
__str__
(
self
):
return
'{} by {}'
.
format
(
self
.
title
,
self
.
author
)
\ No newline at end of file
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