#django

/

      • Matthieu`
        I don't know if I can make something like this ? http://0bin.net/paste/2ORRYhNDJKNlE2dy#Pdl8f0oB...
      • (sorry for my bad english)
      • benbacardi
        Matthieu`: sure you can.
      • Matthieu`
        Yeah !
      • Thank you !
      • benbacardi
        Try it and see...!
      • Poppabear
        anyone can help me get django channels working properly on my staging server ?
      • benbacardi
        Matthieu`: actually, perhaps use 'self' on the FK instead of 'Folder'
      • Matthieu`
        ok
      • benbacardi
        Matthieu`: from the docs:
      • Matthieu`
        thank you for your help
      • benbacardi
        To create a recursive relationship – an object that has a many-to-one relationship with itself – use models.ForeignKey('self', on_delete=models.CASCADE).
      • murk has quit
      • Utal has quit
      • flobin
        benbacardi heh, you're right, I don't know why I was complicating things... I had installed a Django app called django-betterforms because I thought I needed it
      • Matthieu`
        root_folder_id = models.ForeignKey('self', related_name='sub_folder_ids', related_query_name='sub_folder_ids', on_delete=models.CASCADE)
      • tbaxter has quit
      • oups
      • sorry
      • bad tab
      • Synthead joined the channel
      • colinbits joined the channel
      • mingrammer joined the channel
      • archangelic joined the channel
      • flobin
        so in my forms.py I have specified a widget to be CheckboxSelectMultiple() for two fields, but they come out as <select> with <options>, one with multiple and one without
      • this is my forms.py https://gist.github.com/Flobin/56bdaf52094dd7b9... and above it is the output
      • Synthead has quit
      • how does that happen?
      • mingrammer has quit
      • bx2 joined the channel
      • ChrisWarrick
        Poppabear: sudo systemctl enable uwsgi nginx
      • jcda joined the channel
      • lumidify has quit
      • z0ran has quit
      • NomadJim joined the channel
      • Poppabear
        thanks ChrisWarrick
      • colinbits joined the channel
      • olrrai joined the channel
      • bx2 has quit
      • jcda has quit
      • rpkilby joined the channel
      • roflmyeggo has quit
      • olrrai
        Hi, is possible store users in a different table (not on the default auth_user from django-contrib) using djangorestframework ?
      • mattmcc
        olrrai: You can define a custom user model.
      • kevr joined the channel
      • Synthead joined the channel
      • olrrai
        mattmcc: ok, but how to link with django rest authentication?
      • Darkhunter has quit
      • ticketbot has quit
      • mattmcc: I need the default django-auth user class, but also need another one for django rest
      • mattmcc
        Why?
      • jessamynsmith joined the channel
      • olrrai
        mattmcc: I gonna try to explain the project
      • murk joined the channel
      • DLSteve_ joined the channel
      • sanketdg has quit
      • jessamynsmith has quit
      • mattmcc: main users are IT supporters, they support their customers (domains). The domains have OS (operating systems) which need consume one REST API with users and passwords (by token)
      • jamesbvaughan joined the channel
      • garrypolley has quit
      • flobin
        does anyone have any experience in a form not rendering the correct widgets?
      • feathered_person joined the channel
      • garrypolley joined the channel
      • glookoza
        Hi, I have the following issue... I have a CharField in one of my models... in the view, I get a list of that data from all the complete set of that model... now, when I pass it to the html, I print it like in... {{ data }}... and pass it also to some jQuery component... However, when I see the resulting html, I am able to see that the one I print is ['1', '2', ... ] but the one in the jquery
      • is [&#39;1&#39; ... ] I have the same 'tag' in the html source file {{ data }} but why is it pasting it differently inside the <script> tag ?
      • feathered_person has quit
      • mattmcc
        olrrai: Okay, but what calls for two different user models?
      • feathered_person joined the channel
      • flobin
        glookoza I have no experience with that but maybe this helps https://www.reddit.com/r/django/comments/4usz97...
      • roflmyeggo joined the channel
      • olrrai
        mattmcc: sorry, I m newbie with django, what are u meaning with "calls" ?
      • mattmcc
        olrrai: Why do you feel you need two separate user models?
      • rpkilby has quit
      • rodorgas has quit
      • Quitta joined the channel
      • glookoza
        thank you flobin
      • olrrai
        mattmcc: oh, because supportes are administrators of OSs, I dont know if admins and OSs in the same table is a good practice
      • bx2 joined the channel
      • Quitta has quit
      • garrypolley has quit
      • garrypolley joined the channel
      • rpkilby joined the channel
      • mehola joined the channel
      • garrypolley has quit
      • flobin
        if I have a urlpattern like this: url(r'^(?P<pk>\d+)/?$', ArticleView.as_view(), name='article'),
      • what is the correct way to reverse_lazy? I have url(r'^(?P<pk>\d+)/?$', ArticleView.as_view(), name='article'),
      • but that gives me: 'ArticleSubmitView' object has no attribute 'id'
      • rodorgas joined the channel
      • rodorgas has quit
      • feathered_person has quit
      • jonez joined the channel
      • jonez
        greetings
      • kilae joined the channel
      • benbacardi
        flobin: why do you need reverse_lazy over reverse?
      • Also, show us your reverse call if you want us to help with the error ;)
      • flobin
        didn't I show it?
      • in any case I know I got that from somewhere, I'll try to find it
      • benbacardi
        Oh I see, yes that makes sense to use lazy there
      • But you haven't pasted your code :) only the URL definition
      • tga
        cool, when I try to edit this one template in PyCharm chunks of it just disappear
      • olrrai
        mattmcc: Are u meaning that all users (from different models) django is going to store in the same table and me can use as separate objects?
      • lanshark joined the channel
      • tga wonders what that means
      • (sorry for my english)
      • flobin
        benbacardi sorry, here's the full code https://gist.github.com/Flobin/56bdaf52094dd7b9... (this is views.py, the rest, including traceback is above it)
      • tga
        no worries, I literally didn't get what you were asking
      • cyphase joined the channel
      • I also missed the beginning
      • djmoch joined the channel
      • ubuntu_aze joined the channel
      • garrypolley joined the channel
      • benbacardi
        flobin: looks like you need obj.id not self.id. Plus, use reverse, not reverse_lazy.
      • olrrai
        tga: It is the proyect: main users are IT supporters, they support their customers (domains). The domains have OS (operating systems) which need consume one REST API with users and passwords (by token)
      • flobin
        benbacardi when you say it like that, it seems obvious...
      • benbacardi
        reverse_lazy is only for when the URLs haven't loaded - I.e code run when the views are imported. But code _inside_ a view is always run after URLs are loaded
      • flobin
        ah, right
      • thanks
      • looks like we're getting somewhere though, now I get a different error, let me copy/paste it
      • benbacardi
        flobin: well... obj is a new Article instance, self is the instance of the ArticleSubmitView class, not an article
      • flobin
        ah yeah that makes sense
      • tga
        olrrai: one idea would be to keep api tokens separate from django users
      • Qritz has quit
      • devshady joined the channel
      • olrrai
        tga: Ok, but how can I do that?
      • flobin
      • tga
        olrrai: another idea would be exactly opposite, creating django users for api tokens
      • ironfroggy joined the channel
      • mingrammer joined the channel
      • garrypolley has quit
      • olrrai: as far as I know, the DRF token authentication only works with django users, so if you want to use that out of the box, you have to create users for all api clients
      • benbacardi
        flobin: args needs a list: args=[obj.pk]. But you probably actually want kwargs={'pk': obj.id} as its a named pattern in the url
      • flobin
        ah yeah I was wondering how to do that
      • that also makes sense
      • olrrai
        tga: oh
      • benbacardi
        It's all in the docs ;)
      • (Not that I'm not happy to help.)
      • tga
        olrrai: if you want to authenticate api clients with tokens without having anything to do with django authentication, you'll have to do it manually
      • you look at headers, get the token, look in the database, see whether it's ok, then reply or not
      • devshady has quit
      • flobin
        heh, well, I'm a beginner
      • olrrai
        tga: tokens work without users/pass ?
      • tga
        olrrai: not by default, you can reimplement token authentication from scratch if you wnat
      • the drf token authentication works with django users
      • mingrammer has quit
      • olrrai
        tga: can u give me links to start with your 2 ideas?
      • tga
        olrrai: probably the easiest thing for you would be to create django users for everybody
      • benturner has quit
      • olrrai: this way you can use token authentication out of the box