mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixes #1812 -- Added model validity checks to ensure that models.py exists, and has been successfully imported for all INSTALLED_APPS. Previous behaviour was to silently ignore empty/problem models, which resulted in the display of an admin page that doesn't display a supposedly installed model. Thanks to Ian Holsman for the original report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3201 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -803,9 +803,9 @@ class ModelErrorCollection:
|
||||
self.errors = []
|
||||
self.outfile = outfile
|
||||
|
||||
def add(self, opts, error):
|
||||
self.errors.append((opts, error))
|
||||
self.outfile.write(style.ERROR("%s.%s: %s\n" % (opts.app_label, opts.module_name, error)))
|
||||
def add(self, context, error):
|
||||
self.errors.append((context, error))
|
||||
self.outfile.write(style.ERROR("%s: %s\n" % (context, error)))
|
||||
|
||||
def get_validation_errors(outfile, app=None):
|
||||
"""
|
||||
@@ -814,9 +814,14 @@ def get_validation_errors(outfile, app=None):
|
||||
Returns number of errors.
|
||||
"""
|
||||
from django.db import models
|
||||
from django.db.models.loading import get_app_errors
|
||||
from django.db.models.fields.related import RelatedObject
|
||||
|
||||
e = ModelErrorCollection(outfile)
|
||||
|
||||
for (app_name, error) in get_app_errors().items():
|
||||
e.add(app_name, error)
|
||||
|
||||
for cls in models.get_models(app):
|
||||
opts = cls._meta
|
||||
|
||||
|
||||
Reference in New Issue
Block a user