开发者

Django databrowse with custom queryset?

Django's databrowse is very different from the rest of django in that the docs literally don't exist. Has anyone tried to do more that databrowse.site.register on a model? Any code examples?

In particular, I've got a model that has a ForeignKey to an auth.Group a开发者_C百科nd I want databrowse to use this queryset instead of .all():

qs = Model.objects.filter(group__in=request.user.groups.all())

Bonus points for making it possible to have a button that does stuff with the current object (edit/delete/clone/etc). I basically need a simple way to browse and edit rows without giving users access to the admin.

It'd be even better if there was a way to do that on the admin, but I don't want to give users the staff privilege.


There's no way to do this through databrowse. You could try writing a custom Manager for your Model and return the required query set by default.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜