Environment:
Request Method: GET
Django Version: 1.5
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.linkedin',
'django.contrib.admin',
'django.contrib.admindocs')
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.7/dist-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
68. return self.dispatch(request, *args, **kwargs)
File "/var/www/sampleapp/allauth/account/views.py" in dispatch
41. **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in dispatch
86. return handler(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/edit.py" in get
155. return self.render_to_response(self.get_context_data(form=form))
File "/var/www/sampleapp/allauth/account/views.py" in get_context_data
67. "site": Site.objects.get_current(),
File "/usr/local/lib/python2.7/dist-packages/django/contrib/sites/models.py" in get_current
26. current_site = self.get(pk=sid)
File "/usr/local/lib/python2.7/dist-packages/django/d
b/models/manager.py" in get
143. return self.get_query_set().get(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in get
401. (self.model._meta.object_name, kwargs))
Exception Type: DoesNotExist at /accounts/login/
Exception Value: Site matching query does not exist. Lookup parameters were {'pk': 3}
I am new to django,
Help me to fix this issue?
I encountered this problem as well. I was going through the PyCharm Django guide. I fixed this by deleting my sqlite database file and running syncdb again. I don't know why it didn't work the first time, but it works now.
Also, it's probably worth downloading the SQLite Database Browser so that you can see the actual structure of your SQLite database. For this issue, you're interested in the django_site table. After I deleted my database file and reran syncdb, there was one row in this table.
This problem occurs because the first time that you executes python manage.py syncdb. isn't specified a main user. To solve it, delete all tables created by django in data base (with mysql, postgresql..) or delete the database.db (with sqlite3), Then run python manage.py syncdb one more time
Related
I have developed a wagtail site and that works just fine. It's just a simple blog. I was able to add a blog index page and blog posts under them. Hover recently when try to add a new page it gives the error
PathOverflow at /admin/pages/add/blog/blogpage/8/
Bellow is the complete traceback.
Environment:
Request Method: POST
Request URL: https://vikatakavi.info/admin/pages/add/blog/blogpage/8/
Django Version: 2.1.5
Python Version: 3.5.2
Installed Applications:
['home',
'search',
'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'modelcluster',
'taggit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'blog']
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',
'django.middleware.security.SecurityMiddleware',
'wagtail.core.middleware.SiteMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware']
Traceback:
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/wagtail/admin/urls/__init__.py" in wrapper
102. return view_func(request, *args, **kwargs)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/wagtail/admin/decorators.py" in decorated_view
34. return view_func(request, *args, **kwargs)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/wagtail/admin/views/pages.py" in create
224. parent_page.add_child(instance=page)
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/treebeard/mp_tree.py" in add_child
1013. return MP_AddChildHandler(self, **kwargs).process()
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/treebeard/mp_tree.py" in process
387. newobj.path = self.node.get_last_child()._inc_path()
File "/home/ubuntu/projects/blogger/env/lib/python3.5/site-packages/treebeard/mp_tree.py" in _inc_path
1114. raise PathOverflow(_("Path Overflow from: '%s'" % (self.path, )))
Exception Type: PathOverflow at /admin/pages/add/blog/blogpage/8/
Exception Value: Path Overflow from: '000100010005ZZZZ'
I'm absolutely clueless on this.
To store a page's position in the page tree, Wagtail uses a technique called Materialized Path, which (in its standard settings) allows a maximum of 1679615 insertions at a particular point in the tree. It seems that you've hit this limit somehow. (The position at each point in the tree is represented as a 4-character alphanumeric code; the 'ZZZZ' as seen in the error message is the highest available code.)
You would run into this limit if you had >1.6 million blog posts, but obviously that's quite unlikely. A more likely possibility is that you've written an import or maintenance script that's performing a very large number of insertions or page movements - for example, if you had a script to randomly reorder pages, and you were running it on a section with 10000 pages, you would run out of index numbers after running it ~160 times.
If you really can't avoid hitting this limit, then you can increase the limit to 60 million by adding the following code somewhere where it will run on startup:
from wagtail.core.models import Page
Page.steplen = 5
However, this won't work on an existing database - you'll need to delete and recreate your database after making this change - and it means the maximum possible depth of the tree is reduced from 63 levels to 50.
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()
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
I've learned python django since three days ago .
I wanted to remove an field from model, so I put the '#' front of that field.
Then I started the server again, but it gave me such an error message
'Userprofile matching query does not exist' (Userprofile is the model which I made.)
How can I solve this problem. I'm just a totally new to django, so even it's not easy to question my problem. If the clue is not enough, please tell me what other information is need.
p.s here is the total error message.
Environment:
Request Method: GET
Request URL: h ttp://localhost:8000/
Django Version: 1.6.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.admin',
'south',
'autocomplete_light',
'djcelery',
'asap_web',
'facebook',
'venue',
'notification',
'study',
'general',
'member',
'advertise')
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.7/dist-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/jaehoon/PycharmProjects/studysearch/asap_web/__init__.py" in __call__
89. return main()
File "/home/jaehoon/PycharmProjects/studysearch/asap_web/__init__.py" in main
25. return process_request()
File "/home/jaehoon/PycharmProjects/studysearch/asap_web/__init__.py" in process_request
53. return _call_proper_request_processor()
File "/home/jaehoon/PycharmProjects/studysearch/asap_web/__init__.py" in _call_proper_request_processor
77. return getattr(self, method_name)(request, *self.args, **kwargs)
File "/home/jaehoon/PycharmProjects/studysearch/general/views.py" in process_get_request
19. if user.is_authenticated() and user.get_profile().is_required_more_info:
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py" in get_profile
441. self._state.db).get(user__id__exact=self.id)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in get
307. self.model._meta.object_name)
Exception Type: DoesNotExist at /
Exception Value: UserProfile matching query does not exist.
The exception is DoesNotExist which is thrown when you use get to retrieve single instance but it does not exist. In your process_get_request view:
user.get_profile().is_required_more_info
is throwing this exception because there is no profile created for this user. Note that user.get_profile() is deprecated since django 1.5 and you should use OneToOne field or custom user model instead, from docs:
get_profile() Deprecated in Django 1.5: Deprecated since version 1.5:
With the introduction of custom User models, the use of
AUTH_PROFILE_MODULE to define a single profile model is no longer
supported. See the Django 1.5 release notes for more information.
I am trying to fetch information from linkedin but I keep getting the following error?
I have searched around but the fix I saw was only for those getting the error when using djangopiston. Can anyone help me fix this?
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/jobs/1/match/
Django Version: 1.3.1
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.flatpages',
'django.contrib.admin',
'django.contrib.staticfiles',
'compress',
'south',
'filer',
'easy_thumbnails',
'registration',
'socialregistration',
'socialregistration.contrib.facebook',
'socialregistration.contrib.twitter',
'socialregistration.contrib.linkedin',
'socialregistration.contrib.openid',
'privatebeta',
'api',
'profiles',
'jobs',
'misc']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'socialregistration.contrib.facebook.middleware.FacebookMiddleware',
'socialregistration.contrib.linkedin.middleware.LinkedInMiddleware',
'misc.middleware.SubdomainMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
Traceback:
File "/home/arlus/jobmatch/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/arlus/jobmatch/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
93. response = view_func(request, *args, **kwargs)
File "/home/arlus/jobmatch/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "jobs/views.py" in match
60. matches = linkedin_api.get_connections(fields=['headline', 'summary',]).encode('utf-8')
File "../lib/linkedin/linkedin.py" in get_connections
291. response = self._do_normal_query(raw_url)
File "../lib/linkedin/linkedin.py" in _do_normal_query
757. signature_dict, self._access_token_secret, method, update=False)
File "../lib/linkedin/linkedin.py" in _calc_signature
789. hashed = hmac.new(self._calc_key(token_secret), signature_base_string, sha)
File "/usr/lib/python2.7/hmac.py" in new
133. return HMAC(key, msg, digestmod)
File "/usr/lib/python2.7/hmac.py" in __init__
72. self.outer.update(key.translate(trans_5C))
Exception Type: TypeError at /jobs/1/match/
Exception Value: character mapping must return integer, None or unicode
Its hard to tell but somewhere, either in urls.py and views.py are matches you should check the type of object being passed. It may not have expected value.
For instance /jobs/1/match, 1 maybe expected to be int but turns out be be str.
maybe because the text is being entered as unicode, try key.encode.('UTF-8')