Django 2.0 makes no difference either so I've gone back to 1.11 for the time being. To recap ... I'm successfully launching a Stripe payment page from within the Admin  followed by a success (or failure) page which is at the following URL ...

http://localhost:8000/admin/substance/substance/1442/change/payment

... with a link back to the original Admin page.

http://localhost:8000/admin/substance/substance/1442/

On clicking that link the Admin shows *no error but no content* other than the normal top of page at the following correct URL ...

http://localhost:8000/admin/substance/substance/1442/change/

The only way I can get it to show the proper content at that URL is to reload runserver.

Here are my project urls ...

from __future__ import unicode_literals, absolute_import, division

from django.conf import settings
from django.conf.urls import include
from django.conf.urls import url as re_path  # ready for 1.2
from django.contrib import admin
import django.contrib.auth.views as auth_views
import django.views as django_views

from billing import views as billing_views
from common.views import privacy


admin.autodiscover()
adminurls = admin.site.urls


urlpatterns = [

    re_path(r'^substance/', include('substance.urls')),

    re_path(r'', include('common.urls')),

    re_path(r'payment$',
        billing_views.payment_view,
        name='payment_view'
    ),

    re_path(r'success$',
        billing_views.success_view,
        name='success_view'
    ),


    re_path(r'^admin/password_reset/$',
        auth_views.password_reset,
        name='django.contrib.auth.views.admin_password_reset'),

    re_path(r'^admin/password_reset/done/$',
        auth_views.password_reset_done,
        name='django.contrib.auth.views.password_reset_done'),

re_path(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
        auth_views.password_reset_confirm,
name='django.contrib.auth.views.password_reset_confirm'),

    re_path(r'^reset/done/$',
        auth_views.password_reset_complete,
name='django.contrib.auth.views.password_reset_complete'),

    # Uncomment the admin/doc line below to enable admin documentation:
    re_path(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    re_path(r'^admin/', admin.site.urls),
]

if not settings.APACHE:
    urlpatterns.append(
        re_path(r'^media\/(?P<path>.*)$',
            django_views.static.serve,
            {'document_root': settings.MEDIA_ROOT}),
    )
    urlpatterns.append(
        re_path(r'^static\/(?P<path>.*)$',
            django_views.static.serve,
            {'document_root': settings.STATIC_ROOT}),
    )


I'm using ModelAdmin.change_view as follows ...


    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
        """
        # Substance_Ingredients is a m2m (to self being Substance) through table #         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,
                        )
                    )
                    # payment for only one sm2mi at a time
                    break
        return super(SubstanceAdmin, self).change_view(
            request, object_id, form_url, extra_context
        )


 I have tried myriad ways to reload the urls and persist context past the Stripe form but cannot do it apart from reloading the server.

I'm thinking that maybe the Admin has a mechanism to re-init itself but I can't find it. I'm out of ideas at the moment so if anyone can help I would be very appreciative.

I still haven't got Apache working with Python 3.5 mod_wsgi so I can't say anything there.

Thanks

Mike


On 13/02/2019 12:37 pm, Mike Dewhirst wrote:
Starting a new thread with the same subject because the old thread ...
https://groups.google.com/forum/#!topic/django-users/YLbWzmPfHwU
... is too long

Progress report.

No change in the symptoms with Python 3.6 and Django 1.11 and Django runserver.

I deployed to the staging server Ubuntu 16.04, Python 2.7, Django 1.11 and Apache2 to get an error generated by functools.py.

I have decided to bite the bullet and upgrade the staging server to Python 3.5 (I think) and then Django 2.x. It has to be done sometime. I'm moving my Trac instances off the staging server to a spare machine which can remain with Python 2.7 so everything else can go to Py3.x

A side plan is to make a Django 2.1 venv in development to see if that fixes anything.

More later.

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+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/d3222c4e-8cf2-0b25-21d7-e06c21c96675%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to