-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
View function is shown incorrectly #1642
Comments
It would be interesting to see how you're instantiating the |
The view is just as described:
and it is linked in urls.py as:
Everything is in this virtualenv with Python 3.10.4:
if I look in
where (in my case) obj is: The first |
Interesting. I see that the module path is correct. |
Ah no, forget about that. We should do the same thing Django's admindocs app does, see |
yes, it seems to work: just replacing
with
fix my problem. |
Do you want to submit this as a pull request? I think the code looks fine; if the testsuite passes then we're good. |
I had ran a test with this change. And looks like all the tests related to this function fail:
|
Any update on this? It was a very useful feature.. |
Nobody took the time to submit a pull request until now, so there's no update yet, unfortunately :-/ |
@leandrodesouzadev are you working on this? |
Actually no, i wasn't quite sure if i could just make the changes on the tests so they pass. |
I think that makes sense. Let's see it and decide. |
I have implemented the feature and modified some tests to make it work. Now the code it's essentially the same as the quoted by @matthiask:
I wonder if there's any reason for us to keep this piece of code that's essentially the same as the django implementation.
For the first case, the implementation would be the following: def get_name_from_obj(obj: Any) -> str:
if hasattr(obj, "view_class"):
klass = obj.view_class
return f"{klass.__module__}.{klass.__qualname__}"
mod_name = obj.__module__
view_name = getattr(obj, "__qualname__", obj.__class__.__name__)
return mod_name + "." + view_name For the second case, the implementation would be the following: from django.contrib.admindocs.utils import get_view_name
# ...
def get_name_from_obj(obj: Any) -> str:
return get_view_name(obj) For the third case, i saw that are we're going to need to change the following lines to use the Waiting on your suggestions. Cheers. |
We could go the 3. route while keeping at least one unit test and it would probably be fine (we would be warned soon when the code is changed or removed in Django's main branch) Certainly 1. raises less questions about depending on undocumented functions in Django. I think 1. is clearly the better option. Please add a comment where the code is from so that we can copy the code again if anything breaks in the future :-) |
by upgrading django to version 4.0.2 view function on django-debug-toolbar doesn't display properly.
The expected string should be the class name: DashboardView not "backend_base.views.view".
"backend_base" is app name.
The class itself is very simple:
class DashboardView(LoginRequiredMixin, NavBarMixin, TemplateView):
template_name = 'dashboard.html'
backend_base.views.view
source of issue: mario-signorino on stackoverflow.
The text was updated successfully, but these errors were encountered: