#django

/

      • kristian_ has quit
      • Katharsis has quit
      • nix64bit has quit
      • jtiai
        factory-boy to the rescue!
      • Dulcin
        I'll give that a shot
      • moldy
        also factory-boy maybe, but i think it's better for test data than for initial production data?
      • kristian_ joined the channel
      • elit3x joined the channel
      • Dulcin
        Yeah I think so too, I'm using pytest and already have factories set up for 'regular' test data
      • I believe factory_boy is for Django's unittest right?
      • jtiai
        Not really. It's generic object factory tool which has djang orm integration.
      • And it's not tied to unittests. Works with any testing framework.
      • Dulcin
        ah probably nicer than my pytest factories in combination with mommy then
      • Xorg has quit
      • fikka joined the channel
      • BPL joined the channel
      • veduardo joined the channel
      • sayan has quit
      • sayan joined the channel
      • Haudegen joined the channel
      • sunil_bansal joined the channel
      • Xiti joined the channel
      • sunil_bansal has quit
      • laerus joined the channel
      • kyern has quit
      • kyern joined the channel
      • kristian_ has quit
      • daydreamm joined the channel
      • test123 has quit
      • EyePulp joined the channel
      • kristian_ joined the channel
      • ram0n joined the channel
      • ram0n has quit
      • ram0n joined the channel
      • eb0t
      • Kangermu joined the channel
      • hey i am still struggling with creating forms without using bootstrap or the {{form}} variable
      • the forms work ...but i dont know how to code them so that i can loop over the fields in a form
      • and get the error messages displayed in the boxes
      • ie the form fields
      • at the moemnt in time. my forms work, but error messages show above the form fields after i submit the form which isnt ideal
      • any help will be greatly appreciated.
      • kuter has quit
      • enoq joined the channel
      • ram0n
        eb0t: `{% for field in form.visible_fields %} ... {{ field.errors }} .. {{ field }} .. {{ field.help_text }} {% endfor %}`
      • kapil___ joined the channel
      • you can also use `{{ field.html_name }}` to retrieve the proper field name for your input..
      • eb0t
        ah ram0n, i know there is a major hole in my logic. but in my html form, one of the fields is a text area
      • ram0n
        and what's the problem with that?
      • eb0t
        so each of my fields has a label, and a text area
      • or a field and an input
      • but the form has to be submitted before i can check it for errors
      • so if i put values in each box in the form and then submit,
      • the form is then checked for is_valid, and if not a new form with errors is submitted, which i can itterate over
      • but what about the fields that were fine
      • they will not be repopulated on the form, i have to fill it all in again by hand
      • entropish joined the channel
      • randominternetus has quit
      • ok with a small form, do i need some logic in my view which somehow repopulates the working fields
      • with the vales that passed validation
      • as you can see im really a bit lost on these forms
      • GraysonBriggs joined the channel
      • csotelo_at_work joined the channel
      • ah, i will maybe {% for field in form.visible_fields %} ... {{ if field.errors }} .. {{ field }} .. {{ field.help_text }} {{else field }}{% endfor %}
      • soemthing like that
      • i will have a mess about, thanks for the pointers
      • tomchristie joined the channel
      • greg_f has quit
      • jarshwah joined the channel
      • kiloreux joined the channel
      • czart joined the channel
      • kristian_ has quit
      • greg_f joined the channel
      • kristian_ joined the channel
      • ggj has quit
      • rsrx joined the channel
      • cryptopian has quit
      • cryptopian joined the channel
      • Kangermu has quit
      • miknotauro has quit
      • ironi joined the channel
      • Ahuj has quit
      • cryptopian has quit
      • ok ram0n seems to be working now.
      • do you think i could improve on this https://bpaste.net/show/a541fdcc90a1
      • GinFuyou
        eb0t, why don't you render fields always with that for loop
      • ?
      • eb0t
        GinFuyou: when the form is initally sent as a GET request. if i used the for loop then because the fields are manually constructed, then i'm not sure it would work
      • if i removed the manual field declarations
      • Kangermu joined the channel
      • Rocklayth joined the channel
      • GinFuyou
        what do you mean "manually constructed"
      • RCStef has quit
      • They are declared in form class?
      • Rocklayth
        Hello guys. I would like to check if a ManyToManyField is empty in a clean() of the class itself? How do i do it? When I try to access this variable, I get a "needs to have a value for field "id" before this many-to-many relationship can be used."
      • eb0t
        yes they are declared in the form class, but the main reason i have done it this way is that eventually i want to apply some css to the field boxes and the error messages
      • kristian_ has quit
      • cryptopian joined the channel
      • n0nam3 joined the channel
      • and if i use {{form}} variable to get the fields on the html form
      • i was finding it difficult to manipulate the css on the fields
      • this way i can use my own classes
      • GinFuyou
        you can set classes on the widget attrs instead of css
      • kristian_ joined the channel
      • if you want classes on container elements, I'd suggest rendering fields through django-sniplates widgets
      • Fully manual rendering is double royal PITA ^__^"
      • eb0t
        ah .. now i have this kind of working, im going to try and implement the same thing with sniplates.
      • sunil_bansal joined the channel
      • i have the documentation, just got to see how it does things, as it seems sniplates is going to be the final method
      • once i suss it out
      • GinFuyou
        sure, good luck
      • jeffspeff joined the channel
      • eb0t
        thanks
      • pjs joined the channel
      • zothix joined the channel
      • i was avoiding the forms and templates for forms, as i just knew it would be very confusing for me, but slowly getting a feel for it , from total disaster, currently at ...a bit of a disaster.
      • so thats progress
      • GinFuyou
        I totally hated dealing with forms when I started with django. Well... a while after that too >_<"
      • zothix
        does anyone know any 1 to 1 private chat module which shows Online, offline, is typing etc
      • which i can use in my already existing project
      • GinFuyou
        zothix, it's not most trivial
      • zothix
        as in?
      • i should write my own chat module ?
      • waldhar joined the channel
      • GinFuyou
        As in there are most likely such modules, but they may require django-channels or some other additional setup of your server
      • hop
        Rocklayth: if you have no id on an object (i.e. it's not saved), it can't be in a relationship
      • adsworth has quit
      • GinFuyou
        since django by default is not fitted by that kind of async communications
      • zeus1 joined the channel
      • hop
        Rocklayth: what would be in the fk on the other end?
      • zothix
        GinFuyou, what is the best aproach here, i need my web to have chat n all.
      • how should i proceed.
      • bradfordli123 joined the channel
      • GinFuyou
        Django-channels is often mentioned along with chat I think, folks here would know a better advice for you
      • bradfordli123 has quit
      • Just warned you it may not be ass easy ass pip install something
      • zothix
        the last module i was working with used sockets n stuff
      • but it didnt work
      • and it didnt gave any error either
      • GinFuyou
        *as (sorry)
      • greg_f has quit
      • bradfordli123 joined the channel
      • zothix
        GinFuyou, xD yes i know that xD
      • ass seemed to fit better though
      • xD
      • chronos joined the channel
      • greg_f joined the channel
      • GinFuyou
        Shouldn't have kept that danbooru tab opened #^_^#
      • eperzhand has quit
      • zothix
        xD