#django

/

      • Fr4n joined the channel
      • drodger has quit
      • chicocvenancio has quit
      • ajd has quit
      • mrhanky has quit
      • erm has quit
      • sqe_ has quit
      • hdost has quit
      • swift1 has quit
      • iiie0 has quit
      • linovia has quit
      • someguy9881 has left the channel
      • kupi has quit
      • gutierri has quit
      • kingarmadillo has quit
      • ChanServ joined the channel
      • nichi[m] has quit
      • john2x has quit
      • Infra|Red has quit
      • rpkilby has quit
      • techalchemy joined the channel
      • IonutVan_ joined the channel
      • scrapcode joined the channel
      • scrapcode
        Hi guys. I'm trying to take a ShoppingCart with many ShoppingCartItems and have a form on the page that iterates through and shows all ShoppingCartItems, and allows you to update their quantities. Django documentation on Forms seems to show a lot of static examples, but what about this example when ShoppingCartItems is very dynamic?
      • I take that back. I do NOT have a model of "ShoppingCart," only ShoppingCartItem that has the user as their FK. Does it make better sense to create one even though it's to keep track of the items in the cart?
      • I feel like I'm missing something very simple here, as this use case can be used with almost any CRUD app with relationships that I've ever dreamed up
      • lavalamp has quit
      • nichi[m] joined the channel
      • schinckel
        scrapcode: You'd want a formset for this - multiple "forms" each representing an item of the same type (a ShoppingCartItem, probably), which in turn have a reference to the product and the count.
      • Then you might need some JS to make the in-page stuff dynamic.
      • gutierri joined the channel
      • amirpro joined the channel
      • scrapcode
        I don't know why I was thinking so hard into it. I know I've read the FormSet docs and ModelFormSet docs. But yeah, that's exactly what I'm looking for.
      • Thank you.
      • shangxiao joined the channel
      • andym joined the channel
      • amirpro has quit
      • andym has quit
      • amirpro joined the channel
      • bkeating joined the channel
      • bkeating has quit
      • kingarmadillo joined the channel
      • logically
        schinckel, with drf how can i authenticate someone coming from a different server?
      • schinckel
        I have no idea: never used DRF.
      • logically
        FunkyBob, ^ ?
      • jessamynsmith
        logically: read the drf docs on auth
      • you have multiple options
      • logically
        jessamynsmith, these seem to be limited to same-server implementations
      • Infra|Red joined the channel
      • john2x joined the channel
      • jessamynsmith
        logically: What gives you that impression? Requests with auth tokens, for example, can have any source.
      • mcspud
        logically - you need to use an auth token
      • That is why that technology exists
      • You'll also need to set up some sort of CORS policy
      • logically
        mcspud, how do i set up the cors policy
      • mcspud
        I use django-cors-headers for django, and implement it using the AWS CORS configuration on the servers
      • jessamynsmith
        I use the same
      • well, sorry, I use django-cors-headers and heroku
      • solomonix joined the channel
      • newdimension joined the channel
      • logically
        mcspud, jessamynsmith why do i have to create a token for every user as it says?
      • rpkilby joined the channel
      • swift1 joined the channel
      • ekmartin joined the channel
      • mcspud
        logically what do you mean? Every unique user needs a unique way to identify them
      • theWhisper_ joined the channel
      • EyePulp joined the channel
      • logically
        mcspud, but users wont be making the api requests
      • mcspud
        Who will then?
      • logically
        mcspud, oh
      • rpkilby has quit
      • mcspud
        logically - even if you only have a system-to-system type interaction, don't conflate the term "user" with "human". Anything - man or machine - that uses your system is a "USEr"
      • logically
        mcspud, right
      • bkeating joined the channel
      • mcspud, what do you mean you implement django-cors-headers usisng AWS CORS config?
      • mcspud
        Django doesn't allow CORS by default, so you need to modify it so it does. Also, AWS doesn't allow it by default either, so you also need to modify AWS to allow it
      • pionen joined the channel
      • bkeating has quit
      • pionen has quit
      • olto has quit
      • jessamynsmith
        logically: what will be making api requests?
      • Nizumzen joined the channel
      • bkeating joined the channel
      • bkeating has quit
      • logically
        jessamynsmith, my bot hosted on a digitalocean droplet
      • mcspud, but i wont be using aws
      • bradfordli123 has quit
      • jessamynsmith
        logically: so you won't even need cors
      • cors allows other web apps access
      • logically: my advice: enable token auth, make a user for your bot and give it a token, then try connecting from the bot
      • logically
        jessamynsmith, thanks
      • jessamynsmith, what's this about needing https? Is it really needed right now? what if i just want to test in production?
      • jessamynsmith
        it's better to use https but it should work without
      • logically
        jessamynsmith, ok cool B)
      • Diemuzi has quit
      • mcspud
        urgh
      • logically - install django_extensions and werkzeug
      • Then you can automatically generate a self-signed certificate and test on SSL that way
      • Its much better
      • jessamynsmith
        it is indeed
      • Nizumzen joined the channel
      • logically
        how is it better mcspud jessamynsmith ?
      • iiie0 joined the channel
      • mcspud
        Well when you break something, like I do with the CoC (thanks sasha` !), it will keep a handle of every frame in the stack and give you a web-browser based interactive debugger.
      • What that means in non-technical jargon is it you can directly interact with every part of your computation that caused on error
      • Ikoru has quit
      • It also means that your settings for things like SECURE_COOKIES AND SECURE_CSRF are much more consistent between development and production
      • newdimension joined the channel
      • bradfordli123 joined the channel
      • erm joined the channel
      • jezeniel joined the channel
      • amirpro has quit
      • amirpro joined the channel
      • Dunedan_ joined the channel
      • amirpro has quit
      • Dunedan has quit
      • mabus44 joined the channel
      • amirpro joined the channel
      • rpkilby joined the channel
      • ironfroggy joined the channel
      • rpkilby has quit
      • amirpro has quit
      • amirpro joined the channel
      • theWhisper_
        so i have a template i want to include in my django 2.0 but is not loading
      • {% include "foo/bar.html" %}
      • Nizumzen has quit
      • thiras has quit
      • amirpro has quit
      • amirpro joined the channel
      • mcspud
        try ./foo/bar.html
      • bradfordli123 has quit
      • theWhisper_
        nope not working
      • bradfordli123 joined the channel
      • cryocaustik joined the channel
      • amcorreia has quit
      • rpkilby joined the channel
      • kloudi-- joined the channel
      • amirpro has quit
      • amirpro joined the channel
      • rpkilby has quit
      • newdimension
        theWhisper_: (1) Where is the template folder in your file structure ? (2) Did you point django to your template folder in settings?
      • theWhisper_
        yes
      • but i have several template folders
      • newdimension
        What's your structure like? A template folder in each app?
      • kloudi- has quit
      • theWhisper_
        yes
      • correct
      • Ikoru joined the channel
      • newdimension
        Share the path of the tempplate file you're trying to load. Did you remember to namespace the folder?