Sunday, March 26, 2017

Re: AdminURLFieldWidget question

Declaring myAdminURLFieldWidget outside the ModelAdmin class is the answer!

On 26/03/2017 6:32 PM, Mike Dewhirst wrote:
> 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/4a49d908-2d2d-7335-6318-56b63c0a3d4b%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment