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. 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' 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') On Mar 10, 10:30 am, Tom Evans <tevans...@googlemail.com> wrote: > On Thu, Mar 10, 2011 at 3:18 PM, octopusgrabbus > > <old_road_f...@verizon.net> wrote: > > Could my problem be related to the fact that my views.py module first > > performs a get (sql select) on the table in question, and if the > > record is > > not there, then inserts it? > > No, it's probably because you are trying to set a datetime to a > string, and the string is in a format that django cannot grok. You > have failed to show any of the data or code, so all I can say about > the date format you are using is that it is wrong. > > You should be using a datetime.datetime object anyway, rather than > generating a string representation (badly). The entire purpose of > using an ORM is to avoid these issues, but you seem intent on working > around the ORM rather than through it. > > Cheers > > Tom -- 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.