Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cheskahung_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
Cheska Hung
cheskahung_reading
Commits
69d6013b
Commit
69d6013b
authored
Mar 28, 2023
by
Cheska Hung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning code
parent
201aa1b4
Pipeline
#3055
failed with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
8 deletions
+7
-8
models.cpython-311.pyc
bookshelf/__pycache__/models.cpython-311.pyc
+0
-0
urls.cpython-311.pyc
bookshelf/__pycache__/urls.cpython-311.pyc
+0
-0
views.cpython-311.pyc
bookshelf/__pycache__/views.cpython-311.pyc
+0
-0
models.py
bookshelf/models.py
+4
-2
urls.py
bookshelf/urls.py
+3
-3
views.py
bookshelf/views.py
+0
-3
No files found.
bookshelf/__pycache__/models.cpython-311.pyc
View file @
69d6013b
No preview for this file type
bookshelf/__pycache__/urls.cpython-311.pyc
View file @
69d6013b
No preview for this file type
bookshelf/__pycache__/views.cpython-311.pyc
View file @
69d6013b
No preview for this file type
bookshelf/models.py
View file @
69d6013b
from
django.db
import
models
from
django.core.validators
import
MaxValueValidator
,
MinValueValidator
from
django.core.validators
import
MaxValueValidator
,
MinValueValidator
from
django.urls
import
reverse
class
Author
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
50
)
last_name
=
models
.
CharField
(
max_length
=
50
)
...
...
@@ -15,7 +16,8 @@ class Author(models.Model):
class
Books
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
200
)
author
=
models
.
ForeignKey
(
Author
,
related_name
=
"books"
,
on_delete
=
models
.
CASCADE
)
author
=
models
.
ForeignKey
(
Author
,
related_name
=
"books"
,
on_delete
=
models
.
CASCADE
)
publisher
=
models
.
CharField
(
max_length
=
200
)
year_published
=
models
.
DateField
()
ISBN
=
models
.
PositiveIntegerField
(
...
...
bookshelf/urls.py
View file @
69d6013b
from
django.urls
import
path
from
.
import
views
from
.views
import
(
HomeView
,
BooksListView
,
BooksDetailView
,
from
.views
import
(
HomeView
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
)
urlpatterns
=
[
path
(
'home/'
,
views
.
HomeView
,
name
=
'home'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'author'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
]
...
...
bookshelf/views.py
View file @
69d6013b
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views
import
View
from
.models
import
Books
from
.models
import
Author
from
django.views
import
generic
def
HomeView
(
request
):
...
...
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