Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rosetta
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
ExaCT
Rosetta
Commits
40687ec3
Commit
40687ec3
authored
4 years ago
by
Stefano Alberto Russo
Browse files
Options
Downloads
Patches
Plain Diff
Added serving static files if using the development server with DEBUG set to False.
parent
2b2e63b5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/webapp/code/rosetta/urls.py
+30
-2
30 additions, 2 deletions
services/webapp/code/rosetta/urls.py
with
30 additions
and
2 deletions
services/webapp/code/rosetta/urls.py
+
30
−
2
View file @
40687ec3
...
@@ -13,6 +13,11 @@ Including another URLconf
...
@@ -13,6 +13,11 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path(
'
blog/
'
, include(
'
blog.urls
'
))
2. Add a URL to urlpatterns: path(
'
blog/
'
, include(
'
blog.urls
'
))
"""
"""
import
os
import
django
from
django.conf
import
settings
from
django.conf.urls
import
include
,
url
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
include
,
path
from
django.urls
import
include
,
path
from
django.conf.urls
import
url
from
django.conf.urls
import
url
...
@@ -69,6 +74,29 @@ urlpatterns = [
...
@@ -69,6 +74,29 @@ urlpatterns = [
]
]
# This message here is quite useful when developing in autoreload mode
logger
.
info
(
'
Loaded URLs
'
)
#============================
# Serve static if required
#============================
# Get admin files location
admin_files_path
=
'
/
'
.
join
(
django
.
__file__
.
split
(
'
/
'
)[
0
:
-
1
])
+
'
/contrib/admin/static/admin
'
if
not
settings
.
DEBUG
:
# Admin files
urlpatterns
.
append
(
url
(
r
'
^static/admin/(?P<path>.*)$
'
,
django
.
views
.
static
.
serve
,
{
'
document_root
'
:
admin_files_path
}
))
# Rosetta Core app files
document_root
=
'
rosetta/core_app/static
'
if
os
.
path
.
isdir
(
document_root
):
logger
.
info
(
'
Serving static files for app
"
core_app
"
from document root
"
{}
"'
.
format
(
document_root
))
# Static
urlpatterns
.
append
(
url
(
r
'
^static/(?P<path>.*)$
'
,
django
.
views
.
static
.
serve
,
{
'
document_root
'
:
document_root
}
))
else
:
logger
.
warning
(
'
Not static files to serve?!
'
)
else
:
logger
.
info
(
'
Not serving static files at all as DEBUG=True (Django will do it automatically)
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment