Strange django output - python

I've installed transifex - django application. Everything looked ok, but if I run:
./manage runserver 8000
I got error message (below). Since I'm inexpedience django user supposedly it is some easy error/mistake. Unfortunately, I'm unable to discover what the problem is.
Any clue will is appreciated!
Thanks, Tomas
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.3.1
Python Version: 2.7.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.comments',
'django.contrib.contenttypes',
'django.contrib.flatpages',
'django.contrib.humanize',
'django.contrib.markup',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.admindocs',
'staticfiles',
'notification',
'django_filters',
'django_sorting',
'south',
'tagging',
'tagging_autocomplete',
'pagination',
'piston',
'contact_form',
'ajax_select',
'threadedcomments',
'authority',
'haystack',
'social_auth',
'userena',
'guardian',
'easy_thumbnails',
'djcelery',
'djkombu',
'compressor',
'transifex.txcommon',
'transifex.languages',
'transifex.projects',
'transifex.releases',
'transifex.actionlog',
'transifex.txpermissions',
'transifex.teams',
'transifex.resources',
'django_addons',
'autofetch',
'charts',
'cla',
'copyright',
'datastores',
'gtranslate',
'helptext',
'jsonmap',
'locks',
'lotte',
'priorities',
'suggestions',
'timeline',
'trans_memory',
'txapps',
'txcron',
'txtestsuite',
'watches',
'webhooks',
'widgets']
Installed Middleware:
['django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django_sorting.middleware.SortingMiddleware',
'pagination.middleware.PaginationMiddleware',
'userena.middleware.UserenaLocaleMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware']
Traceback:
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/handlers /base.py" in get_response
101. request.path_info)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/urlresolvers.py" in resolve
252. sub_match = pattern.resolve(new_path)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django /core/urlresolvers.py" in resolve
252. sub_match = pattern.resolve(new_path)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/urlresolvers.py" in resolve
250. for pattern in self.url_patterns:
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/urlresolvers.py" in _get_url_patterns
279. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django /core/urlresolvers.py" in _get_urlconf_module
274. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/utils/importlib.py" in import_module
35. __import__(name)
File "/usr/lib/python2.7/site-packages/transifex-1.3.0devel-py2.7.egg/transifex/addons/cla/urls.py" in <module>
2. from transifex.projects.urls import PROJECT_URL
File "/usr/lib/python2.7/site-packages/transifex-1.3.0devel-py2.7.egg/transifex/projects/urls/__init__.py" in <module>
6. from transifex.projects.feeds import LatestProjects, ProjectFeed, ProjectTimelineFeed
File "/usr/lib/python2.7/site-packages/transifex-1.3.0devel-py2.7.egg/transifex/projects/feeds.py" in <module>
11. current_site = Site.objects.get_current()
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/contrib/sites/models.py" in get_current
25. current_site = self.get(pk=sid)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/manager.py" in get
132. return self.get_query_set().get(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/query.py" in get
349. % self.model._meta.object_name)
Exception Type: DoesNotExist at /
Exception Value: Site matching query does not exist.

First of all run python manage.py syncdb. Then check this query in django shell:
Site.objects.get(id=1)
if DoesNotExist error is raised create Site object manually:
Site.objects.create(name='example.com', domain='example.com')

Related

Permanently redirect to another url in django

I have an application in django 1.5. I would like to do redirect from one address to another - permanently. That is, I want to get an effect in which I will redirect:
from:
domain.com/team/event-2019/01-03-2019/827
to:
domain.com/team/event/01-03-2019/827 - (without 2019)
traceback:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/team/event/01-03-2019/827
Django Version: 1.5.4
Python Version: 2.7.12
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'haystack',
'users',
'adminextra',
'cms',
'pages',
'files',
'south',
'debug_toolbar',
'home',
'productions',
'contact',
'search')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'translation.middleware.LocaleMiddleware')
Traceback:
File "project/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "project/web/productions/views.py" in activity_details
284. return redirect(activity.get_absolute_url())
File "project/env/local/lib/python2.7/site-packages/django/shortcuts/__init__.py" in redirect
78. return redirect_class(resolve_url(to, *args, **kwargs))
File "project/env/local/lib/python2.7/site-packages/django/shortcuts/__init__.py" in resolve_url
151. return urlresolvers.reverse(to, args=args, kwargs=kwargs)
File "project/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
496. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "project/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
381. raise NoReverseMatch("Error importing '%s': %s." % (lookup_view, e))
Exception Type: NoReverseMatch at /team/event/01-03-2019/827
Exception Value: Error importing 'Content-Type: text/html; charset=utf-8
Location: /team/event/01-03-2019/827
': 'HttpResponseRedirect' object has no attribute 'rindex'.
I would like the event to be at the address: always under this url: domain.com/team/event/01-03-2019/827 and redirect on this url from: domain.com/team/event-2019/01-03-2019/827
Now I got an error:
'HttpResponseRedirect' object has no attribute 'find'
from this place:
if event_slug != activity.event.slug or str(date_url) != str(format_date(activity.date, "d-m-Y")):
return HttpResponsePermanentRedirect(activity.get_absolute_url())

Django TypeError on every page

I haven't touched the code on my app in weeks but i'm suddenly getting this exact same TypeError on every page, including Admin pages.
The last thing to happen was an update on a model to change a ForeignKey field, but I don't feel the two are related
Environment:
Request Method: GET
Request URL: http://10.0.0.161:8001/admin/
Django Version: 1.9.3
Python Version: 2.7.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'phones',
'jobs',
'profiles',
'freelancers',
'stock',
'finance']
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.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'profiles.middleware.UpdateLastActivityMiddleware']
Traceback:
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
174. response = self.process_exception_by_middleware(e, request)
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
172. response = response.render()
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/response.py" in render
160. self.content = self.rendered_content
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/response.py" in rendered_content
137. content = template.render(context, self._request)
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/backends/django.py" in render
95. return self.template.render(context)
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/base.py" in render
204. with context.bind_template(self):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py" in __enter__
17. return self.gen.next()
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/context.py" in bind_template
260. updates.update(processor(self.request))
Exception Type: TypeError at /admin/
Exception Value: 'NoneType' object is not iterable
Solved it by looking through some of my own context processors. I had one function that was returning None on a request (after changing an entry and having an empty queryset as a result).

'WSGIRequest' object has no attribute 'mode' after adding easy_thumbnails context_porcessors

I'm trying to add to easy_thumbnails context processors in my settings.py and got the next error:
WSGIRequest' object has no attribute 'mode'
Context processors config:
TEMPLATES = [
{
....
'OPTIONS': {
'context_processors': [
....
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters',
],
},
},
]
Traceback:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:10801/uk/
Django Version: 1.8.3
Python Version: 3.4.0
Installed Applications:
('djangocms_admin_style',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'cms',
'adminsortable2',
'treebeard',
'menus',
'sekizai',
'bootstrap3',
'solo',
'mptt',
'modeltranslation',
'easy_thumbnails',
'filer',
'meta',
'meta_mixin',
'djangocms_page_meta',
'djangocms_inherit',
'djangocms_picture',
'djangocms_file',
'djangocms_teaser',
'djangocms_video',
'djangocms_link',
'djangocms_snippet',
'djangocms_text_ckeditor',
'catalog')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware')
Traceback:
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
164. response = response.render()
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/response.py" in render
158. self.content = self.rendered_content
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/response.py" in rendered_content
135. content = template.render(context, self._request)
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/backends/django.py" in render
74. return self.template.render(context)
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/base.py" in render
208. with context.bind_template(self):
File "/usr/lib/python3.4/contextlib.py" in __enter__
59. return next(self.gen)
File "/home/catalog_cms/.env/lib/python3.4/site-packages/django/template/context.py" in bind_template
241. updates.update(processor(self.request))
File "/home/catalog_cms/.env/lib/python3.4/site-packages/easy_thumbnails/processors.py" in colorspace
64. if im.mode == 'I':
Exception Type: AttributeError at /uk/
Exception Value: 'WSGIRequest' object has no attribute 'mode'
Yes I'm using latest version of Pillow and easy_thumbnails.
I made a mistake, sorry. This is not context processors, but thumbnail processors. I just add:
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'easy_thumbnails.processors.filters',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
)
Now all working.

relation "account_emailaddress" does not exist - django error

I am following this tutorial to integrate social media login to my django project -
http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/
However after completing all the steps, when I try to login using facebook, I get this error
relation "account_emailaddress" does not exist
I don't understand what has gone wrong as all the DB modifications ran properly without errors.
Thanks in advance for your valuable answers.
Stacktrace
Environment:
Request Method: POST
Request URL: example.com/accounts/facebook/login/token/
Django Version: 1.6.6
Python Version: 2.7.4
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.admin',
'django.contrib.comments',
'south',
'registration',
'endless_pagination',
'links',
'south',
'debug_toolbar',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook')
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',
'debug_toolbar.middleware.DebugToolbarMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/providers/facebook/views.py" in login_by_token
76. ret = complete_social_login(request, login)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/helpers.py" in complete_social_login
119. return _complete_social_login(request, sociallogin)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/helpers.py" in _complete_social_login
130. ret = _process_signup(request, sociallogin)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/helpers.py" in _process_signup
26. sociallogin)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/adapter.py" in is_auto_signup_allowed
121. if email_address_exists(email):
File "/usr/local/lib/python2.7/dist-packages/allauth/utils.py" in email_address_exists
85. ret = emailaddresses.filter(email__iexact=email).exists()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in exists
515. return self.query.has_results(using=self.db)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in has_results
409. return bool(compiler.execute_sql(SINGLE))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
786. cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /accounts/facebook/login/token/
Exception Value: relation "account_emailaddress" does not exist
LINE 1: SELECT (1) AS "a" FROM "account_emailaddress" WHERE UPPER("a...
` ^
I figured out what the problem was. the allauth uses account app which doesn't support migrations as yet. Initially I had run
python manage.py migrate allauth.socialaccount
python manage.py migrate allauth.socialaccount.providers.facebook
Along with this we need to run the syncdb to complete the puzzle.
I think you added library providers after performing the first migration, this leaves pending migrations
run
python manage.py makemigrations allauth
and
python manage.py migrate allauth

Using a variable as a Model Lookup

I am passing in a variable to my view which is the name of the model to be queried against.
model_name = 'application'
assets = model_name.objects.all()
I get the error that unicode objects don't have objects properties, which makes sense as my debugger shows model_name = u'application' as expected (not as wanted).
I figure it has to do with *args and **kwargs (which I'm new to, but think I get) especially since elsewhere in my code I have:
role_set = ['primary_tech', 'primary_biz', 'backup_tech', 'backup_biz']
for role in role_set:
records_to_change = Item.objects.filter(**{role:old_owner})
which works fine. I tried every combination of * and ** I could think of, as well as wrapping it in a for model_name in [model_name] for consistency's sake, and everything gives me a syntax error. What am I missing?
Python 2.7, Django 1.5
Traceback:
Environment:
Request Method: GET
Request URL: http://localhost:8000/application/all/
Django Version: 1.6.1
Python Version: 2.7.2
Installed Applications:
('suit',
'south',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.redirects',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'rest_framework',
'ldap_sync',
'crispy_forms',
'ownership.apps.Catalog',
'ownership.apps.Assets',
'ownership.apps.Shared',
'ownership.libs.display',
'django_tables2',
'haystack',
'autocomplete_light',
'reversion',
'debug_toolbar')
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.contrib.redirects.middleware.RedirectFallbackMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'reversion.middleware.RevisionMiddleware',
'ownership.libs.shibboleth.CustomHeaderMiddleware',
'ownership.libs.middleware.LoginRequiredMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware')
Traceback:
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
90. response = middleware_method(request)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
40. __import__(name)
File "/Users/nicholsp/code/ownership/ownership/urls.py" in <module>
27. url(r'^', include('ownership.apps.Assets.urls'), name='home'),
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/conf/urls/__init__.py" in include
26. urlconf_module = import_module(urlconf_module)
File "/Users/nicholsp/.virtualenvs/ownership/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
40. __import__(name)
File "/Users/nicholsp/code/ownership/ownership/apps/Assets/urls.py" in <module>
3. import views
Exception Type: SyntaxError at /application/all/
Exception Value: invalid syntax (views.py, line 132)
from django.db.models import get_model
class MyModel(models.Model):
...
model_class = get_model('myapp', 'mymodel')
print model_class.__name__
'MyModel'
model_class.objects.all()
[<MyModel: 1>, <MyModel: 2>, <MyModel: 3>, ... ]

Categories

Resources