#django

/

      • PaulWay[w] joined the channel
      • PaulWay[w]
        Hi all.
      • Anyone use django-rest-models here?
      • UncleVasya joined the channel
      • FunkyBob
        not I
      • PaulWay[w]
        I'm getting an error that it's trying to pass 'chunk_size' to the django-rest-models SQLCompiler `execute_sql` method, which doesn't accept it.
      • FunkyBob
        which "it" is trying to pass chunk-size?
      • fikka joined the channel
      • andyhoang joined the channel
      • fikka has quit
      • Leeds joined the channel
      • theWhisper_
        SmileyChris: actually it didnt even worked
      • SmileyChris: because i have a unique_meta to avoid having duplicates and is not working
      • is working a way to prevent same request but if the other user sends the request to userA it will be inserted in the table
      • PaulWay[w]
        FunkyBob: Django's model query system.
      • FunkyBob
        PaulWay[w]: so... django-rest-model isn't supporting the ORM API?
      • mattmcc
        Sounds like a version disconnect.
      • fission6 joined the channel
      • rpkilby has quit
      • PaulWay[w]
        FunkyBob, mattmcc: yes, that's possible.
      • FunkyBob
        PaulWay[w]: certainly a safe move to report it to their issue tracker [they == django-rest-models project]
      • PaulWay[w]
        FunkyBob: yep. Maybe it's already an issue...
      • If I hack the method accept and ignore that parameter, it does seem to work.
      • theWhisper_
        SmileyChris: still you havent tell me how to handle the friend table
      • fikka joined the channel
      • PaulWay[w]
        FunkyBob: you don't know ottoyh if the chunk_size parameter was added in 2.0 by any chance?
      • Same issue, similar fix (just absorb and ignore all other keyword arguments).
      • fikka has quit
      • zeus1 joined the channel
      • rns joined the channel
      • Nizumzen
        I've added to my migration the pgcrypto extension for PostgreSQL but in order to install the extension you need to be a superuser which I am not when running migrate - is there some way to get around this? I don't want my Django app to connect to the database server as the superuser for security reasons
      • theWhisper_
        can i add something to unique_meta that allowed for arbitrary contrainst? liek it doesnt matter if UserA and USerB or UserB and UserA
      • lorddaedra joined the channel
      • fikka joined the channel
      • Nizumzen
        hmm seems if I add the extension manually as a superuser it works correctly - not sure how I can handle this from CI / CD on Gitlab
      • rns has quit
      • schinckel
        It probably depends on you CI infrastructure: you could (in tox.ini or whatever) execute the relevant command before you start migration.
      • (Do extensions apply to all databases, or will you need to apply it to the template?)
      • amcorreia joined the channel
      • Nizumzen
        I should probably switch to using Docker instead of my current method
      • that way I can automatically deploy using Kubernetes as well
      • theWhisper_
        FunkyBob: ?
      • fission6 has quit
      • schinckel:
      • Nizumzen
        never really used Docker before though
      • UncleVasya has quit
      • fikka has quit
      • schinckel
        theWhisper_: Please don't just @ us because nobody has responded. That's the way to get ignored.
      • theWhisper_
        alright
      • sorrt
      • andyhoang joined the channel
      • FunkyBob
        theWhisper_: you mean Meta.unique_together ? no
      • theWhisper_
        yes that one
      • schinckel
        But, it sounds like what you want is a check constraint.
      • GinFuyou joined the channel
      • theWhisper_
        i thought unique_togehter was a constrint
      • FunkyBob
        it is
      • but you want a different one
      • theWhisper_
        but I need it to be in a way that order doesnt matter
      • schinckel
        Can you elaborate on what you want to do? In business logic speak (like how you'd explain it to a non-programmer).
      • theWhisper_
        UserA and USerB and vice versa
      • FunkyBob
        "It sounds like you need a <tool>. " "But a hammer is a tool!" ....
      • schinckel
        But what exactly do you mean? UserA and UserB in what context?
      • FunkyBob
        schinckel: theWhisper_ is implementing a "friend of" relation with a custom m2m through table
      • theWhisper_
      • in this context
      • lorddaedra
        I have model Item(id, category_id, price), how to select in best way list of item ids with biggest price for each category, only 1 (any) if there are 2+ biggest for some category
      • ?
      • theWhisper_
        i just found out that unique_together doesnt work for insensitive order
      • schinckel
        Ah, you mean you don't want to allow (A, B) and (B, A) in your many-to-many table?
      • theWhisper_
        so it will stop everything if UserA and USerB are in table but not if UserB UserA are being inserted
      • exactly
      • schinckel:
      • i mean i think i can do another unique_together with the relation vice versa
      • but
      • is there something directly?
      • PaulWay[w]
        lorddaedra: So you want Max(price) by category in item?
      • lorddaedra
        yes, and only 1 item if there is multiple items with same price = Max(price)
      • theWhisper_
        do i have to invert the unique_together?
      • bradfordli123 joined the channel
      • lorddaedra
        if some category id contains 10 items with price 100 and it's max price for that category, I need only one of them, not all
      • PaulWay[w]
        That to me sounds like two queries: one to find the maximum price per category, and one to get the first item with that price in that category.
      • theWhisper_
        schinckel: ?
      • PaulWay[w]
        I'm thinking in terms of SQL here.
      • djapo
        how can i acces the cls in a method in a graphene object type, without the classmethod decorator
      • ?
      • theWhisper_
        FunkyBob: alright i tried the viceversa but it didnt worked
      • FunkyBob
        viceversa of what? you mean specifying the fields in a different order?
      • theWhisper_
        i mean unique_together = ('creator', 'following') or unique_together = ('following', 'creator')
      • FunkyBob
        yep.. makes 0 difference
      • theWhisper_
        what you mean?
      • i found out this is not possible
      • FunkyBob
        you mean you put literally "unique_together = ('creator', 'following') or unique_together = ('following', 'creator')" ???
      • theWhisper_
        i tried it that way
      • FunkyBob
        ...
      • theWhisper_
        but it didnt worked
      • fikka joined the channel
      • FunkyBob
        will you STOP making up your own syntax, and READ THE DOCS!
      • hgrsd has quit
      • theWhisper_
        o no i didnt do it like that
      • i just added another unique_togther
      • FunkyBob
        also, answer questions clearly and directly
      • theWhisper_
        but i got redeclared unique_meta
      • FunkyBob
        yes ... because you made up your own syntax, instead of doing it how it's shown in the docs
      • djapo
        how can i pass an argument to a @classmethod decorated method?
      • FunkyBob
        djapo: the same way you do to any method?
      • rpkilby joined the channel
      • theWhisper_
        FunkyBob: unique_together = (('creator', 'following'), ('following', 'creator'))
      • Boom!
      • but damm stop treating me like this you used to be very nice to me always am still learning
      • FunkyBob: btw A ManyToManyField cannot be included in unique_together. (It’s not clear what that would even mean!) If you need to validate uniqueness related to a ManyToManyField, try using a signal or an explicit through model.
      • FunkyBob
        yep
      • fikka has quit
      • PaulWay[w]
        theWhisper_: it is a losing strategy to demand answers of people who have no obligation to help you but are trying to anyway.
      • theWhisper_
        i didnt mean that Paul!
      • FunkyBob
        I used to be nice to you, but you wore out my pateince by expecting me to do all the work... and not reading the docs.
      • chasonchaffin1 joined the channel
      • theWhisper_
        I know FunkyBob always help me
      • but he used to help me not yell me!
      • djapo
        FunkyBob: im using super, so super(class, cls).getobj(info); but getobj says that it takes exactly one but 2 where given
      • PaulWay[w]
        No, actually, he doesn't.
      • djapo
        im decorating the method with @classmethod
      • FunkyBob
        theWhisper_: yes, but being nice didn't seem to get through to you, so I changed tactic... looks like it's actually working
      • theWhisper_
        he doesnt?
      • zeus1 has quit
      • he help me all the time
      • rpkilby has quit
      • FunkyBob
        djapo: and?
      • theWhisper_
        FunkyBob: well thanks anyway
      • PaulWay[w]
        And yet you still fail to read the manuals, theWhisper_
      • FunkyBob
        theWhisper_: no quite often I ignore you... because I just don't have the emotional energy to deal with you.
      • theWhisper_
        I did not
      • PaulWay[w]
        So why help you if you're not helping yourself?
      • theWhisper_
        i got it
      • i needed a tuple
      • FunkyBob
        PaulWay[w]: yep, theWhisper_ actually did read the docs this time...
      • sol1x has quit
      • after I grumped at them
      • theWhisper_
        is not that i read the docs i have no problem reading it but sometimes i cannot find it in the docs
      • FunkyBob
        theWhisper_: experience with you has shown that being nice doesn't work well, but being grumpy does.... does the name Pavlov ring any bells?
      • theWhisper_
        do i have something in here where i can ask a bot if X exists in the docs?
      • FunkyBob
        the docs have a search built in
      • theWhisper_
        PAvlov?
      • what is that
      • djapo
        FunkyBob: it complains that it only takes one argument but two where given.
      • opticdel1sion joined the channel
      • theWhisper_
        FunkyBob: anyway i was suggested to use two tables one for FriendRequest and one for actual Friends
      • noyb has quit