Re: [WARNING - NOT Solved] SVG widget for the Admin

2021-07-25 Thread Mike Dewhirst
On 9/06/2021 12:44 pm, Mike Dewhirst wrote: Do not use this solution. The Svg_AdminTextareaWidget code below deletes data on saving. I think the reason might be that on saving it tries to save the image instead of the image source code. I'm now digging deeper and will report back. I can't

[WARNING - NOT Solved] SVG widget for the Admin

2021-06-08 Thread Mike Dewhirst
Do not use this solution. The Svg_AdminTextareaWidget code below deletes data on saving. I think the reason might be that on saving it tries to save the image instead of the image source code. I'm now digging deeper and will report back. Mike On 7/06/2021 6:00 pm, Mike Dewhirst wrote:

Re: [Solved] SVG widget for the Admin

2021-06-07 Thread Derek
Good to hear! Django once again proving capable, once you figure it out. Am reminded of the Zen: "There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch." On Mon, 7 Jun 2021 at 10:00, Mike Dewhirst wrote: >

[Solved] SVG widget for the Admin

2021-06-07 Thread Mike Dewhirst
Thanks Derek - it is now working as follows ...  class Chemical(models.Model):     ...     ddstructure = models.TextField(null=True, blank=True, verbose_name="2D structure")     ... class Svg_AdminTextareaWidget(AdminTextareaWidget):     def render(self, name, value, attrs=None,

Re: SVG widget for the Admin

2021-06-06 Thread Mike Dewhirst
On 6/06/2021 6:14 pm, Derek wrote: RE - "I've looked at the AdminTextareaWidget which is probably based on the TextInput built-in widget but see no way to influence what it does. " and "How do I get it to display inline in the proper place?" There seems to be similar question on SO:

Re: SVG widget for the Admin

2021-06-06 Thread Mike Dewhirst
On 4/06/2021 5:15 pm, Derek wrote: Hi Mike The SVG is not going to display as SVG in a *form* - for that you'd need a widget, or perhaps just let users edit the text. OK - I'm outta my depth here. I've looked at the AdminTextareaWidget which is probably based on the TextInput built-in

Re: SVG widget for the Admin

2021-06-04 Thread Mike Dewhirst
On 4/06/2021 5:15 pm, Derek wrote: Hi Mike The SVG is not going to display as SVG in a *form* - for that you'd need a widget, or perhaps just let users edit the text. It will always be readonly.  Forever. Did you try displaying in the normal admin lists? This was my understanding of

Re: SVG widget for the Admin

2021-06-04 Thread Derek
Hi Mike The SVG is not going to display as SVG in a *form* - for that you'd need a widget, or perhaps just let users edit the text. Did you try displaying in the normal admin lists? This was my understanding of where you wanted to see it and the code snippets I posted were for that purpose.

Re: SVG widget for the Admin

2021-06-03 Thread Mike Dewhirst
On 3/06/2021 4:00 pm, Derek wrote: > > E.g. > > class MyModel(): >     svg_text = CharField() in my case it is ... class Chemical(models.Model):     ...     ddstructure = models.TextField(     null=True,     blank=True,     verbose_name="2D structure",     ) The above is

Re: SVG widget for the Admin

2021-06-03 Thread Derek
> a safe filter. > > Thanks again > > Mike > > > > -- > (Unsigned mail from my phone) > > > > Original message > From: Derek > Date: 2/6/21 23:39 (GMT+10:00) > To: Django users > Subject: Re: SVG widget for the Admin >

Re: SVG widget for the Admin

2021-06-02 Thread Mike Dewhirst
filter.Thanks againMike--(Unsigned mail from my phone) Original message From: Derek Date: 2/6/21 23:39 (GMT+10:00) To: Django users Subject: Re: SVG widget for the Admin When you say "I tried your suggestion and had no success." what exactly did you try  - i.e. what co

Re: SVG widget for the Admin

2021-06-02 Thread Derek
When you say "I tried your suggestion and had no success." what exactly did you try - i.e. what code did you use and what errors did you get? WRT "Not sure where this should live for the Admin to call it and display the image." - it lives exactly as I showed it in my example; its a

Re: SVG widget for the Admin

2021-06-02 Thread Mike Dewhirst
On 1/06/2021 11:44 pm, Derek wrote: You haven't defined where in the admin interface you want this image to be displayed?  A table? I have not tried this, but could you not create an additional field on your model that returns the HTML-encoding needed to display the SVG? Derek, thanks for

Re: SVG widget for the Admin

2021-06-01 Thread Derek
You haven't defined where in the admin interface you want this image to be displayed? A table? I have not tried this, but could you not create an additional field on your model that returns the HTML-encoding needed to display the SVG? E.g. class MyModel(): svg_text = CharField()

SVG widget for the Admin

2021-05-31 Thread Mike Dewhirst
I collect the svg source for an image from a public API and store it in a models.TextField. I have no difficulty displaying it in a normal view and my own template. Nothing special, it just emerges. I don't even need a 'safe' filter. However, I really want to display such images in the Admin.