Django管理员和MongoDB可以吗? [英] Django admin and MongoDB, possible at all?
问题描述
我正在构建一个简单的短URL服务,可以用于我们公司的使用。我想使用mongodb来存储数据,但是我需要一些简单的界面来添加/编辑短的url到长的url映射。
I'm building a simple short URL service, ala bitly, for our company use. And I would like to use mongodb to store the data, but I will need some kind of simple interface to add/edit short url to long url mappings.
将非常简单,这样的东西:
The mongo documents will be very simple, something like this:
{
shortUrlSlug: 'pbbs',
fullUrl: 'http://example.com/peanut/butter/and/bacon/sandwiches/'
}
有没有什么可以公开一个简单的CRUD管理界面到mongodb,可以与django集成,您可以在其中指定模型?
基本上像django管理员,但不需要一个SQL数据库。
Is there anything out there that exposes a simple "CRUD" admin interface to mongodb, that can be integrated with django, where you can specify the model?
Basically like django admin, but without requiring a SQL database.
谢谢!
推荐答案
我已经确认django-nonrel项目确实支持管理界面。我确实有一个问题,默认的SITE_ID被拾取为一个数字,这不允许作为MongoDB的主键。我通过设置:
I have confirmed that django-nonrel project does support the admin interface. I did have a problem where the default SITE_ID was picked up as a number, which is not allowed as a primary key in MongoDB. I resolved this by setting:
SITE_ID ='4d421623b0207acdc500001d'
SITE_ID = '4d421623b0207acdc500001d'
在我的settings.py
in my settings.py
我通过shell在集合中打印了第一个网站值的ID,获得了该号码。
I got the number by printing the id of the first site value in the collection through the shell.
我还没有测试这是广泛的,但是已经注册了一个用于投票对象的管理员,并看到它的工作。
I have not tested this extensively, but did register an admin for a Poll object and see it work.
这篇关于Django管理员和MongoDB可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!