Getting error while running django_cron - django

When am trying to run the chron job in django using below command
python manage.py runcrons
its showing one error like below
$ python manage.py runcrons
No handlers could be found for logger "django_cron"
Does any one have any idea about this error? Any help is appreciated.

It is kind of given in the error you get. You are missing a handler for the "django_cron" logger. See for example https://stackoverflow.com/a/7048543/1197616. Also have a look at the docs for Django, https://docs.djangoproject.com/en/dev/topics/logging/.

Actually the django-cron library does not require a 'django_cron' logger. I resolved the same problem by running the migrations of django_cron:
python manage.py migrate #migrate database

Related

django programming error : column does not exist

Hello I am running a django app using Django. The app is working correctly . But when I add a new field in my model.py I got this error
ProgrammingError at /admin/challenges/challenge/
column challenge.category does not exist
LINE 1: ..., "challenge"."modified_at", "challenge"."title", "challenge...
I found similar questions but they didn't solve my problem.
I tried to run "python manage.py migrate" and it doesn't solve the problem
Could any one help me please ?
I think you have not done make migration command. Perform
python manage.py makemigrations
and then use command
python manage.py migrate

Django-RQ + Braintree: Submit for settlement

I have read this stackoverflow Q&A but it did not worked it my case.
In my scenario I push a function (submit_transaction_for_settlement(transaction_id)) to the redis queue using the excellent package django-rq. The job of this function is to submit a transaction for settlement.
In the sandbox, whenever this function is executed I keep getting the same error: AttributeError: type object 'Configuration' has no attribute 'environment'.
I tried agf's proposal about instantiate a new gateway for each transaction inside my function, but it did not work!
Maybe this has something to do with the environment of the redis queue or the worker environment?
def submit_transaction_for_settlement(transaction_id):
from braintree import Configuration, BraintreeGateway
config = Configuration(environment=settings.BRAINTREE_ENVIRONMENT, merchant_id=settings.BRAINTREE_MERCHANT_ID,
public_key=settings.BRAINTREE_PUBLIC_KEY, private_key=settings.BRAINTREE_PRIVATE_KEY)
gateway = BraintreeGateway(config=config)
result = gateway.transaction.submit_for_settlement(transaction_id)
Ahrg!
I hate the moments where I answer a question and minutes after I find myself the solution!
The fault was in the command running the rqworker. I was using the command python manage.py rqworker --worker-class rq.SimpleWorker because I had this issue because I used python 2.7 (or something else caused this issue). The command generated this issue was python manage.py rqworker.
Upgrading now to python 3.4, the last command works like a charm!
So, running python manage.py rqworker did the trick and no such errors!

Django: I get a [relation "auth_group" does not exist] error after syncdb

I started a new Django 1.8 project and realized that I missed something (i had done the initial migrations). I dropped the database (postgreSQL) and deleted migration folders from all my apps in order to start from scratch.
Now, when I 'syncdb' I get this error:
django.db.utils.ProgrammingError: relation "auth_group" does not exist
and when I makemigrations I get this:
No changes detected
What am I doing wrong?
Probably you should try to create migrations modules (folders named migrations with empty file named __init__.py inside of each directory) for your apps. And then run manage.py makemigrations again.
The problem is on no changes detected. Please execute these commands with your app name. I guess you didn't add it (just like the mistake I did):
python manage.py makemigrations myappname
python manage.py migrate myappname
The above error occurs when you have django.contrib.admin among the installed applications.
Run these commands in their respective order.
**
./manage.py makemigrations
./manage.py migrate auth
./manage.py migrate**
That worked for me perfectly.
Doing ./manage.py migrate auth first didn't work for me, and every ./manage.py command was throwing this error. My problem was that I was doing stuff with the Group manager in module scope.
If you have code like this in module scope:
customers_group = Group.objects.get(name='customers')
Move it inside a function that is called at runtime instead.
def xyz():
...
customers_group = Group.objects.get(name='customers')
I had the similar problem with Django2.2 migrations. I will post what helped in case someone is looking to fix this.
I commented out all urls to apps(like my_app.urls, your_app.urls) in main project urls.py and then ran makemigrations, it worked.
I think this error is due to some forms/views referring to model/fields that are not yet created. It seems django traverses urls.py to before making migrations
It can be either:
one of the pip dependencies from requirements.txt was using South
had this error when running tests which do migration in Django 1.8. Found the lib with issue by running tests in verbose mode. Consider upgrading the library to newer version.
manage.py test -v 3
one of the /migrations folder might still has old South migrations files.
It can be because others are still adding migrations when you are trying to upgrade Django. Use the following to make sure that the expected migrations files are present in each app.
manage.py showmigrations
One of your paths ("pointing urls.py on your core folder along with the settings.py") makes that problem occur importing django.contrib.auth and directly using methods and properties of "auth" after calling those views
Remove all migrations except "init.py" of each apps
Go to projects urls.py and comment out all the paths
run "heroku run python manage.py makemigrations"
run "heroku run python manage.py migrate"

Error in Heroku run python manage.py syncdb

I'm using django==1.5.1 and I got this error below. Earlier I was using django==1.4.2 and didn't got such error following the same tut in GSWD (I did not update the django version in the middle of the project).
(edu-venv)vagrant#precise32:/vagrant/projects/kodeworms$ heroku run python manage.py syncdb
Running `python manage.py syncdb` attached to terminal... up, run.9132
ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check setti
ngs documentation for more details.
This looks like I missed something which is related more specifically to django==1.5.1 version. Can someone help ?
Someone gave this solution and it worked for me
Original Link: http://gettingstartedwithdjango.com/questions/1/error-in-heroku-run-python-managepy-syncdb/
If you type heroku config you'll get the heroku environment values.
Mine only showed:
HEROKU_POSTGRESQL_BRONZE_URL: postgres://tcmgahtgsrmufa:iyA2dKD5bnO4f7jyv6MSu4453g#ec2-54-225-68-241.compute-1.amazonaws.com:5432/d6oj663f28smnh - there was no DATABASE_URL which dj_database_url.config needs. So then I found our from https://devcenter.heroku.com/articles/heroku-postgresql that you need to promote this to DATABASE_URL. The commands is : heroku pg:promote HEROKU_POSTGRESQL_RED_URL (replace with whatever environment variable your set-up is using). So far so good. I came here to post as soon as I tried this out. I haven't rerun yet but it should work.

What is the best Django syncdb crash debugging technique?

What is the best Django syncdb crash debugging technique ?
I've previously asked a question about a problem with manage.py syncdb returning an exception
and the answer was that the app has a wrong import.
django manage.py syncdb not working?
I'd like to know the technique used to find the place where there is a wrong import.
I tried ./manage.py syncdb --verbosity=2 but I didn't get any more information that way.
You look at the problem the other way around.
syncdb doesnt have anythin to do with "import". You have misconfigured python or/and django install and this is a problem.
If you want to debug what happen with sql queries then you should use
python manage.py sqlall __yourappname__