It looks like the call to @api_view should be like this:
@api_view(['GET', 'POST'])
In other words, pass in a single list of the permitted HTTP methods. Docs here: https://www.django-rest-framework.org/api-guide/views/#api_view
-Jorge
On Thu, Oct 24, 2019 at 5:01 PM chiyabgs <chiyabgs@gmail.com> wrote:
Project was working fine on macos. Now trying to host on linux.--Getting this error on makemigrations / createsuperuser / runserver .....@api_view(['GET'], ['POST'])TypeError: api_view() takes from 0 to 1 positional arguments but 2 were given ( full trace below):Other projects with similar function based views was working fine on linux.Have no clue - no google / django community mentions.Any help appreciatedThanksException in thread django-main-thread:Traceback (most recent call last):File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line 916, in _bootstrap_innerself.run()File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line 864, in runself._target(*self._args, **self._kwargs)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapperfn(*args, **kwargs)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_runself.check(display_num_errors=True)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py", line 390, in checkinclude_deployment_checks=include_deployment_checks,File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py", line 377, in _run_checksreturn checks.run_checks(**kwargs)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/registry.py", line 72, in run_checksnew_errors = check(app_configs=app_configs)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_uniqueall_namespaces = _load_all_namespaces(resolver)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespacesurl_patterns = getattr(resolver, 'url_patterns', [])File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__res = instance.__dict__[self.name] = self.func(instance)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/resolvers.py", line 584, in url_patternspatterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__res = instance.__dict__[self.name] = self.func(instance)File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/resolvers.py", line 577, in urlconf_modulereturn import_module(self.urlconf_name)File "/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 994, in _gcd_importFile "<frozen importlib._bootstrap>", line 971, in _find_and_loadFile "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 665, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 678, in exec_moduleFile "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "/usr/..../drf_api/drf_api/urls.py", line 23, in <module>re_path(r'^api/', include(XYZApp.urls')),File "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/urls/conf.py", line 34, in includeurlconf_module = import_module(urlconf_module)File "/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 994, in _gcd_importFile "<frozen importlib._bootstrap>", line 971, in _find_and_loadFile "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 665, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 678, in exec_moduleFile "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "/usr/.........drf_api/XYZApp/urls.py", line 4, in <module>from .import viewsFile ""/usr/.........drf_api/XYZApp/views.py", line 161, in <module>@api_view(['GET'], ['POST'])TypeError: api_view() takes from 0 to 1 positional arguments but 2 were given
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0577b8aa-4903-4b5b-b3ed-3c0935bf1530%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANfN%3DK8-t_us1unD7QdG%3Dsd1JFJxiDqORq6DAGGbpYYJUYP%3Dfg%40mail.gmail.com.
No comments:
Post a Comment