Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp
Merge requests
!284
Feature/pregenerate anonymous views
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feature/pregenerate anonymous views
feature/pregenerate-anonymous-views
into
master
Overview
0
Commits
17
Pipelines
7
Changes
1
Merged
Benoit Alessandroni
requested to merge
feature/pregenerate-anonymous-views
into
master
9 months ago
Overview
0
Commits
17
Pipelines
7
Changes
1
Expand
0
0
Merge request reports
Viewing commit
f973b5bd
Prev
Next
Show latest version
1 file
+
5
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
f973b5bd
update: comments
· f973b5bd
Benoit Alessandroni
authored
9 months ago
djangoldp/management/commands/generate_static_content.py
+
5
−
5
Options
@@ -21,19 +21,19 @@ class Command(BaseCommand):
for
model
in
apps
.
get_models
():
if
hasattr
(
model
.
_meta
,
'
static_version
'
):
print
(
f
"
model:
{
model
}
"
)
print
(
f
"
Generating content for
model:
{
model
}
"
)
container_path
=
model
.
get_container_path
()
url
=
f
'
{
base_uri
}{
container_path
}
'
print
(
f
"
c
urrent request url before adding params:
{
url
}
"
)
print
(
f
"
C
urrent request url before adding params:
{
url
}
"
)
if
hasattr
(
model
.
_meta
,
'
static_params
'
):
# static_params
which is a json must be decomposed and
added to the url as query parameters
, first with ? then with &
# static_params
are
added to the url as query parameters
url
+=
'
?
'
for
key
,
value
in
model
.
_meta
.
static_params
.
items
():
url
+=
f
'
{
key
}
=
{
value
}
&
'
url
=
url
[:
-
1
]
print
(
f
"
c
urrent request url after adding params:
{
url
}
"
)
print
(
f
"
C
urrent request url after adding params:
{
url
}
"
)
response
=
requests
.
get
(
url
,
timeout
=
request_timeout
)
if
response
.
status_code
==
200
:
@@ -43,7 +43,7 @@ class Command(BaseCommand):
filename
=
container_path
[
1
:
-
1
]
file_path
=
os
.
path
.
join
(
output_dir
,
f
'
{
filename
}
.json
'
)
print
(
f
"
file_path:
{
file_path
}
"
)
print
(
f
"
Output
file_path:
{
file_path
}
"
)
with
open
(
file_path
,
'
w
'
)
as
f
:
f
.
write
(
content
)
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
f
'
Successfully fetched and saved content for
{
model
.
_meta
.
model_name
}
from
{
url
}
'
))
Loading