Passing UUID from one view to another

I’m getting back to this issue as I didn’t succeed to resolve it so far. Let’s see if reformulating publicly what I’m trying to accomplish will help me to better grasp it :slight_smile:

What I’m trying to do

The website is an online survey containing several pages.

  • Accueil is the landing page. It contains two different elements:

    • A GDPR / privacy disclaimer, which the user needs to agree on to access the rest of the survey.

    • A area dedicated to enter the form according to two different modalities:

      • A user entering the survey for the first time will be asked to chose a personal id (a string of characters) before clicking on “yes” to approve the disclaimer. It will then lead to the Entree page, while clicking on “no” to refuse the privacy terms will lead to the Dommage page;

      • Right below it, there is an area dedicated to retrieve a previously and partially answered survey, in order for a returning user to finish its submission. The user is asked to enter the personal id chosen during his previous session. if an existing id is provided, the user is redirected to the corresponding survey page (either Adherent, Ancien or Sympathisant, according to his profile, chosen at the Entree page), and the survey is pre-filled with the data submitted during his previous session (retrieved from the database).

  • The Entree page contains a simple form for the user to chose a profile among three choices (Adherent, Ancien or Sympathisant). Once the profile is selected, the user clicks on the Enter button and is redirected to the corresponding survey page. If no profile is selected, an error is raised.

  • Adherent, Ancien and Sympathisant pages are similar. They’re the backbone of the survey and contain a lot of questions to be answered by the users. There are two buttons at the end of the page:

    • Envoyer is an input button for definitive submission, when the survey is supposed to be complete. If the form is valid, the user is redirected to the Conclusion page.

    • Enregistrer is a button that saves the current state of submission if the user wants to interrupt his submission for the moment and continue later. Then, when he’ll come back, he’ll just have to enter the personal id defined at the Accueil and will be redirected on this page, pre-filled with data from the database.

    (NB: Not sure if this button is the proper solution. The idea is to implement a process to save the data in the database while bypassing the possible validation errors due to an incomplete form).

Once the form is sent by clicking on Envoyer, the survey is considered to be finished. The corresponding personal id won’t allow the user to access its submitted data anymore.

  • The Conclusion page is a complentary group of a few questions, stored in another database, and intentionnaly not linked to the previous page (Adherent, Ancien and Sympathisant) to preserve anonymity. At the end of the page, the form is submitted by clicking on a button labeled Envoyer. Clicking on it redirects to the Merci page.

  • The Merci page is the last page of the survey, where a short “Thank you” message is displayed. No more action is required from the user.

  • Dommage is a page that contains a short message and displays a link sending back to the Accueil page, in case the user landed here by mistake.

What works and what doesn’t so far

All pages are ready and individually functioning, except for:

  1. Passing data from one page to another;
  2. Redirecting the user on the proper page from the Entree page;
  3. The system allowing the user to retrieve data and answer the survey in several sessions.

1. Passing data from one page to another

All data submitted on the Accueil page (basically a boolean field representing the user agreement) and the Adherent, Ancien or Sympathisant pages need to be stored in the same table in the database, and a user’s submission needs to be on the same line in this table, no matter the page on which the data is submitted. It’s not an issue for the three principal pages (a single user is concerned by one and only one of these pages), but I didn’t succeed yet at feeding the same line in the same table while changing pages from Accueil to Adherent, Ancien or Sympathisant (Not sure if i’m being explicit enough here!). I know there’s some sort of cookie management involved, but what I’ve tried so far doesn’t work: no cookie is created, hence no cookie is passed from one page to the other.

2. Redirecting from Entree to Adherent/Ancien/Sympathisant

Edit: this point is solved. I leave the code for reference (and maybe it’ll be useful to someone else!).

class CategorieChoice(models.Model):
    choix = models.CharField(
class Repondant(models.Model):
    categorie = models.ForeignKey(

urlpatterns = [    
    path('', views.AccueilView.as_view(), name='accueil'),
    path('entree/', views.EntreeView.as_view(), name='entree'),
    path('adherent/', views.adherent_view, name='adherent'),
    path('ancien/', views.ancien_view, name='ancien'),
    path('sympathisant/', views.sympathisant_view, name='sympathisant'),
    path('conclusion/', views.conclusion_view, name='conclusion'),
    path('merci/', views.MerciView.as_view(), name='merci'),
    path('dommage/', views.DommageView.as_view(), name='dommage'),

class EntreeView(FormView):
    model = Repondant
    form_class = EntreeForm
    template_name = 'form1/entree.html'
    success_url = '/adherent/'

    def form_valid(self, form):
        categorie_choice = form.cleaned_data['categorie']
        answer = categorie_choice.choix if categorie_choice else None
        if answer and 'sympathisant' in answer:
            return redirect('sympathisant')
        elif answer and 'ex-adherent' in answer:
            return redirect('ancien')
            return redirect('adherent')


<div name="categorie">
{{ form.categorie.errors }}
{{ form.categorie.label_tag }}
{{ form.categorie }}

3. Answering the survey in different sessions

I didn’t start to try and implement this yet. I figure that I’d better solve my previous issue before.

I think that’s good enough for now or I’ll end up writing a book about my little survey website! Solving the issue #2 would a good start (Edit: done!). Then I’d like to tackle the first issue, which this thread is about. Any advice are very welcome, thank you for reading this message so far!