小编tej*_*rss的帖子

在django admin filter list_filter中选择多个选项?

目前我在django的管理界面中通过一些选项进行过滤.例如,假设我按'按状态'过滤.是否可以选择多个状态来过滤结果?以下是过滤器的屏幕截图:

http://imgur.com/tV1Nl

我可以从此列表中选择多个项目吗?

python django admin django-admin content-management-system

9
推荐指数
1
解决办法
4259
查看次数

使用django-haystack计算模板中的总搜索对象数

我使用django haystack和xapian作为后端搜索引擎.我正在使用FacetedSearchViewFacetedSearchForm面对搜索.我已经searchqueryset转到了FacetSearchView我的urls.py文件中.

但问题是我无法searchqueryset在模板中访问它.我想要做的就是计算searchqueryset找到的对象数量.

在shell中我可以用S实现它earchQuerySet().filter(content="foo").count(),我怎样才能在模板中做到这一点?请指导.我想要与搜索匹配的对象总数.

python django xapian django-haystack

8
推荐指数
2
解决办法
6209
查看次数

无法使用django 1.5 Custom用户类执行数据迁移

我有许多应用程序具有历史性的南初始迁移,我想将其转换为django 1.5适用.所以我用自定义文件换出了迁移文件中的所有orm ['auth.User']引用,但是当我尝试运行这些迁移时,我得到以下错误:

迁移错误:django_notify:0001_initial KeyError:"此迁移中无法使用应用程序'配置文件'中的模型'customuser'."

有问题的迁移是这样的:http: //bpaste.net/show/2CwaYrlNifNTd5gcHUfK/

我的自定义User类是:

class CustomUser(AbstractUser):
    image = models.ImageField(_('Image Field'), upload_to='user_images')
Run Code Online (Sandbox Code Playgroud)

我也无法使用convert_to_south命令将my'profiles'应用程序转换为南方.我收到以下错误:

在'/ Users/tejinder/Projects/basidia/apps/profiles/migrations'中创建init .py ...

  • 添加了模型profiles.CustomUser

    • 在profiles.CustomUser上为组添加了M2M表

    • 在profiles.CustomUser上为user_permissions添加了M2M表

创建0001_initial.py.您现在可以将此迁移应用于:./ manage.py迁移配置文件

CommandError:一个或多个模型没有验证:auth.user:模型已被换出'profiles.CustomUser',它尚未安装或是抽象的.

可能出了什么问题?提前致谢.

django django-south django-1.5

6
推荐指数
1
解决办法
4442
查看次数

通过子进程将python的文件类对象传递给ffmpeg

我有一个 django FileField,用于在 Amazon s3 服务器上存储 wav 文件。我已经设置了 celery 任务来读取该文件并将其转换为 mp3 并将其存储到另一个 FileField。我面临的问题是我无法将输入文件传递给 ffmpeg,因为该文件不是硬盘驱动器上的物理文件。为了避免这种情况,我使用 stdin 将 django 的文件字段提供给文件的输入流。这是示例:

output_file = NamedTemporaryFile(suffix='.mp3')
subprocess.call(['ffmpeg', '-y', '-i', '-', output_file.name], stdin=recording_wav)
Run Code Online (Sandbox Code Playgroud)

其中recording_wav文件是: ,它实际上存储在amazon s3服务器上。上述子进程调用的错误是:

AttributeError: 'cStringIO.StringO' object has no attribute 'fileno'
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?先谢谢您的帮助。

编辑:

完整回溯:

[2012-07-03 04:09:50,336: ERROR/MainProcess] Task api.tasks.convert_audio[b7ab4192-2bff-4ea4-9421-b664c8d6ae2e] raised exception: AttributeError("'cStringIO.StringO' object has no attribute 'fileno'",)
Traceback (most recent call last):
  File "/home/tejinder/envs/tmai/local/lib/python2.7/site-packages/celery/execute/trace.py", line 181, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/tejinder/projects/tmai/../tmai/apps/api/tasks.py", line 56, in convert_audio
    subprocess.Popen(['ffmpeg', '-y', '-i', '-', …
Run Code Online (Sandbox Code Playgroud)

python django ffmpeg celery

5
推荐指数
1
解决办法
2061
查看次数

如何更新存储在 django 缓存中的字典?

所以我将登录用户上传的 YouTube 视频元数据存储在 django 的缓存中。元数据看起来像这样:

{'user': {'channels': [{'id': 1, 'etag': '2', 'videos': [{'id': '1', 'etag': '2'},]},]}
Run Code Online (Sandbox Code Playgroud)

每个不同的用户都有自己的元数据。现在我想更新存储在缓存中的数据(例如更新一些频道视频)。我可以做类似的事情吗?

cache.set('user', channels[0]['videos']=[new list], 30)?
Run Code Online (Sandbox Code Playgroud)

提前致谢。

python django memcached youtube-api

5
推荐指数
1
解决办法
7764
查看次数