-
-
Notifications
You must be signed in to change notification settings - Fork 339
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
NameError: name 'silk_profile' is not defined #172
Comments
@coderbhupendra Can you provide a stacktrace outlining you error? At best, right now, I can suggest to make sure |
my setting.py SILKY_PYTHON_PROFILER = True
..
INSTALLED_APPS = [
..
'silk',
]
MIDDLEWARE = [..
'silk.middleware.SilkyMiddleware',
] Here is how am using @silk_profile in views.py class ItemSearchViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
serializer_class = ItemSearchSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
@silk_profile(name='get_queryset')
def get_queryset(self):
request = self.request
queryset = EmptySearchQuerySet()
if request.GET.get('q', ''):
query = request.GET.get('q', '')
return queryset On running my code it give following error: Unhandled exception in thread started by <function wrapper at 0x7f5a09aa4938>
Traceback (most recent call last):
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 313, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/berry/api/env/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 306, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/berry/api/products/products/urls.py", line 18, in <module>
from items import views
File "/home/berry/api/products/items/views.py", line 101, in <module>
class ItemSearchViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
File "/home/berry/api/products/items/views.py", line 105, in ItemSearchViewSet
@silk_profile(name='get_queryset') |
@coderbhupendra In this scenario, is the decorator imported at the top of the view file as so: from silk.profiling.profiler import silk_profile I am sure you do but wanted to make sure I covered that assumption. |
@avelis I wasnt importing this . bsc i didnt knew how to import it , thanks it workd now |
BTW: I also think the documentation and README are very unclear on this. |
do I need to add some extra code for adding @silk_profile
The text was updated successfully, but these errors were encountered: