L
L
lopatin_ay2016-04-29 15:06:42
Django
lopatin_ay, 2016-04-29 15:06:42

How to transfer a user to another group after n-days?

Hello, tell me, please, is there any built-in mechanism that will automatically transfer the user to another group after a specified period of time? The task, in essence, is to implement different types of accounts (paid and free), and accordingly, after the expiration of the paid account, the user must be included in the group with the free ones.
I see two solutions in the forehead:
1. Run the script, for example, once a day, which will run through the accounts and see if the paid tariff has ended.
2. Update information directly upon user authorization on the site.
I don't like the first option at all, but you can still think about the second one. But perhaps there are more "correct" solutions?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
iegor, 2016-04-29
@lopatin_ay

The second version of the rules, you still check that it is authorized on each page, add a check for expiration and I don’t see a fundamental difference between these checks.

N
neatsoft, 2016-04-29
@neatsoft

The canonical way to do this in django is to add a django-admin command, and periodically run that command with cron:
Writing custom django-admin commands
CronHowto

D
Dmitry Astrikov, 2016-04-29
@astrikovd

Junga has no built-in solutions for solving such problems.
Why don't you like the first option? It is possible, through celery, for example, to create a periodic task and run through user accounts once a day.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question