Thank you all for your attention. Kept me going. (another resend
this time hopefully it will be laid out better) The fix is to initialise the self.change_form_template to None *every* time ModelAdmin.change_form() is called. If it is None the ModelAdmin.render_change_form() method will dynamically create the model instance change form. Otherwise it uses the form I give it. My problem was it remembered that instead of doing its own thing when I had finished with it. I reckon it was designed to swap out the default form and completely replace it forever. Thank heavens for open source. Here is the only change to my code ... def change_view(self, request, object_id, form_url='', extra_context=None): """ self = SubstanceAdmin request = wsgi request object object_id = substance form_url = no idea! extra_context = dict of apps, models, admin_urls and permissions """ self.change_form_template = None ############## this works ############# ingredients = Substance_Ingredients.objects.filter(substance_id=object_id) subscription = None for sm2mi in ingredients: payable, fee_type = sm2mi.fee_payable() # eg., True, PAID_DATA if payable: subscription = billing_subscribe(sm2mi, fee_type) if subscription: # we need to collect money for the owner self.change_form_template = 'payment.html' context = billing_collect_context( sm2mi, subscription, ) # get everything into the payment_view context if not extra_context: extra_context = dict() extra_context.update(self.admin_site.each_context(request)) extra_context.update(context) self.admin_site.admin_view( # call the Stripe mechanism billing_payment_view( request, sm2mi, subscription, context=extra_context, ) ) # only one sm2mi at a time break #if extra_context: # logging.log(logging.DEBUG, '205 admin {0}'.format(extra_context)) return super(SubstanceAdmin, self).change_view( request, object_id, form_url, extra_context ) I reckon the Admin can do anything. It just takes some head scratching :) Mike On 23/02/2019 6:58 pm, Mike Dewhirst wrote: (Resend with urls which I previously omitted) -- 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/4cf8ad94-da46-35e1-ba5a-d168de645561%40dewhirst.com.au. For more options, visit https://groups.google.com/d/optout. |
- How can I refresh admin_urls Mike Dewhirst
- Re: How can I refresh admin_urls Scot Hacker
- Re: How can I refresh admin_urls Mike Dewhirst
- How can I refresh admin_urls Mike Dewhirst
- [Solved] Re: How can I refresh admin_urls Mike Dewhirst
- [Solved] Re: How can I refresh admin_urls Mike Dewhirst
- Re: [Solved] Re: How can I refresh admin_urls Dylan Reinhold