class UserProfile(models.Model):
user = models.OneToOneField('auth.User', blank=True, null=True, related_name='userprofile')
owner = models.ForeignKey('auth.User', blank=True, null=True, related_name='subordinates')
fk_name = 'user'
try:
class ProfileInline(admin.StackedInline):
model = get_profile_model()
can_delete = False
template = "admin/profile_inline.html"
extra = 0
UserProfileAdmin.inlines += (ProfileInline,)
except ProfileNotConfigured:
pass
It might be useful if you explain what you're trying to do. For example, why do you need the foreign key relationship back to auth.User? I'm having trouble imagining a situation where you'd need both a OneToOne relationship and a ForeignKey relationship to the same model. Maybe you can accomplish your task a different way.
The additional foreignkey back to user is designated users who have permission to edit the profiles of only their subordinates. These owners are non staff
Hi Matt,
It might be useful if you explain what you're trying to do. For example, why do you need the foreign key relationship back to auth.User? I'm having trouble imagining a situation where you'd need both a OneToOne relationship and a ForeignKey relationship to the same model. Maybe you can accomplish your task a different way.
--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks for asking btw!
That sounds close but I'm not sure it's granular enough. For example an owner can only edit the profiles that has been assigned to him. E.g Owner A owns - and can only edit objects B, C and D. Owner E owns F G and H. And yes both those owners can have a superior over them and should be able to edit the grandchildren and the owners. All of which are not staff
With that it seems like creating a custom permissions would be trivial with with foreign Keys pointing to User for the different ownership relationships
Permissions can be set not only per type of object, but also per specific object instance. By using the has_add_permission(), has_change_permission() and has_delete_permission() methods provided by the ModelAdmin class, it is possible to customize permissions for different object instances of the same type.