我想为没有模型的管理面板创建自定义页面.首先我将index.html复制到项目文件夹:
mysite/
templates/
admin/
index.html
Run Code Online (Sandbox Code Playgroud)
然后添加到应用程序阻止我的代码:
<div class="module">
<table summary="{% blocktrans with name="preferences" %}Models available in the preferences application.{% endblocktrans %}">
<caption><a href="preferences" class="section">{% blocktrans with name="preferences" %}Preferences{% endblocktrans %}</a></caption>
<tr>
<th scope="row"><a href="preferences">Preferences</a></th>
<td><a href="preferences" class="changelink">{% trans 'Change' %}</a></td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
这很好用,然后我创建新页面/templates/admin/preferences/preferences.html并添加到urls.py:
url(r'^admin/preferences/$', TemplateView.as_view(template_name='admin/preferences/preferences.html')),
Run Code Online (Sandbox Code Playgroud)
并将代码添加到preferences.html:
{% extends "admin/base_site.html" %}
{% block title %}Test page{% endblock %}
Run Code Online (Sandbox Code Playgroud)
运行它并查看错误消息"请求的管理页面不存在.".我做错了什么?
我想从url解析查询部分,这是我的代码:
>>> from urlparse import urlparse, parse_qs
>>> url = '/?param1¶m2=2'
>>> parse_qs(urlparse(url).query)
>>> {'param2': ['23']}
Run Code Online (Sandbox Code Playgroud)
此代码看起来不错,但"parse_qs"方法丢失了诸如"param1"或"param1 ="之类的查询参数.我可以用stantard库解析查询部分并保存所有参数吗?
我的celerybeat.conf
[program:celerybeat]
command=/path/app/env/bin/celery beat -A project.tasks --loglevel=INFO
environment=PYTHONPATH=/path/app/env/bin
user=nobody
numprocs=1
stdout_logfile=/var/log/celeryd.log
stderr_logfile=/var/log/celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=998
Run Code Online (Sandbox Code Playgroud)
当我启动主管时,我收到一个错误:
pidfile_fd = os.open(self.path, PIDFILE_FLAGS, PIDFILE_MODE)
celery.platforms.LockFailed: [Errno 13] Permission denied: '/celerybeat.pid'
Run Code Online (Sandbox Code Playgroud)
不知道怎么解决这个问题?
我在本地仓库中添加了一些更改并运行svn diff,但diff输出为空.但svn status标记我的文件已修改.这是文件是外部项目,我怎么能用diff这个命令?
随着git status我可以了解未公布的提交计数信息:
» git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
我想用GitPython获取未发布的提交(或计数).我找到的文档repo.git.status(),但这不是我想要的.
我尝试为基于 ListView 的类编写 get 方法,我想从模板中的表单获取请求,并从请求返回带有过滤器的模型。这是我的代码的一部分:
class SearchListView(ListView):
context_object_name = 'projects_list'
template_name = 'projects/search.html'
paginate_by = 10
def get(self, request, *args, **kwargs):
do smth??
return self.render_to_response(??)
Run Code Online (Sandbox Code Playgroud)
我的表格:
<form class="well form-search" action="/search/" method="get">
<input type="text" class="input-medium search-query" name="q">
<button type="submit" class="btn">Search</button>
</form>
Run Code Online (Sandbox Code Playgroud)
请给我一些例子。
例如,我有主键[1,2,3,4]的列表我想做这样的smth:
Player.objects.order_by('-cup_points').exclude(pk=[1,2,3,4])
Run Code Online (Sandbox Code Playgroud)
但参数必须是字符串或数字,而不是"列表".我可以这样做吗?
python ×6
django ×3
celery ×1
celerybeat ×1
django-admin ×1
django-views ×1
git ×1
gitpython ×1
supervisord ×1
svn ×1
urlparse ×1