i’m completely new to the django eco system, coming from flask.

what i want (and don’t know how to accomplish) is to put some restrictions to a set of urls: x/<uuid>/images x/<uuid>/imageupload and others should only work, if uuid can be found in the database and is still valid.

in flask i would probably use a blueprint, but this concept does not seem to exist in django, right?

what i like about the blueprint concept is, that it’s not possible to add a url under the x/<uuid> “namespace” and forgetting about the auth mechanism, as this is handled for all urls in the blueprint.

how would you handle this in django?

i’ve already learned about apps and a custom middleware, but this looks quite complicated on first sight? as the middleware always intercepts all requests, and i would have to check on my own if this is a request to x/<uuid>?

i’ve also looked at existing apps, and django-rq uses the statt_member_required decorator for each view. i will probably build something like that, but i would be more confident if i could apply this to the whole app, instead of having to decorate each function.

  • 7EP6vuI@feddit.orgOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    7 hours ago

    thanks for the fast answer!i think you understood it correctly. i want a public page, but certain things should only be accessed when you created a session/uuid beforehand.

    class based views sound interesting. will probably use this. thanks again.

    i have to think about, if i can tolerate the uuid being a query parameter of the url… somehow i like the uuid being part of the url better.

    never the less. thanks a lot!