云面板不在django的目录中

时间:2018-03-02 15:36:36

标签: python regex django django-urls

我写云面板写python / django。我的问题是,urls.py无法访问下一个转发目录。我用apache。当它转到下一个前进时,此页面显示:

https://postimg.org/image/b1t9s26b9/

我的urls.py里面:

from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.views.generic.base import TemplateView

admin.autodiscover()

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$','explorer.views.home',name='home'),
    url(r'^servers/$','explorer.views.servers'),
    url(r'^addserver/$','explorer.views.addserver'),
    url(r'^removeserver/$','explorer.views.removeserver'),
    url(r'^manage/(?P<server>[\w]+)/(?P<path>[\w]+)/$','manager.views.filemanager'),
    url(r'^navback/(?P<server>[\w]+)/(?P<path>[\*\w]+)/$','manager.views.navbackward'),
    url(r'^naviforward(?P<server>[\w]+)/(?P<path>[\*\w]+)/(?P<dir>[\w]+)/$','manager.views.navforward'),
    url(r'^edit/(?P<server>[\w]+)/(?P<path>[\*\w]+)/(?P<file>[\.\w]+)$','manager.views.editdata'),
    url(r'^saveandsend/(?P<server>[\w]+)/(?P<path>[\*\w]+)/(?P<file>[\.\w]+)$','manager.views.senddata'),
    url(r'^upload/(?P<server>[\w]+)/(?P<path>[\*\w]+)/$','manager.views.uploadfile'),
    url(r'^delete/(?P<server>[\w]+)/(?P<path>[\*\w]+)/(?P<file>[\.\w]+)$','manager.views.deletefile'),

]

我的views.py里面:

https://postimg.org/image/s2c60qr2d/

views.py里面的ssh连接和sftp连接:

https://postimg.org/image/635rdjhxx/

我的内部路由到html文件:

    <div class="col-md-4">
        {% if path != orginalpath %}
        <a href="http://127.0.0.1:8000/navback/{{ server }}/{{ modpath }}/"><span class="glyphicon glyphicon-arrow-left" style="color: #ac2925;height: 30px"></span></a>
    {% endif %}
    {% for d in dirs %}
        <ul>
            <li>
                <span class="glyphicon glyphicon-folder-close" style="color: #eea236"></span>
        <a href="http://127.0.0.1:8000/naviforward/{{ server }}/{{ modpath }}{{ d }}/">{{ d }}</a>
        </li>
        </ul>
        {% endfor %}
     </div>

如果您可以访问项目和图片,可以查看链接:

https://postimg.org/gallery/3iakj1t7a/

https://gitlab.com/rection/Cloud-Panel-Django.git

如何解决我的问题?

1 个答案:

答案 0 :(得分:0)

url(r'^naviforward(?P<server>[\w]+)/(?P<path>[\*\w]+)/(?P<dir>[\w]+)/$','manager.views.navforward')

naviforward/<server>matched/<path>matched/<dir>not matched/

naviforward/DigitalOcean/*root*docker-bench-security/

你的正则表达式确实有3个不同的匹配组,但只给出了2个部分;而且我也相信url()函数需要正则表达式和可调用而不是正则表达式和字符串。