#django

/

      • Keda87 has quit
      • nozavroni
        but it doesn't seem to be working
      • critias
        being nothing, I hope?
      • jtiai
        critias: Also Python (speclially 3), django and mysql doesn't always getalong.
      • doismellburning
        jtiai: oh really?
      • SDCDev has quit
      • coot joined the channel
      • critias
        after mysql, do i have a long learning curve?
      • doismellburning
        critias: not ime
      • critias
        I'll look into it. thnx
      • zerick has quit
      • SDCDev joined the channel
      • d1rkp1tt
        hmmm, accessing model data passed to my template seems to hit the DB again?
      • is that normal?
      • doismellburning
        critias: (particularly not from a Django perspective; I've had Django projects using MySQL that I never realised were)
      • d1rkp1tt: yes
      • d1rkp1tt: are you trying to optimise for number of db accesses, and if so why?
      • kuter joined the channel
      • d1rkp1tt
        doismellburning, Confused by this, as I already query in my view.
      • doismellburning
        d1rkp1tt: I doubt you do; I suspect you just build up a queryset, and querysets are lazy
      • d1rkp1tt
        doismellburning, What started me down this path was that I was doing a for loop through records and hitting the db again with the django-voting app results... so I thought... I already have that data... why hit it again
      • THEN
      • jargon has quit
      • doismellburning
        d1rkp1tt: code please
      • d1rkp1tt
        view, or template
      • doismellburning
        d1rkp1tt: shrug
      • SDCDev has quit
      • d1rkp1tt
        so queryset is not run in the template
      • doismellburning
        d1rkp1tt: "I was doing a for loop through records and hitting the db again with the django-voting app results" - wherever you were doing that
      • d1rkp1tt
        view side I mean
      • doismellburning
        d1rkp1tt: querysets are lazy
      • jargon joined the channel
      • Lauxley joined the channel
      • d1rkp1tt
        so they are run when the template is crafted?
      • I use a RAW query though!
      • doismellburning
        d1rkp1tt: querysets are lazy; queries will run when they are evaluated (i.e. "when needed", to an approximation)
      • and a "RAQ query" is?
      • *W
      • d1rkp1tt
        and I thought that I mapped results to my model from a RAW query using 'AS' to define the correct fieldname
      • doismellburning
        oh, you just mean using `raw`?
      • d1rkp1tt
        yeah
      • SDCDev joined the channel
      • swi joined the channel
      • ooooh, I think its probably being clever
      • doismellburning
        which returns a queryset
      • d1rkp1tt
        I dont pull back a few fields
      • doismellburning
        and for the third and final time: querysets are lazy
      • d1rkp1tt
        it must go and get the ones I am not pulling back
      • I dont know what lazy is
      • will read up
      • doismellburning
        (actually, I don't know that about RQS, but since you're experiencing that behaviour, I see no reason to assume otherwise yet)
      • d1rkp1tt
        Thanks
      • codeme has quit
      • pxu joined the channel
      • seems like I should try and optimize the hits
      • doismellburning
        d1rkp1tt: why?
      • kushal joined the channel
      • d1rkp1tt
        small VPS
      • ...
      • doismellburning
        d1rkp1tt: noting that premature optimisation is approximately a terrible idea
      • d1rkp1tt: have you measured? is this your bottleneck? (I suspect the answer to the first is no)
      • SDCDev has quit
      • d1rkp1tt
        Theres different degrees of pre optimisation
      • pxu
        hey guys. What is the best practice of serving static assets when I have multiple django servers behind a load balancer?
      • d1rkp1tt
        sometimes doing zero is madness
      • doismellburning
        (if it is, and the second is "yes", I'm slightly surprised)
      • pxu: approximately it's irrelevant, the thing to do is "use something else"
      • apollo13 would like to burn TemplateResponses :(
      • pxu: i.e. Django should not be serving your static assets, $somethingelse should be, which will depend on your setup
      • pxu: (I use S3 a lot, and also nginx)
      • elyezer joined the channel
      • pxu
        currently the load balancer (nginx) is serving the static assets
      • doismellburning
        pxu: sounds sensible
      • SDCDev joined the channel
      • bender314 joined the channel
      • void has quit
      • voidus joined the channel
      • voidus is now known as void
      • raulcd joined the channel
      • marxxin has quit
      • SDCDev has quit
      • cvdk joined the channel
      • elyezer has quit
      • marxxin joined the channel
      • d1rkp1tt
        so I managed to cut out about 30 queries per page request...
      • davejavu has quit
      • jax joined the channel
      • josephleon joined the channel
      • user00123456 joined the channel
      • For each record in my list, it was re-querying for fields that werent accounted for in my query
      • elnappo_off has quit
      • elnappo_off joined the channel
      • elnappo_off is now known as elnappo
      • omarek
        I can't find this in documentation, how do I print the current VALUE of a form field ? I'm getting "CharField instance at blahblahblah"
      • tak30 joined the channel
      • This is for debug purposes. A form is failing validation because of a hidden field.
      • rabbi1 joined the channel
      • Squared has quit
      • rabbi1
        I have moved my django project from mac to windows, Now i get 'Not a Directory error at / ' here is my settings.py. https://gist.github.com/anonymous/0b6fb8425cd22.... How can i solve it. ? also, trying to 'collectstatic' path is c:/static instead of c:/proman(project_name)/static ...
      • SDCDev joined the channel
      • omarek
        I tried getting it from cleaned_data, but there's a KeyError.
      • doismellburning
        rabbi1: at a guess you moved the virtualenv too?
      • rabbi1: and/or you hardcoded some paths in settings
      • FunkyBob
        STATIC_ROOT = '/static/'
      • kezabelle
        form['fieldname'] will get you the boundfield
      • FunkyBob
        that is so very wrong, rabbi1
      • rabbi1
        hardcoded the paths
      • aribao has quit
      • FunkyBob
        no, storing static at /
      • doismellburning
        rabbi1: also what FunkyBob said
      • aviraldg joined the channel
      • rabbi1
        this is my path for static /project_name/static/css ...
      • aviraldg has quit
      • doismellburning
        rabbi1: then it sounds like you want `os.path.join(BASE_DIR, '..', 'static')`
      • rabbi1: er, possibly without the ..; ymmv
      • rabbi1
        yeap, BASE_DIR is set and also os.path.join
      • FunkyBob
        the whole concept of moving _to_ windows is scary, imho
      • rabbi1
        line 112
      • doismellburning
        FunkyBob: well indeed
      • rabbi1: I think you misunderstand me; I was talking about the value of `STATIC_ROOT` (though now I reread what you've said, I think you're confusing STATIC_ROOT with STATICFILES_DIRS)
      • searchingfortao joined the channel
      • rabbi1
        i tried to set path here like STATIC_PATH = os.path.join(BASE_DIR, 'proman/static')
      • but din't work
      • omarek
        kezabelle: Thank you.
      • Forgetful_Lion joined the channel
      • doismellburning
        rabbi1: multiple things not to do there
      • rabbi1: os.path.join takes arbitraryish numbers of arguments; don't `proman/static`, those are two arguments; doing it like that defeats much of the point
      • rabbi1: don't hardcode your project name in the path like that
      • rabbi1
        STATIC_URL = '/static/'
      • STATIC_ROOT = '/'
      • STATIC_PATH = os.path.join(BASE_DIR, 'static')
      • STATICFILES_DIRS = ( STATIC_PATH, )
      • doismellburning
        rabbi1: don't paste code into here
      • rabbi1
        this is what i got now ^^
      • doismellburning
        rabbi1: don't have / as STATIC_ROOT
      • elnappo has quit
      • greg_f joined the channel
      • rabbi1
        In that case why BASE_DIR = os.path.dirname(os.path.dirname(__file__)) is directing to right project path ?
      • BASE_DIR should be atleast c:/project_name/
      • fero has quit
      • os.path is ok, but .dirname is what it is missing to get
      • elnappo joined the channel
      • doismellburning
        rabbi1: I'm afraid I don't understand your question
      • rabbi1
        doismellburning: to start: moving project from mac to windows i get 'Not a Directory error at / ' this error
      • d1rkp1tt has quit
      • doismellburning
        rabbi1: yes, this is probably to do with your multiple hardcoded directory separators
      • rabbi1: as above, stop doing that, use os.path.join more
      • jtiai
        doismellburning: I think that forward slash is guaranteed to work across platforms in paths...
      • rabbi1
        doismellburning: that case, i have to make change only at one place STATIC_URL = 'os.path' and change STATIC_ROOT = ''