#django

/

      • enoq joined the channel
      • shaib joined the channel
      • jakogut has quit
      • kezabelle joined the channel
      • ovalseven8
        n000b, django-cookiecutter is popular
      • I'm currently working on my first Django project and did it from scratch. It's definitely a lot to do. When I have more experience I'll definitely look into django-cookiecutter or similar templates
      • hop has quit
      • hop_ joined the channel
      • GinFuyou
        so you mean base template, not project template?
      • You can use any general-purpose (not intended for specific CMS\template engine) html template you can find around webs, just throw in template tags to make better use of it with django
      • crCr62U0 has quit
      • Or you can use some frontend framework like bootstrap, material-design-lite, whatever
      • sash_ has quit
      • crCr62U0 joined the channel
      • sh3iny joined the channel
      • emihir0 has quit
      • emihir0 joined the channel
      • xcm joined the channel
      • jtiai_ joined the channel
      • rakiru joined the channel
      • jtiai has quit
      • adsworth has quit
      • viejafea joined the channel
      • Jellyg00se joined the channel
      • Jellyg00se has quit
      • viejafea
        If I were to extend the User model by using this method (https://wsvincent.com/django-custom-user-model-...)
      • Could I just name my User model "User"?
      • ovalseven8
        viejafea, Yes
      • VikingHoarder joined the channel
      • viejafea
        thats good to know. I feel its pretty redundant to rename it something like: AppUser or something like that
      • thanks ovalseven8!
      • ovalseven8
        viejafea, My custom User model is also called User :D
      • jgadelange joined the channel
      • amirpro has quit
      • viejafea has quit
      • ovalseven8 has quit
      • sydbarret
        how do i extract the username of logged user in a view?
      • GinFuyou
        (self.)request.user.username
      • nix64bit has quit
      • "self" depending FBV or CBV
      • nix64bit joined the channel
      • sydbarret
        ok thanks
      • viejafea joined the channel
      • Jellyg00se joined the channel
      • Ahuj joined the channel
      • adsworth joined the channel
      • sash_ joined the channel
      • subleq has quit
      • subleq joined the channel
      • Xorg joined the channel
      • Ergo joined the channel
      • what would be the equivalence to make a dlookup in django?
      • fleetfox
        wtf is dlookup
      • sydbarret
        for example in Access you have a table called X with fields a and b and you wanna extract value of a based on value of b
      • fleetfox
        Do you have model describing X?
      • sydbarret
        you do dlookup ("a", "X", "b=value)
      • yes
      • dlam has quit
      • kezabelle
        case/when/then?
      • fleetfox
        X.objects.filter(b=value).values_list('a')
      • values_list('a', flat=True)
      • sydbarret
        what does flat do?
      • GinFuyou
        those description looked more like related lookups to me %_%
      • fleetfox
        makes it list
      • sydbarret
        ok thank you
      • fleetfox
        else it's list of tuples, since you could be selecting more than one value
      • if b is PK and you are sure it exists, you could probably just X.objects.get(pk=value).a
      • madsj joined the channel
      • sydbarret
        it says 'QuerySet' object has no attribute 'value_list'
      • fleetfox
        it's valueS
      • rtfm please
      • docs have examples
      • cesario joined the channel
      • greg_f joined the channel
      • jpg joined the channel
      • sandeepK has quit
      • JustASlacker joined the channel
      • GinFuyou
        up old question: can I extract msgid from translation string? e.g. _('name') -> 'name' ?
      • Stigster
        FunkyBob: My issue with the populated formset was solved by passing a queryset with no objects, like so: formset = EntryFormSet(queryset=Entry.objects.none()). The same issue was solved by apollo13 in May 2013. :P
      • Sorry, September 2010.
      • lqez
        GinFuyou: gettext does not have a reverse lookup function. So django neither.
      • viejafea
        What would be the recommended way to implement 'fake' users in django. meaning these will be users that'll have the same fields as my extended User model, yet won't need to login logout? (related q2: what if there is a possibility of them registering later?)
      • GinFuyou
        lqez, but if there is no translation provided it returns msgid, right?
      • lqez
        it's default behavior. But it looks like you're trying to get msgid from 'translated' msgstr.
      • I'm just wondering why do you need it
      • could you explain a bit more?
      • GinFuyou
        lqez, translating model choices which are named tuples
      • so I need attributes in solid english, but values as translation strings
      • stahl joined the channel
      • FunkyBob
        Stigster: glad you got it working! :)
      • Stigster
        hehe, me too! Looks like I might actually meet my deadline. :D
      • AlecTaylor has quit
      • lqez
        GinFuyou: in which case? please share your models code
      • VikingHoarder has quit
      • GinFuyou
        lqez, in any case? Not exactly what I really have now, but I used similar code for a while now: https://dpaste.de/Su7w
      • lqez
        GinFuyou: if you want to translate choice field, I recommend you to use like this style: https://github.com/pythonkr/pyconkr-2017/blob/d...
      • GinFuyou
        _n is gettext_noop, it actually can work as a hack
      • lqez, i don't want tuple
      • lqez
        understood
      • GinFuyou
        tuple is much easier ofc, but it's ugly to refer in code later
      • if makemessages wouldn't overwrite translation when it's done with gettext_noop...
      • sandeepK joined the channel
      • tm007 joined the channel
      • Maybe I could force translation to English? (Which is not used anyway) It didn't appear to me that translation can be done only once
      • Jellyg00se joined the channel
      • sydbarret has quit
      • VikingHoarder joined the channel
      • Haudegen has quit
      • lqez has quit
      • gcain joined the channel
      • gcain
        I'm using django forms, is there a way to submit fields as soon as they change?
      • The goal is to have a toggle switch that turns something on and off on the backend.
      • viejafea has quit
      • GinFuyou
        gcain, ajax
      • jpg
        gcain: I would implement the toggle as a separate functionality out of the form
      • GinFuyou
        yeah, simple toggle doen't really need a form I guess
      • gcain
        OK, thanks.
      • Guess. django can't do everything. :)
      • jpg
        gcain: you can still include the link that makes the call inside the <form></form>
      • gcain
        Actually, it doesn't even need to be a form, you're right!
      • GinFuyou
        it's not really about what django can do )
      • gcain
        I could just do something like onClick="callthe_api"
      • jpg
        gcain: exactly
      • gcain
        That works.
      • Beauty, thanks again.
      • shangxiao joined the channel
      • adsworth has quit
      • dodobrain_ joined the channel
      • dodobrain_ has quit
      • dodobrain joined the channel
      • dodobrain has quit
      • adsworth joined the channel
      • jarshwah_ joined the channel
      • kapil___ joined the channel
      • jarshwah has quit
      • jarshwah_ has quit
      • shruggedwm has quit
      • djent joined the channel
      • djent
        Hi everyone! I have a Django app running within docker container served by uwsgi. Single container works fine, but when served in Kubernetes, I got an "upstream prematurely closed connection" error in nginx ingress log. That requests are not visible in container log so it seems like they are not reaching them. Here is my nginx.conf: https://dpaste.de/B44u could you please take a look?
      • zothix joined the channel
      • I'm trying different solutions since few days, haven't found any good solution...
      • zothix
        how can i send a dictionary item in all views? example { 'example' : example }
      • djent
        the nginx returns 502 error after 3 minutes, but I see no 3m timeout anywhere in the config
      • phiofx has quit
      • GinFuyou
        zothix, context processor
      • zothix
        GinFuyou, alright ill look into that, any kind of documentation will be helpful
      • pere
        I want to verify the identity of my users of my python 3 django site using OpenID Connect, and use both web pages and a REST API. Do any of you have any experience with such setup? What options should I look at?
      • shangxiao
      • zothix
        thanks!