Closed michaelmior closed 11 years ago
Just a note that there's no test for this right now. One option could be to get the verbose name for each model and construct the permission name as Django would to make sure it doesn't hit the limit.
Hi there. Thanks a lot for reporting, I will merge this pull request.
I just do not consider this a bug, but a test-fix, that is the reason I set it to 'enhancement'.
Regards
Well, if the app is added to INSTALLED_APPS
, this will cause syncdb
to fail. This doesn't happen only when running tests.
It's not picked up in the test environment since sqlite lets you pretty much insert anything anywhere. Anyway, thanks for the merge!
Oh, absolutely! So I agree, I will change the label! ;) Thanks for commenting!
Maybe a better solution is to generate a distribution package without models and tests, to avoid any similar problem. What do you think?
Seems like a lot of extra complexity. Personally I like to be able be able to just pip install foo
and have everything work and I'm not sure that's achievable in a clean way with a separate distribution package.
It would be nice not to have the models installed when not running tests anyway though. This ticket from the Django tracker suggests some ways of handling the problem of having models defined only for tests.
I like the approach @jphalip uses of modifying INSTALLED_APPS
during tests and then manually calling syncdb
.
Actually, I just realized that django_nose
will allow you to put models in any file (they suggest test_models.py
) and when it is imported in tests, the models will be created automatically. That seems like the cleanest solution.
I tried this out by just renaming models.py
to test_models.py
and it seems to work as expected. These seems like the cleanest solution IMO.
This avoids hitting the 50-character limit of automatically generated Django permission names.
Not sure if this issue occurs with older versions of Django, but in Django 1.5, the names generated for the default add, change, and delete permissions end up being too long for the 50 characters field in auth_permissions. I simply set
verbose_name
for each model to something a bit shorter.