-
Notifications
You must be signed in to change notification settings - Fork 86
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
Support for different field names #12
Comments
Dear All, Mine are: And in the admin this won't work: class MyAdminClassGenericAdminModelAdmin): ideas? |
I think (it's been some time since I last looked at this) that the field id is hardcoded in the javascript and the trouble with making this more flexible is that exchanging data between Django and javascript files sucks quite a bit. So, I hope I can take a look at this a bit more tomorrow but if you want to try yourself and just need something that works, try to change the javascript file so that it finds the right field. HTH |
Thanks for replying and point me. |
Took a little longer then expected, but the newest version will a) figure out all generic foreign keys on the model by itself (yes, it does work with multiple generic fks) and b) also work with all names provided. If you want to configure manually which fields the javascript will handle, you can set the class MyAdmin(GenericAdminModelAdmin):
generic_fk_fields = [{
'ct_field': <field_name_for_contenttype_fk>,
'fk_field': <field_name_for_object_id>,
}] For more then one I'm not sure if this interferes with the inline admin options. |
So, as far as I can tell version 0.5 (yay, it's even on Pypi) works with an unlimited number of generic fields and completely supports inline admins. If you find problems, I'd appreciate reopening this issue or a new issue. |
The interface doesn't work when the ContentType-related fields aren't object_id. Is there a way to integrate genericadmin into an existing a codebase? For my model, I've been using target_id as the field for storing IDs of other objects in my ContentType-enabled models.
The text was updated successfully, but these errors were encountered: