N
N
nurzhannogerbek2018-05-20 16:46:46
Django
nurzhannogerbek, 2018-05-20 16:46:46

Referral system in Django?

Hello!
In my Django project, I'm trying to create a referral system. And to be more precise, you need to find out from the referral link the number of users who followed it and how many of these users further registered on the site.
I'm trying to tie the pinax-referrals library, but it's not entirely clear from the documentation how everything works. Could someone give an example?
I understand that you can create a referral like this:

referral = Referral.create(user=request.user, redirect_to=reverse("registration_register"))

but how to keep track of those who have registered on the site using this link? And how to create a referral link yourself?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vikholodov, 2018-05-22
@vikholodov

You need to make a field for the user with a unique code, which will then form a ref link and a model where referrals will be stored.
In the middleware, you write the logic for decrypting the get request of unauthorized users, look for the referral code there, and write it to the session. When registering, you try to get the code from the session, if there is one, we determine which user it belongs to and add this referral to him.
I would do that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question