Re: models queryset and permissions
Hi Danfi, thanks for your reply. This help me! On 5 Gen, 10:06, Danfiwrote: > Esame: > name = models.Foreignkey(User) > ... > > Then queryset=Esame.name.get_rows_with_permission(Ecg(),'add') > > On 1月4日, 下午8时02分, MarcoS wrote: > > > Hi people, probably I'm making a mountain out of a molehill but I > > can't figure > > how to solve this problem; > > > I've a form with a ModelMultipleChoiceField. The queryset will > > contains all models for > > which the user has a particular permission > > (django.contrib.auth.models.Permission) (can_add). > > > This is the models.py > > > class Esame(models.Model): > > name = models.CharField(max_length=80) > > name_model_referenced = models.CharField(max_length=80) > > > class Ecg(models.Model): > > esame = models.ForeignKey(Esame) > > patient = models.ForeignKey(Patient, null=True) > > > class Ecg_da_sforzo(models.Model): > > esame = models.ForeignKey(Esame) > > patient = models.ForeignKey(Patient, null=True) > > > Supposing we have a user Tom which can add an Ecg but not an > > Ecg_da_sforzo, > > can I use the Django Queryset API to obtaing the correct queryset? > > If yes, how can I construct it? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: models queryset and permissions
Esame: name = models.Foreignkey(User) ... Then queryset=Esame.name.get_rows_with_permission(Ecg(),'add') On 1月4日, 下午8时02分, MarcoSwrote: > Hi people, probably I'm making a mountain out of a molehill but I > can't figure > how to solve this problem; > > I've a form with a ModelMultipleChoiceField. The queryset will > contains all models for > which the user has a particular permission > (django.contrib.auth.models.Permission) (can_add). > > This is the models.py > > class Esame(models.Model): > name = models.CharField(max_length=80) > name_model_referenced = models.CharField(max_length=80) > > class Ecg(models.Model): > esame = models.ForeignKey(Esame) > patient = models.ForeignKey(Patient, null=True) > > class Ecg_da_sforzo(models.Model): > esame = models.ForeignKey(Esame) > patient = models.ForeignKey(Patient, null=True) > > Supposing we have a user Tom which can add an Ecg but not an > Ecg_da_sforzo, > can I use the Django Queryset API to obtaing the correct queryset? > If yes, how can I construct it? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: models queryset and permissions
The ModelMultipleChoicheField will return Esame objects -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
models queryset and permissions
Hi people, probably I'm making a mountain out of a molehill but I can't figure how to solve this problem; I've a form with a ModelMultipleChoiceField. The queryset will contains all models for which the user has a particular permission (django.contrib.auth.models.Permission) (can_add). This is the models.py class Esame(models.Model): name = models.CharField(max_length=80) name_model_referenced = models.CharField(max_length=80) class Ecg(models.Model): esame = models.ForeignKey(Esame) patient = models.ForeignKey(Patient, null=True) class Ecg_da_sforzo(models.Model): esame = models.ForeignKey(Esame) patient = models.ForeignKey(Patient, null=True) Supposing we have a user Tom which can add an Ecg but not an Ecg_da_sforzo, can I use the Django Queryset API to obtaing the correct queryset? If yes, how can I construct it? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.