编制库存系统,具有多态项目和可管理的项目类型 [英] Coding an inventory system, with polymorphic items and manageable item types

查看:91
本文介绍了编制库存系统,具有多态项目和可管理的项目类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前拥有员工的库存系统。它包含
笔记本电脑,手机,还符合人体工程学的椅子,冰箱或软件
许可证...所以非常不同的东西,管理员可以创建/阅读/
更新/删除。



完全基于管理界面完成版本后,我放弃了
,因为它没有提供足够的灵活性。所以我卷起了一个完整的
自定义版本,但是有太多的代码我的口味...这是一个
的痛苦维持。



我面临的一些问题包括:




  • 允许管理员添加自己的项目类型通过
    接口,例如:笔记本电脑,电视,...基本上就像是可以通过一个接口通过一组属性创建Django模型。项目类型也是分层的,例如。电视
    和笔记本电脑是ElectronicItem的子类,它又是Item的
    子类,...


  • 多态:当列表所有的项目,他们应该知道他们是什么类型的
    ,这是为了搜索/过滤列表与
    javascript,并且还生成URL到项目详细视图。


  • 通过Ajax更新一些属性,例如笔记本电脑有
    许可证。在笔记本电脑的详细信息页面上,我有一个javascript经理,
    关联/分离许可证到该笔记本电脑。




所以我想知道有人有什么建议使用! I
特别想知道,如果一个django CMSes应用程序可以帮助我,
,因为这听起来像CMS可以提供​​的功能!我甚至想到一个NOSql数据库...但是这些听起来像复杂的解决方案。



实际上我第一次面对Django的这个多态性问题,我还没有找到一个很好的解决方案。所以我有希望,他们是我完全错过的东西,有人可以向我展示光。

解决方案

好的,在撰写本文的时候,Django并没有那么好。



像mongodb这样的无架构数据库是这个问题的一个很好的解决方案,而Django根本不支持那些开箱即用。



所以我放弃了Django,并在 node.js 与mongodb数据库。


We currently have an inventory system for our employees. It contains laptops, phones, but also ergonomic chairs, fridges or software licenses ... So very different stuff that admins can create/read/ update/delete.

After doing a version completely based on admin interface, I gave up cause it didn't provide enough flexibility. So I rolled-up a complete custom version, but there is far too much code to my taste ... it's a pain to maintain.

Some of the problems I have been facing include :

  • allowing the admins to add their own item types through an interface, e.g. : laptop, TV, ... so basically like if they could create Django models themselves with a set of attributes through an interface. Also item types are hierarchical, e.g. TV and Laptop are subclasses of ElectronicItem, which in turn is a subclass of Item, ...

  • polymorphism : when listing all the items, they should be aware of what type they are, this in order to search/filter the list with javascript and also generate urls to the item detailed view.

  • updating some attributes through Ajax, e.g. laptops have licenses. On a laptop detail page, I have a javascript "manager", to associate/detach licenses to that laptop.

So I was wondering if anybody had a suggestion on what to use ! I especially wonder if one of the django CMSes apps could help me, because that does sound like functionalities a CMS could provide ! I was even thinking of a NOSql database ... but those sound like complicated solutions.

It is actually not the first time I am facing this problem of polymorphism with Django, and I still haven't found a good solution. So I kind of hope, their is something that I have completely missed, and that somebody can show me the light !!!

解决方案

Ok ... at the time of the writing, Django is just not good with that.

Schema-free databases such as mongodb are a good solution for this problem, and Django simply doesn't support those out of the box.

So I gave up Django, and rewrote the whole thing in node.js with a mongodb database.

这篇关于编制库存系统,具有多态项目和可管理的项目类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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