-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
rest_framework 3.10.0 - crash with runserver #6808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Due to this pull request #6762 ... |
UserAdmin is Django’s right? In which case we may need to revert... |
Looks like it does define search_fields. So are you using a custom user model and admin? If so, does adding search_fields like the error says fix it? |
Yes I use custom user model and custom admin model. But if I have to do it, it means that it's not backward compatible ... |
I don’t know if there’s any great options here. I guess we could do a runtime check for if search_fields is set on the user model, and only include it in the autocomplete list if it is? |
A small break, with an easy fix, between a minor version, especially that is caught by a system check is OK. The SemVer purists will scream but that's how we've always done it on DRF. BUT we should add a small clarification to the release notes. (If there's not one already.) |
Just to provide further information. If a custom admin site is used and the User model is not registered, the following error will occur:
I fixed it by registering my User model. |
Yes, that would be expected. TBH I think the system check does the best job here of explaining what’s needed. (We’d just he repeating the Django docs to try to cover it.) |
Just chiming in on this. It's breaking my stuff as well. Except, I'm not even doing The issue appears to resolve itself if I comment out a line from this file:
Kind of a bummer this happened. I do not understand what this is at all and why it's failing. |
Hi @loganknecht - any management command (runserver, migrate, etc..) should fail since this is causing a system check failure. You need to do either one of two things:
|
@rpkilby Thank you for taking the time to respond. I think my point of confusion for this is why does version In addition to that, why do I now have to do either one of those two things? That doesn't make sense why I have to unregister something I never registered before, or add a field I never used before? |
DRF doesn't use strict semantic versioning. The versioning scheme is slightly different, and the jump from 3.9.4 to 3.10 is considered a "medium" version release, which may contain breaking API changes. You can think of 3.9 and 3.10 as analogous to Django's "feature" releases.
You've likely enabled it unknowingly. If you're getting this error, then |
@rpkilby Again, Thank you for taking the time to respond. Is there somewhere I can read about |
No problem - this is useful feedback, as other users are likely to run into the same issue.
The django admin docs explain |
@rpkilby I think I it's really hard for me to understand what you've explained. I've read the documentation and I kind of understand what Does Django Rest Framework have to add the I think I understand the problem, but I don't have an admin configuration for my django project. What should I do to fix this? Does this mean I simply add:
I would like to politely express some frustration regarding this because it seems like I have to go back and account for changes because of DRF after the fact. And it would be nice to have a clear explanation in the form of documentation from DRF to understand why this information is needed for the DRF admin configurations, and why I have to change my user model to match that. Is there no way to opt-in to this? I do need to use the Additionally, for me this isn't a huge deal because my user model hasn't been formalized yet, but I imagine this is going to affect a lot of people who don't have the luxury of easily modifying their custom user model? Is this going to affect them as well? I have been under the impression that having to make changes to the user model after the fact is a hard thing to do. Thank you for all the work, and the responses. I really appreciate everything. |
I think this little change is doing more harm than good. Maybe it's better to revert it ... or to change something to do not force users to do something weird. Updating the doc is the simplest solution but the problem is still here. And please be careful before merging pull request, a lot of people use this awesome package and their works can be broken with thing like this. Thanks for all. |
But the system check shouldn't fire is django.contrib.admin is not in The usability benefits of autocomplete fields are worth the costs here. Anyone using the admin with a decent number of user records will benefit. The system check error messages are pretty clear. #6811 adds an extra explanatory note but the admin docs are the canonical source. This isn't a big enough issue to revert over. |
No, but it is beneficial when there are a large number of users in your database. Otherwise the token admin becomes unusable (rendering a select dropdown for 150k users is slow).
If you're not using the Django admin, you could also fix this by just removing
Of course. There are a few issues that intersect, and the result in this case is surprising/confusing.
The admin works via autodiscovery, and 3rd party apps generally self-register on discovery. It would be atypical for an app to provide admin classes and require projects to register them separately. Note that you're effectively opting in by having the
This doesn't require changing the user model - just the admin for the custom user model. |
Checklist
master
branch of Django REST framework.Steps to reproduce
python manage.py runserver 0.0.0.0:8080
Expected behavior
Not crash
Actual behavior
The text was updated successfully, but these errors were encountered: