id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 11936,Proxy models' names are too long for django.contrib.auth which causes weird test failures,ryszard,Charlie La Mothe,"When you call `SomeModel.objects.only('somefield')`, then the generated deferred proxy model class name may be too long for django.contrib.auth.models.Permission, resulting in DB warnings which are raised as an exception. This manifests itself if you use `only` in your tests cases. The just created proxy model will still be floating among the normal models and contrib.auth.management.create_permissions will try to create Permission objects, resulting in queries like INSERT INTO `auth_permission` (`name`, `content_type_id`, `codename`) VALUES (Can add episode_ deferred_air_date_art_large_art_medium_art_small_created_description_duration_free_available_free_channel_free_video_url_info_modified_number_parental_rating_released_season_streaming_available_subscription_id, 19, add_episode_deferred_air_date_art_large_art_medium_art_small_created_description_duration_free_available_free_channel_free_video_url_info_modified_number_parental_rating_released_season_streaming_available_subscription_id) which will cause the NEXT test case to fail. I was able to reproduce this on Linux, with Python 2.6, MySQL_python 1.2.3c1 and MySQL 5.0.51a (it may depend on how django reacts to MySQL warnings). I will attach a models.py and tests.py that allow to reproduce this bug. Potential solutions: django.db.models.get_models should not return proxies for deferred models, the deferred proxy models should have shorter names or their type some custom __repr__.",,closed,"Database layer (models, ORM)",1.1,,fixed,"test, only, deferred fields",ryszard.szopa+django@…,Unreviewed,1,0,0,0,0,0