Hi,

I just upgraded my two months old Django installation, MySQLdb was
already at the required level.

I have now the problem that MySQL-warnings come through and throw a
Warning exception.

The reason is that some smallint values are filled with empty strings
when a choice-Field got no selection. This was the case also before
the upgrade.
Because I set default=0 this shouldn't happen, it should insert 0
instead.

Here is one generated INSERT:

INSERT INTO `eh02_eh02fragebogen`
(`durchgang`,`bereichname`,`bereich_id`,
  `eh02user_id`,`loginname`,`timestamp`,`frage1`,`frage2`,`frage3`,
  `frage4`,`frage5`,`frage6`,`frage7`,`frage8`,`frage9`,`frage10_1`,
  `frage10_2`,`frage10_3`,`frage11`,`frage12`)
VALUES
(2,'intern','2','1','fte','2007-03-23','3','','','','','','','','',0,1,0,'',1)

Here is my model (part):

class EH02Fragebogen(models.Model):
    ##### Personendaten ############
    durchgang = models.SmallIntegerField('Durchgang', null=False, blank=False)
    bereichname   = models.CharField('Bereichname', maxlength=50, blank=False)
    bereich   = models.ForeignKey(Bereich)
    eh02user = models.ForeignKey(EH02User, blank=True)
    loginname = models.CharField('Login-Name', maxlength=5)
    timestamp = models.DateField("Timestamp", auto_now=True)
    ###### Fragenbereich #########
    WERTUNGS_CHOICES = (
        (1, 'trifft voll und ganz zu'),
        (2, 'trifft im Grossen und Ganzen zu'),
        (3, 'teils, teils'),
        (4, 'trifft weniger zu'),
        (5, 'trifft ganz und gar nicht zu'),
    )

    frage1 = models.SmallIntegerField('frage1', blank=True, default=0,
                       choices=WERTUNGS_CHOICES)


And here the generated table (part):

+-------------+-------------+------+-----+---------+----------------+
| Field       | Type        | Null | Key | Default | Extra          |
+-------------+-------------+------+-----+---------+----------------+
| id          | int(11)     | NO   | PRI | NULL    | auto_increment | 
| durchgang   | smallint(6) | NO   |     |         |                | 
| bereichname | varchar(50) | NO   |     |         |                | 
| bereich_id  | int(11)     | NO   | MUL |         |                | 
| eh02user_id | int(11)     | NO   | MUL |         |                | 
| loginname   | varchar(5)  | NO   |     |         |                | 
| timestamp   | date        | NO   |     |         |                | 
| frage1      | smallint(6) | NO   |     |         |                | 
...

Questions:

1. Why is the default value in the database not set to 0?
2. Why does the generic view not use the default value when inserting
   blank values? Instead data with a wrong type (string) is used.
3. How can I work around the situation (suppress warnings?)?

Regards, Frank

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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