Re: [flask] Best way to use Wtforms and MongoDB in Flask
- From:
- lynadge
- Date:
- 2012-06-17 @ 08:58
Hi,
for adding form content to mongodb it works perfect.
But when i try to make a edit form, it raise a TypeError. It is a
similar problem like in this thread:
http://groups.google.com/group/wtforms/browse_thread/thread/c5380381cdc8d304
The Problem lies in the DatetimeField. A spontaneous workaround is by
using a TextField but i think, when there exist a DatetimeField why
shouldn't i use it?..
Is there any approach for this scenario?
Am 10.06.2012 03:51, schrieb Simon Sapin:
> Le 08/06/2012 23:45, lynadge a écrit :
>> For Wtforms i use flask-wtforms. Works perfect for my needs.
>>
>> For MongoDB i use flask-pymongo, works also fine for my needs.
>>
>> But, how can i bring it together?
>
> Apparently PyMongo works with dictionaries.
>
> Once you have a validated Form object from WTForms, its 'data'
> attribute
> is a dict. You can either pass it directly to (Flask-)PyMongo or use
> some_other_dict.update(my_form.data)
>
> This is all well-documented API in WTForms:
>
> http://packages.python.org/WTForms/forms.html#the-form-class
>
> Regards,
Re: [flask] Best way to use Wtforms and MongoDB in Flask
- From:
- lynadge
- Date:
- 2012-06-17 @ 12:25
Hi,
for adding form content to mongodb it works perfect.
But when i try to make a edit form, it raise a TypeError. It is a
similar problem like in this thread:
http://groups.google.com/group/wtforms/browse_thread/thread/c5380381cdc8d304
The Problem lies in the DatetimeField. A spontaneous workaround is by
using a TextField but i think, when there exist a DatetimeField why
shouldn't i use it?..
Is there any approach for this scenario?
Am 10.06.2012 03:51, schrieb Simon Sapin:
> Le 08/06/2012 23:45, lynadge a écrit :
>> For Wtforms i use flask-wtforms. Works perfect for my needs.
>>
>> For MongoDB i use flask-pymongo, works also fine for my needs.
>>
>> But, how can i bring it together?
>
> Apparently PyMongo works with dictionaries.
>
> Once you have a validated Form object from WTForms, its 'data'
> attribute
> is a dict. You can either pass it directly to (Flask-)PyMongo or use
> some_other_dict.update(my_form.data)
>
> This is all well-documented API in WTForms:
>
> http://packages.python.org/WTForms/forms.html#the-form-class
>
> Regards,
Re: [flask] Best way to use Wtforms and MongoDB in Flask
- From:
- lynadge
- Date:
- 2012-06-22 @ 21:36
Ok, i solved this problem with a simple TextField. Not the best
workaround but it works for me...
Now i have a problem with wtforms. In my form i have a BooleanField and
i want to edit the Document/Object in my form. When i get the saved
Document/Object from mongoDB the booleanfield is set to 'False'. So, if
i put it in the form wtforms will set the BooleanField to 'True' but
thats wrong and it should be 'False'. If i delete the one entry in
MongoDB wtforms will set the BooleanField to false...but that is not the
solution i want to...
Has Anyone an idea for this problem?
regards, lynadge
Am 10.06.2012 03:51, schrieb Simon Sapin:
> Le 08/06/2012 23:45, lynadge a écrit :
>> For Wtforms i use flask-wtforms. Works perfect for my needs.
>>
>> For MongoDB i use flask-pymongo, works also fine for my needs.
>>
>> But, how can i bring it together?
>
> Apparently PyMongo works with dictionaries.
>
> Once you have a validated Form object from WTForms, its 'data'
> attribute
> is a dict. You can either pass it directly to (Flask-)PyMongo or use
> some_other_dict.update(my_form.data)
>
> This is all well-documented API in WTForms:
>
> http://packages.python.org/WTForms/forms.html#the-form-class
>
> Regards,
Re: [flask] Best way to use Wtforms and MongoDB in Flask
- From:
- lynadge
- Date:
- 2012-06-11 @ 07:54
I will try it in the next few days. The idea looks very awesome and
simple. :)
Am 10.06.2012 03:51, schrieb Simon Sapin:
> Le 08/06/2012 23:45, lynadge a écrit :
>> For Wtforms i use flask-wtforms. Works perfect for my needs.
>>
>> For MongoDB i use flask-pymongo, works also fine for my needs.
>>
>> But, how can i bring it together?
>
> Apparently PyMongo works with dictionaries.
>
> Once you have a validated Form object from WTForms, its 'data'
> attribute
> is a dict. You can either pass it directly to (Flask-)PyMongo or use
> some_other_dict.update(my_form.data)
>
> This is all well-documented API in WTForms:
>
> http://packages.python.org/WTForms/forms.html#the-form-class
>
> Regards,
Re: [flask] Best way to use Wtforms and MongoDB in Flask
- From:
- azwar akbar
- Date:
- 2012-06-11 @ 08:23
Hi lnadge, can you tell me your progress using WTForm with Flask + pyMongo?
I also use Flask + pyMongo and will use WTForm soon, so I need the advice.
Thank you.
On Mon, Jun 11, 2012 at 2:54 PM, lynadge <lynadge@barfooz.de> wrote:
> I will try it in the next few days. The idea looks very awesome and
> simple. :)
>
> Am 10.06.2012 03:51, schrieb Simon Sapin:
> > Le 08/06/2012 23:45, lynadge a écrit :
> >> For Wtforms i use flask-wtforms. Works perfect for my needs.
> >>
> >> For MongoDB i use flask-pymongo, works also fine for my needs.
> >>
> >> But, how can i bring it together?
> >
> > Apparently PyMongo works with dictionaries.
> >
> > Once you have a validated Form object from WTForms, its 'data'
> > attribute
> > is a dict. You can either pass it directly to (Flask-)PyMongo or use
> > some_other_dict.update(my_form.data)
> >
> > This is all well-documented API in WTForms:
> >
> > http://packages.python.org/WTForms/forms.html#the-form-class
> >
> > Regards,
>
>
--
regards,
Azwar Akbar
Re: [flask] Best way to use Wtforms and MongoDB in Flask
- From:
- lynadge
- Date:
- 2012-06-11 @ 09:15
Hi, i work on an flask skeleton for my needs. I hope i get it ready at
the end of the next weekend.
The current status you can find here:
https://github.com/haengebruegge/flaskeleton
Am 11.06.2012 09:23, schrieb azwar akbar:
> Hi lnadge, can you tell me your progress using WTForm with Flask +
> pyMongo?
> I also use Flask + pyMongo and will use WTForm soon, so I need the
> advice.
>
> Thank you.
>
> On Mon, Jun 11, 2012 at 2:54 PM, lynadge <lynadge@barfooz.de [2]>
> wrote:
>
>> I will try it in the next few days. The idea looks very awesome and
>> simple. :)
>>
>> Am 10.06.2012 03:51, schrieb Simon Sapin:
>>
>>> Le 08/06/2012 23:45, lynadge a écrit :
>> >> For Wtforms i use flask-wtforms. Works perfect for my needs.
>> >>
>> >> For MongoDB i use flask-pymongo, works also fine for my needs.
>> >>
>> >> But, how can i bring it together?
>> >
>> > Apparently PyMongo works with dictionaries.
>> >
>> > Once you have a validated Form object from WTForms, its 'data'
>> > attribute
>> > is a dict. You can either pass it directly to (Flask-)PyMongo or
>> use
>> > some_other_dict.update(my_form.data)
>> >
>> > This is all well-documented API in WTForms:
>> >
>> > http://packages.python.org/WTForms/forms.html#the-form-class [1]
>> >
>> > Regards,
Re: [flask] Best way to use Wtforms and MongoDB in Flask
- From:
- azwar akbar
- Date:
- 2012-06-11 @ 09:46
Hi, looked like very interesting... :-)
Thanks for your share...
Vielen dank.
On Mon, Jun 11, 2012 at 4:15 PM, lynadge <lynadge@barfooz.de> wrote:
> Hi, i work on an flask skeleton for my needs. I hope i get it ready at
> the end of the next weekend.
>
> The current status you can find here:
> https://github.com/haengebruegge/flaskeleton
>
> Am 11.06.2012 09:23, schrieb azwar akbar:
> > Hi lnadge, can you tell me your progress using WTForm with Flask +
> > pyMongo?
> > I also use Flask + pyMongo and will use WTForm soon, so I need the
> > advice.
> >
> > Thank you.
> >
> > On Mon, Jun 11, 2012 at 2:54 PM, lynadge <lynadge@barfooz.de [2]>
> > wrote:
> >
> >> I will try it in the next few days. The idea looks very awesome and
> >> simple. :)
> >>
> >> Am 10.06.2012 03:51, schrieb Simon Sapin:
> >>
> >>> Le 08/06/2012 23:45, lynadge a écrit :
> >> >> For Wtforms i use flask-wtforms. Works perfect for my needs.
> >> >>
> >> >> For MongoDB i use flask-pymongo, works also fine for my needs.
> >> >>
> >> >> But, how can i bring it together?
> >> >
> >> > Apparently PyMongo works with dictionaries.
> >> >
> >> > Once you have a validated Form object from WTForms, its 'data'
> >> > attribute
> >> > is a dict. You can either pass it directly to (Flask-)PyMongo or
> >> use
> >> > some_other_dict.update(my_form.data)
> >> >
> >> > This is all well-documented API in WTForms:
> >> >
> >> > http://packages.python.org/WTForms/forms.html#the-form-class [1]
> >> >
> >> > Regards,
>
>
--
regards,
Azwar Akbar
Re: [flask] Best way to use Wtforms and MongoDB in Flask
- From:
- lynadge
- Date:
- 2012-06-11 @ 09:49
Thanks and no problem. ;)
Am 11.06.2012 10:46, schrieb azwar akbar:
> Hi, looked like very interesting... :-)
> Thanks for your share...
>
> Vielen dank.
>
> On Mon, Jun 11, 2012 at 4:15 PM, lynadge <lynadge@barfooz.de [4]>
> wrote:
>
>> Hi, i work on an flask skeleton for my needs. I hope i get it ready
>> at
>> the end of the next weekend.
>>
>> The current status you can find here:
>> https://github.com/haengebruegge/flaskeleton [1]
>>
>> Am 11.06.2012 09:23, schrieb azwar akbar:
>>
>>> Hi lnadge, can you tell me your progress using WTForm with Flask +
>> > pyMongo?
>> > I also use Flask + pyMongo and will use WTForm soon, so I need
>> the
>> > advice.
>> >
>> > Thank you.
>> >
>> > On Mon, Jun 11, 2012 at 2:54 PM, lynadge <lynadge@barfooz.de [2]
>> [2]>
>>
>>> wrote:
>> >
>> >> I will try it in the next few days. The idea looks very awesome
>> and
>> >> simple. :)
>> >>
>> >> Am 10.06.2012 03:51, schrieb Simon Sapin:
>> >>
>> >>> Le 08/06/2012 23:45, lynadge a écrit :
>> >> >> For Wtforms i use flask-wtforms. Works perfect for my needs.
>> >> >>
>> >> >> For MongoDB i use flask-pymongo, works also fine for my
>> needs.
>> >> >>
>> >> >> But, how can i bring it together?
>> >> >
>> >> > Apparently PyMongo works with dictionaries.
>> >> >
>> >> > Once you have a validated Form object from WTForms, its 'data'
>> >> > attribute
>> >> > is a dict. You can either pass it directly to (Flask-)PyMongo
>> or
>> >> use
>> >> > some_other_dict.update(my_form.data)
>> >> >
>> >> > This is all well-documented API in WTForms:
>> >> >
>> >> > http://packages.python.org/WTForms/forms.html#the-form-class
>> [3] [1]
>> >> >
>> >> > Regards,