0

How can I change the field name of Django's autoincrement from id to something like tablename_id?

I want to do it in the model definition itself.

The autoincrement key is created automatically do there doesn't seem a way to set it via the db_column attribute.

vfclists
  • 19,193
  • 21
  • 73
  • 92
  • I solved it by usingAutoField and set the primary key.`tablename_id = models.AutoField(primary_key=True)` – vfclists May 23 '14 at 11:05

1 Answers1

0
class ModelTest(models.Model):
    tablename_id = models.AutoField(primary_key=True)

I hope I've helped.