1đź‘Ť
âś…
Returning a redirect will “remove” the querystring from the url. The storefront view checks if that querystring is in the url, sets a flag in the session, then redirects. If that string isn’t there, and the session flag isn’t set, it redirects back to the other website.
def storefront(request):
if request.GET.get('enki') == '0011':
request.session['from_main_site'] = True
return redirect('storefront')
elif not request.session.get('from_main_site'):
return redirect('http://main-site.com/')
# at this point the user has come from the main site
# and doesn't have "enki" in the url
return render(request, 'storefront.html')
👤davidism
Source:stackexchange.com