Django admin 和 MongoDB,可能吗? [英] Django admin and MongoDB, possible at all?

查看:32
本文介绍了Django admin 和 MongoDB,可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个简单的短 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.

mongo 文档将非常简单,如下所示:

The mongo documents will be very simple, something like this:

{
  shortUrlSlug: 'pbbs',
  fullUrl: 'http://example.com/peanut/butter/and/bacon/sandwiches/'
}

是否有任何东西可以向 mongodb 公开一个简单的CRUD"管理界面,可以与 django 集成,您可以在其中指定模型?
基本类似于 django admin,但不需要 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.

我没有对此进行广泛测试,但确实为 Poll 对象注册了一个管理员并看到它工作.

I have not tested this extensively, but did register an admin for a Poll object and see it work.

这篇关于Django admin 和 MongoDB,可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆