I've done a basic django app with a user which contains an organisation and premises foreign key inside the user model which has been inherited using the features of django 1.5.
I use the organisation id and premises id inside other models which I would like to present themselves providing they are the same.
I have tried to closely follow the 'two scoops of django approach' in that I use a CBV with django braces approach to show my models.
It is very important for me only to show the models in the views which use either the organisation id or premises id.
At the moment in my forms.py for my user it looks like
****************************************************
#forms.py
class HeatingUserForm ( forms.ModelForm):
premises = CustomModelChoiceField(queryset=Premises.objects.all())
organisation = CustomModelChoiceField(queryset=Organisation.objects.all())
class Meta:
model=Heating_User
fields = [ 'username', 'password', 'first_name', 'last_name', 'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 'organisation', 'premises' ]
***************************************************
Unless the user is a super user, I want the organisation to be restricted to the organisation that the logged in user is of the same . The premises should be restricted to those premises that have the same id as the logged in user.
Can anyone tell me how this is done?
:)
-- 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment