Opened 16 years ago

Closed 16 years ago

#10350 closed (worksforme)

Model with one field and field is unique -> field data become pk

Reported by: laundro@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords: unique pk
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class Subscriber(models.Model):
    email = models.EmailField(unique = True)

>>> s = Subscriber(email = "test@test.be")
>>> s.save()
ValueError: invalid literal for int() with base 10: 'test@test.be'

It appears the email field is automatically being used as the pk field, where the Django docs specifically state that:
By default, Django gives each model the following field:
id = models.AutoField(primary_key=True)

(see http://docs.djangoproject.com/en/dev/topics/db/models/#id1).

Change History (2)

comment:1 by Alex Gaynor, 16 years ago

I'm not seeing this at all http://dpaste.com/1150/ (eventual exception is because I didn't create the table, you got an error before that point). Please try to provide some additional details as to what's going on otherwise I'm going to wontfix.

comment:2 by Alex Gaynor, 16 years ago

Resolution: worksforme
Status: newclosed

No new news on this front, marking as worksforme.

Note: See TracTickets for help on using tickets.
Back to Top