Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
crud
Project
Project
Details
Activity
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
Dio Maulana
crud
Commits
b0092f94
Commit
b0092f94
authored
Feb 03, 2022
by
dio maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
day 2
parent
cee9341c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
models.py
belajar/models.py
+6
-1
views.py
belajar/views.py
+4
-0
No files found.
belajar/models.py
View file @
b0092f94
...
...
@@ -8,4 +8,9 @@ class Category(models.Model):
class
Product
(
models
.
Model
):
name_product
=
models
.
CharField
(
max_length
=
200
)
category
=
models
.
ForeignKey
(
Category
,
on_delete
=
models
.
CASCADE
)
\ No newline at end of file
category
=
models
.
ForeignKey
(
Category
,
on_delete
=
models
.
CASCADE
)
def
get_dict
(
self
):
result
=
{}
result
[
'name_product'
]
=
self
.
name_product
result
[
'category_id'
]
=
self
.
category
.
name_category
return
result
\ No newline at end of file
belajar/views.py
View file @
b0092f94
...
...
@@ -94,3 +94,7 @@ def search(request):
page_obj
=
paginator
.
get_page
(
page_number
)
context
=
{
'search'
:
search
,
'page_obj'
:
page_obj
,
'getSearch'
:
getSearch
}
return
render
(
request
,
'belajar/search.html'
,
context
)
# for json
# context = {'search': [x.get_dict() for x in search]} #untuk json
# return render(request, 'belajar/search.html', context)
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