Thanks Jorge , this is working fine on my local (mac) but failing on the linux m/c hence getting confused but fixing it seems to have done the trick -Thanks again for the response. my first attempt posting on a group :-)
BGS On Friday, October 25, 2019 at 5:58:13 AM UTC+5:30, jlgimeno71 wrote: > > 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 <[email protected] <javascript:>> > 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 appreciated >> Thanks >> >> >> Exception in thread django-main-thread: >> Traceback (most recent call last): >> File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line >> 916, in _bootstrap_inner >> self.run() >> File "/root/anaconda3/envs/py36latest/lib/python3.6/threading.py", line >> 864, in run >> self._target(*self._args, **self._kwargs) >> File >> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/utils/autoreload.py", >> >> line 54, in wrapper >> fn(*args, **kwargs) >> File >> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/commands/runserver.py", >> >> line 117, in inner_run >> self.check(display_num_errors=True) >> File >> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py", >> >> line 390, in check >> include_deployment_checks=include_deployment_checks, >> File >> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/management/base.py", >> >> line 377, in _run_checks >> return checks.run_checks(**kwargs) >> File >> "/root/anaconda3/envs/py36latest/lib/python3.6/site-packages/django/core/checks/registry.py", >> >> line 72, in run_checks >> new_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_unique >> all_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_namespaces >> url_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_patterns >> patterns = 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_module >> return import_module(self.urlconf_name) >> File >> "/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line >> 126, in import_module >> return _bootstrap._gcd_import(name[level:], package, level) >> File "<frozen importlib._bootstrap>", line 994, in _gcd_import >> File "<frozen importlib._bootstrap>", line 971, in _find_and_load >> File "<frozen importlib._bootstrap>", line 955, in >> _find_and_load_unlocked >> File "<frozen importlib._bootstrap>", line 665, in _load_unlocked >> File "<frozen importlib._bootstrap_external>", line 678, in exec_module >> File "<frozen importlib._bootstrap>", line 219, in >> _call_with_frames_removed >> File "/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 include >> urlconf_module = import_module(urlconf_module) >> File >> "/root/anaconda3/envs/py36latest/lib/python3.6/importlib/__init__.py", line >> 126, in import_module >> return _bootstrap._gcd_import(name[level:], package, level) >> File "<frozen importlib._bootstrap>", line 994, in _gcd_import >> File "<frozen importlib._bootstrap>", line 971, in _find_and_load >> File "<frozen importlib._bootstrap>", line 955, in >> _find_and_load_unlocked >> File "<frozen importlib._bootstrap>", line 665, in _load_unlocked >> File "<frozen importlib._bootstrap_external>", line 678, in exec_module >> File "<frozen importlib._bootstrap>", line 219, in >> _call_with_frames_removed >> File "/usr/.........drf_api/XYZApp/urls.py", line 4, in <module> >> from .import views >> File ""/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 [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/0577b8aa-4903-4b5b-b3ed-3c0935bf1530%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/0577b8aa-4903-4b5b-b3ed-3c0935bf1530%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/08fab532-8f7b-42fe-858e-57f96a2034a2%40googlegroups.com.

