Rendering of templates in project with users

Hello everybody, I am new to django and web and the question is:
We have project with users that can be authorised and not authorised.
We create views for some, for example, GET requests and html response for them should be different depending on if user is authorised and not.
How should we solve this problem? Should we create different templates for authorised users and not authorised, or, for example, we just can pass in context of django.shortcuts.render function is_authorised value and then people, who writes template will do all work with differentiation of page depending on if user is authorised and not?
Is it good practice? Are here some common pratices?

You’re not going to find any one answer to your question because the answers are all going to be highly dependent upon the specific situation. This is not a one-size-fits-all question.

For example, when you say the response is going to be different depending upon whether or not they’re authorized, that can actually mean a number of different things.

  • Same template but different data (may be different rows from the same model)
  • Same template but more or less data (fields added or removed)
  • Different templates because the data being shown is completely different
    (Data from different models)

Each one of these situations is going to affect the choices you make.

Ken

1 Like