I have a problem with django template. I made new template file in pycharm and in code i think all is good. But i have errno 13 permission denied. Other templates are working fine.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/Doggo/2/results/
Django Version: 1.11
Python Version: 3.6.1
Installed Applications:
['Doggo.apps.DoggoConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "C:\Python36-32\lib\site-packages\django\core\handlers\exception.py" in inner
41. response = get_response(request)
File "C:\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response
217. response = self.process_exception_by_middleware(e, request)
File "C:\Python36-32\lib\site-packages\django\core\handlers\base.py" in _get_response
215. response = response.render()
File "C:\Python36-32\lib\site-packages\django\template\response.py" in render
107. self.content = self.rendered_content
File "C:\Python36-32\lib\site-packages\django\template\response.py" in rendered_content
82. template = self.resolve_template(self.template_name)
File "C:\Python36-32\lib\site-packages\django\template\response.py" in resolve_template
64. return select_template(template, using=self.using)
File "C:\Python36-32\lib\site-packages\django\template\loader.py" in select_template
48. return engine.get_template(template_name)
File "C:\Python36-32\lib\site-packages\django\template\backends\django.py" in get_template
39. return Template(self.engine.get_template(template_name), self)
File "C:\Python36-32\lib\site-packages\django\template\engine.py" in get_template
162. template, origin = self.find_template(template_name)
File "C:\Python36-32\lib\site-packages\django\template\engine.py" in find_template
136. name, template_dirs=dirs, skip=skip,
File "C:\Python36-32\lib\site-packages\django\template\loaders\base.py" in get_template
38. contents = self.get_contents(origin)
File "C:\Python36-32\lib\site-packages\django\template\loaders\filesystem.py" in get_contents
28. with io.open(origin.name, encoding=self.engine.file_charset) as fp:
Exception Type: PermissionError at /Doggo/2/results/
Exception Value: [Errno 13] Permission denied: 'C:\\Users\\noob1_000\\PycharmProjects\\eWybory\\Doggo\\templates'
i think i have permission to this folder because other templates are working.
I'm working on windows 10
I would recommend to go through this-
Also , the view that you uses the template are also in the same directory as other views since you said that other views are able to access their templates ?
Let me know , if this solves your problem
Maybe you are just forgetting to indicate the template path (template / app/index.html) in the views.py.
Related
I am creating REST api, with Django Rest Framework, and first of all I have to give users the way to register. I saw django-rest-registration as easy way to make this, but when I did everything as is said in Quickstart, my terminal throws those errors:
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
?: (rest_registration.E001) RESET_PASSWORD_VERIFICATION_URL is not set
?: (rest_registration.E004) VERIFICATION_FROM_EMAIL is not set
System check identified 2 issues (0 silenced).
Here's my code:
settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_registration',
'app',
]
REST_REGISTRATION = {
'REGISTER_VERIFICATION_ENABLED': False,
'REGISTER_EMAIL_VERIFICATION_ENABLED': False,
'RESET_PASSWORD_VERIFICATION_ENABLED': False,
}
urlpatterns:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('app.urls')),
path('accounts/', include('rest_registration.api.urls')),
]
But, when I tried to change REST_REGISTRATION to this:
REST_REGISTRATION = {
'REGISTER_VERIFICATION_URL': 'https://frontend-host/verify-user/',
'RESET_PASSWORD_VERIFICATION_URL': 'https://frontend-host/reset-password/',
'REGISTER_EMAIL_VERIFICATION_URL': 'https://frontend-host/verify-email/',
'VERIFICATION_FROM_EMAIL': 'no-reply#example.com',
}
and I submitted the request, I saw another error:
ConnectionRefusedError at /accounts/register/
+ Traceback:
Environment:
Request Method: POST
Request URL: http://localhost:8000/accounts/register/
Django Version: 2.2.3
Python Version: 3.7.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_registration',
'app']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
495. response = self.handle_exception(exc)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in handle_exception
455. self.raise_uncaught_exception(exc)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
492. response = handler(request, *args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_framework/decorators.py" in handler
55. return func(*args, **kwargs)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/api/views/register.py" in register
96. send_verification_notification(user, signer, template_config)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/notifications/email.py" in send_verification_notification
24. send_notification(notification)
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/rest_registration/notifications/email.py" in send_notification
209. notification.send()
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/message.py" in send
291. return self.get_connection(fail_silently).send_messages([self])
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py" in send_messages
103. new_conn_created = self.open()
File "/home/fullnamedebian/.local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py" in open
63. self.connection = self.connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python3.7/smtplib.py" in __init__
251. (code, msg) = self.connect(host, port)
File "/usr/lib/python3.7/smtplib.py" in connect
336. self.sock = self._get_socket(host, port, self.timeout)
File "/usr/lib/python3.7/smtplib.py" in _get_socket
307. self.source_address)
File "/usr/lib/python3.7/socket.py" in create_connection
727. raise err
File "/usr/lib/python3.7/socket.py" in create_connection
716. sock.connect(sa)
Exception Type: ConnectionRefusedError at /accounts/register/
Exception Value: [Errno 111] Connection refused
I added email settings:
# Email settings
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 8000
And now when I submit post I just see this in terminal: [22/Sep/2019 14:44:54] "POST /accounts/register/ HTTP/1.1" 400 13646 (Its drawn with red font, if it matters). And webpage is loading infinitley.
ive just upgraded Django from 1.9 to 1.10. i run 1.10 in my test environment and ironed out any upgrade issues to make sure it all worked.
however when ive gone to do it on my live site and gone to load the home page i get the errors below
Environment:
Request Method: GET
Request URL: http://it.local.com/
Django Version: 1.10.5
Python Version: 2.7.5
Installed Applications:
('home.apps.HomeConfig',
'oncall.apps.OncallConfig',
'tools.apps.ToolsConfig',
'sites.apps.SitesConfig',
'maintenance.apps.MaintenanceConfig',
'service.apps.ServiceConfig',
'management.apps.ManagementConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'bootstrap_pagination',
'easy_thumbnails')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware')
Traceback:
File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
39. response = get_response(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in _legacy_get_response
249. response = self._get_response(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/infternal/home/views.py" in index
13. return render(request, 'home/index.html', {"user": user})
File "/usr/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render
49. context_instance = RequestContext(request, current_app=current_app)
Exception Type: TypeError at /
Exception Value: __init__() got an unexpected keyword argument 'current_app'
It looks like you haven't installed Django 1.10 properly. The line from the traceback context_instance = RequestContext(request, current_app=current_app) does not exist in Django 1.10. I would try uninstalling and reinstalling Django, and then restarting the server.
So I am trying to use django-excel: https://github.com/pyexcel/django-excel
and just simply export a certain model into xls. I set up the settings according to the documentation, but I got this error when running:
Exception at /calbase/export/sheet
Unexpected data type <class 'django.db.models.fields.files.FieldFile'>
Here is my views:
def export_data(request, atype):
if atype == "sheet":
return excel.make_response_from_a_table(
Equipment, 'xls', file_name="sheet")
elif atype == "book":
return excel.make_response_from_tables(
[Equipment, Calibration], 'xls', file_name="book")
elif atype == "custom":
equipment = Equipment.objects.get(slug='ide')
query_sets = Choice.objects.filter(equipment=equipment)
column_names = ['choice_text', 'id', 'votes']
return excel.make_response_from_query_sets(
query_sets,
column_names,
'xls',
file_name="custom"
)
else:
return HttpResponseBadRequest(
"Bad request. please put one of these " +
"in your url suffix: sheet, book or custom")
and when I tried to go
http://127.0.0.1:8000/calbase/export/sheet
it gives me the exception above.
By the way is there any good example using django-excel? I can't seem to run the one provided
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/calbase/export/sheet
Django Version: 1.10
Python Version: 3.5.2
Installed Applications:
['calbase.apps.CalbaseConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'haystack',
'whoosh',
'carton']
Installed 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']
Traceback:
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\exception.py" in inner
39. response = get_response(request)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\hansong.li\Documents\GitHub\equipCal\calbase\views.py" in export_data
97. Equipment, 'xls', file_name="sheet")
File "C:\Users\hansong.li\Documents\GitHub\equipCal\django_excel\__init__.py" in make_response_from_a_table
147. file_name=file_name, **keywords)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel_webio\__init__.py" in make_response
244. file_stream = pyexcel_instance.save_to_memory(file_type, None, **keywords)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel\sheets\sheet.py" in save_to_memory
114. self.save_to(out_source)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel\sheets\sheet.py" in save_to
79. source.write_data(self)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel\sources\file_source_output.py" in write_data
86. sheet, **self.keywords)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel\sources\renderer\_excel.py" in render_sheet_to_stream
35. **keywords)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel_io\io.py" in save_data
70. **keywords)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel_io\io.py" in store_data
91. writer.write(data)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel_io\book.py" in write
177. sheet_writer.write_array(incoming_dict[sheet_name])
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel_io\sheet.py" in write_array
82. self.write_row(row)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyexcel_xls\xls.py" in write_row
230. self.native_sheet.write(self.current_row, i, value)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\xlwt\Worksheet.py" in write
1033. self.row(r).write(c, label, style)
File "C:\Users\hansong.li\AppData\Local\Programs\Python\Python35-32\lib\site-packages\xlwt\Row.py" in write
263. raise Exception("Unexpected data type %r" % type(label))
Exception Type: Exception at /calbase/export/sheet
Exception Value: Unexpected data type <class 'django.db.models.fields.files.FieldFile'>
I am trying to do webservice calls with django views using Amara library.
However anytime I do import amara (by simply importing it!) and call a django view with it imported, I get such errors:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:4444/test
Django Version: 1.2.1
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'azula.epgdb',
'django_extensions']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
80. response = middleware_method(request)
File "/usr/local/lib/python2.6/dist-packages/django/middleware/common.py" in process_request
58. _is_valid_path("%s/" % request.path_info, urlconf)):
File "/usr/local/lib/python2.6/dist-packages/django/middleware/common.py" in _is_valid_path
143. urlresolvers.resolve(path, urlconf)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in resolve
301. return get_resolver(urlconf).resolve(path)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in resolve
216. sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in resolve
123. return self.callback, args, kwargs
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in _get_callback
129. self._callback = get_callable(self._callback_str)
File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py" in wrapper
124. result = func(*args)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py" in get_callable
56. lookup_view = getattr(import_module(mod_name), func_name)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py" in import_module
35. __import__(name)
File "/home/uluc/azula/epgdb/views.py" in <module>
4. from azula.epgdb.utils import EventSet
File "/home/uluc/azula/epgdb/utils.py" in <module>
6. import amara
File "/usr/lib/pymodules/python2.6/amara/__init__.py" in <module>
11. import binderytools
File "/usr/lib/pymodules/python2.6/amara/binderytools.py" in <module>
13. from Ft.Xml import InputSource
File "/usr/lib/python2.6/dist-packages/Ft/Xml/InputSource.py" in <module>
355. DefaultFactory = InputSourceFactory(catalog=GetDefaultCatalog())
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Catalog.py" in GetDefaultCatalog
579. catalog = Catalog(uri, quiet)
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Catalog.py" in __init__
95. self._parseXmlCat(data)
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Catalog.py" in _parseXmlCat
372. from Ft.Xml.Sax import CreateParser
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Sax.py" in <module>
242. class SaxPrinter(ContentHandler):
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Sax.py" in SaxPrinter
247. def __init__(self, printer=XmlPrinter(sys.stdout, 'utf-8')):
File "/usr/lib/python2.6/dist-packages/Ft/Xml/Lib/XmlPrinter.py" in __init__
39. self.stream = sw = cStreamWriter.StreamWriter(stream, encoding)
Exception Type: TypeError at /test
Exception Value: argument must have 'write' attribute
How can this be solved ? I tried this under either Debian Lenny & Ubuntu 10.04 yet via Django SVN version and Amara 1
I am suspicious of some character encoding problem.
Putting "WSGIRestrictStdout Off" to my apache fixed the issue as said in here.
I got the following error when calling the url in Django.
It's working before, I guess it's related with some accidental changes I made, but I have no idea what they are.
Thanks before for the help,
Robert
Environment:
Request Method: GET Request URL: http://localhost:8000/time/ Django Version: 1.2 Python Version: 2.6.1 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.admin', 'djlearn.books'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')
Traceback: File "/Library/Python/2.6/site-packages/django/core/handlers/base.py" in get_response
100. response = callback(request, *callback_args,
**callback_kwargs) File "/Users/rhenru/Workspace/django/djlearn/src/djlearn/../djlearn/views.py" in current_datetime
16. return render_to_response('current_datetime.html',{'current_date':now,}) File "/Library/Python/2.6/site-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs) File "/Library/Python/2.6/site-packages/django/template/loader.py" in render_to_string
181. t = get_template(template_name) File "/Library/Python/2.6/site-packages/django/template/loader.py" in get_template
157. template, origin = find_template(template_name) File "/Library/Python/2.6/site-packages/django/template/loader.py" in find_template
128. loader = find_template_loader(loader_name) File "/Library/Python/2.6/site-packages/django/template/loader.py" in find_template_loader
111. if not func.is_usable:
Exception Type: AttributeError at /time/ Exception Value: 'module' object has no attribute 'is_usable'
It looks like Django is looking for a usable template loader, but is finding something in settings.TEMPLATE_LOADERS that isn't honoring the template loader function protocol (described briefly here.)
Is it possible that one of your recent changes was to either settings.TEMPLATE_LOADERS or to a custom template loader? If the latter, your template function needs an is_usable attribute, presumably set to True.