REST framework Official Tutorial 6 bug

683 views
Skip to first unread message

YUN TANG

unread,
Nov 16, 2017, 8:17:54 AM11/16/17
to Django REST framework
I've been following the official tutorial until 6-viewsets-and-routers/

After I changed the urls.py to

router = DefaultRouter()
router.register(r'snippets', views.SnippetViewSet)
router.register(r'users', views.UserViewSet)

# The API URLs are now determined automatically by the router
# Additionally, we include the login URLs for the browsable API.
urlpatterns = [
url(r'^', include(router.urls)),
]

I got an error: 
TypeError: SnippetViewSet() received an invalid keyword 'renderer_class'


Please help. 

Xavier Ordoquy

unread,
Nov 16, 2017, 8:31:29 AM11/16/17
to django-res...@googlegroups.com
Hi,

The tutorial has no mention of renderer_class but has renderer_classes (note the extra ES at the end).

Regards,
Xavier.

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

YUN TANG

unread,
Nov 16, 2017, 8:43:07 AM11/16/17
to Django REST framework
hi Thanks for your reply. 

Now i've fixed that issue, and i'm getting a new one....

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000002C71F682BF8>
Traceback (most recent call last):
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\urls\resolvers.py", line 105, in _compile
    return re.compile(regex, re.UNICODE)
  File "C:\Tools\Anaconda3\envs\django-env\lib\re.py", line 233, in compile
    return _compile(pattern, flags)
  File "C:\Tools\Anaconda3\envs\django-env\lib\re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "C:\Tools\Anaconda3\envs\django-env\lib\sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "C:\Tools\Anaconda3\envs\django-env\lib\sre_parse.py", line 855, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "C:\Tools\Anaconda3\envs\django-env\lib\sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "C:\Tools\Anaconda3\envs\django-env\lib\sre_parse.py", line 759, in _parse
    raise source.error(err.msg, len(name) + 1) from None
sre_constants.error: redefinition of group name 'format' as group 2; was group 1 at position 40

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
    self.check(display_num_errors=True)
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\management\base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\management\base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\urls\resolvers.py", line 255, in check
    warnings.extend(check_resolver(pattern))
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\urls\resolvers.py", line 255, in check
    warnings.extend(check_resolver(pattern))
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\urls\resolvers.py", line 255, in check
    warnings.extend(check_resolver(pattern))
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\urls\resolvers.py", line 172, in check
    warnings = self._check_pattern_startswith_slash()
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\urls\resolvers.py", line 140, in _check_pattern_startswith_slash
    regex_pattern = self.regex.pattern
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\urls\resolvers.py", line 93, in __get__
    instance.__dict__['regex'] = self._compile(instance._regex)
  File "C:\Tools\Anaconda3\envs\django-env\lib\site-packages\django\urls\resolvers.py", line 109, in _compile
    (regex, six.text_type(e))
django.core.exceptions.ImproperlyConfigured: "^snippets\.(?P<format>[a-z0-9]+)/?\.(?P<format>[a-z0-9]+)/?$" is not a valid regular expression: redefinition of group name 'format' as group 2; was group 1 at position 40




在 2017年11月16日星期四 UTC+8下午9:31:29,Xavier Ordoquy写道:
Xavier.

To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsub...@googlegroups.com.

Felipe Rodrigues

unread,
Nov 17, 2017, 9:29:11 AM11/17/17
to django-res...@googlegroups.com
Xavier.

To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages