开发者

how to select or display records based on some query in django's admin

(i'm a django newbie)

We need to delete certain records from a django table (comments).

I prefer to do this from the admin and not directly using the database engine (mysql, btw), because of the naive assumption that it will handle relastionships or software restrictions.

there are hundreds or thousands of records, and the ideal was to put a 开发者_高级运维WHERE query somehow, and select all.

how can I filter the recordset in the admin?

django: latest stable.

thank you


python script / django console is an option? there you could simply

Comment.objects.filter(**where_dict).delete()

of course not the best to try directly on production environments :)


Easiest way would be to use the shell:

$ python /path/to/site/manage.py shell

Then

>>> from comments.models import Comment
>>> Comment.objects.filter(content__icontains='spam').delete()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜