不能修改django休息框架的base.html文件 [英] Can't modify django rest framework base.html file

查看:163
本文介绍了不能修改django休息框架的base.html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用django休息框架,如下所述: django rest framework doc 我已经在我的模板目录中添加了/rest_framework/api.html。



现在的结构是:

  | 
| \
| apps
| \
| settings.py
\
模板
\
rest_framework
\
api.html
/ pre>

api.html

  {%extendsrest_framework /base.html%

{%block footer%}
您好!
{%endblock%}

settings.py:



...

  TEMPLATE_LOADERS =(
('django.template.loaders.cached .Loader',(
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs。装载机,
)),

...

  INSTALLED_APPS =(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.markup',
'django.contrib.webdesign',
..
'rest_framework',
...



...

  REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES':(
'rest_framework.authentication.BasicAuthentication',
'rest_framework ,
'
'DEFAULT_PERMISSION_CLASSES':('rest_framework.permissions.IsAuthenticated',)
'PAGINATE_BY':10
}

我在api.html中进行的修改不会显示在可浏览的api中。我做错了什么?

解决方案

您正在使用哪个版本的Django REST框架?
我对base.html中的块脚注进行了更改,这是为3.0版本而设计的。



您的Hello!还没有显示页面的源代码(您可以通过按CTRL + U获得)?



如果是,最终可能是使CSS变为白色的问题。你可以在这样一个标签中添加Hello!:< p> Hello!< / p>



编辑:



其他信息。



粘性页脚总是显示在下面60px的问题页面底部,因此需要滚动才能看到它。如果您使用的是旧版本,这也可能导致问题。
最重要的问题是:'你好!'源代码HTML中没有发送到浏览器或是在那里,但是你看不到它在页面上?



请给我一个反馈,所以我们可以解决这个问题。


I'm using django rest framework, and as discribed here : django rest framework doc I've added /rest_framework/api.html in my templates dir.

The structure now is :

|
|\
| apps
|  \
|   settings.py
\
 templates
  \
   rest_framework
    \
     api.html

api.html :

{% extends "rest_framework/base.html" %}

{% block footer %}
    Hello !
{% endblock %}

settings.py :

...

TEMPLATE_LOADERS = (
    ('django.template.loaders.cached.Loader', (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
        'django.template.loaders.eggs.Loader',
    )),
)

...

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'django.contrib.markup',
    'django.contrib.webdesign',
     ...
    'rest_framework',
     ...


)

...

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',),
    'PAGINATE_BY': 10
}

The modification I do in api.html are not displayed in the browsable api. What am I doing wrong ?

解决方案

Which version of Django REST Framework are you using? I made changes to the block footer in the base.html and this was planed for the 3.0 release.

Is your 'Hello !' also not showing in the source code of the page (you can get it by pressing CTRL+U)?

If yes, than it could eventually be an issue with CSS making the colour white. You can put 'Hello !' in a tag like this: <p>Hello !</p>.

EDIT:

Additional info.

There was an issue with the sticky footer displaying always 60px below the page bottom, thus scrolling down was needed to see it. If you are using an older version this can be also causing the problem. The most important question is: is 'Hello !' not at all in the source HTML sent to the browser or is it there, but you can't see it on the page?

Please give me a feedback, so we can solve this.

这篇关于不能修改django休息框架的base.html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆