Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
justinreyes_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
Justin Reyes
justinreyes_reading
Commits
d0c4552a
Commit
d0c4552a
authored
Mar 27, 2023
by
justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created bookshelf app, Author and Books models and corresponding Admin panels
parent
d516727b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
0 deletions
+86
-0
__init__.py
justinreyes_reading/bookshelf/__init__.py
+0
-0
admin.py
justinreyes_reading/bookshelf/admin.py
+47
-0
apps.py
justinreyes_reading/bookshelf/apps.py
+6
-0
__init__.py
justinreyes_reading/bookshelf/migrations/__init__.py
+0
-0
models.py
justinreyes_reading/bookshelf/models.py
+27
-0
tests.py
justinreyes_reading/bookshelf/tests.py
+3
-0
views.py
justinreyes_reading/bookshelf/views.py
+3
-0
No files found.
justinreyes_reading/bookshelf/__init__.py
0 → 100644
View file @
d0c4552a
justinreyes_reading/bookshelf/admin.py
0 → 100644
View file @
d0c4552a
from
django.contrib
import
admin
from
models
import
Author
,
Books
class
AuthorAdmin
(
admin
.
ModelAdmin
):
model
=
Author
list_display
=
(
"first_name"
,
"last_name"
,
"age"
,
"nationality"
,
"bio"
,
)
search_fields
=
(
"first_name"
,
"last_name"
,
)
list_filter
=
(
"nationality"
,)
class
BooksAdmin
(
admin
.
ModelAdmin
):
model
=
Books
list_display
=
(
"title"
,
"author"
,
"publisher"
,
"year_published"
,
"isbn"
,
)
search_fields
=
(
"title"
,
"author"
,
"publisher"
,
"isbn"
,
)
list_filter
=
(
"publisher"
,
"author"
,
)
class
BooksInline
(
admin
.
StackedInline
):
model
=
Books
admin
.
site
.
register
(
Author
,
AuthorAdmin
)
admin
.
site
.
register
(
Books
,
BooksAdmin
)
justinreyes_reading/bookshelf/apps.py
0 → 100644
View file @
d0c4552a
from
django.apps
import
AppConfig
class
BookshelfConfig
(
AppConfig
):
default_auto_field
=
'django.db.models.BigAutoField'
name
=
'bookshelf'
justinreyes_reading/bookshelf/migrations/__init__.py
0 → 100644
View file @
d0c4552a
justinreyes_reading/bookshelf/models.py
0 → 100644
View file @
d0c4552a
from
django.db
import
models
from
django.core.validators
import
MaxLengthValidator
class
Author
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
255
)
last_name
=
models
.
CharField
(
max_length
=
255
)
age
=
models
.
PositiveIntegerField
()
nationality
=
models
.
CharField
(
max_length
=
255
)
bio
=
models
.
TextField
(
max_length
=
700
)
def
__str__
(
self
):
return
f
"{self.first_name} {self.last_name}"
class
Books
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
255
)
author
=
models
.
ForeignKey
(
Author
,
on_delete
=
models
.
CASCADE
)
publisher
=
models
.
CharField
(
max_length
=
255
,
default
=
"Unknown"
,
)
year_published
=
models
.
IntegerField
(
default
=
0
)
isbn
=
models
.
PositiveBigIntegerField
(
validators
=
[
MaxLengthValidator
(
13
)])
def
__str__
(
self
):
return
self
.
title
justinreyes_reading/bookshelf/tests.py
0 → 100644
View file @
d0c4552a
from
django.test
import
TestCase
# Create your tests here.
justinreyes_reading/bookshelf/views.py
0 → 100644
View file @
d0c4552a
from
django.shortcuts
import
render
# Create your views here.
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