Ticket #1972: management.2.diff

File management.2.diff, 722 bytes (added by ubernostrum, 9 years ago)

Better patch; this puts it in model validation

  • management.py

     
    819819    e = ModelErrorCollection(outfile)
    820820    for cls in models.get_models(app):
    821821        opts = cls._meta
    822 
     822        # Check the model.
     823        if len(opts.fields) == 1 and opts.fields[0].get_internal_type() == 'AutoField':
     824            e.add(opts, "model '%s' in application '%s': A model must have at least one explicitly declared field." % (cls._meta.object_name, opts.app_label))
     825       
    823826        # Do field-specific validation.
    824827        for f in opts.fields:
    825828            if f.name == 'id' and not f.primary_key and opts.pk.name == 'id':
Back to Top