T
T
Tobim2021-04-22 14:47:42
Django
Tobim, 2021-04-22 14:47:42

How to pass one record from the database to all templates in Django?

I have a table entry that is created when a user registers and connects via OneToOne, with a subscription period. And I need that if the end date of the subrice is less than the real date, then redirect to the payment page. Can this be done via middleware?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maksam07, 2021-04-23
@maksam07

Sergey Gornostaev 's option is good, but in this case it will redirect to the extension form on absolutely all pages, incl. and on the main page, which may not be very good.
Or look for how to display the payment page not on all pages in a row (I did not study this issue)
Or, in really significant views, make a la Mixin and expand views through it, and in the mixin there will be a check for payment

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question