I converted my date, and it all works fine. Thanks for your help.

On Mar 10, 12:54 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Thu, Mar 10, 2011 at 5:46 PM, octopusgrabbus
>
>
>
> <old_road_f...@verizon.net> wrote:
> > I'm confused as to how this code isn't using the model?
>
> > Here's the model I'm using. The table is in a MySQL database.
> > class CsRemove(models.Model):
> >    action = models.CharField(max_length=3, db_column='Action') #
> > Field name made lowercase.
> >    endpointid = models.IntegerField(primary_key=True,
> > db_column='EndpointId') # Field name made lowercase.
> >    devicetype = models.IntegerField(primary_key=True,
> > db_column='DeviceType') # Field name made lowercase.
> >    channelnumber = models.IntegerField(primary_key=True,
> > db_column='ChannelNumber') # Field name made lowercase.
> >    actiondate = models.DateField(primary_key=True,
> > db_column='ActionDate') # Field name made lowercase.
> >    class Meta:
> >        db_table = u'cs_remove'
>
> > Here's the code extract.
>
> > This date, not a datetime, format works fine in other python code, and
> > it is a string in the form 2011-03-08 format.
>
> It 'works in other code' - talking directly to mysql though, right,
> using mysqldb and not using django's ORM? You are no longer using
> mysqldb, you are using django's ORM, and you must obey it's rules, not
> mysql's.
>
> Truthfully, if you are using django's ORM, you should be using the
> objects it expects, eg date or datetime. Your date format, I can't
> tell whether it is 'Y-m-d' or 'Y-d-m'. Using the proper python objects
> would resolve ambiguity.
>
>
>
> >   try:
> >                            temp_ept_id =
> > CsRemove.objects.get(endpointid=requested_serial_number)
> >                            errors.append('Endpoint and channel
> > already queued for removal.')
>
> >                        except ObjectDoesNotExist:
> >                            # element was not found - it is OK to add
> > to cs_remove
>
> >                            load_date = '0000-00-00'
>
> This isn't a valid date. MySQL will accept it just fine, but it isn't
> valid in many other databases, and its not valid in django.
>
>
>
> >                            inv_obj = \
> >                                    CsRemove(action='R', \
>
> > endpointid=request.POST.get('inv_id'), \
>
> > devicetype=request.POST.get('ept_type'), \
>
> > channelnumber=request.POST.get('ept_ch'), \
> >                                           actiondate=load_date)
>
> >                            inv_obj.save(force_insert=True)
> >                            errors.append('Endpoint ID queued for
> > customer synch removal')

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to