Hi! I would like to render views based on the user. I have some differents type of users on my app and I would like to create a class like this one for the view:
class MyView(MyCustomView) # MyCustomView subclass View
def __init__(self, *args, **kwargs):
# common code for all persons
def personA(self):
# code for personA
def personB(self):
# code for personA
# ....
def personN(self):
# code for personA
def anyPerson(self)
# For any user non listed above
Then if the MyView is run, the function based on the user is automatically fired.
My doubts (at the moment):
1) Do you think is the a good way to face the problem?
2) I have methods in the models to know what person is logged. How I can automatically load the right function in the class based on the user?
Thank you
Karim N. Gorjux
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACeuRGX4Oy%3D4qs6QLLkugsqw1Tb1niaEwCqAaa3-ZncsE8-iig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment