Django per-object permissions -


I have users who are connected to the list of all real estate properties, which they are allowed to access multiple users Can be allowed to view the same site.

How can I set it up in the Django?

I have:

  class UserProfile (Models.Model): user = models.OneToOneField (user) last_session_time_online = models.IntegerField () total_time_online = models.IntegerField ( ) Def __unicode __ (self): return self   

and

  class site (models.model): site_name = models.CharField (max_length = 512) ... other stuff ... def __unicode __ (self): return self.user    

These are many things:

  class site (models.model): site_name = models.CharField (max_length = 512) permission_useor = model. ManyToManyField (user) ... sam = User.objects.get (username = ' Sam ') frodo = User.objects.get (user name =' froado ') hobbithole = Site.objects.get (site_name =' The Hobbit Hole ') hobbithole.allowed_users.add (Sam, Frodo) frodo.site_set.all ( ) # Return the "Hub Hit Whole" object, and somebody Other places to allow Frodo to visit are Somesite.allowed_users.exists (User = Frodo) # Returns the fact that Frodo is in the set of allowed users of the site.   

If you do not want to dislodge site , you can create an intermediate through "medium". This creates a layer of indirection, but allows you to add things through the table like the level of permission, if you want you "group defining the group" and "groups that modify the groups "You can use the auth module's groups feature on that table to define. / P>



Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -