Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
sharmchua_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
Sharmaine Chua
sharmchua_reading
Commits
fe433cfb
Commit
fe433cfb
authored
Mar 28, 2023
by
Sharmaine Chua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
did some minor changes in the models and populated the database
parent
bb051541
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
6 deletions
+60
-6
admin.py
sharmchua_reading/bookshelf/admin.py
+3
-3
0003_alter_author_nationality.py
...ing/bookshelf/migrations/0003_alter_author_nationality.py
+18
-0
0004_rename_book_books.py
...ua_reading/bookshelf/migrations/0004_rename_book_books.py
+17
-0
0005_alter_books_isbn.py
...hua_reading/bookshelf/migrations/0005_alter_books_isbn.py
+19
-0
models.py
sharmchua_reading/bookshelf/models.py
+3
-3
No files found.
sharmchua_reading/bookshelf/admin.py
View file @
fe433cfb
from
django.contrib
import
admin
from
.models
import
Author
,
Book
from
.models
import
Author
,
Book
s
class
AuthorAdmin
(
admin
.
ModelAdmin
):
model
=
Author
...
...
@@ -9,10 +9,10 @@ class AuthorAdmin(admin.ModelAdmin):
list_filter
=
(
'first_name'
,
'last_name'
,
'age'
,
'nationality'
,)
class
BooksAdmin
(
admin
.
ModelAdmin
):
model
=
Book
model
=
Book
s
list_display
=
(
'title'
,
'author'
,
'publisher'
,
'year_published'
,
'ISBN'
,
'blurb'
,)
search_fields
=
(
'title'
,
'author'
,
'publisher'
,
'year_published'
,
'ISBN'
,)
list_filter
=
(
'title'
,
'author'
,
'publisher'
,
'year_published'
,)
admin
.
site
.
register
(
Author
,
AuthorAdmin
)
admin
.
site
.
register
(
Book
,
BooksAdmin
)
admin
.
site
.
register
(
Book
s
,
BooksAdmin
)
sharmchua_reading/bookshelf/migrations/0003_alter_author_nationality.py
0 → 100644
View file @
fe433cfb
# Generated by Django 3.2 on 2023-03-28 11:40
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0002_rename_books_book'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'author'
,
name
=
'nationality'
,
field
=
models
.
CharField
(
default
=
''
,
max_length
=
50
),
),
]
sharmchua_reading/bookshelf/migrations/0004_rename_book_books.py
0 → 100644
View file @
fe433cfb
# Generated by Django 4.1.6 on 2023-03-28 11:57
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0003_alter_author_nationality'
),
]
operations
=
[
migrations
.
RenameModel
(
old_name
=
'Book'
,
new_name
=
'Books'
,
),
]
sharmchua_reading/bookshelf/migrations/0005_alter_books_isbn.py
0 → 100644
View file @
fe433cfb
# Generated by Django 4.1.6 on 2023-03-28 12:18
import
bookshelf.models
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bookshelf'
,
'0004_rename_book_books'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'books'
,
name
=
'ISBN'
,
field
=
models
.
IntegerField
(
default
=
0
,
unique
=
True
,
validators
=
[
bookshelf
.
models
.
validate_isbn
]),
),
]
sharmchua_reading/bookshelf/models.py
View file @
fe433cfb
...
...
@@ -9,18 +9,18 @@ class Author(models.Model):
first_name
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
last_name
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
age
=
models
.
IntegerField
(
default
=
0
)
nationality
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
,
default
=
""
)
nationality
=
models
.
CharField
(
max_length
=
50
,
default
=
""
)
bio
=
models
.
TextField
(
max_length
=
700
,
default
=
""
)
def
__str__
(
self
):
return
'{} {}'
.
format
(
self
.
first_name
,
self
.
last_name
)
class
Book
(
models
.
Model
):
class
Book
s
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
50
,
default
=
""
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
publisher
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
year_published
=
models
.
IntegerField
(
default
=
2023
)
ISBN
=
models
.
IntegerField
(
validators
=
[
validate_isbn
],
default
=
0000000000000
)
ISBN
=
models
.
IntegerField
(
validators
=
[
validate_isbn
],
unique
=
True
,
default
=
0000000000000
)
blurb
=
models
.
TextField
(
max_length
=
200
,
default
=
""
)
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