On Wed, Oct 22, 2008 at 11:53 AM, urukay <[EMAIL PROTECTED]> wrote:

> Hi,
>
> v got this error, tried almost everything to get it right, but no effect.
> Can anynone pls help me with that?
> It happens when i submit the form:
>
> class AddPartnerForm(WTForm):
>
>        def __init__( self, user,  *args, **kwargs ):
>                super( AddPartnerForm, self ).__init__( *args, **kwargs )
>                #create choices with empty value as default
>                CHOICES = [('', '---------'),]+ [(str(company.id), str(
> company.name)) for
> company in Company.objects.filter(Q(owner=user) | Q(editors=user))]
>                self.fields['companies']._set_choices(CHOICES)
>
>        ico = forms.IntegerField(label=_(u'ICO'), max_value=999999999)
>        name = forms.CharField(label=_(u'Company name'), max_length=50)
>        companies = forms.ChoiceField()
>

Here you've defined AddPartnerForm to take a first parameter of 'user' which
is used as a value to match in your Company filter.


> Company model is:
>
> class Company(AContact, ATag, ARating, AImage, ALog):
>    # owner of this recore - 'company admin'
>    owner = models.ForeignKey(User, verbose_name=_("owner"), blank=False,
> null=False)
>
>    name = models.CharField(_('name'), max_length=127)
>    company_form = models.CharField(_('company form'),max_length=6,
> choices=FORMS)
>    partners = models.ManyToManyField('Company', null=True, blank=True)
>

> and trace:
> Traceback:
> File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
> get_response
>  86.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "C:\Python25\lib\site-packages\django\contrib\auth\decorators.py" in
> __call__
>  67.             return self.view_func(request, *args, **kwargs)
> File "D:\Workspace\yau\py\company\views.py" in add_partner
>  262.          form = AddPartnerForm(request.POST)


Here you create an AddPartnerForm passing in request.POST as the first
parameter, so that's what gets assigned to your 'user' variable in
AddPartnerForm __init__.  That's the QueryDict you see referenced in the
ultimate exception.  Your Company filter is trying to match against
owner=request.POST, etc. which doesn't work.  You seem to have neglected to
pass in the real 'user' value you want to use.


>
> File "D:\Workspace\yau\py\company\forms.py" in __init__
>  187.          CHOICES = [('', '---------'),]+ [(str(company.id),
> str(company.name)) for company in Company.objects.filter(Q(owner=user) |
> Q(editors=user))]
> File "C:\Python25\lib\site-packages\django\db\models\query.py" in
> _result_iter
>  179.                 self._fill_cache()
> File "C:\Python25\lib\site-packages\django\db\models\query.py" in
> _fill_cache
>  612.                     self._result_cache.append(self._iter.next())
> File "C:\Python25\lib\site-packages\django\db\models\query.py" in iterator
>  269.         for row in self.query.results_iter():
> File "C:\Python25\lib\site-packages\django\db\models\sql\query.py" in
> results_iter
>  206.         for rows in self.execute_sql(MULTI):
> File "C:\Python25\lib\site-packages\django\db\models\sql\query.py" in
> execute_sql
>  1700.         cursor.execute(sql, params)
> File "C:\Python25\lib\site-packages\django\db\backends\util.py" in execute
>  19.             return self.cursor.execute(sql, params)
> File "C:\Python25\lib\site-packages\django\db\backends\mysql\base.py" in
> execute
>  83.             return self.cursor.execute(query, args)
> File "C:\Python25\lib\site-packages\MySQLdb\cursors.py" in execute
>  168.         if not self._defer_warnings: self._warning_check()
> File "C:\Python25\lib\site-packages\MySQLdb\cursors.py" in _warning_check
>  82.                     warn(w[-1], self.Warning, 3)
> File "C:\Python25\lib\warnings.py" in warn
>  62.                   globals)
> File "C:\Python25\lib\warnings.py" in warn_explicit
>  102.         raise message
>
> Exception Type: Warning at /company/9/add/partner/
> Exception Value: Truncated incorrect DOUBLE value: '<QueryDict: {u'ico':
> [u'9'], u'companies': [u'7'], u'name': [u'Uzivatelova'], u'submit': [u'Next
> =>']}>'
>
> I appreciate any help. Thanks!
>
>

--~--~---------~--~----~------------~-------~--~----~
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