#django

/

      • Diegao joined the channel
      • tbaxter
        jordan87: you need to tell it what app/module to run tests for, as I recall
      • NomadJim has quit
      • rmwdeveloper
        tbaxter: is the initial dict typically empty?
      • tbaxter
        dunno.
      • I would add to it though
      • v0lksman
        is there a way to get the timezone of the end user? is it in the request object somewhere?
      • Diegao
        FunkyBob: hi
      • zz_saschpe is now known as saschpe
      • Genitrust joined the channel
      • tbaxter
        v0lksman: well, how do you expect to know the end user’s time zone?
      • Genitrus_ has quit
      • jordan87
        tbaxter: I'm able to run with Tools > run manage.py task > test no issues
      • dyl
        hrm
      • v0lksman
        tbaxter: maybe something sent by the browser based on the users locale?
      • dyl
        how to do this >_>
      • jordan87
        tbaxter: but when I try to set up tests under configuration, it doesn't work
      • natea joined the channel
      • tbaxter
        v0lksman: but other than geolocation, which is poorly supported and easy to turn off, how would the browser know locale? And which locale? Where they’re at most, or where they are now? For example, if I’m filling out an incident report form while I’m on the road, which is relevant, my home locale, the inciden’ts locale, or where I”m at now.
      • Timezones are hard.
      • v0lksman
        tbaxter: they are...but in my case I'm not that picky...the "current" location timezone is good enough for my puroposes.
      • I guess the answer is no. so I'll dig another route (they provide postal code, maybe there is a way to determin from that)
      • radez_g0n3 is now known as radez
      • josephleon joined the channel
      • ovnicraft joined the channel
      • benjf joined the channel
      • bwreilly has quit
      • surfnturf
        i'm using django-summernote in my project. works fine on my pc. but when i run on digital ocean, the editor doesn't show. I traced the problem to the html file created by summernote. It has a path "/static/django_summernote/summernote.min.js". How can I fix this?
      • bwreilly joined the channel
      • matthiaswahl has quit
      • v0lksman
      • matthiaswahl joined the channel
      • quake_guy has quit
      • anyone from newfoundland in here/
      • ?
      • nvm...this works
      • surfnturf
        nm. i added a symbolic link
      • but isn't this a bug?
      • v0lksman
        surfnturf: sounds like it
      • it's not django though so you'd have to open with the author
      • stickperson
        can i get some help with a model? i want to save an image from a url. here’s what i have: https://dpaste.de/az0D
      • jazzzu has quit
      • bkuberek joined the channel
      • Genitrust has quit
      • tbaxter
        surfnturf: perhaps you need to collectstatic on your production server?
      • josephleon joined the channel
      • dyl
        random nitpick
      • anyone else notice the "site" element (leftmost except djangocms logo)
      • is not aligned nicely?
      • surfnturf
        tbaxter: i tried that. didn't work
      • dyl
        It's the only thing not li>a>span, (it's just li>a)
      • idk why
      • surfnturf
        it's possible i have not configured nginx properly
      • dyl
        seems like such an obvious oversight :\
      • cnk joined the channel
      • surfnturf
        coulld be solved anther way
      • tbaxter
        “didn’t work” is a useless phrase
      • surfnturf
        tbaxter: lol. well i did collectstatic, reran the project and the editor still didn't show
      • tbaxter
        surfnturf: it seems likely you don’t have your production static assets serving correctly.
      • jordan87
        any idea on how to exclude django tests in pycharm. Or set a different interpreter for them?
      • surfnturf
        tbaxter: yeah I wouldn't be surprised. I'm newbie with nginx and gunicorn also
      • shredding joined the channel
      • tbaxter
        stickperson: you definitely need upload_to, and since you didn’t provide a traceback we have no idea what your error is
      • jfkdaddy
        Does Django ever cache POSTs?
      • Goopyo joined the channel
      • stickperson
        tbaxter: ah, duh. let me get a traceback. as for upload_to, is there a convention? i’m going to just input a bunch of beer.
      • tbaxter
        upload_to is where ever you want the uploaded media to go. See the filefield/imagefield docs
      • dyl
        > cache POSTs
      • why would you do that jfkdaddy ?
      • stickperson
        tbaxter: here’s an updated dpaste. https://dpaste.de/ALm3
      • jfkdaddy
        dyl: I just want to make sure it never will.
      • dyl
        POSTs are almost always stateful.
      • also, they're not defined as idempotent.
      • mFacenet has quit
      • (unlike GET, HEAD, PUT, DELETE)
      • roshanavand has quit
      • so there's no possibility to cache them.
      • And no, Django doesn't cache any requests by default at all.
      • idontneedanick has quit
      • I usually use Varnish + ESIs
      • roshanavand joined the channel
      • audioburn__away has quit
      • mmikeym
        I'm getting csrf failure on PATCH and PUT request with restframework...I feel like it should be obvious what Im doing wrong but I see the csrf token in the request body just fine...any ideas?
      • dyl
        Check your <form> tags.
      • jessamynsmith joined the channel
      • Your {% csrf_token %} might be rendering outside it.
      • {% csrf_token %}
      • mmikeym
        it's an ajax PUT/PATCH request and its rendering fine
      • dyl
        {{ my_form }}
      • surfnturf
        tbaxter: you were right, my nginx was serving out /static instead of /staticfiles
      • mmikeym
        first thing I checked
      • dyl
        doesn't work.
      • hmm
      • paste?
      • paste it, I'll brb
      • Also, pop open your web debugger and intercept the request
      • check that the csrf token is indeed valid.
      • and present.
      • tbaxter
        surfnturf: huh?
      • dyl
        mmikeym If you can't figure it out, you ought to consider the X-CSRFToken header.
      • mmikeym
      • dyl
        Might be significantly easier for AJAX stuff :)
      • mmikeym
        to be honest I just never really used PUT or PATCH much before
      • surfnturf
        tbaxter: you were right that i did not configure my production server properly.
      • so it wasn't a bug. pilot error
      • jfkdaddy
        Thanks, dyl.
      • erik` joined the channel
      • dyl
        mmikeym hmm
      • mmikeym
        dyl: works fine for POST requests....even from the same page
      • csrf is in the data from chromes console
      • dyl
        Oh you know what.
      • Kronuz joined the channel
      • cleme1mp has quit
      • Those views are probably GETTING the csrf token
      • it's just *not the right one*.
      • mmikeym
        ah that somewhat makes sense, but isn't the csrf token just set on a session basis since the user is logged in?
      • Kronuz has quit
      • dyl
        CSRF is a cookie
      • (session independent nonce)
      • Kronuz joined the channel
      • It's session independent because it's supposed to prevent exploiting a users active session.
      • "This cookie is set by CsrfViewMiddleware. It is meant to be permanent, but since there is no way to set a cookie that never expires, it is sent with every response that has called django.middleware.csrf.get_token()"
      • nmd, it's one token.
      • limbera joined the channel
      • jordan87
        So I'm trying to run all of my unit tests with my remote interpreter, but don't want my selenium tests to use that remote interpreter since it doesn't have any browsers (or GUI). is there an elegant way to handle this in pycharm/intellij (or even command line?)
      • dyl
        mmikeym I'd just do this:
      • veb has quit
      • josephleon has quit
      • $.ajaxSetup({ beforeSend: (xhr, settings) => { xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'); })
      • but you know, using ES5 syntax :p
      • but
      • make sure you check the domain in that beforesend!!!
      • Do not leak your token!!!
      • Should only go to your own domain.
      • wldcordeiro_
        Do permissions and groups have to be applied to User model instances?
      • dyl
        They're not "applied". Users and Groups have permission sets. They're M2M.
      • mmikeym
        dyl: thanks will give it a go
      • dyl
        Might solve it, if not look at your requests on both ends
      • Try the Werkzeug debugger to inspect state on crash
      • Django Debug Toolbar is also helpful for viewing context and ajax stuff
      • wldcordeiro_
        dyl: If you had another model like TeamUser that had an fk to your User model could you give that model permissions?
      • Or would it have to be the User model?
      • veb joined the channel
      • tbaxter
        I’d put it on the user.
      • josephleon joined the channel
      • radez is now known as radez_g0n3
      • mlavin has quit
      • jMyles joined the channel
      • al1o joined the channel
      • wldcordeiro_
        tbaxter: But what if your user can have multiple teams and different permissions in each team?