Git Product home page Git Product logo

django-eav's People

Contributors

amarder avatar cv3d avatar dgelvin avatar dorey avatar fosil avatar gingerjoos avatar jiargei avatar jpwhite3 avatar katembu avatar madeng84 avatar mrsaints avatar nicpottier avatar reinoudvansanten avatar tavaresb avatar thedavidmccann avatar timlinux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-eav's Issues

eav.register need sites app

hi,
eav.register(MonitorObject) trigger:

RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

put django.contrib.sites into INSTALLED_APPS resolve this

this maybe need documented

Site framework is required but not documented, Site framework should be optional

It seems that trying to use django-eav without Django's site framework in installed apps causes errors. This doesnt seem to be documented anywhere. Also it would be nice to have Sites framework integration as optional feature.

Run server with eav on installed apps and no Sites framework:
Validating models...

CommandError: One or more models did not validate:
eav.attribute: 'site' has a relation with model <class 'django.contrib.sites.models.Site'>, which has either not been installed or is abstract.

More of a question

I'm wanting to use eav in multiple apps in the same project. The first one works like a charm. When I try create new schema and attr tables in the new project I get an error complaining about 'related_name'. What would be the correct solution? Should I use the original schema and attr table thereby building a dependency to another django app, or should I change the related name?

UPDATE: I just realised I should change the model name of the model inheriting base attribute. Not ideal, but i guess workable for this edge case

`unique_together` constraint not working

I might be doing something wrong, but if the following example code is executed:

Attribute.objects.create(name='Height', datatype=Attribute.TYPE_TEXT)

There is no content_type. Furthermore, it can be executed multiple times resulting in several attributes, and judging from unique_together = ('site', 'content_type', 'slug'), perhaps it is not desirable?

using sort operations like order_by, latest, etc.

Looking at your code and doing some testing it appears sorting querysets with eav attributes using operations like order_by isn't supported. If it isn't supported, can you recommend a technique for getting around this limitation short of bringing everything into memory and sorting it their?

instance attributes filtering

Hello,

I'd like to be able to filter attributes, not for a model, but for each instances of a model, regarding a value of one of its field.

an example:

class EavConfigClass(EavConfig):
@classmethod
def get_attributes(cls, id_of_my_instance):
type = filtering_from_my_instance_value
return Attribute.objects.filter(type=type)

ImportError: No module named tests.models when installed via PIP

Hey guys - just wanted to let you know that since setup.py does not install the eav.tests package, the app breaks on the following line:

File "/path/to/rapidsms-xforms/rapidsms_xforms/models.py", line 5, in <module>
  from eav.models import Attribute, Value
File "/home/tobias/.virtualenvs/my-env/lib/python2.6/site-packages/eav/models.py", line 540, in <module>
  from .tests.models import Patient, Encounter
ImportError: No module named tests.models

Cheers!
Tobias

Filter broken on Django 1.11

I get the following error when using the examples:

Cannot resolve keyword 'eav' into field. Choices are: eav_values, id

Can not use EAV model in ManyToMany relation

Consider the following example:

class Fruit(BaseEntity):
    title = models.CharField(max_length=50)

class Customer(models.Model):
   name = models.CharField(max_length=50)
   fruits = odels.ManyToManyField(Fruit)

Trying to edit Customer in django admin will complain:

Caught AttributeError while rendering: Fruit does not have attribute named "attrs".

The problem is that django ModelMultipleChoiceField does this:

    def prepare_value(self, value):
        if hasattr(value, '__iter__'):
            return [super(ModelMultipleChoiceField, self).prepare_value(v) for v in value]
        return super(ModelMultipleChoiceField, self).prepare_value(value)

I.e. since Fruit has __iter__ method, prepare_value tries to iterate it and it goes wrong.

Doesn't work with Django 1.9

django.contrib.contenttypes.generic is deprecated and removed in Django 1.9 which causes django-eav to break as it is referenced from the module eav.models.

Repo still alive?

Hey guys, just want to touch base on whether this repo is still being actively maintained.

There are a few great PRs out there that requires merging for the latest Django 2.0.X

Unicode in Validation for Python3

I happened to use django-eav for my project. I found a small bug in the validation module (Validators.py).

The function validate_text raises validation error saying "unicode" is not defined when using Python 3. I understand the cause of the error. I have updated it in my local project.

Can I create a pull request? Has anybody other than me experienced this issue with python3? Thank you

Filter attributes by entity?

I have three different models that I want to use EAV with. I don't want to share any Attributes between them, and in fact want to have three different admin pages for managing each type of Attribute. I notice that the Attribute model doesn't have a foreign key to a ContentType, so the only way to filter attributes is to hardcode references to attribute names, which isn't an option for me as I have no idea what attributes will exist.

Is there another way to handle this, or would the best approach be to fork the project to add this feature? If so, is there any guidance you can give me for what other parts of django-eav I'd need to adapt?

ImportError: No module named 'registry'

I got an Error at Python3.5.2 Django 1.11
ImportError: No module named 'registry'
locate init.py
def register(model_cls, config_cls=None):
from registry import Registry
Registry.register(model_cls, config_cls)

def unregister(model_cls):
from registry import Registry
Registry.unregister(model_cls)

I solve this issue using relative imput:
.....
from .registry import .....
......

Filter 'and' logic is broken

I was expecting products with weight between 3 and 4, however this gives OR query instead:
Product.objects.filter(eav__weight__gt=3, eav__weight__lt=4)
.. so I received weight with 2 because it was less than 4.

Django's filter convention is to use that as a AND query, I think that should change to that.

Filtering by slugs doesn't work when chained

The documentation says that this works:

Patient.objects.filter(eav__weight=42.2)

While that is correct, this will not work:

Patient.objects.filter(foo=bar).filter(eav__weight=42.2)

Nor will this:

queryset = Patient.objects.filter(foo=bar)
queryset = queryset.filter(eav__weight=42.2)

The EntityManager should somehow always return a wrapped function instead of the original.

issue with using django 2.x

when using with latest django version its having some issue with ForeignKey , I corrected it with adding
' on_delete = models.CASCADE' to model field.

Make a release on PyPi

It would be great to have a release on PyPi, so that we can add django_eav to our setup.py's require.

Feel free to contact me if you need help (jpic on freenode)

Maintain django-eav?

If you would like to maintain this project, please post here. I think I'm now the only person that looks at these PRs, but I don't use this app myself.

Alternatively, we could ask github to point to a different fork as the root node, if someone else is keeping it up-to-date with django updates, etc. (E.g. SideStudios/django-eav and @drewisme)

Pinging the most recent contributors-- @Michael-Spirit @novoxudonoser @jpwhite3 @Torjas

Thanks

validate_enum

It seems to me that there is a problem w/ validation process for validate_enum(value) method.
first, the synthax from .models import EnumValue is no longer right
next, it seems that 'if not isinstance(value, EnumValue):' is always true even if it's false. value.class is unicode for me each time.

TypeError: __init__() missing 1 required positional argument: 'on_delete‘

python 3.5 ubuntu18.4
my code:
`class Task(models.Model):

STATUS_CHOICES = (
    ("New", "New"),
    ("In Progress", "In Progress"),
    ("Completed", "Completed")
)

PRIORITY_CHOICES = (
    ("Low", "Low"),
    ("Medium", "Medium"),
    ("High", "High")
)

# xiaowy
# title = models.CharField(_("title"), max_length=200)
# status = models.CharField(
#     _("status"), max_length=50, choices=STATUS_CHOICES)
# priority = models.CharField(
#     _("priority"), max_length=50, choices=PRIORITY_CHOICES)
# due_date = models.DateField(blank=True, null=True)
# created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
# account = models.ForeignKey(
#     Account, related_name='accounts_tasks', null=True, blank=True, on_delete=models.SET_NULL)

# contacts = models.ManyToManyField(
#     Contact, related_name="contacts_tasks")

# assigned_to = models.ManyToManyField(
#     User, related_name='users_tasks')
# end
name = models.CharField(_('name'), max_length=200, null=True)
contact = models.CharField(_('contact'), max_length=50, null=True, blank=True)
phone = PhoneNumberField(null=True)
email = models.EmailField(null=True, blank=True)
weixin = models.CharField(_('wechat'), max_length=50, null=True, blank=True)
qq = models.CharField(_('qq'), max_length=26, null=True, blank=True)
website = models.URLField(_("Website"), blank=True, null=True)
effective  = models.IntegerField(choices=PARTNER_IS_EFFECTIVE, default=1)
partner_type = models.IntegerField(choices=PARTNER_TYPE, default=1)
# description = models.CharField(_('description'), max_length=255, null=True, blank=True)
description = models.TextField(blank=True, null=True)
address = models.CharField(_('address'), max_length=255, null=True, blank=True)
created_on = models.DateTimeField(_("Created on"), auto_now_add=True)

created_by = models.ForeignKey(
    User, related_name='task_created', blank=True, null=True, on_delete=models.SET_NULL)
# xiaowy
# teams = models.ManyToManyField(Teams, related_name='tasks_teams')


def __str__(self):
    return self.name

@property
def created_on_arrow(self):
    return arrow.get(self.created_on).humanize(locale='zh_CN')

class Meta:
    # ordering = ['-due_date']
    ordering = ['-created_on']

xiaowy

import eav
eav.register(Task)`

exception:
(env) xiaowy@ubuntu:~/django-crm/django-crm$ python manage.py migrate
No local settings file found
Traceback (most recent call last):
File "manage.py", line 24, in
execute_from_command_line(sys.argv)
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/core/management/init.py", line 357, in execute
django.setup()
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/home/xiaowy/django-crm/env/lib/python3.5/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 665, in exec_module
File "", line 222, in call_with_frames_removed
File "/home/xiaowy/django-crm/django-crm/tasks/models.py", line 79, in
eav.register(Task)
File "/home/xiaowy/django-crm/env/src/django-eav/eav/init.py", line 30, in register
from .registry import Registry
File "/home/xiaowy/django-crm/env/src/django-eav/eav/registry.py", line 35, in
from .managers import EntityManager
File "/home/xiaowy/django-crm/env/src/django-eav/eav/managers.py", line 34, in
from .models import Attribute, Value
File "/home/xiaowy/django-crm/env/src/django-eav/eav/models.py", line 109, in
class Attribute(models.Model):
File "/home/xiaowy/django-crm/env/src/django-eav/eav/models.py", line 186, in Attribute
verbose_name=
(u"content type"))
TypeError: init() missing 1 required positional argument: 'on_delete'

get_field_by_name has been deprecated.

m2 = MonitorObject.objects.get(pk=1)

site-packages/eav/managers.py:113: RemovedInDjango110Warning: 'get_field_by_name is an unofficial API that has been deprecated. You may be able to replace it with 'get_field()'
field, m, direct, m2m = model_cls._meta.get_field_by_name(fields[0])

Heads-up on Django EAV 2 fork

Hey!

In case this repository is no longed maintained, I just wanted to let you guys know (and everyone interested), that we forked django-eav (which was always very useful to us) and are actively developing it at django-eav2.

Backwards compatibility is not exactly our highest priority, but will be monitoring this repository and pulling updates, feature requests and such. We would gladly use a hand, too. ✋

Thanks!

Ability to set default values for an attribute?

Hi there,

I am currently using EAV to collect data for my machine learning module. As I foresee the need to add additional attributes to my entity as my project grows, I wonder whether django-eav provides any sort of default value that I can set every time I add a new attribute to an entity.

License ?

It's unclear what license applies to this codebase. It would be nice to have a clear FOSS license specified. I propose a MIT license which essentially provides maximum flexibility to any developer as well as user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.