-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter attributes by entity? #10
Comments
I needed the same feature. What I did was create a another model called Template which points to a ContentType and to which Attribute points to. There are several areas that you'll need to change EAV. The biggest one, by far, is the manager.py module. Currently, since, django-eav assumes that slug is unique in attribute, it can do the lookup and be confident it won't get multiple results. For example: If you have two attributes with the slug eav_m.Patient.objects.get(eav__test_date=date_var) I've modified django-eav to support my changes by making my Template have a unique slug, so I can do the following: eav_m.Patient.objects.get(blood_test__eav__test_date=date_var)
eav_m.Patient.objects.get(fasting_glucose_test__eav__test_date=date_var) HTH |
I ended up forking the project to add a parent model field (a foreign key to ContentType), a custom manager to retrieve only those Attributes belonging to a parent, and some proxy models to make the Admin happy. I'm still working on it, but pushing out updates as I need them. |
Interesting... I've never used proxy models before. I noticed you haven't On Tue, Dec 13, 2011 at 5:48 PM, George Dorn <
|
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?
The text was updated successfully, but these errors were encountered: