Hi Ma On 08/25/2015 07:46 AM, Marcin Nowak wrote: > Thanks for replies, Carl, Adam, Shai. > > But I think you're worrying too much for too many things. You're > trying to control everything, trying to replace automated tests with > system check framework, trying to block "invalid" operations, etc, > etc. This is bad way, IMO. > > Let's see a small example how system check framework works: > > 1. I'm adding custom field to user (by patching User models, don't > ask why - other ways does not work) > > class MyAppConfig(AppConfig): name = 'my app' > > def ready(self): from django.contrib.auth.models import User from > django.db import models > > User.add_to_class('is_verified', models.BooleanField(default=False)) > > 2. I'm adding new field to admin interface > > @admin.register(User) class MyUserAdmin(UserAdmin): [...] list_filter > = ('is_superuser', 'is_active', 'is_verified') [...] > > 3. Django raises an error: > > ERRORS: <class 'myapp.admin.MyUserAdmin'>: (admin.E116) The value of > 'list_filter[2]' refers to 'is_verified', which does not refer to a > Field. > > Which is not true!
I think likely the root problem here is that your monkeypatch is in a module which is not imported when validation runs. If I were you, I'd make sure that your `admin.py` imports whatever module does the monkeypatching, and then I'd expect this error to go away. > 4. I'm silencing E116: > > SILENCED_SYSTEM_CHECKS = ['admin.E116'] > > 5. Django starts, admin works (and new filter works also), but > runserver still prints out a false message: > > Performing system checks... > > System check identified some issues: > > ERRORS: <class 'myapp.admin.MyUserAdmin'>: (admin.E116) The value of > 'list_filter[2]' refers to 'is_verified', which does not refer to a > Field. > > I know that this is unbelievable, Carl, but the message *is > displayed!* And prints out untrue message at all... Yes, I guess it is by design that errors (as opposed to warnings) are still printed even if "silenced". I didn't realize that - I guess I've never tried to silence a system check error, just warnings. That seems like a bad design decision to me, and I think we should change it. Silenced should mean silenced. Carl -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/55DC80F7.50407%40oddbird.net. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature