Hi Ben,

Thanks for the change you suggested.

On Tuesday 28 April 2015 09:48:26 Ben L wrote:

>[paraphrase] An automatic primary key shouldn't be added to unmanaged models,
>[paraphrase] the current behavior where it is added is a bug

Please have a look at the documentation[1] -- it states clearly that each 
model requires a primary key field. Quite a lot of Django's behavior depends on 
it -- in particular, you cannot save an instance of a model without a primary 
key; of course, you cannot have another model point to it with an FK; etc.

So, the use case supported by your suggested fix -- an isolated table which the 
Django app never updates -- seems to be supported by raw queries; the 
potential for problems created by relaxing the requirement to have a PK, seems 
to outweigh the benefits by far. Thus, I don't think we should accept your 
suggestion.

Perhaps it may seem better to error out more gracefully when faced with 
unmanaged models with no explicit PK. However, that would lead to funny 
results when introspecting a schema which was, in fact, created by Django. 

If I've missed anything, please explain,

Shai.

[1] 
https://docs.djangoproject.com/en/1.8/topics/db/models/#automatic-primary-key-fields


Reply via email to