#django

/

      • quansai
        mattmcc: Yeah, thanks.
      • fission6
        A string representing an attribute on the model. This behaves almost the same as the callable, but self in this context is the model instance. Here’s a full model example:
      • Genitrust joined the channel
      • Genitrust has quit
      • quansai
        Thanks, fission6
      • ambar has quit
      • rahulrrixe_ joined the channel
      • brat197 joined the channel
      • mihow has quit
      • mihow joined the channel
      • HowardwLo has quit
      • dbkaplun
        Anyone? This is killing me
      • brockhaywood has quit
      • natea joined the channel
      • dAnjou joined the channel
      • dAnjou
        hi, can i simply check whether DEBUG is True in a template? or do i have to write code for that?
      • kushal joined the channel
      • knbk has quit
      • pantsofchocolate
        settings.DEBUG right?
      • dAnjou
        yes
      • eka has quit
      • eka_ joined the channel
      • google results tell me to write a context processor and whatnot
      • mattmcc
        dAnjou: There's a 'debug' context processor that checks DEBUG and whether or not your IP is in the INTERNAL_IPs setting.
      • jiang42 joined the channel
      • delgiudices joined the channel
      • dAnjou
        does that mean i have to pass a RequestContext everytime?
      • Diegao joined the channel
      • heatmeiser joined the channel
      • mattmcc
        If you're using render() it uses RequestContext by default. So do CBVs.
      • denys joined the channel
      • dAnjou
        going through our existing code and checking whether that's the case is quite some effort *sigh*
      • nikhil_
        grep ftw
      • dAnjou
        looks like i have to hack something in a middleware
      • fission6
        create a template tag if need be
      • dAnjou
        nikhil_: it's not that easy, and in general I find it quite inefficient to do it that way
      • jaddison has quit
      • kurt21 joined the channel
      • fission6
        what are you deciding to display based on DEBUG=True
      • mattmcc
        Middleware can't write to the context, unless you're using TemplateResponse.
      • m8 joined the channel
      • dAnjou
        fission6: debug flags for JS snippets
      • fission6
        why
      • tell us more
      • dAnjou
        man, django's template engine never fails to disappoint me
      • mattmcc
        Doesn't sound like it's doing any disappointing here. If you want to use context processors, you need RequestContext.
      • dAnjou
        i simply want access to settings in my template
      • mattmcc
        render() (which does by default) has been the recommended shortcut for function-based views for years.
      • Providing simple access to settings in templates is a really bad idea.
      • Xiti joined the channel
      • dAnjou
        no it's not.
      • i'm a responsible dev, i know what i'm doing
      • fission6
        what is the js doing
      • mattmcc
        Yes, it is. It's an interface meant for non-programmers to be able to use.
      • dAnjou
        mattmcc: that's your *opinion*
      • mattmcc
        Well, it's also the opinion of the people who wrote it..
      • quansai
        Looking through the docs: is there any way to link to a foreignkey's admin?
      • mattmcc
        Which is why, for example, you can't call arbitrary Python methods from templates.
      • quansai
        So if I have a blog post model with an 'author' field, can I link to the admin modification form for the author?
      • harobed joined the channel
      • fission6
      • quansai
        I was afraid of that!
      • dAnjou
        fission6: second question https://www.wootric.com/pages/faq
      • mattmcc: that should *really* be configurable
      • knbk joined the channel
      • fission6
        dAnjou: you only want this when debug is true?
      • dAnjou
        fission6: i only want "wootric_survey_immediately = true;" in debug mode
      • mattmcc
        dAnjou: Django natively supports Jinja2 these days, if that would make your life easier..
      • fission6
        do you have a proper base template?
      • HowardwLo joined the channel
      • can you not create a template tag?
      • ambar joined the channel
      • mihow has quit
      • dAnjou
        mattmcc: it's fine that you don't share my idea about how templates are being used. but this restriction has left me frustrated countless times.
      • mattmcc: i'm stuck in 1.4
      • upgrading now is not an option
      • fission6: i guess i could, and that's basically what i was asking
      • DLSteve joined the channel
      • keimlink joined the channel
      • grumpi has quit
      • rpkilby has quit
      • brat197 has quit
      • tbaxter
        I would agree with mattmcc. if it’s frustrating you, it’s probably because you’re doing something awful.
      • FWIW, I think you want a simple context processor.
      • dAnjou
        people use their PC with possible admin/root access every day and they are still alive
      • i don't need django to tell me what's a bad idea and what is not
      • fission6
        thats not their point.
      • (and you dont have to take what they say to heart they are just offering best practices)
      • dAnjou
        their point is that web designers who don't have any clue can take these templates and contribute to the project
      • fission6
        yea, which is true
      • dAnjou
        not in real life
      • mihow joined the channel
      • tekknokrat joined the channel
      • mattmcc
        Non-programmers manage templates in Django projects all the time..
      • fission6
        plenty of designers work with django templates
      • dAnjou
        i've never seen that
      • slackorama joined the channel
      • fission6
        this is all a useless side conversation and doesn’t help you so why go down this road
      • mattmcc
        At my work, I'd say 90% of our client site templates were written by non-programmers.
      • dAnjou
        fission6: i'm not the only one who's annoyed by this
      • rpkilby joined the channel
      • so it's not useless, it's worth it to think about changing it
      • mattmcc
        The change has already been made; native support for Jinja2.
      • With the requisite APIs for a programmer to plug in any other template engine of their choosing.
      • dAnjou
        and that's really nice to hear
      • i didn't know that
      • cebor has quit
      • Silvering joined the channel
      • tbaxter
        fission6 you’re right. it is a useless side conversation in which no one is going to change anyone’s mind.
      • dAnjou
        unfortunately i'm stuck in th dark age :/
      • tbaxter
        And it doesn’t change the recommendation: use a simple context processor.
      • Silvering
        Hi guys! I would like to integrated a tcp server in my django app. This is possible?
      • tbaxter
        Would you like an example?
      • dAnjou
        i'm gonna write a simle tag
      • evany has quit
      • fission6
        tbaxter: mattmcc are you both using jinja2
      • mattmcc
        Nope.
      • LotusEcho joined the channel
      • dAnjou
        Silvering: this sounds really bad. mind explaining why?
      • fission6
        Silvering: what are you trying to do
      • tbaxter
        dAnjou: again, I think you really want a simple context processor, not a TT.
      • fission6: nope, me neither. I have no use or interest in Jinja
      • mattmcc
        tbaxter: Apparently there's a concern that render() isn't being used everywhere.
      • cebor joined the channel
      • tbaxter
        that’s a stupid concern.
      • mattmcc shrugs.
      • dAnjou
        it's not
      • tbaxter
        That’s like saying “i’m going to do the wrong thing because the wrong thing was already done"
      • natea joined the channel
      • and even then, one doesn’t HAVE to use render() everywhere anyway.
      • dAnjou
        tbaxter: it seems for a cp i'd have to run around and add code in X places while a simple tag requires me to write only one decorated function
      • tbaxter
        well, clearly you know more than the rest of us.
      • mattmcc
        I got the sense this is a base template thing.
      • Silvering
        I have a iOS app working on my iPhone. I would like to create a django app which listen for the iOS app. If I tap a button on my mobile, a view appear on my django app. This is possible ?
      • dAnjou
        mattmcc: it is
      • fission6
        Silvering: sure but you don’t need a tcp server
      • just create a web service/view
      • dAnjou
        Silvering: "listens for the iOS app"?
      • Silvering
        dAnjou : sorry ;-)
      • david-lyle joined the channel
      • Satchitananda has quit
      • fission6
        (when you click the button it makes a request to /activate/) or whatever
      • the hard part is loading somthing on your screen without a request first from the desktop
      • what do you mean by a view appears on my django app?
      • Silvering
        fission6 : yes exactly. Or swich to another view
      • glassresistor
        so i have a TemporaryUploadedFile that i need to process as a csv in python3, i need to convert the temp file to something ~= opening a file as text
      • fission6
        where is the view appearing, just tell us the whole story with details
      • Silvering
        a simple <a href …> to another page
      • Satchitananda joined the channel