[Fixed]-Django – Change URL displayed in browser

1👍

If I am right :

Write a view for localhost:8000/myapp/ In this view generate your token and then redirect it to new url from the view .

def mytoken(request):
    token = '0-wedfbdhfgm'

    return redirect(localhost:8000/myapp/token='+token)

0👍

This is a two-step process. You need to create

  • a view with a matching url to retrieve your individual token
  • a view with a matching named url to provide the result to the user

urls.py

...

url(r'^myapp/(?P<token>\w+)/$', views.your_user_result_view, name='your-user-result-view'),
url(r'^myapp/$', views.your_token_appender_view, name='your-token-appender-view'),

...

views.py

...

def your_user_result_view(request):
    ...

def your_token_appender_view(request):
    token = ...

    redirect(reverse('your-user-result-view',kwargs={'token':token}))

...

Leave a comment