B
B
Boldy2014-12-08 18:22:10
Django
Boldy, 2014-12-08 18:22:10

Why is primary_key not editable in django?

Available model

class TreeNode(MPTTModel):
    id = models.CharField(max_length=10, primary_key=True)
    itn = models.CharField(max_length=40, unique=True)

When trying to edit the id, it says that a TreeNode with this itn already exists, although it has not been edited. itn is edited without problems. What's the matter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Scherbakov, 2014-12-08
@Boldy

The primary key is not meant to be edited at all, and no one expects you to edit it. Any side effects may appear. Why do you need it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question