# as\_view not working

**URL:** <https://forum.djangoproject.com/t/as-view-not-working/21460>\
**Category:** Forms & APIs\
**Created:** [June 8, 2023, 7:05pm UTC](https://forum.djangoproject.com/t/as-view-not-working/21460 "2023-06-08T19:05:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djuan](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@djuan](https://forum.djangoproject.com/u/djuan)\
**Post date:** [June 8, 2023, 7:05pm UTC](https://forum.djangoproject.com/t/as-view-not-working/21460/1 "2023-06-08T19:05:49Z")

</div>

here is urls.py

```auto
from django.urls import path
from . import views
from rest_framework.authtoken.views import obtain_auth_token
urlpatterns = [
    path('menu-items', views.MenuItemsView.as_view({'get': 'list'})),
    path('menu-items/<int:pk>', views.SingleMenuItemView.as_view()),
    path('secret/',views.secret),
    path('manager-view/',views.manager_view),
    path('api-auth-token/',obtain_auth_token),
    path('throttle-check/', views.throttle_check),
    path('throttle-check-auth/', views.throttle_check_auth),
]

```

here is error

```auto
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\threading.py", line 980, in _bootstrap_inner 
    self.run()
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs)
  File "C:\Users\\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\core\management\commands\runserver.py", line 133, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\core\management\base.py", line 485, in check
    all_issues = checks.run_checks(
  File "C:\Users\\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "C:\Users\l\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
    return check_method()
  File "C:\Users\\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\urls\resolvers.py", line 494, in check   
    for pattern in self.url_patterns:
  File "C:\Users\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\utils\functional.py", line 57, in __get__ res = instance. __dict__ [self.name] = self.func(instance)
  File "C:\Users\\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\urls\resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\l\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\utils\functional.py", line 57, in __get__ res = instance. __dict__ [self.name] = self.func(instance)
  File "C:\Users\l\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\urls\resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\importlib\ __init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\Desktop\Files\home\coder\project\LittleLemon\LittleLemon\urls.py", line 21, in <module>
    path('api/' ,include('LittleLemonDRF.urls')),
  File "C:\Users\\.virtualenvs\LittleLemon-Ga0zCWan\lib\site-packages\django\urls\conf.py", line 38, in include       
    urlconf_module = import_module(urlconf_module)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\lib\importlib\ __init__.py", line 127, in import_m return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\*Desktop\Files\home\coder\project\LittleLemon\LittleLemonDRF\urls.py", line 5, in <module>
    path('menu-items', views.MenuItemsView.as_view({'get': 'list'})),
TypeError: as_view() takes 1 positional argument but 2 were given

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 8, 2023, 7:56pm UTC](https://forum.djangoproject.com/t/as-view-not-working/21460/2 "2023-06-08T19:56:22Z")

</div>

First, when posting code (or templates or error messages) enclose the text between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep the text properly formatted. (I’ve taken the liberty of editing your original post, please remember to do this in the future.)

> [@djuan](#):
>
> `path('menu-items', views.MenuItemsView.as_view({'get': 'list'})),`

This is not a valid `path` statement as the error message is pointing out. Review the docs at [django.urls functions for use in URLconfs | Django documentation | Django](https://docs.djangoproject.com/en/4.2/ref/urls/#path) and [URL dispatcher | Django documentation | Django](https://docs.djangoproject.com/en/4.2/topics/http/urls/#passing-extra-options-to-view-functions)

---

<div class="post-metadata">

**Author:** ![djuan](https://avatars.discourse-cdn.com/v4/letter/d/a4c791/32.png) [@djuan](https://forum.djangoproject.com/u/djuan)\
**Post date:** [June 8, 2023, 8:06pm UTC](https://forum.djangoproject.com/t/as-view-not-working/21460/3 "2023-06-08T20:06:15Z")

</div>

thank you for your assistance and i will ensure to keep my posts formatted from now on 😄
