Tom*_*Tom 4 python django django-widget-tweaks
我是 django 的新手,我正在尝试实现一个使用小部件调整的表单。
我确实安装了小部件调整(我使用的是 Ubuntu 14.04)
sudo pip install django-widget-tweaks
Run Code Online (Sandbox Code Playgroud)
我的设置文件如下所示:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'core',
'addattr',
'widget_tweaks',
)
Run Code Online (Sandbox Code Playgroud)
html 看起来像这样:
{% extends "base/theme.html" %}
{% load widget_tweaks %}
{% block main_content %}
...more code...
Run Code Online (Sandbox Code Playgroud)
视图中的类和 url 中的链接工作得很好。
但是每次当我尝试加载 html 时,它都会说:
widget_tweaks' is not a valid tag library: Template library widget_tweaks not found, tried django.templatetags.widget_tweaks,django.contrib.admin.templatetags.widget_tweaks,django.contrib.staticfiles.templatetags.widget_tweaks
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮忙吗?提前致谢
小智 4
sudo pip install django-widget-tweaks
Run Code Online (Sandbox Code Playgroud)
到:
sudo pip3 install django-widget-tweaks
Run Code Online (Sandbox Code Playgroud)
在settings.py中添加名称lib
您可以使用 :
INSTALLED_APPS+=['widget-tweaks']
Run Code Online (Sandbox Code Playgroud)
或里面
已安装的应用程序
{% load widget_tweaks %}
Run Code Online (Sandbox Code Playgroud)
测试:
在模板中
{% load widget_tweaks %}
<!-- change input type (e.g. to HTML5) -->
{% render_field form.search_query type="search" %}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7043 次 |
| 最近记录: |