django 管理页面只显示文本和链接
django administration page display only texts and links
我用
python+django+mysql+iis
服务器运行良好,但是当我浏览到管理页面时,我只看到文本和 links,而不是图像..我的管理页面的屏幕截图在下面的 link 中。
(抱歉,我没有足够的声誉 post 图像..)
非常感谢您的帮助
谢谢!
admin network path
C:\inetpub\wwwroot\swingqa>python manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings:
C:\inetpub\wwwroot\swingqa\qablog\static
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Found another file with the destination path 'admin\css\base.css'. It will be ig
nored since only the first encountered file is collected. If this is not what yo
u want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\changelists.css'. It wil
l be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\dashboard.css'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\fonts.css'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\forms.css'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\login.css'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\rtl.css'. It will be ign
ored since only the first encountered file is collected. If this is not what you
want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\widgets.css'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\LICENSE.txt'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\README.txt'. It will b
e ignored since only the first encountered file is collected. If this is not wha
t you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\Roboto-Bold-webfont.wo
ff'. It will be ignored since only the first encountered file is collected. If t
his is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\Roboto-Light-webfont.w
off'. It will be ignored since only the first encountered file is collected. If
this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\Roboto-Regular-webfont
.woff'. It will be ignored since only the first encountered file is collected. I
f this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\calendar-icons.svg'. It
will be ignored since only the first encountered file is collected. If this is n
ot what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-addlink.svg'. It wi
ll be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-alert.svg'. It will
be ignored since only the first encountered file is collected. If this is not w
hat you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-calendar.svg'. It w
ill be ignored since only the first encountered file is collected. If this is no
t what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-changelink.svg'. It
will be ignored since only the first encountered file is collected. If this is
not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-clock.svg'. It will
be ignored since only the first encountered file is collected. If this is not w
hat you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-deletelink.svg'. It
will be ignored since only the first encountered file is collected. If this is
not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-no.svg'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-unknown-alt.svg'. I
t will be ignored since only the first encountered file is collected. If this is
not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-unknown.svg'. It wi
ll be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-yes.svg'. It will b
e ignored since only the first encountered file is collected. If this is not wha
t you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\inline-delete.svg'. It w
ill be ignored since only the first encountered file is collected. If this is no
t what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\LICENSE'. It will be ign
ored since only the first encountered file is collected. If this is not what you
want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\README.txt'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\search.svg'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\selector-icons.svg'. It
will be ignored since only the first encountered file is collected. If this is n
ot what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\sorting-icons.svg'. It w
ill be ignored since only the first encountered file is collected. If this is no
t what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\tooltag-add.svg'. It wil
l be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\tooltag-arrowright.svg'.
It will be ignored since only the first encountered file is collected. If this
is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\gis\move_vertex_off.svg'
. It will be ignored since only the first encountered file is collected. If this
is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\gis\move_vertex_on.svg'.
It will be ignored since only the first encountered file is collected. If this
is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\actions.js'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\actions.min.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\calendar.js'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\cancel.js'. It will be ig
nored since only the first encountered file is collected. If this is not what yo
u want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\change_form.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\collapse.js'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\collapse.min.js'. It will
be ignored since only the first encountered file is collected. If this is not w
hat you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\core.js'. It will be igno
red since only the first encountered file is collected. If this is not what you
want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\inlines.js'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\inlines.min.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\jquery.init.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\popup_response.js'. It wi
ll be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\prepopulate.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\prepopulate.min.js'. It w
ill be ignored since only the first encountered file is collected. If this is no
t what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\prepopulate_init.js'. It
will be ignored since only the first encountered file is collected. If this is n
ot what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\SelectBox.js'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\SelectFilter2.js'. It wil
l be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\timeparse.js'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\urlify.js'. It will be ig
nored since only the first encountered file is collected. If this is not what yo
u want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\admin\DateTimeShortcuts.j
s'. It will be ignored since only the first encountered file is collected. If th
is is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\admin\RelatedObjectLookup
s.js'. It will be ignored since only the first encountered file is collected. If
this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\jquery\jquery.js'.
It will be ignored since only the first encountered file is collected. If this
is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\jquery\jquery.min.
js'. It will be ignored since only the first encountered file is collected. If t
his is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\jquery\LICENSE-JQU
ERY.txt'. It will be ignored since only the first encountered file is collected.
If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\xregexp\LICENSE-XR
EGEXP.txt'. It will be ignored since only the first encountered file is collecte
d. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\xregexp\xregexp.js
'. It will be ignored since only the first encountered file is collected. If thi
s is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\xregexp\xregexp.mi
n.js'. It will be ignored since only the first encountered file is collected. If
this is not what you want, make sure every static file has a unique path.
0 static files copied to 'C:\inetpub\wwwroot\swingqa\qablog\static', 62 unmodifi
ed.
尝试 运行 命令 python manage.py collectstatic
好的,听着!首先,您需要在 settings.py
中填写
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
稍后,您可以运行 collectstatic 命令将不同的管理静态文件保存在正确的文件夹中。
您将需要设置服务器以提供静态文件,我不知道 iis 中的正确配置是什么,但您可以在此 link 中找到 apache 配置。
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/modwsgi/
最后,你必须像这样放置你的 urlpatterns。
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'',include(api_urls)),
url(r'^api-token-auth/', obtain_jwt_token),
url(r'^api-token-verify/', verify_jwt_token),
]+static(settings.STATIC_URL,document_root = settings.STATIC_ROOT)
试试这个,评论你的结果,我们会帮助你!
祝你好运!
我解决了问题!!
首先,我更改了 settings.py 文件,如下所示
STATIC_URL = '/static/'
STATIC_ROOT = os.path.abspath(os.path.join(os.path.dirname(file), 'static'))
STATICFILES_DIRS = (os.path.join('static'), )
其次,我通过查看下面这三个来编辑我的 iis
- Django Static Files - 404
- What are the problems with loading CSS and JS from Django to IIS7?
我实际上按照与第三个答案完全相同的步骤,除了我使用如下所示的网络配置文件并将其放在 C:\inetpub\wwwroot\myprojectname\static 文件夹下
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<!--
This removes Helicon Zoo handler and makes IIS processing static files.
-->
<remove name="django.project#x64" />
<remove name="django.project#x86" />
</handlers>
</system.webServer>
</configuration>
我真的很感谢帮助我的人,尤其是 soupboy、auros132 和 cutteeth。谢谢大家的支持!
如果您查看服务器控制台,您可能会看到一些 404 错误。
您需要在您的 settings.py 文件上启用 DEBUG=True
,尽管根据 Django docs,不建议在生产环境中这样做,只应在开发环境中使用。
我用 python+django+mysql+iis
服务器运行良好,但是当我浏览到管理页面时,我只看到文本和 links,而不是图像..我的管理页面的屏幕截图在下面的 link 中。
(抱歉,我没有足够的声誉 post 图像..)
非常感谢您的帮助
谢谢!
admin network path
C:\inetpub\wwwroot\swingqa>python manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings:
C:\inetpub\wwwroot\swingqa\qablog\static
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Found another file with the destination path 'admin\css\base.css'. It will be ig
nored since only the first encountered file is collected. If this is not what yo
u want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\changelists.css'. It wil
l be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\dashboard.css'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\fonts.css'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\forms.css'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\login.css'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\rtl.css'. It will be ign
ored since only the first encountered file is collected. If this is not what you
want, make sure every static file has a unique path.
Found another file with the destination path 'admin\css\widgets.css'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\LICENSE.txt'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\README.txt'. It will b
e ignored since only the first encountered file is collected. If this is not wha
t you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\Roboto-Bold-webfont.wo
ff'. It will be ignored since only the first encountered file is collected. If t
his is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\Roboto-Light-webfont.w
off'. It will be ignored since only the first encountered file is collected. If
this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\fonts\Roboto-Regular-webfont
.woff'. It will be ignored since only the first encountered file is collected. I
f this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\calendar-icons.svg'. It
will be ignored since only the first encountered file is collected. If this is n
ot what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-addlink.svg'. It wi
ll be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-alert.svg'. It will
be ignored since only the first encountered file is collected. If this is not w
hat you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-calendar.svg'. It w
ill be ignored since only the first encountered file is collected. If this is no
t what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-changelink.svg'. It
will be ignored since only the first encountered file is collected. If this is
not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-clock.svg'. It will
be ignored since only the first encountered file is collected. If this is not w
hat you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-deletelink.svg'. It
will be ignored since only the first encountered file is collected. If this is
not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-no.svg'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-unknown-alt.svg'. I
t will be ignored since only the first encountered file is collected. If this is
not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-unknown.svg'. It wi
ll be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\icon-yes.svg'. It will b
e ignored since only the first encountered file is collected. If this is not wha
t you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\inline-delete.svg'. It w
ill be ignored since only the first encountered file is collected. If this is no
t what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\LICENSE'. It will be ign
ored since only the first encountered file is collected. If this is not what you
want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\README.txt'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\search.svg'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\selector-icons.svg'. It
will be ignored since only the first encountered file is collected. If this is n
ot what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\sorting-icons.svg'. It w
ill be ignored since only the first encountered file is collected. If this is no
t what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\tooltag-add.svg'. It wil
l be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\tooltag-arrowright.svg'.
It will be ignored since only the first encountered file is collected. If this
is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\gis\move_vertex_off.svg'
. It will be ignored since only the first encountered file is collected. If this
is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\img\gis\move_vertex_on.svg'.
It will be ignored since only the first encountered file is collected. If this
is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\actions.js'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\actions.min.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\calendar.js'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\cancel.js'. It will be ig
nored since only the first encountered file is collected. If this is not what yo
u want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\change_form.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\collapse.js'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\collapse.min.js'. It will
be ignored since only the first encountered file is collected. If this is not w
hat you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\core.js'. It will be igno
red since only the first encountered file is collected. If this is not what you
want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\inlines.js'. It will be i
gnored since only the first encountered file is collected. If this is not what y
ou want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\inlines.min.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\jquery.init.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\popup_response.js'. It wi
ll be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\prepopulate.js'. It will
be ignored since only the first encountered file is collected. If this is not wh
at you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\prepopulate.min.js'. It w
ill be ignored since only the first encountered file is collected. If this is no
t what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\prepopulate_init.js'. It
will be ignored since only the first encountered file is collected. If this is n
ot what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\SelectBox.js'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\SelectFilter2.js'. It wil
l be ignored since only the first encountered file is collected. If this is not
what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\timeparse.js'. It will be
ignored since only the first encountered file is collected. If this is not what
you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\urlify.js'. It will be ig
nored since only the first encountered file is collected. If this is not what yo
u want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\admin\DateTimeShortcuts.j
s'. It will be ignored since only the first encountered file is collected. If th
is is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\admin\RelatedObjectLookup
s.js'. It will be ignored since only the first encountered file is collected. If
this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\jquery\jquery.js'.
It will be ignored since only the first encountered file is collected. If this
is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\jquery\jquery.min.
js'. It will be ignored since only the first encountered file is collected. If t
his is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\jquery\LICENSE-JQU
ERY.txt'. It will be ignored since only the first encountered file is collected.
If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\xregexp\LICENSE-XR
EGEXP.txt'. It will be ignored since only the first encountered file is collecte
d. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\xregexp\xregexp.js
'. It will be ignored since only the first encountered file is collected. If thi
s is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin\js\vendor\xregexp\xregexp.mi
n.js'. It will be ignored since only the first encountered file is collected. If
this is not what you want, make sure every static file has a unique path.
0 static files copied to 'C:\inetpub\wwwroot\swingqa\qablog\static', 62 unmodifi
ed.
尝试 运行 命令 python manage.py collectstatic
好的,听着!首先,您需要在 settings.py
中填写STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
稍后,您可以运行 collectstatic 命令将不同的管理静态文件保存在正确的文件夹中。
您将需要设置服务器以提供静态文件,我不知道 iis 中的正确配置是什么,但您可以在此 link 中找到 apache 配置。
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/modwsgi/
最后,你必须像这样放置你的 urlpatterns。
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'',include(api_urls)),
url(r'^api-token-auth/', obtain_jwt_token),
url(r'^api-token-verify/', verify_jwt_token),
]+static(settings.STATIC_URL,document_root = settings.STATIC_ROOT)
试试这个,评论你的结果,我们会帮助你!
祝你好运!
我解决了问题!! 首先,我更改了 settings.py 文件,如下所示
STATIC_URL = '/static/'
STATIC_ROOT = os.path.abspath(os.path.join(os.path.dirname(file), 'static')) STATICFILES_DIRS = (os.path.join('static'), )
其次,我通过查看下面这三个来编辑我的 iis
- Django Static Files - 404
- What are the problems with loading CSS and JS from Django to IIS7?
我实际上按照与第三个答案完全相同的步骤,除了我使用如下所示的网络配置文件并将其放在 C:\inetpub\wwwroot\myprojectname\static 文件夹下
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<!--
This removes Helicon Zoo handler and makes IIS processing static files.
-->
<remove name="django.project#x64" />
<remove name="django.project#x86" />
</handlers>
</system.webServer>
</configuration>
我真的很感谢帮助我的人,尤其是 soupboy、auros132 和 cutteeth。谢谢大家的支持!
如果您查看服务器控制台,您可能会看到一些 404 错误。
您需要在您的 settings.py 文件上启用 DEBUG=True
,尽管根据 Django docs,不建议在生产环境中这样做,只应在开发环境中使用。