#django

/

      • foxmask
        pendekar_langit: what do you do ? is there {% csrf_token %} in the template like it's said here https://docs.djangoproject.com/en/1.10/ref/csrf/ ?
      • jas02 has quit
      • jas02 joined the channel
      • pendekar_langit
        yes i add yet.
      • ubuntu_aze joined the channel
      • token is already on template, but on post cant get csrf_token
      • doubitchou joined the channel
      • i use a class on views, what because of this?
      • hamub joined the channel
      • tneva82 joined the channel
      • foxmask
        if you could show us the piece of code that display your form and save the data + the code of the template ; we try can see what is going worng
      • tneva82
        Is there some sort of caching in django DB? Was looking at what SQL queries my page generates up. First load 8 queries. I hit refresh and only 7. I have identified SQL that went missing and certainly result is still visible on the HTML page. Not problem obviously(good if it has!) but just wondering why SQL queries goes down sometimes despite otherwise identical requests have lesser amount of
      • SQL queries.
      • shangxiao has quit
      • Debnet joined the channel
      • vdboor has quit
      • tulioz has quit
      • marmalodak has quit
      • Itkovian has quit
      • rokups joined the channel
      • waterCreature has quit
      • pendekar_langit has quit
      • tulioz joined the channel
      • Itkovian joined the channel
      • Nizumzen has quit
      • Combined2857 has quit
      • johnnypyve has quit
      • ubuntu_aze has quit
      • dlam has quit
      • kuter joined the channel
      • toxinu has quit
      • toxinu joined the channel
      • airstrik3 has quit
      • toxinu has quit
      • jtiai
        tneva82: Django only caches results of querysets within queryset itself. There is no additional caching normally.
      • toxinu joined the channel
      • bochecha joined the channel
      • tneva82: There though exists session database backend with write-through caching. Which could explain what you see.
      • koniiiik
        tneva82: Maybe you're setting some class attributes yourself without realizing...
      • airstrike joined the channel
      • lacrymology joined the channel
      • doubitchou has quit
      • jas02_ joined the channel
      • Lenz joined the channel
      • johnnypyve joined the channel
      • jas02_ has quit
      • lacrymology has quit
      • davur has quit
      • Popzi joined the channel
      • lacrymology joined the channel
      • Dennis82 joined the channel
      • arifin4web has quit
      • PabloSandav joined the channel
      • andygmb has quit
      • encod3 joined the channel
      • ubuntu_aze joined the channel
      • zamro has quit
      • plfiorini joined the channel
      • renlo has quit
      • doismellburning
        db-backed sessions, so first load causes a Session INSERT?
      • (guessing here)
      • arifin4web joined the channel
      • StucKman joined the channel
      • FunkyBob
        would help to know the code, template, and queries
      • StucKman
        hi all. given the following model:
      • ubuntu_aze has quit
      • class CyrusUserModel(Model):
      • id = BigAutoField(db_column='AUT_ID', primary_key=True) # real_size=10
      • FunkyBob
        don't paste in here ,StucKman
      • StucKman
        FunkyBob: 3 lines
      • FunkyBob
        read the topic
      • StucKman
        ok, ok
      • FunkyBob
        don't paste in here, StucKman
      • lacrymology has quit
      • now.. what's your question?
      • FunkyBob wonders if the answer is "editable=False"
      • Lauxley joined the channel
      • nazarewk joined the channel
      • kezabelle joined the channel
      • liothe has quit
      • morning, kezabelle
      • kezabelle
        ahoy
      • kaizoku
        YAARRR
      • Bajax has quit
      • StucKman
        I was saying: given the model at the line 1 this: http://linkode.org/HOxwAD2s5oWf83NcaQhwT4 , how can I implement the sql query at line 10? I tried something at line 15, but I either get something that looks like None (line 19), or an exception (line 23). 'cyrus_crm-dev' is connected to the same mySQL db as the query
      • SimpleName has quit
      • FunkyBob: ok, ok, it was *more* than three lines :)
      • keimlink joined the channel
      • kuter has quit
      • FunkyBob
        CyrusUserModel.objects.filter(is_active=True)
      • oops... is_actif
      • you likely want to mark supervisor as null=True too
      • StucKman
        context: the table is a hierarchy of users, but it doesn't have a field marking supervisors. I can only findem as supervisors of somebody else
      • kezabelle
        .filter(is_actif=True).distinct().values_list('supervisor', flat=True) would get you the distinct supervisor columns, I think
      • ASUChander has quit
      • StucKman
        aha, and from there to the objects?
      • Ahuj joined the channel
      • FunkyBob
        oh, missed the first line of the query
      • arifin4web has quit
      • StucKman
        a query using id__in (sup_ids) ?
      • kezabelle
        MyModel.objects.filter(pk__in=my_values_list) ... so it'd be a subquery, essentially
      • FunkyBob
        aren't subqueries one of the (many) things mysql sucks at? :)
      • kezabelle
        (unless you forcibly evaluate the values_list into a list/tuple/set, then it'd use the values themselves)
      • FunkyBob: for a given value of suck at :)
      • StucKman
        FunkyBob: I can give a full list of things of which MySQL sucks at
      • kezabelle
        it'll get gnarly at you sometimes for complex ones, or multi-nested ones, IIRC
      • vdboor joined the channel
      • but pk in some other simple query isn't usually the pathological case, IMHE.
      • annnnd I think recent versions are somewhat better.
      • arifin4web joined the channel
      • StucKman
        ah, yes, then that, this one is not really recent
      • but that's 'an implementation problem' :-P
      • hylje
        subqueries can be a less bad option when dealing with mysql
      • kezabelle
        truth
      • FunkyBob
        StucKman: so.. you want all supervisors of all active users?
      • StucKman
        the most strange thing is the exception I get
      • FunkyBob: yes
      • ASUChander joined the channel
      • FunkyBob
        objects.filter(cyrususermodel_set__is_actif=True).distinct()
      • StucKman
        is there a way to log the queries that django builds and/or executes?
      • kezabelle
        using a pk subquery over a values list can be a good way to get expensive late rows, at least historically
      • StucKman
        late rows?
      • hylje
        StucKman: you can print the queryset's query attr, or you can flip DEBUG on and use django.db.connection.queries
      • StucKman
        historically==this is what happened in the past
      • ?
      • FunkyBob
        django logs all the queries, so if you configure that logger to be noisy enough
      • StucKman
        hylje: connection.queries just has the queries still running, not all executed. I already tried that
      • arifin4web has quit
      • hylje
        kezabelle: yeah i remember making a small query that joins into itself to get the rest of the values
      • FunkyBob
        StucKman: no, it has all executed this request
      • vlt
        StucKman: ddt can show queries and there’s a middleware listed on awsome-django that also does this.
      • Itkovian_ joined the channel
      • Bajax joined the channel
      • kezabelle
        hylje: yeah. also handy if you have concrete inheritance and want to page into a late offset without eating a bunch of joins ;)
      • (just pop the pks from the base table, and then let the joins happen in the outer query)
      • vlt
        FunkyBob: Why do you need the .distinct() in your ..._set__is_actif=True query?
      • kuter joined the channel
      • SimpleName joined the channel
      • StucKman reading about logging in djiango
      • kingarmadillo joined the channel
      • StucKman
        vlt: because that's what I need...
      • (the distinct)
      • FunkyBob
        it's standard python logging, StucKman
      • vlt: because multiple people may have the same supervisor ...
      • StucKman
        FunkyBob: yes, i see, thanks
      • kezabelle
        FunkyBob: lol. have fun ;)
      • FunkyBob
        kezabelle: pass
      • rather work out what I'm doing wrong with FieldStorage
      • FeersumEndjinn joined the channel