List Info

Thread: Django admin confuses '' with null on foreign char primary key




Django admin confuses '' with null on foreign char primary key
user name
2006-10-31 18:01:43
While we're on the subject of null vs '' (empty string),
here's a
perverse case:

class TestSlug(models.Model):
  sluggy=models.SlugField(maxlength=17,
primary_key=True,blank=True,null=False, editable=True)
  name=models.CharField(maxlength=40)
  def __str__(self): return "'%s': %s"
%(self.sluggy,self.name)
  class Admin: pass

class TestSlugRef(models.Model):
  testslug= models.ForeignKey(TestSlug, default=HOME_SLUG,
blank=True,
null=False)
  viewed_by = models.CharField(maxlength=40)
  class Admin: pass

Create some testslugs, give one a blank "sluggy"
primary key.

Create some TestSlugRefs- if you try selecting the testslug
with an
empty primary key, the admin says:
OperationalError at /admin/test/testslugref/2
(1263, "Column was set to data type implicit default;
NULL supplied for
NOT NULL column ...")

admin ought not be trying to use a null when the field is
explicitly
null=False...

tried to submit a ticket, got 'Askimet rejected spam'


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )