Sunday, March 26, 2017

AdminURLFieldWidget question

How can I manipulate the link in an Admin URLField so it uses the normal
HTML hyperlink attributes?

I have a substance with ingredients in a self m2m relationship and I
want the ingredients displayed to carry a link to open themself in
another substance page.

IOW, I want to use the substance.name (ie, ingredient name) instead of
substance.id in the URL.

Also, I don't need the user to see the input ("Change") part of the
field because that is always done by the software.

I guess the answer is to sub-class the AdminURLFieldWidget and use that
via ...

formfield_overrides = {

URLField: {'widget': myAdminURLFieldWidget},

}


However, I'm a bit lost in making it happen. Where do I learn more?

Thanks

Mike


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5496a937-8e44-fc70-ec39-514e79ede142%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment