Hello!
Yes, I used what* *sacrac show:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model
In my "Item" class I added "owner" charfield and in admin.py did this:
class ItemAdmin(admin.ModelAdmin):
...
# save user information in owner field after post "Item"
def save_model(self, request, obj, form, change):
obj.owner = request.user
obj.save()
# show item's who owner is user or for super user show all items
def queryset(self, request):
qs = super(ItemAdmin, self).queryset(request)
if request.user.is_superuser:
return qs
return qs.filter(owner=request.user)
Thanks for help! :)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/rNy8CZ4LRZkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.