Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Collection of Practice
2019
1606889830-practice
Commits
62feec58
Commit
62feec58
authored
Dec 01, 2019
by
Luthfi Dzaky Saifuddin
Browse files
readme md
parent
592dd2c8
Pipeline
#26473
passed with stages
in 8 minutes and 26 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
62feec58
...
...
@@ -537,7 +537,26 @@ slug = models.SlugField(blank=True)
Kemudian migrasi seperti berikut untuk melakukan backfill pada 100 data yang sudah ada:
```
python
from
django.db
import
migrations
from
django.utils.text
import
slugify
def
slugify
(
apps
,
schema_editor
):
List
=
apps
.
get_model
(
"lists"
,
"List"
)
for
list_
in
List
.
objects
.
all
():
items
=
list_
.
item_set
.
all
()
for
ix
,
item
in
enumerate
(
items
):
item
.
slug
=
slugify
(
item
.
text
)
item
.
save
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'lists'
,
'0007_item_slug'
),
]
operations
=
[
]
```
Eksekusi migrasi bisa dilakukan dengan menggunakan scheduler,
...
...
Write
Preview
Supports
Markdown
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