ViewDoesNotExist at /accounts/register/ (django-registration-me error) - django

I am currently working on a project which uses mongoengine and django. I am using django-registration-me to handle user registrations, but I am having problems after submitting the new user registration form.
The error I am receiving is:
"ViewDoesNotExist at /accounts/register/" "Tried settings in module
core.views. Error was: 'module' object has no attribute 'settings'"
It sends a verification email out fine though. I am new to django and mongoengine, so any help with this would be greatly appreciated.
The traceback is below.
Environment:
Request Method: POST Request URL:
http://dev.teamfit.us:8000/accounts/register/
Django Version: 1.3 beta 1 SVN-15207
Python Version: 2.6.6
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'registration']
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/src/django-trunk/django/core/handlers/base.py"
in get_response
111. response = callback(request,
*callback_args, **callback_kwargs)
File
"/usr/local/lib/python2.6/dist-packages/django_registration_me-0.7-py2.6.egg/registration/views.py"
in register
153. return HttpResponseRedirect(success_url or
reverse('registration_complete'))
File
"/usr/src/django-trunk/django/core/urlresolvers.py"
in reverse
390. *args, **kwargs)))
File
"/usr/src/django-trunk/django/core/urlresolvers.py"
in reverse
311. possibilities = self.reverse_dict.getlist(lookup_view)
File
"/usr/src/django-trunk/django/core/urlresolvers.py"
in _get_reverse_dict
228. self._populate()
File
"/usr/src/django-trunk/django/core/urlresolvers.py"
in _populate
219. lookups.appendlist(pattern.callback,
(bits, p_pattern))
File
"/usr/src/django-trunk/django/core/urlresolvers.py"
in _get_callback
169. raise ViewDoesNotExist("Tried %s in module
%s. Error was: %s" % (func_name,
mod_name, str(e)))
Exception Type: ViewDoesNotExist at
/accounts/register/
Exception Value: Tried settings in
module core.views. Error was: 'module'
object has no attribute 'settings'

I guess, you have
import settings
or some such variation in your code.
You should change it to:
from django.conf import settings
and it should work

Related

How generate a pdf file with django-wkhtmltopdf on IIS 7.5 - 8

I use django-wkhtmltopdf to generate pdfs in my webapp, Works fine using the django integrate server, but when I use IIS 7.5 or 8 gives me this error: WindowsError [Error 6] The handle is invalid
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8006/blabla/pdf/10/
Django Version: 1.8.5
Python Version: 2.7.10
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'NuevoTicket',
'crispy_forms',
'wkhtmltopdf',
'ckeditor',
'ckeditor_uploader')
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 "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
164. response = response.render()
File "C:\Python27\lib\site-packages\django\template\response.py" in render
158. self.content = self.rendered_content
File "C:\Python27\lib\site-packages\wkhtmltopdf\views.py" in rendered_content
78. cmd_options=cmd_options
File "C:\Python27\lib\site-packages\wkhtmltopdf\utils.py" in render_pdf_from_template
159. cmd_options=cmd_options)
File "C:\Python27\lib\site-packages\wkhtmltopdf\utils.py" in convert_to_pdf
121. return wkhtmltopdf(pages=[filename], **cmd_options)
File "C:\Python27\lib\site-packages\wkhtmltopdf\utils.py" in wkhtmltopdf
109. return check_output(ck_args, **ck_kwargs)
File "C:\Python27\lib\subprocess.py" in check_output
566. process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py" in __init__
702. errread, errwrite), to_close = self._get_handles(stdin, stdout, stderr)
File "C:\Python27\lib\subprocess.py" in _get_handles
857. errwrite = _subprocess.GetStdHandle(_subprocess.STD_ERROR_HANDLE)
Exception Type: WindowsError at /blabla/pdf/10/
Exception Value: 6 The handle is invalid
Finally got it, thank's to n1b0r. I have to update the check_out method in python27/lib/subprocess.py like this
from:
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
process = Popen(stdout=PIPE, *popenargs, **kwargs)
to:
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
kwargs.pop('stderr', None)
process = Popen(stdout=PIPE, stderr=PIPE, stdin=PIPE, *popenargs, **kwargs)
That make it works in IIS but gives an error if use the django integrate server.
I used to have the same problem. Add the option quiet to the pdfkit and also try to modify the file configuration.py from pdfkit
options = {'quiet': ''}
pdfkit.from_file('in.html', 'out.pdf',options = options)
configuration.py
from this:
self.wkhtmltopdf = subprocess.Popen(['where','wkhtmltopdf'],stdout=subprocess.PIPE).communicate()[0].strip()
to:
self.wkhtmltopdf = subprocess.Popen(['which','wkhtmltopdf'],stdin=subprocess.PIPE,stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0].strip()

ConnectionError in Djrill after upgrading to Mac OSX 10.10.5

I just upgraded to Mac OSX 10.10.5 today and now I get a ConnectionError every time I try to send an email locally in GAE using the djrill Django app.
Exception Type: ConnectionError
Exception Value: ('Connection aborted.', error(22, 'Invalid argument'))
I've received this error prior to 10.10.5, but included the following code at the top of my views.py as a workaround.
import imp
import os.path
from google.appengine.tools.devappserver2.python import sandbox
sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
# Use the system socket.
psocket = os.path.join(os.path.dirname(os.__file__), 'socket.py')
imp.load_source('socket', psocket)
But now if I attempt to execute the following block of code after upgrading to 10.10.5, I encounter the error.
msg = EmailMultiAlternatives(
to=['user#domain.com'],
subject='TEST',
from_email='Admin <admin#projectname.appspotmail.com>',
)
msg.template_name = "template-name"
msg.send()
Here's the full traceback:
Request Method: GET
Request URL: http://localhost:16080/
Django Version: 1.4.13
Python Version: 2.7.10
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'<projectapp>',
'djrill')
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 "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-1.4/django/core/handlers/base.py" in get_response
109. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/<username>/<projectname>/order_manager/views.py" in _decorated
53. return view_func(request)
File "/Users/<username>/<projectname>/order_manager/views.py" in select_job
102. msg.send()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-1.4/django/core/mail/message.py" in send
248. return self.get_connection(fail_silently).send_messages([self])
File "/Users/<username>/<projectname>/djrill/mail/backends/djrill.py" in send_messages
68. sent = self._send(message)
File "/Users/<username>/<projectname>/djrill/mail/backends/djrill.py" in _send
107. response = requests.post(api_url, data=json.dumps(api_params, cls=JSONDateUTCEncoder))
File "/Users/<username>/<projectname>/requests/api.py" in post
109. return request('post', url, data=data, json=json, **kwargs)
File "/Users/<username>/<projectname>/requests/api.py" in request
50. response = session.request(method=method, url=url, **kwargs)
File "/Users/<username>/<projectname>/requests/sessions.py" in request
470. resp = self.send(prep, **send_kwargs)
File "/Users/<username>/<projectname>/requests/sessions.py" in send
578. r = adapter.send(request, **kwargs)
File "/Users/<username>/<projectname>/requests/adapters.py" in send
410. raise ConnectionError(err, request=request)
Exception Type: ConnectionError at /
Exception Value: ('Connection aborted.', error(22, 'Invalid argument'))
I appreciate any advice on how to once again send emails from my GAE local server using djrill after upgrading to OSX 10.10.5. Thanks!
I was troubleshooting a seemingly unrelated issue and stumbled across a suitable workaround. I replaced the latest version of the python requests module in my App Engine project with version 2.3.

TypeError in Django after attempting to write data to MySQL using Django Models

I am trying to write data to MySQL DB using models in django but I am getting TypeError. I have failed to identify the problem. I have attached the errot summary, traceback and the lines of code generating the bug. Please help me identify the problem
TypeError at /httptester/670747/
'str' object is not callable
Request Method: POST Request URL: http://127.0.0.1:8000/httptester/670747/ Django Version: 1.5.12 Exception Type: TypeError Exception Value:
'str' object is not callable
Exception Location: /home/ronchino/deltasms/entry.py in handle, line 59 Python Executable: /home/ronchino/deltasms-venv/bin/python Python Version: 2.7.3 Python Path:
['/home/ronchino/deltasms', '/home/ronchino/deltasms-venv/lib/python2.7', '/home/ronchino/deltasms-venv/lib/python2.7/plat-linux2', '/home/ronchino/deltasms-venv/lib/python2.7/lib-tk', '/home/ronchino/deltasms-venv/lib/python2.7/lib-old', '/home/ronchino/deltasms-venv/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages']
Server time: Mon, 26 Jan 2015 10:14:12 -0600
TRACEBACK Environment:
Request Method: POST Request URL: http://127.0.0.1:8000/httptester/670747/
Django Version: 1.5.12 Python Version: 2.7.3 Installed Applications: ('model', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django_nose', 'django_tables2', 'selectable', 'south', 'rapidsms', 'rapidsms.backends.database', 'rapidsms.contrib.handlers', 'rapidsms.contrib.httptester', 'rapidsms.contrib.messagelog', 'rapidsms.contrib.messaging', 'rapidsms.contrib.registration', 'rapidsms.contrib.default') 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', 'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback: File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
113. response = callback(request, *callback_args, **callback_kwargs) File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
25. return view_func(request, *args, **kwargs) File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/rapidsms/contrib/httptester/views.py" in message_tester
70. storage.store_and_queue(identity, cd["text"]) File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/rapidsms/contrib/httptester/storage.py" in store_and_queue
39. receive(text, connection) File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/rapidsms/router/api.py" in receive
40. router.receive_incoming(message) File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/rapidsms/router/blocking/router.py" in receive_incoming
124. self.process_incoming(msg) File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/rapidsms/router/blocking/router.py" in process_incoming
135. continue_processing = self.process_incoming_phases(msg) File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/rapidsms/router/blocking/router.py" in process_incoming_phases
165. handled = func(msg) File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/rapidsms/contrib/handlers/app.py" in handle
33. if handler.dispatch(self.router, msg): File "/home/ronchino/deltasms-venv/local/lib/python2.7/site-packages/rapidsms/contrib/handlers/handlers/pattern.py" in dispatch
74. cls(router, msg).handle(*match.groups()) File "/home/ronchino/deltasms/entry.py" in handle
59. p2 = entry(full_name=fullname.title(), mobile_number=sender, address=address.title(), citytown=cityortown.title(), creation_datetime=date, combination=combination, entry_code=entryref)
Exception Type: TypeError at /httptester/670747/ Exception Value: 'str' object is not callable
CODE:
entry = '%32x' % random.getrandbits(32*5)
entryref = 'ENT' + entry[2] + entry [4] + entry[6] + entry[8] + entry [10] + entry[12] + entry[14] + entry [16] + entry[18] + entry[20]
#Add entry
try:
p2 = entry(full_name=fullname.title(), mobile_number=sender, address=address.title(), citytown=cityortown.title(), creation_datetime=date, combination=combination, entry_code=entryref)
p2.save()

Django registration error after switching interpreter to Python 2.78

I initially had python 3.4 installed with django 1.65. But i searched and found out Django registration doesn't work with python 3. So I downloaded python 2.78 and even uninstalled python 3.4.
However When i am on url http://www.localhost:8000/accounts/register/ and try to register a user an error comes up. It seems like its django registration is still reading my old virtual env linked to python 3.4 and its path. I have edited my environmental variable PATH to delete any Python 3.4 and replaced with Python 2.7. But still same error occurs. I'm new to web development. Sorry if I didn't provide enough detail or to little detail.
TypeError at /accounts/register/
Unicode-objects must be encoded before hashing
Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/register/
Django Version: 1.6.5
Exception Type: TypeError
Exception Value:
Unicode-objects must be encoded before hashing
Exception Location: C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\registration\models.py in create_profile, line 106
Python Executable: C:\Users\jasan\virtual_enc_matchmaker\Scripts\pythonw.exe
Python Version: 3.4.1
Python Path:
['C:\\Users\\jasan\\PycharmProjects\\matchmaker',
'C:\\Users\\jasan\\PycharmProjects\\matchmaker',
'C:\\WINDOWS\\SYSTEM32\\python34.zip',
'C:\\Python34\\DLLs',
'C:\\Python34\\lib',
'C:\\Python34',
'C:\\Users\\jasan\\virtual_enc_matchmaker',
'C:\\Users\\jasan\\virtual_enc_matchmaker\\lib\\site-packages']
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/register/
Django Version: 1.6.5
Python Version: 3.4.1
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'profiles',
'south',
'registration',
'PIL',
'stripe')
Installed Middleware:
('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\jasan\virtual_enc_matchmaker\lib\site-packages\django\core\handlers\base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\django\views\generic\base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\registration\views.py" in dispatch
79. return super(RegistrationView, self).dispatch(request, *args, **kwargs)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\django\views\generic\base.py" in dispatch
87. return handler(request, *args, **kwargs)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\registration\views.py" in post
35. return self.form_valid(request, form)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\registration\views.py" in form_valid
82. new_user = self.register(request, **form.cleaned_data)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\registration\backends\default\views.py" in register
80. password, site)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\django\db\transaction.py" in inner
431. return func(*args, **kwargs)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\registration\models.py" in create_inactive_user
88. registration_profile = self.create_profile(new_user)
File "C:\Users\jasan\virtual_enc_matchmaker\lib\site-packages\registration\models.py" in create_profile
106. salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
Exception Type: TypeError at /accounts/register/
Exception Value: Unicode-objects must be encoded before hashing

Some cache problems

I'm wondering if I can delete a cached content made in template cache. I want to delete it from my view. I have in my template {% cache 500 cache_name sites.number %}
Is it possible to delete all "cache_name" cached content within the view, for example when some action is made?
I want to use per-vie cache. I do all what is described, but when I call: #cache_page(3600, cache="cache_name") I get error:
Exception Type: ValueError Exception
Value: need more than 1 value to
unpack
(Below is the traceback)
What I want to achieve is to cache all my template block or view and have a possibility to delete all cache connected with it when some actions are made. Pagination is included
Traceback:
Environment:
Request Method: GET
Request URL: http://localhost:8000/portfolio/
Django Version: 1.3 beta 1 SVN-15661
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'apps.index']
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 "E:\Python\django\core\handlers\base.py" in get_response
101. request.path_info)
File "E:\Python\django\core\urlresolvers.py" in resolve
252. sub_match = pattern.resolve(new_path)
File "E:\Python\django\core\urlresolvers.py" in resolve
252. sub_match = pattern.resolve(new_path)
File "E:\Python\django\core\urlresolvers.py" in resolve
158. return ResolverMatch(self.callback, args, kwargs, self.name)
File "E:\Python\django\core\urlresolvers.py" in _get_callback
164. self._callback = get_callable(self._callback_str)
File "E:\Python\django\utils\functional.py" in wrapper
124. result = func(*args)
File "E:\Python\django\core\urlresolvers.py" in get_callable
91. lookup_view = getattr(import_module(mod_name), func_name)
File "E:\Python\django\utils\importlib.py" in import_module
35. __import__(name)
File "E:\Python\apps\index\views.py" in <module>
29. #cache_page(600, cache='my_cache')
File "E:\Python\django\views\decorators\cache.py" in cache_page
58. return decorator_from_middleware_with_args(CacheMiddleware)(cache_timeout=args[0], cache_alias=cache_alias, key_prefix=key_prefix)
File "E:\Python\django\utils\decorators.py" in _make_decorator
81. middleware = middleware_class(*m_args, **m_kwargs)
File "E:\Python\django\middleware\cache.py" in __init__
204. self.cache = get_cache(self.cache_alias, **cache_kwargs)
File "E:\Python\django\core\cache\__init__.py" in get_cache
173. backend, location, params = parse_backend_conf(backend, **kwargs)
File "E:\Python\django\core\cache\__init__.py" in parse_backend_conf
131. mod_path, cls_name = backend.rsplit('.', 1)
Exception Type: ValueError at /portfolio/
Exception Value: need more than 1 value to unpack
What version of Django are you using? The parameter "cache" is only available in the development version. If you're using Django 1.2, you can only use "key_prefix".
http://docs.djangoproject.com/en/1.2/topics/cache/
The cache middleware caches every page
that doesn't have GET or POST
parameters.