Skip to content
This repository has been archived by the owner on Feb 27, 2021. It is now read-only.

no such table: background_task #14

Open
jayata opened this issue Jul 7, 2015 · 14 comments
Open

no such table: background_task #14

jayata opened this issue Jul 7, 2015 · 14 comments

Comments

@jayata
Copy link

jayata commented Jul 7, 2015

Hi, I'm very new at Django and all the 3rd party app world. I found yours and it seems very easy to use, I installed it, but when I ran an example had got this error "no such table: background_task". I notice that it have its own models.py file but after doing "$ sudo python setup.py install" in my database there is not a "background_task" table created, not even after doing "python manage.py makemigrations" or "syncdb", I'm afraid that I'm missing something. Hope you can help me.

@lilspikey
Copy link
Owner

Have you added background_task to your INSTALLED_APPS in your settings?

Without that Django won't no to include it when running syncdb.

On 7 July 2015 at 19:16, jayata notifications@github.com wrote:

Hi, I'm very new at Django and all the 3rd party app world. I found yours
and it seems very easy to use, I installed it, but when I ran an example
had got this error "no such table: background_task". I notice that it have
its own models.py file but after doing "$ sudo python setup.py install" in
my database there is not a "background_task" table created, not even after
doing "python manage.py makemigrations" or "syncdb", I'm afraid that I'm
missing something. Hope you can help me.


Reply to this email directly or view it on GitHub
#14.

http://psychicorigami.com/

@jayata
Copy link
Author

jayata commented Jul 8, 2015

Tanks a lot!! I knew I was missing something basic! Now the task is in the database, but never is executed???? my code is very simple, it just change the value of some variable, nothing else....

@background(schedule=5)
def check():
    #my code here

@jayata
Copy link
Author

jayata commented Jul 8, 2015

After running "python manage.py process_tasks" to process the scheduled tasks I got this stack trace:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 160, in run_task
    tasks.run_task(task.task_name, args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 44, in run_task
    task = self._tasks[task_name]
KeyError: u'main.views.check'

@lilspikey
Copy link
Owner

It looks like you've defined your task inside you views.py file?

This means that process_tasks can't find it. To ensure it can find it I'd
recommend putting it inside tasks.py. You might need to remove that old
one from the database too.

This should be covered in the readme:

https://github.com/lilspikey/django-background-task

On 8 July 2015 at 19:53, jayata notifications@github.com wrote:

After running "python manage.py process_tasks" to process the scheduled
tasks I got this stack trace:

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 160, in run_task
tasks.run_task(task.task_name, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 44, in run_task
task = self._tasks[task_name]
KeyError: u'main.views.check'


Reply to this email directly or view it on GitHub
#14 (comment)
.

http://psychicorigami.com/

@jayata
Copy link
Author

jayata commented Jul 9, 2015

Yes it was exactly that, sorry English is not my native language..., I really want to get your app working in my project! after your corrections every seems to be OK, but when executed process_tasks throws a warning saying that @transaction.autocommit was deprecated and it must be replaced by set_autocommit, so I did and reinstalled. Now there is no warnings, but mys task is never executed, not even with process_tasks. I saw this issue #10 and I noticed that the time in the db is not the same than the machine's. Besides when run process_tasks got this:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/management/commands/process_tasks.py", line 81, in handle
    if not tasks.run_next_task():
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 48, in run_next_task
    return self._runner.run_next_task(self)
  File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 173, in run_next_task
    task = self.get_task_to_run()
TypeError: 'NoneType' object is not callable

Thanks for your time...I appreciate it.

@lilspikey
Copy link
Owner

I think that error is because you have edited the source code and replace
@transation.autocommit with something that isn't actually a decorator.
That's not the right thing to do.

There is actually a pull request that's meant to be dealing with this:

#12

But it's not been merged in yet.

On 9 July 2015 at 15:34, jayata notifications@github.com wrote:

Yes it was exactly that, sorry English is not my native language..., I
really want to get your app working in my project! after your corrections
every seems to be OK, but when executed process_tasks throws a warning
saying that @transaction.autocommit was deprecated and it must be replaced
by set_autocommit, so I did and reinstalled. Now there is no warnings, but
mys task is never executed, not even with process_tasks. I saw this issue
#10 #10 and I
noticed that the time in the db is not the same than the machine's. Besides
when run process_tasks got this:

Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/init.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/init.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(_args, *_options)
File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/management/commands/process_tasks.py", line 81, in handle
if not tasks.run_next_task():
File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 48, in run_next_task
return self._runner.run_next_task(self)
File "/usr/local/lib/python2.7/dist-packages/django_background_task-0.1.8-py2.7.egg/background_task/tasks.py", line 173, in run_next_task
task = self.get_task_to_run()
TypeError: 'NoneType' object is not callable

Thanks for your time...I appreciate it.


Reply to this email directly or view it on GitHub
#14 (comment)
.

http://psychicorigami.com/

@jayata
Copy link
Author

jayata commented Jul 13, 2015

Thanks, this pull request was very helpful. It works just fine with "python manage.py process_tasks" but the time issue still (the 'run_at' field in the db is about 4 or 5 hours ahead), what should I do?

@lilspikey
Copy link
Owner

Have you got the right timezone set in your Django settings file?

Reviewing the code it should be calling the right functions to deal with
the timezone. It might be that it's storing the times in UTC, rather than
your local timezone?

On 13 July 2015 at 15:40, jayata notifications@github.com wrote:

Thanks, this pull request was very helpful. It works just fine with
"python manage.py process_tasks" but the time issue still (the 'run_at'
field in the db is about 4 or 5 hours ahead), what should I do?


Reply to this email directly or view it on GitHub
#14 (comment)
.

http://psychicorigami.com/

@jayata
Copy link
Author

jayata commented Jul 13, 2015

In my settings.py got this (defaults):

LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

I'm using Ubuntu and this is the result of the "$ date" command:
lun jul 13 15:18:16 CDT 2015
[CDT – Central Daylight Time / Central Daylight Saving Time (Daylight Saving Time)]

This is the task in the db:
bd

@matthewgo
Copy link

Hello @lilspikey , I'm still getting the error No Such Table: background_task even though I have "background_task" in my INSTALLED_APPS, what other possible reason might have caused it?

@lilspikey
Copy link
Owner

Have you run syncdb?
On 14 May 2016 13:35, "matthewgo" notifications@github.com wrote:

Hello @lilspikey https://github.com/lilspikey , I'm still getting the
error No Such Table: background_task even though I have "background_task"
in my INSTALLED_APPS, what other possible reason might have caused it?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#14 (comment)

@matthewgo
Copy link

Please disregard my comment, I reimplemented the entire sequence and now have other problems.

May I first ask what version in Python and Django is this compatible to? I'm using Python 3.4.2 and Django 1.9.6.

Now, what happened was I start receiving errors about package naming issues because apparently the name some import naming convention changed.

I'm doing the following step:

  1. Download the ZIP file, do a setup.py build and setup.py install.
  2. Add background_task to the INSTALLED_APPS
  3. Created tasks.py containing a method with @background annotation and the line inside the method is a print statement.
  4. Call the method in urls.py (just to make sure it will be called) (I think I'm doing something wrong here).
  5. In the command line, run 'python manage.py makemigrations'
    After this, I received the errors with the import naming conventions.

What steps am I doing wrong? Thanks for the help!

@matthewgo
Copy link

After I downloaded the fork version of this project here https://github.com/arteria/django-background-tasks, I am now back with my problem of No Such Table: background_task.

I'm guessing that since I am only referencing an installed app, my project does not know that it should be creating a background_task table for that app, hence outputting "No migrations to apply" when I called 'manage.py makemigrations'. Do you have an idea how to resolve this?

@lilspikey
Copy link
Owner

I’d take this up with the owners of that fork.

This project currently doesn’t support the latest version of Django. It’s also only meant for Python 2 - not Python 3.

I’m no longer using this project in production, so updates are unlikely for a while.

On 14 May 2016, at 17:55, matthewgo notifications@github.com wrote:

After I downloaded the fork version of this project here https://github.com/arteria/django-background-tasks https://github.com/arteria/django-background-tasks, I am now back with my problem of No Such Table: background_task.

I'm guessing that since I am only referencing an installed app, my project does not know that it should be creating a background_task table for that app, hence outputting "No migrations to apply" when I called 'manage.py makemigrations'. Do you have an idea how to resolve this?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #14 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants