This was answered in IRC, but for completeness, in case someone else
comes along this:

You can't use **new_data in a manipulator, as it's not a normal dict -
the resulting data was invalid, which triggered the bad query :)

On Mar 13, 8:39 am, "dbee" <[EMAIL PROTECTED]> wrote:
> I have a Customers model that I'd trying to add values to from an
> oldform custom form manipulator. However it keeps telling me that
> there's a ProgrammingError... ( seemingly a malformed SQL string ).
>
> Help.
>
> # Customers model
> class Customers (models.Model):
>         name = models.CharField(maxlength=100)
>         business_name = models.CharField(maxlength=40)
>         telephone = models.IntegerField(maxlength=50)
>         email = models.EmailField()
>         country = models.CharField(maxlength=5)
>         sms_enable = models.BooleanField()
>         join_date = models.DateField(default=datetime.now)
>         message = models.TextField(maxlength=100)
>
>         class Admin:
>                 pass
>
>         def __str__(self):
>                 return self.name
>
> # Custom form manipulator in views.py
> class JoinManipulator(forms.Manipulator):
>     def __init__(self):
>         self.fields = (
>             forms.TextField(field_name="name", is_required=True,
> length=20),
>             forms.TextField(field_name="business_name",
> is_required=True),
>             forms.IntegerField(field_name="telephone",
> is_required=True, length=40),
>             forms.EmailField(field_name="email", is_required=True),
>             forms.SelectField(field_name="country", is_required=True,
> choices=countries),
>             forms.CheckboxField(field_name="sms_enable"),
>             forms.LargeTextField(field_name="message",
> is_required=True),
>         )
>
>     def __str__(self):
>         return 'Join Manipulator'
>
>     def save(self, new_data):
>         new_customer = Customers(**new_data)
>         new_customer.save()
>         return new_customer
>
> # Programming Error
> #
> (1064, 'You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near \'),("\'Inter\'",),(\'35050505\',),("\'[EMAIL PROTECTED]'",),
> (\'0\',),\'2007-03-13\',("\'asdf\'"\' at line 1')
>
> # Mysql query
> 'INSERT INTO `flowerhour1_customers`
> (`name`,`business_name`,`telephone`,`email`,`sms_enable`,`join_date`,`message`,`country`)
> VALUES (("\'dara\'",),("\'Inter\'",),(\'35050505\',),("\'[EMAIL PROTECTED]
> \'",),(\'0\',),\'2007-03-13\',("\'asdf\'",),("\'AF\'",))'


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to