Ticket #992 (accepted defect)

Opened 2 years ago

Last modified 2 years ago

Primary Key: SlugField to CharField

Reported by: guettli Owned by: andrew
Priority: minor Milestone: 1.0
Component: migrations Version: unknown
Keywords: Cc: hv@…


I changed a SlugField? to CharField? of a primary key.

  class EmailSender(models.Model):
-    id=models.SlugField(primary_key=True)
+    id=models.CharField(primary_key=True, max_length=50, validators=[RegexValidator(r'^[a-zA-Z0-9_.-]+$')])

The migration created with --auto looks like this:

class Migration(SchemaMigration):

     def forwards(self, orm):

         # Changing field ''
         db.alter_column('modwork_emailsender', 'id','django.db.models.fields.CharField')(max_length=50,

         # Removing index on 'EmailSender', fields ['id']
         db.delete_index('modwork_emailsender', ['id'])

{{{ psql \d modwork_emailsender
modwork_tbz_d=> \d modwork_emailsender

Table "public.modwork_emailsender"

Column | Type | Modifiers

id | character varying(50) | not null
email | character varying(75) | not null
footer | text |


"modwork_emailsender_pkey" PRIMARY KEY, btree (id)
"modwork_emailsender_email_uniq" UNIQUE, btree (email)


2012-01-13 10:04:36 generic: DEBUG south execute "DROP INDEX "modwork_emailsender_id"" with params "[]"
django.db.utils.DatabaseError?: ERROR: Index »modwork_emailsender_id« does not exist

I removed the "delete_index()" and the migration was successfull.

south version:

hg summary
parent: 997:fcf464bd036f tip
 Fixed the timezone handling by simply converting the timezone aware datetime object into a naive version with the help of the default timezone (aka settings.TIME_ZONE).
branch: default
commit: 1 unknown (clean)
update: (current)



Change History

comment:1 Changed 2 years ago by andrew

  • Status changed from new to accepted
  • Milestone set to 1.0

comment:2 Changed 2 years ago by guettli

I am sorry, I could not find a way to fix the markup of the description.


Add a comment

Modify Ticket

as accepted

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.