Monday, March 2, 2015

Re: Django OperationalError

Hello James, sorry for not uploading mine answer on this mater, I was busy whit something else this day, ok now back to mine Operational Error I have got.
I tried to google some solution to this problem had no luck, and I did what have you told me.
I heave done some
python manage.py sqlflush

and that has gave me this output: 

(django17)04:20 ~/mineDjango$ python manage.py sqlflush BEGIN;DELETE FROM "django_admin_log";DELETE FROM "auth_permission";DELETE FROM "auth_group";DELETE FROM "auth_group_permissions";DELETE FROM "django_session";DELETE FROM "auth_user_groups";DELETE FROM "auth_user_user_permissions";DELETE FROM "account_emailaddress";DELETE FROM "django_site";DELETE FROM "profiles_profile";DELETE FROM "auth_user";DELETE FROM "profiles_userstripe";DELETE FROM "account_emailconfirmation";DELETE FROM "django_content_type";COMMIT;

Then I have done
python manage.py syncdb python manage.py migrate

Output of mine recreating tables are this:
(django17)04:20 ~/mineDjango$ python manage.py syncdbOperations to perform: Synchronize unmigrated apps: allauth, crispy_forms Apply all migrations: account, sessions, admin, sites, profiles, contenttypes, authSynchronizing apps without migrations: Creating tables... Installing custom SQL... Installing indexes...Running migrations: No migrations to apply.(django17)04:20 ~/mineDjango$ python manage.py migrateOperations to perform: Synchronize unmigrated apps: allauth, crispy_forms Apply all migrations: account, sessions, admin, sites, profiles, contenttypes, authSynchronizing apps without migrations: Creating tables... Installing custom SQL... Installing indexes...Running migrations: No migrations to apply.
Basically I have had no changes in mine attempt to drop and recreate tables in mine application.
The error is still there.
Error:
Environment:




Request Method: GET
Request URL: http://copser.pythonanywhere.com/


Django Version: 1.7.2
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',
 
'profiles',
 
'crispy_forms',
 
'django.contrib.sites',
 
'allauth',
 
'allauth.account',
 
'stripe')
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',
 
'django.middleware.clickjacking.XFrameOptionsMiddleware')




Template error:
In template /home/copser/static/templates/home.html, error at line 40
   
no such table: django_session
   
30 :  




   
31 : {% block content %}




   
32 :  <div class="row" style="margin-top: 60px">




   
33 :         <div class="col-md-4">




   
34 :          




   
35 :         </div>




   36 :         <div class="col-md-4">




   37 :          {# <a href="#"> <img class="img-responsive img-rounded" src="{% static 'img/
07.jpg' %}"/> </a> #}




   38 :        </div>




   39 :         <div class="col-md-4">




   40 :          {% if request.user.is_authenticated %}




   41 :             <h3>Hello {{ request.user }}</h3>




   42 :         {% else %}




   43 :           <form class="login" method="POST" action="{% url '
account_login' %}">




   44 :             <input type="hidden" name="csrfmiddlewaretoken" value="sczg1f8U4tWQRa8kgNJC1QsSBKAD9Lvw"> {% csrf_token %}




   45 :                 <div id="div_id_login" class="form-group"><label for="id_login" class="control-label  requiredField">




   46 :                     Login<span class="asteriskField">*</span></label><div class="controls "><input autofocus="autofocus" class="textinput textInput form-control" id="id_login" name="login" placeholder="Username or e-mail" type="text"> </div></div><div id="div_id_password" class="form-group"><label for="id_password" class="control-label  requiredField">




   47 :                     Password<span class="asteriskField">*</span></label><div class="controls "><input class="textinput textInput form-control" id="id_password" name="password" placeholder="Password" type="password"> </div></div><div class="form-group"><div id="div_id_remember" class="checkbox"><label for="id_remember" class=""><input class="checkboxinput checkbox" id="id_remember" name="remember" type="checkbox">




   48 :                     Remember Me




   49 :                     </label>




   50 :                 </div>




Traceback:
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/copser/mineDjango/profiles/views.py" in home
  7.     return render(request, template, context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/shortcuts.py" in render
  48.     return HttpResponse(loader.render_to_string(*args, **kwargs),
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  174.         return t.render(context_instance)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in render
  148.             return self._render(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in _render
  142.         return self.nodelist.render(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in render
  844.                 bit = self.render_node(node, context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  80.             return node.render(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  126.         return compiled_parent._render(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in _render
  142.         return self.nodelist.render(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in render
  844.                 bit = self.render_node(node, context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  80.             return node.render(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  65.                 result = block.nodelist.render(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in render
  844.                 bit = self.render_node(node, context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
  80.             return node.render(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  305.                     match = condition.eval(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/defaulttags.py" in eval
  898.         return self.value.resolve(context, ignore_failures=True)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in resolve
  596.                 obj = self.var.resolve(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in resolve
  734.             value = self._resolve_lookup(context)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/template/base.py" in _resolve_lookup
  764.                     current = current[bit]
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/utils/functional.py" in inner
  224.             self._setup()
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/utils/functional.py" in _setup
  357.         self._wrapped = self._setupfunc()
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in <lambda>
  22.         request.user = SimpleLazyObject(lambda: get_user(request))
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in get_user
  10.         request._cached_user = auth.get_user(request)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in get_user
  152.         user_id = request.session[SESSION_KEY]
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in __getitem__
  49.         return self._session[key]
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in _get_session
  175.                 self._session_cache = self.load()
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in load
  21.                 expire_date__gt=timezone.now()
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
  92.                 return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/models/query.py" in get
  351.         num = len(clone)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/models/query.py" in __len__
  122.         self._fetch_all()
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
  966.             self._result_cache = list(self.iterator())
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/models/query.py" in iterator
  265.         for row in compiler.results_iter():
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
  700.         for rows in self.execute_sql(MULTI):
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  786.             cursor.execute(sql, params)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  81.             return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)
File "/home/copser/.virtualenvs/django17/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
  485.         return Database.Cursor.execute(self, query, params)


Exception Type: OperationalError at /
Exception Value: no such table: django_session
Mine question is can you tell why is this happening, and why is there an error on line 40 in mine home.html page.
Is it maybe because I am using Sql3 insted of postgresql?
Tank you
Best
Petar
On Saturday, 28 February 2015 07:59:50 UTC+1, Petar Pilipovic wrote:
Hello James, will do but I am not at mine lap top atm, gona do it as soon as posible, tank you very much.

On Saturday, February 28, 2015, James Schneider <jrschneider83@gmail.com> wrote:
> Generally this happens when you don't apply the initial migration. Have you run 'python manage.py migrate' (assuming Django >= 1.7 since you mentioned making migrations) and if you have, what was the output? If you aren't sure, run it again as it shouldn't hurt anything.
>
> Check your database and make sure that the tables actually exist. If not, and there is no production data (assuming not based on the question), drop and recreate the DB to clear out any previously failed migration attempts and apply your migrations again using the command I specified. Capture the entire output of the command and paste it back to this list so that we can help more.
>
> -James
>
> On Feb 27, 2015 10:02 PM, "Petar Pilipovic" <iamrmot@gmail.com> wrote:
>>
>> Hello, I have manage to merge mine application to pythonanywhere.com. After I have done all the needed installing, uploading files, collecting static, making migrations to mine django application, I have experienced an OperationError saying:
>>
>> no such table: django_session
>> You can find the rest of mine question here on stackoverflow, Can someone help me over come this error, tank you.
>>  
>>
>> --
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/01f5c13c-5b7e-40ea-b98b-e37640e477df%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/MOsaEEDNyQg/unsubscribe.
> To unsubscribe from this group and all its topics, 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXfPuqKgQz89CVgaB07cf_Lwj%3DK-XcdtV9GK1EZ%3DQxMaQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53c159e0-864d-4de4-b3fc-8f111bffbeae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment