Django admin 和 MongoDB,可能吗?

发布于 2024-09-14 22:40:35 字数 357 浏览 7 评论 0 原文

我正在构建一个简单的短 URL 服务,供我们公司使用。我想使用 mongodb 来存储数据,但我需要某种简单的界面来添加/编辑短 url 到长 url 映射。

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

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

是否有任何东西可以向 mongodb 公开一个简单的“CRUD”管理界面,可以与 django 集成,您可以在其中指定模型?
基本上就像 django admin,但不需要 SQL 数据库。

谢谢!

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/'
}

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.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

标点 2024-09-21 22:40:35

我已经确认 django-nonrel 项目确实支持管理界面。我确实遇到了一个问题,默认的 SITE_ID 被选择为数字,这在 MongoDB 中是不允许作为主键的。 设置:

SITE_ID = '4d421623b0207acdc500001d'

我通过在 settings.py 中

解决了这个问题。我通过 shell 打印集合中第一个站点值的 id 来获取数字。

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

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'

in my settings.py

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.

谁与争疯 2024-09-21 22:40:35

我已将 django-nonrel 与 mongodb-engine 一起使用,效果很好。 Django admin 还可以使用标准模型字段。但如果您使用 listfield 和 dictfield,则需要进行一些修改。

I have used django-nonrel with mongodb-engine and it works well. Django admin also works with standard model fields. But if you are using listfield and dictfield, you would need to do some hacking.

緦唸λ蓇 2024-09-21 22:40:35

我并不肯定,但 django-nonrel 和 mongodb 后端现在可能支持 django 管理...可能值得研究

http://www.allbuttonspressed.com/projects/django-nonrel

I'm not positive, but django-nonrel and the mongodb backend may support the django admin nowadays... it might be worth looking into

http://www.allbuttonspressed.com/projects/django-nonrel

允世 2024-09-21 22:40:35

django-nonrel 是 django 的一个分支,并且已经一年多没有更新了。 django-mongonautdjango-mongoadmin 是 django 软件包,可能更适合。

django-nonrel is a fork of django and it hasn't been updated for over a year. django-mongonaut and django-mongoadmin are django packages and are probably a better fit.

赠我空喜 2024-09-21 22:40:35

Django Admin 可以通过 MongoDB 实现。您是否研究过 Djongo 项目?

Djongo 是一个 SQL 到 MongoDB 查询编译器。它将每个 SQL 查询字符串转换为 mongoDB 查询文档。因此,

  • 所有 Django 模型和相关模块都按原样工作。
  • 使用 Django 管理 GUI 添加 MongoDB 嵌入文档。
  • Djongo 为 Django ORM 提供 API 扩展,让您可以将一个文档“嵌入”到另一个文档中,例如 MongoEngine。

有一篇文章 djongo 文档并开始使用它。

Django Admin is VERY MUCH possible with MongoDB. Have you looked into the Djongo project?

Djongo is a SQL to MongoDB query compiler. It translates every SQL query string into a mongoDB query document. As a result,

  • All Django models and related modules work as is.
  • Use the Django Admin GUI to add MongoDB embedded documents.
  • Djongo provides API extensions to the Django ORM that let you ‘embed’ one document inside another, like MongoEngine.

There is an article on Using Django with MongoDB by adding just one line of code, if you are looking for more information. Otherwise, you can jump directly into the djongo documentation and start using it.

汹涌人海 2024-09-21 22:40:35

这是一个老问题,但如果今天有人碰巧面临同样的问题,我认为他最好的选择是 http://humongous.io 。它是 mongoDB 的类似 django-admin 的界面。它知道如何猜测/处理关系,并且工作方式与 Django 管理员非常相似。

This is an old question but if someone happens to be facing the same problem today, I think his best bet would be http://humongous.io. It's a django-admin like interface for mongoDB. It knows how to guess/deal with relationships and works pretty much as the Django admin.

迷鸟归林 2024-09-21 22:40:35

mongodb 有很多行为,django-admin 适用于像 postgresql 这样的关系数据库,

您可以使用 django-nonrel 创建 django admin,但它不是优化的,也不是很好。我认为最好为您的应用程序创建自定义管理。

mongodb has many behaviors and django-admin is for relation database like postgresql

you can create django admin with django-nonrel but its not optimize and good. i think its bettwr you create custom admin for your application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文