How does Django decide what in the model will be assigned an _id, when generated automatically on ‘syncdb’? (from this tut https://docs.djangoproject.com/en/1.1/intro/tutorial01/)
Secondly, when I run a ‘p.save()’, how does Django assign the id=i number?
From the exact page you linked:
(In other words,
_idgets suffixed to anymodels.ForeignKey()fields.)Every model in Django has an
idfield that is specific to that model (which is whatp.idis, there). This is used when referencing a given item from that model. It’s called a “primary key”. It’s typically set via simply looking at what the highest current primary key is for that model, and then adding 1.For instance, the very first instance of a model you create will probably have id=1. The second would then have id=2, and so on.