#django

/

      • toothpick joined the channel
      • toothpick
        Hey, I made a form, how do i surround 2 form inputs by a <div> tag ?
      • apollo13
        Reinbow: please see the topic
      • jessamynsmith
        can't view your paste, Reinbow
      • apollo13
        toothpick: by putting <div> </div> around the two inputs in your template?!
      • Reinbow
        ok sorry
      • grafa has quit
      • toothpick
        apollo13: I was hoping to get an answer in the scope of Form and not in the scope of a Template because my template does not know the form, it only knows "{{ form.as_p }}"
      • apollo13
        toothpick: as_p is just a shortcut to get a simple default layout
      • everything else needs manual layouting
      • frek818 joined the channel
      • toothpick
        So everytime i change my form i need to redundantly change my template?
      • schinckel
        TheElf: don't worry about extra queries/joins. It probably won't be as much of an issue as you think.
      • apollo13
        well you can write your own as_p and put the logic there…
      • ie like the admin does with fieldsets
      • schinckel
        toothpick: I did write a fieldsets mixin at some point, but mostly I wind up writing custom templates per view anyway.
      • Kronuz joined the channel
      • toothpick
        schinckel: bah :(
      • apollo13
        well what did you expect?
      • Kronuz has quit
      • schinckel
        toothpick: or look at sniplates for field rendering.
      • apollo13
        the next user wants to put it into a div and then into two separate spans etc…
      • makes no sense for django to support that
      • koobs joined the channel
      • toothpick
        apollo13: i cant see why it makes no sense to you
      • schinckel
        I tend to use {{ form }} initially, and then straight to custom layout.
      • apollo13
        toothpick: just because __you__ need something doesn't mean it is a good idea for django to support it
      • toothpick
        apollo13: oh i bet it is a common issue
      • apollo13
        toothpick: what? putting two items in a div?
      • toothpick
        but thats a pointless argument we are having here, i rather stop it now
      • schinckel
        IMHO form/field rendering doesn't belong in Python code anyway. ;)
      • jessamynsmith
        toothpick: display is highly individual
      • So if you need some particular layout, you need to specify it yourself
      • apollo13
        toothpick: that's fine, but just don't put words into my mouth, I said it makes no sense for django to support it, not that it doesn't make sense to me
      • toothpick
        apollo13: I am deeply sorry
      • dualbus joined the channel
      • heyts joined the channel
      • kuter joined the channel
      • frek818 joined the channel
      • mossplix joined the channel
      • echevemaster joined the channel
      • veb joined the channel
      • Terminus
        hello. i have a ModelForm with an ImageField. on creation, it works fine. on update, it fails validation because a new file is not being uploaded. how do i get around that?
      • lieber joined the channel
      • BPL has quit
      • stahl has quit
      • BonkDonk has quit
      • AntiSpamMeta_ is now known as AntiSpamMeta
      • mmikeym
        make the field required=False?
      • apollo13
        hmm, I'd expect it to work as long as django knows that there is already something uploaded
      • show some code…
      • Terminus
        mmikeym: but it's required on creation.
      • apollo13: just a sec. i'll try to simplify this.
      • zzing
        Got my django application (from 1.5/6) running with only one api change in django-nap usage.
      • apollo13
        Terminus: mhm, rather not, you might edit out the issue with that
      • jcdesimp_ joined the channel
      • mossplix has quit
      • Terminus
        apollo13: it's kinda split across multiple files. i'm just copying and pasting stuff.
      • mossplix joined the channel
      • lfritts joined the channel
      • apollo13: https://dpaste.de/brZk line 64 is where it fails.
      • apollo13
        oh boy
      • get rid of all those bare try/except
      • mmikeym
        second time today ;)
      • apollo13
        indeed
      • jrrickerson has quit
      • then use is_valid and checks for the request method as described in the form docs
      • shredding joined the channel
      • Hairy joined the channel
      • s/checks/check/
      • by then your problems are probably gone
      • Terminus
        apollo13: i'm using them to ensure that only one record of that kind exists. that's all it is.
      • apollo13
        no that is not all it is
      • Terminus
        apollo13: forgot, here's the stacktrace -> https://dpaste.de/7sTa
      • mossplix has quit
      • shredding joined the channel
      • CrowX-
        what's wrong with this models.py? http://pastebin.com/J9BbSVxy
      • apollo13
        Terminus: doesn't change a thing, please do as I said
      • mossplix_ joined the channel
      • Terminus
        apollo13: ok. i'll think about another way to do this.
      • CrowX-
        apparently, when I try to create a user, I get an error. I can't see what the error is, cause it's an ajax request, and just says "500 internal error"
      • apollo13
        CrowX-: so configure your logging properly to get the error
      • CrowX-
        how
      • apollo13
      • dray3 has quit
      • Hairy joined the channel
      • Terminus
        apollo13: found the bug while i was trimming. it's line 60. it should be models.Overlay.objects.get, not models.Overlay.get. XD
      • apollo13
        Terminus: yeah and you didn't get an error before cause you used except: …
      • johnny2600 joined the channel
      • Terminus
        apollo13: i was being lazy and didn't specify the exact exception to watch out for. >_<
      • apollo13
        well that is what you get for beeing lazy
      • that said, that code would be nicer without try/except anyways
      • mossplix_ has quit
      • michael-k has quit
      • tdy has quit
      • heyts has quit
      • Terminus
        apollo13: except objects.get will raise an exception if the record does not exist so i have to handle it anyway.
      • apollo13
        Terminus: no
      • you'd use get_object_or_404
      • croepha has quit
      • BonkDonk joined the channel
      • if a user specifies a wrong identifier you probably want that anyways instead of just creating a new one
      • BonkDonk has quit
      • anyways, that whole code is just lazy, you don't handle invalid form inputs anywhere etc…
      • tdy joined the channel
      • MarkusH
        Terminus: and there is http://django.me/get_or_create
      • Terminus
        apollo13: this is on form submission so i'm trying to think about how get_object_or_404 can be appropriate. also, the identifier is never manually specified by the user because it is sent as initial data in a hidden field if it does not exist yet.
      • apollo13
        Terminus: ah hidden field can be manipulated by the user
      • Terminus
        apollo13: i haven't gotten to that much validation yet.
      • apollo13
        well you should, data validation of user input should be the first step
      • jcdesimp joined the channel
      • Terminus
        apollo13: i understand that but i've gotta balance time vs effort.
      • crakrjak joined the channel
      • apollo13
        Terminus: so you are saying a server error is better than a message to the user telling him that he mistakenly entered a letter instead of the required number?!
      • also time vs effort? if you did it right in the first place (it's probably even less code) you wouldn't have your issues
      • johnf_ joined the channel
      • Destos joined the channel
      • ben_vulpes has quit
      • Terminus
        i won't pretend to know everything. if i did, i'd make zero mistakes. in any case, thanks for the help.
      • actually, even if i knew everything i'd still make mistakes. in any case, this is veering offtopic now.
      • MarkusH: thanks. i'll take a look at that.
      • apollo13
        MarkusH: wanna help rewriting django.me :þ
      • johnf_
        is this right channel to ask about restful framework?
      • MarkusH
        apollo13: you said you have time the other day
      • apollo13: used it for the first time :-D
      • apollo13
        MarkusH: lalalala, already back at $company ;)
      • vater joined the channel
      • vater has left the channel
      • croepha joined the channel
      • jrrickerson joined the channel
      • tyfighter joined the channel
      • croepha has quit
      • croepha joined the channel
      • shredding joined the channel
      • Hairy joined the channel
      • sonthonax joined the channel
      • shredding has quit
      • heyts joined the channel
      • sonthonax has quit
      • shredding joined the channel
      • Reinbow has quit
      • pecg has quit
      • kuter has quit
      • heyts has quit
      • murk has quit
      • Hairy joined the channel
      • crakrjak has quit
      • d1981 joined the channel
      • d1981
        Anyone recently start having problems with CSRF protected posts?
      • Hairy joined the channel