#django

/

      • firefox has quit
      • wreed joined the channel
      • LiftLeft joined the channel
      • LiftLeft
        my internet messed up, in case anyone responded to me
      • micahscopes joined the channel
      • derk0pf has quit
      • astarrh has quit
      • schinckel
        LiftLeft: Nobody did - but this channel has logs anyway. https://botbot.me/freenode/django/
      • LiftLeft
        ok
      • Debnet joined the channel
      • Debnet has quit
      • Debnet joined the channel
      • schinckel
        LiftLeft: There is https://docs.djangoproject.com/en/2.1/ref/contr..., which happens on _any_ login/logout.
      • IIRC there's an attribute on an authenticated User that indicates which backend was used to authenticate them.
      • Leeds joined the channel
      • LiftLeft: I've not used the package you mentioned, but a quick read of the docs there seems to indicate that it doesn't generate signals: you'll need to handle it in django.
      • LiftLeft
        maybe I should I use a different module
      • I dunno
      • Haudegen has quit
      • greatgatsby has quit
      • darkhanb has quit
      • ruffni_ joined the channel
      • ruffni_ is now known as ruffni
      • derk0pf joined the channel
      • ticketbot has quit
      • dziadekludojadek
        Hi guys! What's wrong with this: https://dpaste.de/Sd8v
      • nedbat
        dziadekludojadek: why do you say there is something wrong with it?
      • dziadekludojadek
        when I put print inside if instruction it never goes inside method.request == post
      • nedbat
        dziadekludojadek: try "POST" instead of "post"
      • Leeds has quit
      • dziadekludojadek: or, print(request.method) to see
      • dziadekludojadek
        ok it's wired
      • it says GET when I'm loading and POST when I'm clicking submit
      • so it should go inside if instruction
      • nedbat
        dziadekludojadek: did you change the code to check for "POST" instead of "post"?
      • FunkyBob
        dziadekludojadek: you really shouldn't be using relative paths in your action... better to use {% url %}
      • and you should test "if request.method == 'POST': " ... case is important
      • jessamynsmith has quit
      • dziadekludojadek
        nedbat: it doesn't help
      • nedbat
        dziadekludojadek: pastebin the latest code.
      • KeyJoo has quit
      • FunkyBob
        monring, nedbat
      • nedbat
        FunkyBob: you too
      • eribol has quit
      • dziadekludojadek
        if request.method == 'POST': doesn't work but log said method is POST when sending form
      • Debnet has quit
      • derk0pf has quit
      • nedbat
        dziadekludojadek: pastebin the latest code and output
      • FunkyBob
        dziadekludojadek: are you certain (a) you're editing the right file? (b) the request is hitting the view function you think it is? and (c) than runserver reloaded correctly?
      • shruggedwm joined the channel
      • opticdelusion has quit
      • darkhanb joined the channel
      • opticdelusion joined the channel
      • dziadekludojadek
        Ok it wokrs!
      • Don't ask :)
      • zivl has quit
      • wreed has quit
      • BPL has quit
      • BPL joined the channel
      • gyia joined the channel
      • csotelo joined the channel
      • chihiro has quit
      • k_sze[work] joined the channel
      • lavalamp has quit
      • K-ballo has quit
      • dg_vrani has quit
      • massover has quit
      • cluelessperson joined the channel
      • dg_vrani joined the channel
      • aldnav has quit
      • aldnav joined the channel
      • micahscopes has quit
      • Dunedan_ joined the channel
      • amcorreia has quit
      • Dunedan has quit
      • darkhanb has quit
      • sydbarret joined the channel
      • sydbarret
        I already have the login/logout functionality. Now how can I limit access or make invisible some menu option according user login?
      • I have to add users and groups and roles in the admin page first?
      • FunkyBob
        do you mean django.contrib.admin /
      • ?
      • if so, it already has users and groups... and permissions... in the views and template context
      • sydbarret
        yeah so first i access the admin panel and create my users and assign them permissions?
      • and then I guess in the template and view I have to limit the access innit?
      • FunkyBob
        that's one way to do it, sure
      • yes
      • the auth docs cover how this is handled...
      • the auth context manager provides the user and a handy, easy-to-use proxy to permissions
      • sydbarret
      • o0 joined the channel
      • FunkyBob
        no
      • close
      • you're not trying to customise auth, just use it
      • y0ur1 has quit
      • sydbarret
        ok
      • o0 has left the channel
      • y0ur1 joined the channel
      • imadm joined the channel
      • schinckel
        There was a suggestion that if you think maybe you'll change something to do with the auth models at some point, then maybe consider doing a subclass right from the get-go; even if you don't make any model changes right now, it's far easier to add fields to a custom auth model than it is to migrate to one.
      • cgfuh has quit
      • jaddison
        I can confirm from experience what schinckel said.
      • derk0pf joined the channel
      • micahscopes joined the channel
      • imadm has quit
      • yeshurun joined the channel
      • shangxiao
        oh bugger the little language & version selectors at the bottom of the docs don't appear to be reachable via keyboard only
      • via tabbing or vimium
      • shangxiao grumbles about accessibility
      • dlam joined the channel
      • ubernostrum
        shangxiao: can you figure out if that's Sphinx, or something custom we did to it?
      • shangxiao
        ubernostrum: ah happy to take a look but would need to be later tonight or on the weekend :)
      • ubernostrum
        Sure. I may have some time in the next couple days to look into it, too.
      • Just curious where the problem is, in order to figure out how to fix it.
      • shangxiao
        👍
      • FunkyBob
        ubernostrum: do you know why django docs created the snipped:: directive?
      • I was working on a suggestion from someone at the pyconau sprints, and ran into that
      • derk0pf has quit
      • graphene joined the channel
      • jessamynsmith joined the channel
      • UncleVasya joined the channel
      • ubernostrum
        FunkyBob: I'm not sure. Commented in -dev recently that I think a few of the custom directives are obsolete.
      • micahscopes has quit
      • FunkyBob
        ubernostrum: ok, thanks
      • since ISTM code-block can do all it does, and more
      • might make it my train project
      • schinckel
        Anyone used a postgres_fdw table in their django project?
      • FunkyBob
        not yet
      • lolidunno has quit
      • UncleVasya has quit
      • lolidunno joined the channel
      • jaddison has quit
      • sydbarret
        ok i have created some users and assign them to a group. how can i limit the menu options based on their groups? is there something like this {% if user.is_authenticated and user.group=groupname %} ?
      • FunkyBob
        sydbarret: no need to test is_authenticated .... the AnonymousUser never has groups...
      • however, there is no template support for testing group membership
      • groups are intended mostly as a convenient way to manage bulk-assignment of permissions
      • sydbarret
        so i need to check based on the permission instead?
      • aldnav
        sydbarret, maybe you can create your own templatetag with a simple `user.groups.filter(name='groupname').exists()` check
      • sydbarret
        aldnav can I have also {% if user.is_authenticated and user.is_staff %} ?
      • FunkyBob
        sydbarret: those are your two options...
      • sydbarret: you can
      • sydbarret
        ok th anks
      • FunkyBob
        no need to keep checking user.is_authenticated if you ALSO check for something _only_ an authenticated user can have
      • [like is_staff, or groups, or perms]
      • stevanr- is now known as stevanr
      • schinckel
        You probably don't want to have a whole stack of tests against group membership: the django permissions stuff is pretty heavily optimised to prevent multiple db queries.
      • If you go around querying user.groups.filter(...).exists() you'll wind up with a stack of extra queries.
      • You could write something that is similar to django's permissions checks: where it loads up _all_ permissions for a user when the first permissions check is made, but for groups.
      • gregf_ has quit
      • We do something similar to this for features based on the "company" a user belongs to.