#django

/

      • IanHoffman
        yeah, that part makes sense. Issue is just that if I handle it in clean(), I still want to change the names of fields/which fields are shown whenever the user toggles countries
      • I guess that part would be in JS
      • then the validation in Django
      • sms
        Yeah
      • IanHoffman
        there's no sort of widget or package that handles this already? Ha
      • fission6 has quit
      • jarshwah has quit
      • sms
        Because if you wanted to only let them enter a certain amount of digits based on country (depending on the countries format) that'd have to be handled by JS
      • And that's probably what you want
      • Kangermu_
        morenoh149: yeah, just pass a default value (hard coded or as a callable, however you want), then just overwrite it on save
      • IanHoffman
        sms: yeah, makes sense. Because otherwise, using for example a regex field, I'd have to change the regex when they toggle country... and I don't think that's possible w/out a page reload
      • jarshwah_ has quit
      • geekodour08 has quit
      • sms
        Well you don't have to reload, you could use Ajax
      • chocoelho1 joined the channel
      • IanHoffman
        Fair point. Seems a little crazy though to hit the server just to update the regex.
      • sms
        Yeah that's definitely overengineering
      • Creatornator joined the channel
      • chasonchaffin joined the channel
      • IanHoffman
        ok, I think I may keep this pure JS: there's enough of an eco-system there already that I don't think I'll even need to worry about clean(). Thanks for the info!
      • samsagaz has quit
      • sms
        Np
      • chocoelho has quit
      • chocoelho1 is now known as chocoelho
      • gugah has quit
      • polaris joined the channel
      • chasonchaffin has quit
      • imack joined the channel
      • morenoh149
        I can't seem to get models that point to a created model in it's {post,pre}_save hooks
      • empedokles78
        Is it possible to make SelectDateWidget show year only?
      • fikka joined the channel
      • szicari
        Greetings, all. Are there any general recommendations for project layout to support multiple API versions in a Django project?
      • redir has quit
      • joshuajonah has quit
      • Creatornator joined the channel
      • Creatornator has quit
      • lolidunno joined the channel
      • Creatornator joined the channel
      • arielfe1984 has quit
      • Kangermu_ has quit
      • lborda has quit
      • samsagaz joined the channel
      • samsagaz
        exist some function in django that let me display a json response formated (like pprint) inside a template file?
      • Creatornator has quit
      • dardevelin joined the channel
      • TheJoey
        samsagaz: There is nothing built in, but you can create a template tag for it using pygments.
      • samsagaz
        is just for debuggin purpose, but dont want to get all the plain json because ir hard to read
      • oh, will search about it
      • TheJoey
        samsagaz: This is what I have in my application: https://gist.github.com/tarkatronic/0b31eef92a7...
      • medeirosthiiago joined the channel
      • samsagaz
        let me see
      • what @register.filter do? :/
      • FunkyBob
        it... registers a function as a template filter?
      • dang`r`us
        it registers a filter
      • so you can use it
      • otherwise it's just some function in some file
      • TheJoey
      • redir joined the channel
      • samsagaz
        never used filters, will read about it
      • i was importing the pygments in the view :D
      • TheJoey
        samsagaz: If you have this filter available to you, then all you need to do in your template is: {{ my_json_variable|jsonify }}
      • samsagaz
        nice!
      • jarshwah joined the channel
      • django is incredible
      • :)
      • medeirosthiiago has quit
      • ebsen joined the channel
      • im close...
      • empedokles78
        Can I provide choices tuples as integers? But why do I need a list of two for this?
      • dang`r`us
        label and value
      • FunkyBob
        one for the value, one to display
      • csotelo_at_work has quit
      • empedokles78
        and they both can be integers?
      • dang`r`us
        label might need to be a string
      • "1" vs 1 ... but try it out, maybe int is ok too.
      • samsagaz
        Incredibe!
      • kanja joined the channel
      • but i need to use <p> {{ content | jsonify | safe}} </p> to get it working :)
      • Creatornator joined the channel
      • thanks TheJoey get it working very quick!
      • empedokles78
        can I get the current year (e.g. 2017) from timezone.now?
      • c17r has quit
      • jonesnc joined the channel
      • XofP has quit
      • aclark
        empedokles78: yup
      • ssv has quit
      • FunkyBob
        timezone.now().year
      • Creatornator joined the channel
      • empedokles78
      • FunkyBob
        sure
      • nowever
      • remember that will be evaluated as soon as that code is imported
      • c17r joined the channel
      • tourdownunder
        My coworkers like to squash migrations. I have a long running branch and I regularly get errors when I merge django.db.migrations.exceptions.NodeNotFoundError: Migration foo.0009_auto_20171121_0325 dependencies reference nonexistent parent node ('bar', '0008_auto_20171116_0430') into my long running branch. Is squashing migrations causing these issues?
      • empedokles78
        FunkyBob, imported where? You don't suggest it?
      • aclark
        tourdownunder: if the parent isn't there… then probably yes?
      • tourdownunder: i certainly wouldn't expect it to work, from a "conservative approach" perspective.
      • FunkyBob
        empedokles78: whatever imports it. if it's a models.py then django setup will import it
      • tourdownunder: more likely manually editingmigrations will cause it
      • or leafing out migrations from git
      • empedokles78
        FunkyBob, so it's a bit ressource heavy putting choices inside the model?
      • xliiv joined the channel
      • Creatornator has quit
      • rpkilby joined the channel
      • Creatornator joined the channel
      • chasonchaffin joined the channel
      • iamriel has quit
      • slav0nic has quit
      • fission6 joined the channel
      • c17r has quit
      • Haudegen joined the channel
      • FunkyBob
        empedokles78: in this specific case... you might have troubleif, for instance, aninstance is left running over the new year
      • Oli
        Well, no. It runs once on first import. It's relatively short. You'll survive. The problem comes if the process that loads it stays running over a year boundary. The year will change but the choices will be last years'.
      • FunkyBob
        "this year" is not a constant :)
      • chasonchaffin has quit
      • in this specific case, y ou'd want to set it in an overridden __init__
      • but as a general pattern, it's fine
      • Oli
        It's a shame choices have to be baked into migrations (never quite understood that) or a callable would be on the table.
      • empedokles78
        FunkyBob, can you provide an example? Overwriting __init__ seems advanced python :)
      • FunkyBob
        pfft
      • tourdownunder
        Thanks for your replies I've just been in standup
      • chowmeined joined the channel
      • chocoelho has quit
      • FunkyBob
        it's not rank beginner python, true, but it's something you should learn early on
      • Creatornator has quit
      • empedokles78
        FunkyBob, I had it in models, is it better to be placed in forms?
      • FunkyBob
        oh, well, yeah, can do in models...
      • not the same way, though
      • redir joined the channel
      • empedokles78
        What's different?
      • FunkyBob
        you don't want to override __init__ on models
      • netheranthem has quit
      • TheJoey
        I think I've done that before. It wasn't pretty.
      • fission6
        does anyone here use django-filters
      • FunkyBob
        once
      • enough to test itwas compatible withdjango-nap .... not sure if it still is
      • fission6
        FunkyBob how was your experience with it?
      • TheJoey
        I use it
      • empedokles78
        FunkyBob, what do you override then?
      • TheJoey
        It works for simple cases... but I still have cases where I just write my own filter functionality
      • FunkyBob
        do you really need to enforce the choices onthe model level, empedokles78 ?
      • given you'll aquire "invalid" years over time, that way
      • empedokles78
        FunkyBob, I just thought it's easiest to bundle everything there, because I use also a modelform and specify the models fields in a class meta.
      • iamriel joined the channel
      • imack has quit
      • arielfe1984 joined the channel
      • Why invalid?
      • arielfe1984
        hi - im trying to write a unit test in django for an existing project that runs with an existing oracle db - ive downloaded oracle vm and changed the settings as written in https://code.djangoproject.com/wiki/OracleTestS...
      • but i get this traceback https://dpaste.de/Rgvj