Hi Tim, thanks for the reply :)

It's not that I want to store the model instance on self.instance, it's 
just the solution I was able to come up with, given the problem "I need to 
get to the model instance for this HTTP request". If there's a better way 
to do it, I'm all ears!

T

On Thursday, September 15, 2016 at 5:34:50 PM UTC-7, Tim Graham wrote:
>
> I think these ideas have been floated before. If you look through the Trac 
> tickets you might find something related. However, your subclass where you 
> store "self.instance" on ModelAdmin is a no no due to thread safety. See 
> http://stackoverflow.com/questions/3388111/modeladmin-thread-safety-caching-issues
>  
> for an explanation.
>
> On Thursday, September 15, 2016 at 6:53:15 PM UTC-4, th...@copperleaf.com 
> wrote:
>>
>> I have a ModelAdmin subclass (code at: <https://dpaste.de/0LAt>) and I 
>> need to do a couple of things, but the functionality seems to be missing:
>>
>> 1. I need to access the model instance to perform some initialization, 
>> but there's no instance member set. There are a few questions on Stack 
>> Overflow on this topic, so I know I'm not alone.
>>
>> 2. I need to initialize my form with a parameter derived from the model 
>> instance. If this were a View, I could just override get_form_kwargs and be 
>> done with it, but ModelAdmin doesn't have it.
>>
>> Is there a reason why those two features are missing from ModelAdmin? 
>> Maybe they could be added (and I could open a PR)? Or is there a better way 
>> to do what I need to do?
>>
>>

-- 
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+unsubscr...@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/39bbf43e-3a6c-47a4-ab4d-46e5c49cf32b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to