#django

/

      • fikka joined the channel
      • imack joined the channel
      • mattmcc
        Were select_related and prefetch_related not useful?
      • But yeah, being able to populate related models with raw() is a longtime wishlist item of mine.
      • fikka has quit
      • drodger has quit
      • mojtaba joined the channel
      • fikka joined the channel
      • schinckel
        ihor: You can use a View as the source of models, and then do select_related etc.
      • geetar joined the channel
      • mattmcc
        Right, but select_related will still join to the other model.
      • schinckel
        Well, you get a new model, which you can still access using related_nam
      • skali joined the channel
      • drodger joined the channel
      • mattmcc
        That's the piece I'd love to have, is something like select_related(trust_me_i_already_queried_those_fields=True)
      • ihor
        mattmcc: it is usefull, but join all records in related table and then apply filters on joined table.
      • mattmcc: +1
      • schinckel
        ihor: You might want Prefetch objects; sometimes that can do what you might need there.
      • mattmcc
        ihor: You can filter prefetch_related with a queryset of the related model to get around that.
      • schinckel
        No guarantees though ;)
      • ihor
        No, prefetch_related is not option
      • schinckel: I can not get what about you talk. Can you please post link on example or documentation?
      • fikka has quit
      • schinckel
      • skali has quit
      • ihor
        > You can use a View as the source of models, and then do select_related etc.
      • this
      • shangxia1 joined the channel
      • schinckel
        Oh, right, sorry.
      • This pattern works if you have an SQL View that does the query you want (and then you may still filter it, as you see fit).
      • FunkyBot joined the channel
      • fikka joined the channel
      • ihor
        schinckel: nice! It is looks nice
      • schinckel
        You can even use that sort of stuff with recursive CTEs.
      • deramius has quit
      • geetar joined the channel
      • ihor
        I need to check how indexes works with views and how to update views for big table
      • schinckel
        It uses the indexes on the original tables: views are calculated live.
      • mattmcc
        Views are essentially stored queries. Materialized views, though, can have their own.
      • schinckel
        Yeah, that.
      • mattmcc
        Which has pros & cons. Updates to large materialized views may be more expensive than if you'd used a plain view and updated its constituent tables for example.
      • We use a materialized view for products so that (among other reasons) all the FTS related indexing that pulls from a dozen tables happens in one place.
      • geetar joined the channel
      • fikka has quit
      • ihor
        > building materialized view with FTS
      • Does it have any cons over separated FTS solution?
      • sorry advantages
      • mattmcc
        It just depends on your needs. Our FTS needs are met quite adequately by PG's own FTS support, so we use that rather than maintain, say, an Elasticsearch stack.
      • rpkilby joined the channel
      • ihor has quit
      • geetar joined the channel
      • mightyspaj joined the channel
      • fikka joined the channel
      • rpkilby has quit
      • fikka has quit
      • limbera joined the channel
      • limbera
        my application has organizations and members, and i'm writing an API in which the organization payload contains a list of it's members, and the members endpoint contains a reference to the organization (that links a User with the Organization)
      • i'm wondering if that's bad design, it has some code smell because the serializers i am using are referencing each other
      • epopt has quit
      • timkofu joined the channel
      • the MemberSerializer is in the same file as the OrganizationSerializer and they both need to reference each other
      • i guess my question is, should i be remodelling my payloads and the way the front end consumes this data to not do this? or is there something i'm missing
      • fikka joined the channel
      • mcspud
        limbera you're alive
      • This is a great thing
      • limbera
        hey mate
      • hah yes i am
      • mcspud
        limbera - its not bad design, especially if you are implementing a strict HATEOAS pattern
      • But typically you'll have "reduced" serialisers for the nested resources
      • limbera
        i am doing so
      • and i am doing that too
      • how are you mate?
      • mcspud
        Great!
      • You?
      • PM
      • limbera
        how do i handle the OrgSerializer trying to serialize the MemberSerializer
      • fikka has quit
      • valhalla_22 joined the channel
      • greg_f joined the channel
      • govg joined the channel
      • fikka joined the channel
      • FunkyBob
        limbera: !
      • valhalla_22
        what is meaning of this https://bpaste.net/show/9283721d312a
      • mcspud
        limbera - do you want it do?
      • valhalla_22
        dont know how to fix this
      • Sonderblade joined the channel
      • asked in python , later realized not a right room so asking here
      • mcspud
        limbera - you can always set it to `read_only=True`
      • FunkyBob
        valhalla_22: what did you do to elicit that error?
      • valhalla_22
        earlier i thought it was time stamp format error due to UTC or something else.
      • FunkyBob
        did you run a command?
      • fikka has quit
      • valhalla_22: are you going to provide the full tracback?
      • valhalla_22
        python - m unittest -v test
      • mightyspaj joined the channel
      • sure FunkyBob i will
      • crhamiltonj joined the channel
      • FunkyBob
        valhalla_22: oh... why not "manage.py test" ?
      • crhamiltonj has quit
      • like you saw in the tutorial? and in the docs?
      • specifically, that error is complaining you haven't set the DJANGO_SETTINGS_MODULE env var... which manage.py does for you
      • fikka joined the channel
      • valhalla_22
        yes now i get it , i have two settings defined in django
      • kiloreux joined the channel
      • FunkyBob
        python manage.py test --settings=.....
      • manage.py will only set it if it's not set... so you can also do DJANGO_SETTINGS_MODULE=.... ./manage.py test
      • valhalla_22
        settings.py and settings.test.py and settigns.production.py
      • FunkyBob
        not python friendly names
      • also, I'll shamelessly self-promot and suggest you look at django-classy-settings :)
      • it can make that sort of thing easier to maintain
      • davidjackson has quit
      • fikka has quit
      • mattmcc_ joined the channel
      • valhalla_22
        yes old school better to understand.
      • FunkyBob
        indeed.
      • you might want to opt for _ not . in the filenames
      • anyway... time to leave work
      • Nizumzen joined the channel
      • Leeds has quit
      • redir joined the channel
      • fikka joined the channel
      • sopanshewale joined the channel
      • fikka has quit
      • Yaser_Amiri joined the channel
      • rpkilby joined the channel
      • limbera has quit
      • eperzhand joined the channel
      • rpkilby has quit
      • eperzhand has quit
      • redir joined the channel
      • fikka joined the channel
      • mojtaba has quit
      • fikka has quit
      • valhalla_22 has quit
      • pyface joined the channel
      • sopanshewale has quit
      • Leeds joined the channel
      • fikka joined the channel
      • CorsairX has quit
      • fikka has quit
      • timkofu has quit
      • arossouw joined the channel
      • limbera joined the channel
      • pathrocle joined the channel
      • limbera
        sorry got disconnected
      • greg_f joined the channel
      • fikka joined the channel
      • ginseng has quit