I'm trying to get django-cron to work on a winXP machine. (Wish I could use *nix).
Done
pip install django-cron
Added django_cron to INSTALLED_APPS in settings.py.
Then from windows console, ran below command
python manage.py syncdb
The result I got is:
"Not synced (use migrations):
`- django_cron`
(use ./manage.py migrate to migrate these)"
OK, So as per instructions from error msg I did, C:\ python manage.py migrate. Result is as follow:
Running migrations for django_cron:
- Nothing to migrate.
- Loading initial data for django_cron.
Installed 0 object(s) from 0 fixture(s)
Now what? What should I Google in order to figure out what's wrong with the migration?
Did I installed django-cron on the appropriate location?
Right now it's in
python27\Lib\site-packages\django_cron
Related
I downloaded a folder with multiple python files in the form of a Django project for a course and I am unable to run it. Usually, when you create a Django project it is created within the terminal with the line django-admin startproject web_project . and then python manage.py migrate is used and then the line python manage.py runserver to start a server.
How do I start a server to run my project?
When I use django-admin startproject web_project ., it creates a new project which I don't want. When I use python manage.py migrate or python manage.py runserver it says:
Command 'python' not found, did you mean:
command 'python3' from deb python3
command 'python' from deb python-is-python3
But even when I used python3 manage.py migrate or python3 manage.py runserver instead and it returned:
python3: can't open file 'manage.py': [Errno 2] No such file or directory
At first make sure you opened command prompt or terminal in right directory(in projects directory) when you are running the runserver command.
If you are on windows open the project folder(the folder that contains files like manage.py), then right click and press open PowerShell window here.
first of all I recommend creating a virtual environment using the following command
python3 -m venv .env
then activate it
source .env/bin/activate
"django-admin statproject" its for initalite a new project for running an excited Django app you should just install Django - if there is now "requirements.txt" file- , migrate and run.
pip install Django
python manage.py migrate
python manage.py runserver
I'm doing the CS50Web course, and there is a Django project in which I want to create a new app called "wikipedia". The problem is that after I run this command in Windows PowerShell:
python manage.py runserver
this loop happens:
loop print
I don't know what I did wrong for that to happen. After running
python manage.py startapp wikipedia
, I:
went to my Django project and added 'wikipedia' in the installed apps in settings.py
went to urls.py and added a path like this:
path("wiki/", include("wikipedia.urls))
And then I tried running the server. What did I do wrong?
You must have something improperly configured.
Run this:
$ pip uninstall django
$ pip install django
$ django-admin startproject <projectname>
$ cd <projectname>
$ django-admin startapp wikipedia
$ python manage.py makemigrations
$ python manage.py migrate
do what you described in your question
Also, it is always a better idea to run these things in the CMD, rather than in the PowerShell
Are you sure you have url mappings in your wikipedia app urls.py? Not having any patterns there could be the cause of an error.
Q1.
I am running a local server. It was running without any issue. I ran pip install -r requirements.txt to make sure I have all the packages before running it again.
Now I keep getting the following error:
django.db.utils.ProgrammingError: relation "celery_taskmeta" does not exist
There is a related question on SO that's rather old and it suggests running manage.py migrate but running it also returns the same error.
Here is the contents of my requirements.txt:
amqp==1.4.6
anyjson==0.3.3
apns-clerk==0.1.1
arrow==0.4.1
backports.ssl-match-hostname==3.4.0.2
billiard==3.3.0.19
bootstrap-admin==0.3.0
boto==2.25.0
celery==3.1.17
certifi==14.5.14
cffi==0.8.6
cryptography==0.7.1
Cython==0.19.1
dill==0.2.1
Django==1.6.1
django-appconf==0.6
django-bower==4.8.1
django-celery==3.1.0
django-compressor==1.3
django-debug-toolbar==1.2
django-extensions==1.4.9
django-gravatar2==1.1.3
django-picklefield==0.3.1
django-resized==0.2.4
django-ses==0.6.0
djangorestframework==2.3.8
enum34==1.0.4
gcm-client==0.1.4
Jinja2==2.7.3
joblib==0.8.0a3
kombu==3.0.24
line-profiler==1.0b3
MarkupSafe==0.23
mlpy==3.5.0
mock==1.0.1
nose==1.3.4
numpy==1.8.0
Pillow==2.7.0
psycopg2==2.4.6
pyasn1==0.1.7
pycparser==2.10
pyOpenSSL==0.14
pyparsing==2.0.3
python-dateutil==2.2
python-memcached==1.48
python-slugify==0.1.0
pytz==2014.10
pyzmq==14.4.1
raven==3.3.7
requests==2.5.1
scipy==0.13.3
six==1.8.0
South==0.7.6
sqlparse==0.1.11
tornado==4.0.2
Unidecode==0.4.17
yattag==1.0.7
I'm not sure what to do to resolve this issue.
Is it an incompatibility between older and newer versions of Django and Celery? My latest install was two weeks old, so is there a release in the past two weeks that might be causing this? Or is it something completely unrelated?
Q2.
I'm a beginner so I'm not even sure what celery_taskmeta is and what is its significance.
The problem in this case was solved by running:
python manage.py syncdb --all
This question points to a mismatch in version between django and celery but reinstalling them didn't change anything. It seems it was an issue in older versions (here too)
Other sources point out that this might work:
python manage.py migrate djcelery
or
python manage.py syncdb
python manage.py migrate
But the --all option proved critical in solving this problem. This was the source that was most helpful.
I hope this is useful for anyone
I'm unable to make django-dilla work with my django1.4 project. I've installed django-dilla through pip and I can import it properly from shell.
>>import dilla
>>dilla.__file__
'/Users/misterte/.envs/python2.7-Django1.4/lib/python2.7/site-packages/django_dilla-0.2beta-py2.7.egg/dilla/__init__.py'
I've added it to my installed apps just before south, and ran my syncdb command.
INSTALLED_APPS = (
[...]
'dilla',
'south',
)
But when I try to call it, it won't work.
$python manage.py dilla --cycles=30
Unknown command: 'dilla'
Type 'manage.py help' for usage.
$python manage.py run_dilla --cycles=30
Unknown command: 'run_dilla'
Type 'manage.py help' for usage.
Then, of course, no sub commands are present under the [dilla] app when running help.
$python manage.py help | grep dilla
# emptiness :(
Any clues? Does dilla work in the django1.4 layout?
Thanks!
A.
So I found the problem.
For some reason pip is not installing dilla under site packages. I can import dilla and the egg is present under my site-packages folder, but further inspection showed that there were no packages under dilla.
Solution: copy dilla into you folder manually. I downloaded it from github.
Also, I recommend you copy it to a 'vendor' subfolder in your project. This way you avoid probably having to do the same hack in your production server. Then you import app as 'vendor.dilla' in your installed apps.
A.
I cannot seem to get this working.
I need South to do migrations for a bunch of apps.
Downloaded south 0.7.3
Unzipped, ran setup.py develop (as it says in the turorial)
Double checked to see if it south is where it should be by going to python interpreter and doing (no errors)
import south
I do
C:\Users\j\iMiCode\imi_admin>python ./manage.py syncdb
Syncing... No fixtures found.
Synced:
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.sites
> django.contrib.messages
> django.contrib.admin
Not synced (use migrations):
- south (use ./manage.py migrate to migrate these)
-At this point from what I understand south should have been synced correct?
Anything else I do after this, complains that I have no south_migrationhistory tables in the database.
PS. I am working with Django 1.2.7, python 2.6, on Windows7
It seems to me like a bug in South.
Also this may be cause by doing wrong thigs like: running schemamigration --auto south and etc. My suggestion would be install it by running python setup.py install or through easy_install or pip
South documentation says: "Once South is added in, you’ll need to run ./manage.py syncdb to make the South migration-tracking tables (South doesn’t use migrations for its own models, for various reasons)."
But your output says that south skipped making tables for its own models because it thought south app used migrations
As a workaround you could use
python manage.py syncdb --all
Which causes all tables regardless of migrations to be synchronized and
python manage.py migrate --fake
to fake migrations.
For a new app, with no existing tables the steps to adding south are this:
add 'south', to the list of INSTALLED_APPS.
make sure the app you need to migrate is also in INSTALLED_APPS.
run ./manage.py syncdb (or python manage.py syncdb from inside your project directory). This adds the migration tables to the database.
from the command line, perform ./manage.py schemamigration yourappname --initial
run ./manage.py migrate yourappname
Based on the error you're giving, it sounds like after step 1 & 2 you forgot to run syncdb to create the migration tables, and the South app isn't finding the place it wants to store schema migrations.
I ran into this same issue. Turns out, by some magics, I had created migrations inside of hte south app.
Discovered by:
~ $ # cd to python library
~ $ cd `python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`
python2.7/site-packages $ cd south
python2.7/site-packages/south $ ls migrations
0001_initial.py 0002_initial.py 0003_initial.py __init__.py
These are bad, should not be there, and is what triggers south to skip itself.
Removed all things south, reinstalled, then syncdb once again worked.
python2.7/site-packages $ rm -rf south* South*
~ $ pip install south