These are chat archives for django/django

4th
Apr 2017
Anish Shrestha
@annshress
Apr 04 2017 03:59
OBEY THE TESTING GOAT
Do you think it is a good idea to let programmer backend and frontend study each other?
Ismael Venegas Castelló
@SalchiPapa
Apr 04 2017 05:12
@annshress thanks for the goat reference, I found one can read it online for free, very good book! :D
I don't get what you are doing there @elcolie
Anish Shrestha
@annshress
Apr 04 2017 05:15
@theodesp referenced it. I have never used a TDD approach. I plan to use it someday :sparkles:
Ismael Venegas Castelló
@SalchiPapa
Apr 04 2017 05:15
Ah yes, thanks to both! :D
I have never used it myself, I always make tests, but after the fact
Anish Shrestha
@annshress
Apr 04 2017 05:15
I plan to make it my mantra.
Ismael Venegas Castelló
@SalchiPapa
Apr 04 2017 05:15
:+1:
Anish Shrestha
@annshress
Apr 04 2017 05:16
:D
DanielAlderman
@DanielAlderman
Apr 04 2017 07:14
Is anyone using Class Based Consumers in Django-Channels?
Theofanis Despoudis
@theodesp
Apr 04 2017 13:35
I found it good because it builds progressively the examples
and you can follow along
FrankGwada
@skafis
Apr 04 2017 14:35
hi good people any idea on how i can create dynamic forms with django?
Theofanis Despoudis
@theodesp
Apr 04 2017 14:43
I know the package django-crispy-forms
Randolph Pe Benito
@randolphpebenito
Apr 04 2017 14:45
Any data structure enthusaist out there?
Philip Eckert
@pae4557
Apr 04 2017 14:46
Anybody know a good way to use a Model as a template for an object without actually making database entries? I have an applet that used a ModelForm to process the data and then performs calculations on it via a function named process_data(model_instance). I want to now make a version of the applet that anonymous users can access. Is there a pythonic way of doing this? I don't really want to make a new version of my process_data() that has to accept a form as an argument and rewrite all the syntax for accessing data from a form instead of an object. Any advice?
FrankGwada
@skafis
Apr 04 2017 14:46
@theodesp i can not create dynamic form fields with django-crispy
Theofanis Despoudis
@theodesp
Apr 04 2017 14:50
i think is quite tricky to do as you need create a form from the POST request that will pass all validations and then you need to return the validated data. So if you need something dynamic you need to create a form factory method of something
Philip Eckert
@pae4557
Apr 04 2017 14:51
Hmmm. Possibly just checking form.is_valid() and then building an iterator to pass all the fields of the valid form into a ModelInstance?
Theofanis Despoudis
@theodesp
Apr 04 2017 14:51
the idea of the forms it to provide model validation that conforms with the database model validation
Philip Eckert
@pae4557
Apr 04 2017 14:52
Right yeah, I guess I don't really need that in this case, I just don't want to 1) rewrite all that code and 2) have two versions of the same applet as that's twice as hard to maintain
Luis Sebastian Urrutia Fuentes
@LuisUrrutia
Apr 04 2017 16:01
Hi everyone, who lives in NYC?
Philip Eckert
@pae4557
Apr 04 2017 16:15
@theodesp yep, that was the winning strategy. I just subclassed the Model, set the meta attribute managed to False, then built an iterator in the view as such:
    fields = form.fields

                # initialize a dict and fill with form data
                _data ={}
                for key in fields.iterkeys():
                    _data[key] = form[key].value()
                _data.pop("savedTests") # doesn't belong in Model

                # initialize a Model instance from the dictionary
                instance = AnonFlowTest(**_data)
Theofanis Despoudis
@theodesp
Apr 04 2017 16:20
Yes otherwise it will fail to save
Roel
@roelzkie15
Apr 04 2017 16:56
Is there still no support for getting pks on bulk_create() with mysql?