#django

/

      • FancyCamel
        I just realized, it's not working because filter goes based on And, I need to switch it to OR to get it to work I guess!
      • Either that or I run the 3 queries I need and then add the querysets up together or something.
      • I just wanted to avoid that because I obviously want unique values
      • Koterpillar
        FancyCamel: you can build up Q() objects, and you can | querysets
      • FancyCamel
        Yeah that was going to be my original approach, Koterpillar, but I wasn't sure how to handle it because I can't go if potato: foo=Q() and then qs=Bar.objects.filter(foo) because foo may not be a thing.
      • dethos joined the channel
      • Koterpillar
        there are lots of ways to do all this, hard to say what's best without knowing what do you want
      • bee_keeper has quit
      • treyhunner has quit
      • FancyCamel
      • That was the dpaste I had before I started messing with the multiple if filters we discussed above.
      • But the grouped filter gives a succinct idea of what I'm wanting with the exception of or over and. :>
      • treyhunner joined the channel
      • sn_ joined the channel
      • x-warrio_ has quit
      • mrjazzcat has quit
      • SecondForm_Glenn joined the channel
      • bee_keeper joined the channel
      • sn_ has quit
      • onizo joined the channel
      • tpete
        FancyCamel: you want all of those ANDed together right?
      • FancyCamel
        OR'd
      • But I need to check that instance.whatever is not None before I include it in the filter though.
      • tpete
        Ok
      • When the filter as-is will not OR them together, Django doesnt do OR without Q objects
      • But you could pretty easily stop the error by doing:
      • total_qs = Patient.objects.filter(practice=instance.practice, id__in=instance.to, tags__in=instance.tags or [], practitioners__in=instance.practitioners or [])
      • If the values are None it will just pass a blank list instead
      • Koterpillar
        and Q(...) | Q(...)
      • tpete
        Right
      • eperzhand joined the channel
      • FancyCamel
        Yeah I thought of the Q() thing but I already said earlier why I was confused with it.
      • eperzhand has quit
      • tpete
        Sorry I didnt see what you said earlier
      • FancyCamel
        Oh I was referring to Koterpillar, no worries !
      • And I know it's nobody's job to figure out my work for me, was just saying. Just noticed my tone was a tad rude there.
      • But yeah I think I need Q's.
      • tpete
        Yes, you will have to use Qs to achieve OR statements
      • FancyCamel
        tpete: Think I can combine what you said with Q's like that?
      • tpete
        Yes
      • FancyCamel
        So Q(id__in=instance.to or [])|Q() etc.
      • Yeah? Sweet! I'll give that a go.
      • cnk has quit
      • ubuntu_aze has quit
      • tpete has quit
      • tpete joined the channel
      • rubencm joined the channel
      • onizo joined the channel
      • Threw distinct on that and I think I got it all working!
      • :)
      • sandwichheat joined the channel
      • chippie_ has quit
      • tpete
        great!
      • chippie joined the channel
      • Ruzzy joined the channel
      • chris0101 joined the channel
      • sandwichheat has quit
      • chris0101
        Can someone help me figure out why my simple registration w/ angular+django combo isn't working?
      • transit has left the channel
      • It seems I can register users through the API interface
      • but when I try the actual angular form, does not work
      • dardevelin joined the channel
      • tpete
        So you can make a POST manually with curl or some other API client but when you POST with angular it doesnt work?
      • adamsilver has quit
      • chris0101_ joined the channel
      • chris0101_
        connection to irc seemed to have dropped
      • so I can create a user through the API endpoint /api/user using the built-in form that DRF provides
      • but when I go to the browser, my webform isn't working
      • Koterpillar
        did you inspect the data sent to the server?
      • chris0101_
        well, it works because I get 'registration failed' in the console. but i don't understand if it's invalid data or what not
      • the_rat joined the channel
      • jaddison has quit
      • chris0101 has quit
      • Koterpillar
        inspect the data sent to the server
      • using the browser tools
      • jaddison joined the channel
      • roflmyeggo has quit
      • chris0101_
        i get a 403 forbidden error
      • in console
      • along with the output "registration failed"
      • Koterpillar
        perhaps you are not authenticating properly
      • but again
      • inspect the data *sent* to the server
      • READ10 has quit
      • compare it to the working data from the other form
      • nouser has quit
      • surfnturf_ has left the channel
      • chris0101_
        k, 1 sec
      • douedd_ joined the channel
      • ambar has quit
      • robattila256 has quit
      • holler_ has quit
      • the_rat has quit
      • douedd has quit
      • maryokhin has quit
      • notdaniel joined the channel
      • Lisa1157 has quit
      • Lisa1157 joined the channel
      • maryokhin joined the channel
      • @koterpillar: yea, doesn't send anything
      • i'm printing the request.data in my view
      • but nothing
      • maryokhin has quit
      • retailify joined the channel
      • Koterpillar
        chris0101_: no, go to the Network tab in your browser
      • and look at the requests made there
      • chris0101_
        ok
      • what am I suppose to see if there is a request?
      • brsc2909 joined the channel
      • i see a bunch of .js files loading
      • then when i fill in form and click register
      • pemby has quit
      • another request with /api/users/ status: 403
      • and that's it
      • Koterpillar
        so that's your failing request
      • DLSteve has quit
      • click on it to show the details
      • then do another request from whatever form that succeeds
      • chris0101_
        Oooo
      • Koterpillar
        and look at that one's details
      • chris0101_
        it's CSRF toekn
      • token
      • donspaulding joined the channel
      • Koterpillar
        here you go
      • chris0101_
        danka!
      • microdex joined the channel
      • retailify has quit
      • Koterpillar
        不客气
      • greydawg joined the channel
      • Omega037 has quit
      • domino14 joined the channel
      • CrowX- has quit
      • darkfader has quit
      • Snowmist has quit
      • robvdl has quit
      • ursan joined the channel
      • mihow has quit
      • mihow joined the channel
      • bee_keeper has quit
      • chris0101_
        Ok, so my registration works. Now, I'm testing the login part. I run into this error: RawPostDataException at * You cannot access body after reading from request's data stream
      • Is this happenning because I run another POST request right after
      • ?
      • tpete has quit
      • I use request.data in my registration
      • and request.body in my login
      • wkm has quit
      • AndrewBC_ joined the channel
      • dlam has quit
      • Koterpillar
        it tells you you can't
      • Omega037 joined the channel