Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
janang_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
Jan Ericsson Ong Ang
janang_reading
Commits
8e125393
Commit
8e125393
authored
Apr 27, 2023
by
Jan Ericsson Ong Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edited addbook and addauthor urls and abosulte url
parent
519e668e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
4 deletions
+9
-4
models.cpython-310.pyc
janang_reading/bookshelf/__pycache__/models.cpython-310.pyc
+0
-0
urls.cpython-310.pyc
janang_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
models.py
janang_reading/bookshelf/models.py
+7
-2
urls.py
janang_reading/bookshelf/urls.py
+2
-2
db.sqlite3
janang_reading/db.sqlite3
+0
-0
No files found.
janang_reading/bookshelf/__pycache__/models.cpython-310.pyc
View file @
8e125393
No preview for this file type
janang_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
8e125393
No preview for this file type
janang_reading/bookshelf/models.py
View file @
8e125393
from
django.db
import
models
from
django.db
import
models
from
django.urls
import
reverse
# Create your models here.
# Create your models here.
class
Author
(
models
.
Model
):
class
Author
(
models
.
Model
):
...
@@ -12,7 +13,7 @@ class Author(models.Model):
...
@@ -12,7 +13,7 @@ class Author(models.Model):
return
self
.
first_name
+
" "
+
self
.
last_name
return
self
.
first_name
+
" "
+
self
.
last_name
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
'
product_change
'
,
kwargs
=
{
'id'
:
self
.
id
})
return
reverse
(
'
bookshelf:author-detail
'
,
kwargs
=
{
'id'
:
self
.
id
})
#https://stackoverflow.com/questions/70442828/django-object-list-from-listview-with-two-models%20#}%20{%%20for%20object%20in%20author.books_set.all
#https://stackoverflow.com/questions/70442828/django-object-list-from-listview-with-two-models%20#}%20{%%20for%20object%20in%20author.books_set.all
# for absolute url and _set_all
# for absolute url and _set_all
...
@@ -26,4 +27,8 @@ class Books(models.Model):
...
@@ -26,4 +27,8 @@ class Books(models.Model):
blurb
=
models
.
TextField
(
max_length
=
10000
)
blurb
=
models
.
TextField
(
max_length
=
10000
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
title
return
self
.
title
\ No newline at end of file
def
get_absolute_url
(
self
):
return
reverse
(
'bookshelf:books-detail'
,
kwargs
=
{
'id'
:
self
.
id
})
\ No newline at end of file
janang_reading/bookshelf/urls.py
View file @
8e125393
...
@@ -8,11 +8,11 @@ urlpatterns = [
...
@@ -8,11 +8,11 @@ urlpatterns = [
path
(
''
,
views
.
HomeView
,
name
=
'home'
),
path
(
''
,
views
.
HomeView
,
name
=
'home'
),
path
(
'authors/'
,
AuthorView
.
as_view
(),
name
=
'authors'
),
path
(
'authors/'
,
AuthorView
.
as_view
(),
name
=
'authors'
),
path
(
'authors/<int:id>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'authors/<int:id>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'authors/
<int:id>/
add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
),
path
(
'authors/<int:id>/edit/'
,
AuthorUpdateView
.
as_view
(),
name
=
'edit-author'
),
path
(
'authors/<int:id>/edit/'
,
AuthorUpdateView
.
as_view
(),
name
=
'edit-author'
),
path
(
'books/'
,
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'books/'
,
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:id>/details/'
,
BookDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'books/<int:id>/details/'
,
BookDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'books/
<int:id>/
add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/<int:id>/edit/'
,
BooksUpdateView
.
as_view
(),
name
=
'edit-book'
),
path
(
'books/<int:id>/edit/'
,
BooksUpdateView
.
as_view
(),
name
=
'edit-book'
),
]
]
...
...
janang_reading/db.sqlite3
View file @
8e125393
No preview for this file type
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