#django

/

      • lumidee
        yes, you can either write <form action="...> <select> <option>example </option> <option> ...</option> </select> </form> manually into djangos html template or you can use {{ form }} by defining the form in forms.p.y
      • mcspud
        lumidee: there is a 3rd way
      • FunkyBob
        lumidee: or, as the docs show you, use the middle ground for slightly more control
      • mcspud
        You can just access the rendered field templates, like {{ form.fieldname }}
      • lumidee
        FunkyBob, you mean {{ form.my_field }} ?
      • mcspud, ah yea.
      • FunkyBob
        beyond that, there are some template-based form rendering libs
      • lumidee
        is the first way, by manually writing the form elements and omit forms.py okay or should be avoided?
      • FunkyBob
        like floppy-forms and sniplates
      • mcspud
        lumidee: your call
      • FunkyBob
        lumidee: you should not omit forms.py
      • you should use forms for validating input... that's what thy're form
      • but you don't have to use them for rendering html
      • "that's what they're for" ... blah
      • sayan joined the channel
      • lumidee
        ah thanks for clarifying. i'll use them for validating then, because i couldn't find a way to render them in my case to the html. i need multiple forms that correspond to a specific <section> http://paste.ofcode.org/w9y2CGep7RbtgMRxycSbE3
      • mcspud
        lumidee: personally, I use FloppyForms, and I always build out the form using the {{ form.field }} style. As FunkyBob said, its a good middle ground and allows lots of styling
      • FunkyBob
        lumidee: ah, well, wait a minute
      • do you need multiples of the same form?
      • lumidee
        FunkyBob, multiple different forms unfortunatetly, every form has different options
      • FunkyBob
        lumidee: ok
      • d42 has quit
      • wow... HNs search is well broken
      • mattmcc
        They must've outsourced it.
      • FunkyBob
        search for my name... first article is something referencing django-nap... everything else is posts by "funkyboy"
      • sayan joined the channel
      • literally... _every_ other match
      • mcspud
        lumidee: you can pass in multiple forms like this- https://dpaste.de/vXDG
      • FunkyBob: Damn
      • You're deifnitely on there
      • I'll get him to track down some articles
      • bed666 has quit
      • Also, about my original question, any suggestions? In your experience is it appropriate to put external package dependencies on model methods (like python-requests?)
      • Poulet joined the channel
      • lumidee
        mcspud, good to know thanks. can't use that in my case either, because the amount of forms is also dynamic
      • d42 joined the channel
      • FunkyBob
      • enkrypt joined the channel
      • Dibble134 joined the channel
      • mcspud
        lumidee: How are the correct forms to be displayed determined?
      • drag0niu1 has quit
      • drag0nius joined the channel
      • melhiors joined the channel
      • ulhas joined the channel
      • bed666 joined the channel
      • jladage has quit
      • lumidee
        mcspud, i pass two dictionaries to the template, one contains the options for the forms and the other dictionary is compared to it to determine what options to use: http://paste.ofcode.org/w9y2CGep7RbtgMRxycSbE3
      • timkofu has quit
      • mcspud
        lumidee: why dont you do that in the view and just passed down the finalised result?
      • lumidee: also what does jcv stand for?
      • domino14 joined the channel
      • lumidee
        mcspud, ye i should do that. i could put the form options to the second nested dict within a tuple as such: myDict = { "client1", "fileset1": (["opt1", "opt2"], [ other list ])}
      • mcspud, jcv stands for job client value, that is the nested fileset dictionary
      • mcspud
        lumidee: I'm not quite sure how you're constructing the form, but what you've shown doesnt' look right
      • (could be wrong though)
      • AtomicSpark has quit
      • domino14 has quit
      • Joshee joined the channel
      • bed666
        ;)
      • jladage joined the channel
      • lumidee
        mcspud, ye it was just a scheme, didn't implement it yet fully :)
      • the_rat joined the channel
      • sagaragarwal94 joined the channel
      • Alina-malina has quit
      • eka joined the channel
      • sayan joined the channel
      • codeme joined the channel
      • dray3 joined the channel
      • kingplusplus_ joined the channel
      • kingplusplus has quit
      • kingplusplus_ is now known as kingplusplus
      • bee_keeper joined the channel
      • ulhas has quit
      • aavrug joined the channel
      • Alina-malina joined the channel
      • Ariel_Calzada joined the channel
      • grumpi joined the channel
      • pytony joined the channel
      • codeme has quit
      • josuebrunel joined the channel
      • grumpi has quit
      • grumpi joined the channel
      • jladage has quit
      • bmispelon has quit
      • eka joined the channel
      • mr-foobar joined the channel
      • b23 joined the channel
      • afidegnum joined the channel
      • afidegnum
        hi, good morning, I am reading this documentation, and encountered the model class... https://docs.djangoproject.com/en/1.8/topics/cl...
      • I thought the model class is used to generate the models and map to the form if possible why returning urls again?
      • codeme joined the channel
      • mattmcc
        afidegnum: By convention, a model class can indicate what its primary URL is by providing a get_absolute_url method.
      • afidegnum
        mattmcc: can you please explain that?
      • mattmcc
        afidegnum: Well, in the context of the link you provided, CreateView and UpdateView both need a URL to redirect to after a successful creation/update of a model.
      • If a model class has a get_absolute_url method, then the view knows to use that URL for the redirect.
      • jladage joined the channel
      • afidegnum
        ok, thanks for throwing the light,
      • YuanModu joined the channel
      • mattmcc
        Otherwise, the view would have to provide a success_url.
      • Personne
        "help me I don't have any collectstatic command in Django 1.6" :D
      • afidegnum
        so after the CRUD, it will return back to the Model's class url, right?
      • Personne
        Very curious, I'm using agenda-libre-python project. And no collectstatic available :-/. So in production mode, no 404 error or 500 error pages :'(
      • schinckel
        Unless you provide a different URL (get_success_url)
      • microdex joined the channel
      • mattmcc
        afidegnum: If the view doesn't override it, yes.
      • afidegnum
        ok, ok, good, :) thanks for the tip
      • mattmcc
        It's just a convenience. Since it's not uncommon for a model to have one 'main' URL (like a detail page)
      • CMSBottu has quit
      • Personne
        Is there any way to do the same as collectstatic command? To know what it do?
      • afidegnum
        Django has lot's of references and documentation, I am wondering when will I be acquainted to all that,
      • CMSBottu joined the channel
      • mattmcc
        Personne: Is django.contrib.staticfiles in your INSTALLED_APPS?
      • Earlo joined the channel
      • afidegnum: I wouldn't worry too much about learning "all" of it. It's a process, like anything else. I've been doing Django as a day job for seven years now and I still look things up in the docs on a regular basis.
      • lacrymology joined the channel
      • Also, some things just aren't worth memorizing.
      • afidegnum
        ok, thanks,
      • teebes has quit
      • thibaud joined the channel
      • shangxia1 joined the channel
      • Personne
        mattmcc: wow, no contrib.staticfiles oO. WTF! I don't understand how people from this project can use this application. No STATIC_ROOT, no collectstatic command -__-
      • mattmcc: so, with just a STATIC_ROOT, django.contrib.staticfiles, a collectstatic (if enable) should suffise for uwsgi/nginx to find 404.html and 500.html page you think?
      • Because 404.html page is in templates/404.html
      • mattmcc
        Well, now we're talking about something completely different.
      • Templates are not static files, after all.
      • How about we back up and identify what actual problem you're having at the moment.
      • mitaka has quit
      • slick666_work joined the channel
      • Personne
        mattmcc: ok, so in fact I "just" want to have 404 and 500.html page when I make something like "mysite.com/sgrumblbl"
      • for static files, it seems that it's not needed as the website work properly.
      • I thought it was static files that makes 404.html page available.
      • kurse has quit
      • mattmcc
        No, not by default. The default behavior is that a 404 request will be routed to the page_not_found view, which renders a template named 404.html if it's available. No static files involved.
      • If there isn't a 404.html template, then the view just spits back a raw HTML string.
      • Personne
        In production mode ?
      • mattmcc
        Yes.
      • If DEBUG is True, then you'd get a generated error page detailing why there wasn't any urlpattern match for the URL in question.
      • Personne
        Yes, in DEBUG=True, I see a page with details.
      • michalmo joined the channel
      • bee_keeper has quit
      • afidegnum has quit
      • mcspud
        Personne: mattmcc is saying that you don't need that
      • Whenever a 404 or 500 is encountered, Django goes and looks in your template dirs for a file called "500.html"
      • And renders it out
      • codeme has quit
      • YuanModu has quit
      • Personne
        mcspud: yes, but I think it make a problem with nginx I suppose.
      • YuanModu joined the channel
      • mattmcc
        No, it doesn't.