Monday, August 27, 2018

Re: TypeError at /users/login/ login() got an unexpected keyword argument 'template_name'

#Import auth views
from django.contrib.auth import views as auth_views
#Use the views in the url
path('login/', auth_views.LoginView.as_view(), name='login'),
Happy coding!

On Mon, Aug 27, 2018 at 6:29 PM Tim Vogt (Tim Vogt) <timtvogt@gmail.com> wrote:
Hi Jason, 
Thank !

my urls.py in /users looks like this

This is the error I get with amusement.

How to change the old import? I suppose this is the way. Because the admin is imported from django. 






"""Defines URL patterns for users"""

from django.conf.urls import url
from . import views
# from django.contrib.auth import login
from django.contrib.auth.views import LoginView

app_name='users'


urlpatterns = [
# Login page
url('login/', LoginView, {'template_name': 'users/login.html'}, name='login'),
# Logout page
url('logout/', views.logout_view, name='logout'),
]



TypeError at /users/login/

__init__() takes 1 positional argument but 2 were given
Request Method:GET
Request URL:http://localhost:8000/users/login/
Django Version:2.0.7
Exception Type:TypeError
Exception Value:
__init__() takes 1 positional argument but 2 were given
Exception Location:/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py in _get_response, line 126
Python Executable:/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Python Version:3.6.5
Python Path:
['/Users/timvogt/Software_projects/learning_log',   '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',   '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',   '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',   '/Users/timvogt/Library/Python/3.6/lib/python/site-packages',   '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']
Server time:Mon, 27 Aug 2018 15:26:32 +0000

Traceback Switch to copy-and-paste view

  • /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/exception.py in inner
    1.             response = get_response(request)
      ...
  • /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py in _get_response
    1.                 response = self.process_exception_by_middleware(e, request)
      ...
  • /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/handlers/base.py in _get_response
    1.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
      ...

Request information

USER

AnonymousUser

GET

No GET data

POST

No POST data

FILES

No FILES data

COOKIES

VariableValue
csrftoken
'zKJ7uZOTcHNiYr4arCV6YjzR36mq7Ie2HpK607EMlKDhQcxObqHBTFSRrtkyaNZa'
snipcart_order_token
'142952d7-baae-4ab2-b2b0-ac5462367122'
_xsrf
'2|878cf834|c449d16f85d12cdef7046b0ac6567a54|1534532218'
username-localhost-8888
'2|1:0|10:1534532218|23:username-localhost-8888|44:YWY3N2MyNDAxYzQ0NDI3NmIxNWY4ZjUyNTI5Y2Y4YTY=|060151f0b69a6428ef01d3516fe0550735f33337c8e205b9f59bf602134027e9'
_ga
'GA1.1.581090691.1515705617'
pretix_csrftoken
'4D01Mhbc4oN2AvqmkxKaDPdzh040pxwHykOr0hc5afYoMMWtYpFcukamsEO2j3lg'
__stripe_mid
'c72941fc-ac1e-4460-b838-5eeeec87b673'
Pycharm-77c83f85
'1f4c7cc4-a97c-4bdc-b2cc-4c190f485abd'

META

VariableValue
Apple_PubSub_Socket_Render
'/private/tmp/com.apple.launchd.v0QRbL5XFB/Render'
CONTENT_LENGTH
''
CONTENT_TYPE
'text/plain'
CSRF_COOKIE
'zKJ7uZOTcHNiYr4arCV6YjzR36mq7Ie2HpK607EMlKDhQcxObqHBTFSRrtkyaNZa'
DISPLAY
'/private/tmp/com.apple.launchd.n1qjsNP13q/org.macosforge.xquartz:0'
DJANGO_SETTINGS_MODULE
'learning_log.settings'
GATEWAY_INTERFACE
'CGI/1.1'
HOME
'/Users/timvogt'
HTTP_ACCEPT
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
HTTP_ACCEPT_ENCODING
'gzip, deflate'
HTTP_ACCEPT_LANGUAGE
'nl-nl'
HTTP_CONNECTION
'keep-alive'
HTTP_COOKIE
('csrftoken=zKJ7uZOTcHNiYr4arCV6YjzR36mq7Ie2HpK607EMlKDhQcxObqHBTFSRrtkyaNZa; '   'snipcart_order_token=142952d7-baae-4ab2-b2b0-ac5462367122; '   '_xsrf=2|878cf834|c449d16f85d12cdef7046b0ac6567a54|1534532218; '   'username-localhost-8888="2|1:0|10:1534532218|23:username-localhost-8888|44:YWY3N2MyNDAxYzQ0NDI3NmIxNWY4ZjUyNTI5Y2Y4YTY=|060151f0b69a6428ef01d3516fe0550735f33337c8e205b9f59bf602134027e9"; '   '_ga=GA1.1.581090691.1515705617; '   'pretix_csrftoken=4D01Mhbc4oN2AvqmkxKaDPdzh040pxwHykOr0hc5afYoMMWtYpFcukamsEO2j3lg; '   '__stripe_mid=c72941fc-ac1e-4460-b838-5eeeec87b673; '   'Pycharm-77c83f85=1f4c7cc4-a97c-4bdc-b2cc-4c190f485abd')
HTTP_HOST
'localhost:8000'
HTTP_REFERER
'http://localhost:8000/'
HTTP_UPGRADE_INSECURE_REQUESTS
'1'
HTTP_USER_AGENT
('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, '   'like Gecko) Version/11.1.2 Safari/605.1.15')
LANG
'nl_NL.UTF-8'
LOGNAME
'timvogt'
PATH
'/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:~/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Postgres.app/Contents/Versions/latest/bin'
PATH_INFO
'/users/login/'
PWD
'/Users/timvogt/Software_projects/learning_log'
QUERY_STRING
''
REMOTE_ADDR
'127.0.0.1'
REMOTE_HOST
''
REQUEST_METHOD
'GET'
RUN_MAIN
'true'
SCRIPT_NAME
''
SECURITYSESSIONID
'186a7'
SERVER_NAME
'1.0.0.127.in-addr.arpa'
SERVER_PORT
'8000'
SERVER_PROTOCOL
'HTTP/1.1'
SERVER_SOFTWARE
'WSGIServer/0.2'
SHELL
'/bin/bash'
SHLVL
'1'
SSH_AUTH_SOCK
'/private/tmp/com.apple.launchd.1AEql525ni/Listeners'
TERM
'xterm-256color'
TERM_PROGRAM
'Apple_Terminal'
TERM_PROGRAM_VERSION
'404'
TERM_SESSION_ID
'DF7EEBC0-6943-44C1-BF34-F96CAB314B94'
TMPDIR
'/var/folders/r7/mzwmw_kn2px58v7clw0vxy700000gn/T/'
TZ
'UTC'
USER
'timvogt'
VIRTUALENVWRAPPER_HOOK_DIR
'/Users/timvogt/virtualenvs'
VIRTUALENVWRAPPER_PROJECT_FILENAME
'.project'
VIRTUALENVWRAPPER_SCRIPT
'/Library/Frameworks/Python.framework/Versions/3.6/bin/virtualenvwrapper.sh'
VIRTUALENVWRAPPER_WORKON_CD
'1'
WORKON_HOME
'/Users/timvogt/virtualenvs'
XPC_FLAGS
'0x0'
XPC_SERVICE_NAME
'0'
_
'/Library/Frameworks/Python.framework/Versions/3.6/bin/python3'
__CF_USER_TEXT_ENCODING
'0x1F5:0x0:0x5'
__PYVENV_LAUNCHER__
'/Library/Frameworks/Python.framework/Versions/3.6/bin/python3'
wsgi.errors
<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
wsgi.file_wrapper
''
wsgi.input
<_io.BufferedReader name=6>
wsgi.multiprocess
False
wsgi.multithread
True
wsgi.run_once
False
wsgi.url_scheme
'http'
wsgi.version
(1, 0)

Settings

Using settings module learning_log.settings

SettingValue
ABSOLUTE_URL_OVERRIDES
{}
ADMINS
[]
ALLOWED_HOSTS
[]
APPEND_SLASH
True
AUTHENTICATION_BACKENDS
['django.contrib.auth.backends.ModelBackend']
AUTH_PASSWORD_VALIDATORS
'********************'
AUTH_USER_MODEL
'auth.User'
BASE_DIR
'/Users/timvogt/Software_projects/learning_log'
CACHES
{'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
CACHE_MIDDLEWARE_ALIAS
'default'
CACHE_MIDDLEWARE_KEY_PREFIX
'********************'
CACHE_MIDDLEWARE_SECONDS
600
CSRF_COOKIE_AGE
31449600
CSRF_COOKIE_DOMAIN
None
CSRF_COOKIE_HTTPONLY
False
CSRF_COOKIE_NAME
'csrftoken'
CSRF_COOKIE_PATH
'/'
CSRF_COOKIE_SECURE
False
CSRF_FAILURE_VIEW
'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME
'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS
[]
CSRF_USE_SESSIONS
False
DATABASES
{'default': {'ATOMIC_REQUESTS': False,               'AUTOCOMMIT': True,               'CONN_MAX_AGE': 0,               'ENGINE': 'django.db.backends.sqlite3',               'HOST': '',               'NAME': '/Users/timvogt/Software_projects/learning_log/db.sqlite3',               'OPTIONS': {},               'PASSWORD': '********************',               'PORT': '',               'TEST': {'CHARSET': None,                        'COLLATION': None,                        'MIRROR': None,                        'NAME': None},               'TIME_ZONE': None,               'USER': ''}}
DATABASE_ROUTERS
[]
DATA_UPLOAD_MAX_MEMORY_SIZE
2621440
DATA_UPLOAD_MAX_NUMBER_FIELDS
1000
DATETIME_FORMAT
'N j, Y, P'
DATETIME_INPUT_FORMATS
['%Y-%m-%d %H:%M:%S',   '%Y-%m-%d %H:%M:%S.%f',   '%Y-%m-%d %H:%M',   '%Y-%m-%d',   '%m/%d/%Y %H:%M:%S',   '%m/%d/%Y %H:%M:%S.%f',   '%m/%d/%Y %H:%M',   '%m/%d/%Y',   '%m/%d/%y %H:%M:%S',   '%m/%d/%y %H:%M:%S.%f',   '%m/%d/%y %H:%M',   '%m/%d/%y']
DATE_FORMAT
'N j, Y'
DATE_INPUT_FORMATS
['%Y-%m-%d',   '%m/%d/%Y',   '%m/%d/%y',   '%b %d %Y',   '%b %d, %Y',   '%d %b %Y',   '%d %b, %Y',   '%B %d %Y',   '%B %d, %Y',   '%d %B %Y',   '%d %B, %Y']
DEBUG
True
DEBUG_PROPAGATE_EXCEPTIONS
False
DECIMAL_SEPARATOR
'.'
DEFAULT_CHARSET
'utf-8'
DEFAULT_CONTENT_TYPE
'text/html'
DEFAULT_EXCEPTION_REPORTER_FILTER
'django.views.debug.SafeExceptionReporterFilter'
DEFAULT_FILE_STORAGE
'django.core.files.storage.FileSystemStorage'
DEFAULT_FROM_EMAIL
'webmaster@localhost'
DEFAULT_INDEX_TABLESPACE
''
DEFAULT_TABLESPACE
''
DISALLOWED_USER_AGENTS
[]
EMAIL_BACKEND
'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST
'localhost'
EMAIL_HOST_PASSWORD
'********************'
EMAIL_HOST_USER
''
EMAIL_PORT
25
EMAIL_SSL_CERTFILE
None
EMAIL_SSL_KEYFILE
'********************'
EMAIL_SUBJECT_PREFIX
'[Django] '
EMAIL_TIMEOUT
None
EMAIL_USE_LOCALTIME
False
EMAIL_USE_SSL
False
EMAIL_USE_TLS
False
FILE_CHARSET
'utf-8'
FILE_UPLOAD_DIRECTORY_PERMISSIONS
None
FILE_UPLOAD_HANDLERS
['django.core.files.uploadhandler.MemoryFileUploadHandler',   'django.core.files.uploadhandler.TemporaryFileUploadHandler']
FILE_UPLOAD_MAX_MEMORY_SIZE
2621440
FILE_UPLOAD_PERMISSIONS
None
FILE_UPLOAD_TEMP_DIR
None
FIRST_DAY_OF_WEEK
0
FIXTURE_DIRS
[]
FORCE_SCRIPT_NAME
None
FORMAT_MODULE_PATH
None
FORM_RENDERER
'django.forms.renderers.DjangoTemplates'
IGNORABLE_404_URLS
[]
INSTALLED_APPS
['django.contrib.admin',   'django.contrib.auth',   'django.contrib.contenttypes',   'django.contrib.sessions',   'django.contrib.messages',   'django.contrib.staticfiles',   'learning_logs',   'users']
INTERNAL_IPS
[]
LANGUAGES
[('af', 'Afrikaans'),   ('ar', 'Arabic'),   ('ast', 'Asturian'),   ('az', 'Azerbaijani'),   ('bg', 'Bulgarian'),   ('be', 'Belarusian'),   ('bn', 'Bengali'),   ('br', 'Breton'),   ('bs', 'Bosnian'),   ('ca', 'Catalan'),   ('cs', 'Czech'),   ('cy', 'Welsh'),   ('da', 'Danish'),   ('de', 'German'),   ('dsb', 'Lower Sorbian'),   ('el', 'Greek'),   ('en', 'English'),   ('en-au', 'Australian English'),   ('en-gb', 'British English'),   ('eo', 'Esperanto'),   ('es', 'Spanish'),   ('es-ar', 'Argentinian Spanish'),   ('es-co', 'Colombian Spanish'),   ('es-mx', 'Mexican Spanish'),   ('es-ni', 'Nicaraguan Spanish'),   ('es-ve', 'Venezuelan Spanish'),   ('et', 'Estonian'),   ('eu', 'Basque'),   ('fa', 'Persian'),   ('fi', 'Finnish'),   ('fr', 'French'),   ('fy', 'Frisian'),   ('ga', 'Irish'),   ('gd', 'Scottish Gaelic'),   ('gl', 'Galician'),   ('he', 'Hebrew'),   ('hi', 'Hindi'),   ('hr', 'Croatian'),   ('hsb', 'Upper Sorbian'),   ('hu', 'Hungarian'),   ('ia', 'Interlingua'),   ('id', 'Indonesian'),   ('io', 'Ido'),   ('is', 'Icelandic'),   ('it', 'Italian'),   ('ja', 'Japanese'),   ('ka', 'Georgian'),   ('kab', 'Kabyle'),   ('kk', 'Kazakh'),   ('km', 'Khmer'),   ('kn', 'Kannada'),   ('ko', 'Korean'),   ('lb', 'Luxembourgish'),   ('lt', 'Lithuanian'),   ('lv', 'Latvian'),   ('mk', 'Macedonian'),   ('ml', 'Malayalam'),   ('mn', 'Mongolian'),   ('mr', 'Marathi'),   ('my', 'Burmese'),   ('nb', 'Norwegian Bokmål'),   ('ne', 'Nepali'),   ('nl', 'Dutch'),   ('nn', 'Norwegian Nynorsk'),   ('os', 'Ossetic'),   ('pa', 'Punjabi'),   ('pl', 'Polish'),   ('pt', 'Portuguese'),   ('pt-br', 'Brazilian Portuguese'),   ('ro', 'Romanian'),   ('ru', 'Russian'),   ('sk', 'Slovak'),   ('sl', 'Slovenian'),   ('sq', 'Albanian'),   ('sr', 'Serbian'),   ('sr-latn', 'Serbian Latin'),   ('sv', 'Swedish'),   ('sw', 'Swahili'),   ('ta', 'Tamil'),   ('te', 'Telugu'),   ('th', 'Thai'),   ('tr', 'Turkish'),   ('tt', 'Tatar'),   ('udm', 'Udmurt'),   ('uk', 'Ukrainian'),   ('ur', 'Urdu'),   ('vi', 'Vietnamese'),   ('zh-hans', 'Simplified Chinese'),   ('zh-hant', 'Traditional Chinese')]
LANGUAGES_BIDI
['he', 'ar', 'fa', 'ur']
LANGUAGE_CODE
'en-us'
LANGUAGE_COOKIE_AGE
None
LANGUAGE_COOKIE_DOMAIN
None
LANGUAGE_COOKIE_NAME
'django_language'
LANGUAGE_COOKIE_PATH
'/'
LOCALE_PATHS
[]
LOGGING
{}
LOGGING_CONFIG
'logging.config.dictConfig'
LOGIN_REDIRECT_URL
'/accounts/profile/'
LOGIN_URL
'/accounts/login/'
LOGOUT_REDIRECT_URL
None
MANAGERS
[]
MEDIA_ROOT
''
MEDIA_URL
''
MESSAGE_STORAGE
'django.contrib.messages.storage.fallback.FallbackStorage'
MIDDLEWARE
['django.middleware.security.SecurityMiddleware',   'django.contrib.sessions.middleware.SessionMiddleware',   'django.middleware.common.CommonMiddleware',   'django.middleware.csrf.CsrfViewMiddleware',   'django.contrib.auth.middleware.AuthenticationMiddleware',   'django.contrib.messages.middleware.MessageMiddleware',   'django.middleware.clickjacking.XFrameOptionsMiddleware']
MIGRATION_MODULES
{}
MONTH_DAY_FORMAT
'F j'
NUMBER_GROUPING
0
PASSWORD_HASHERS
'********************'
PASSWORD_RESET_TIMEOUT_DAYS
'********************'
PREPEND_WWW
False
ROOT_URLCONF
'learning_log.urls'
SECRET_KEY
'********************'
SECURE_BROWSER_XSS_FILTER
False
SECURE_CONTENT_TYPE_NOSNIFF
False
SECURE_HSTS_INCLUDE_SUBDOMAINS
False
SECURE_HSTS_PRELOAD
False
SECURE_HSTS_SECONDS
0
SECURE_PROXY_SSL_HEADER
None
SECURE_REDIRECT_EXEMPT
[]
SECURE_SSL_HOST
None
SECURE_SSL_REDIRECT
False
SERVER_EMAIL
'root@localhost'
SESSION_CACHE_ALIAS
'default'
SESSION_COOKIE_AGE
1209600
SESSION_COOKIE_DOMAIN
None
SESSION_COOKIE_HTTPONLY


--
"The lion can't miss the hunt!"
https://kodenaut.github.io/

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACYP3VHqfSoxSCNk2bQ%2BKvN45sbQtP_tF0kyxU_NF-o3btjttA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment