How to run a function in the background-Django - django

I want to run an API call after every 5 mins in the app. I want to generate a notification whenever new data is added to the database through the API.So to check this I need to run the task in background to make it a real time application.
How can I achieve this task in Django?
I am facing multiple errors while using django background_tasks so I don't want to use it. Celery is not compatible with windows. Is there any other option whose tutorial is available also

As you mentioned in your another question here ,
you previously have installed django-background-task instead of django-background-tasks [notice the difference between task and tasks]. So you have got ImportError: cannot import name 'background' from 'background_task'.
Later you installed the proper one i.e django-background-tasks and then you uninstalled django-background-task which also uninstalled some of the dependencies of django-background-tasks.
SOLUTION: Uninstall both packages first. Then pip install django-background-tasks

Related

Bitnami Django Stack - not importing modules

I just tried deploying my Django application on my windows machine using Bitnami's Django stack. However, when I try to access my project via localhost/myapp/, I get an error stating that I can't load my modules/python libraries. I checked via pip and I have these modules installed. It seems this error applies to all my modules/python libraries. How do I solve this? Thanks!
When you install the Bitnami Django Stack, it will ask you for changing Association Setting for Python with the following message:
"This option lets you change the Windows properties to associate the Python files to the new Python that are going to be installed. If you have your own Python you may want to disable this feature."
If you decided to use your Python instead of the one that is installed with the Stack, you have must ensure that you have installed Python in your system and all the modules and libraries are loaded, otherwise you won't be able to use any of them.

Django edit in place package installation

I am trying to utilize the package for editing html content in place and saving it into my database.
https://pypi.python.org/pypi/django-inplaceedit
I've never used Django before until this past week and am wondering how I can install this to be able to use it in my project. I've only been used to using pip install commands and can't seem to use that for this. Thanks.

Python Invoke tasks on a pip package

I'm working on a pip package for our company that we can hopefully install on your applications and have a set of invoke task that we run use locally on our machines. So far, creating a task is really simple but I want to know if it's possible to have invoke find tasks inside installed packages?
Thanks!
From invoke you can certainly use the Collection class to aggregate the tasks that you find. Not so sure there is auto-detecting.
github: invoke/collection.py

How do I handle DB model migrations in pip installable package

I am developing a Django app that can be installed via pip for use within a larger project.
I have DB models in this app. I plan to use South in case I need to do any migrations in future versions.
Should I make South an install requirement and then have the user manually run migration(s) or should I do it automatically in the setup.py?
Running migrations is a part of an application setup/startup routine, in my opinion it is out of the scope of installation.
If I was the user, I prefer one setup script can figure everything out. And it is not a complex function, why not do it automatically.

How apps installed at pip really works?

I'm new at django and i was looking for a wysiwyg and i fuond tinymce.
I installed at pip command line and i expect that create a folder at my folder project like a new app. It dont created no one folder but i did the next steps and for my surprise the app works fine at my project.
I want to know how this app really works at my project, in case im gonne deploy this project and how to deploy the app installed at pip or something like that.
My englhish is not good but i hope that was clear.
The applications, or libraries rather are copied directly inside one of the folders inside your python directory called Lib/site-packages. This exact location depends on your operating system you can find usually find your newly installed packages under
For Windows
C:/PythonXX/Lib/site-packages/
For Linux
/usr/local/lib/pythonX.Y/site-packages
When you run a python script, Python will automatically include these folders as available resources, and when you add for example import X to your code, it will check to see if X is listed.
You have more information on the topic available here.