carltongibson / neapolitan

Quick CRUD views for Django
https://noumenal.es/neapolitan/
MIT License
413 stars 30 forks source link

User decorador and User sessions #36

Closed leonardomporto closed 5 months ago

leonardomporto commented 5 months ago

Good morning Carl. Congratulations on the work, what a practical thing. Forgive me for the newbie question, but I would like to use Neapolitan with user sessions, so that I could restrict a reading page, for example, to only logged in users, and that the display would only represent the registrations made by that logged in user. I couldn't elaborate on this, I always have a list of errors. Can you give me some light? thank you very much.

carltongibson commented 5 months ago

For auth you can use @login_required as normal, for example.

For filtering, override get_queryset()...

class PageView(CRUDView):
    def get_queryset(self):
         return Page.objects.filter(user=self.request.user)

Or some such, similar.