Pinax on Webfaction - manage.py syncdb not finding virtualenv - django

(pinax09)[user#web213 social]$ python manage.py syncdb
Error: Can't import Pinax. Make sure you are in a virtual environment that has
Pinax installed or create one with pinax-boot.py.
I'm obviously in pinax09 virtualenv which has pinax installed hence I could create a social project with setup_project. However, once I run the syncdb it complains it can't import Pinax. What could be the problem?

Might be a problem with Python versions - I've had that on Webfaction before. Try just ./manage.py syncdb, without the python, which should run the correct version.

Related

how do solve import error in django project

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable i have activated the virtualenv on many but yet I can't run the server
When you install Django on your computer all things go fine but when you install a Virtual environment it gets separated from all things.
Just reinstall Django in the virtual environment:
pip install Django
and then just run the command for testing:
python manage.py runsever

"Unknown command syncdb" running "python manage.py syncdb"

I want to create the tables of one database called "database1.sqlite", so I run the command:
python manage.py syncdb
but when I execute the command I receive the following error:
Unknown command: 'syncdb'
Type 'manage.py help' for usage.
But when I run
manage.py help
I don`t see any command suspicious to substitute
python manage.py syncdb
Version of Python I use: 3.4.2 Version of Django I use:1.9
I would be very grateful if somebody could help me to solve this issue.
Regards and thanks in advance
If you look at the release notes for django 1.9, syncdb command is removed.
Please use migrate instead. Moving forward, the migration commands would be as documented here
Please note that the django-1.9 release is not stable as of today.
Edit: Django 1.9 is stable now
the new django 1.9 has removed "syncdb",
run "python manage.py migrate",
if you are trying to create a super user, run "python manage.py createsuperuser"
$python manage.py syncdb is deprecated and not supported now.
So instead of this follow below instructions..
Whatever model you have created:
First run:
$python manage.py makemigrations
After running this command you model will be reflected in a migration.
Then you have to run:
$python manage.py migrate
Then run server:
$python manage.py runserver
Now, your project will run perfectly.
In Django 1.9 onwards syncdb command is removed. So instead of use that one, you can use migrate command,eg: python manage.py migrate.Then you can run your server by python manage.py runserver command.
Django has removed python manage.py syncdb command now you can simply use python manage.py makemigrations followed bypython manage.py migrate. The database will sync automatically.
You can run the command from the project folder as: "python.exe manage.py migrate", from a commandline or in a batch-file.
You could also downgrade Django to an older version (before 1.9) if you really need syncdb.
For people trying to run Syncdb from Visual Studio 2015:
The option syncdb was removed from Django 1.9 (deprecated from 1.7), but this option is currently not updated in the context menu of VS2015.
Also, in case you didn't get asked to create a superuser you should manually run this command to create one: python.exe manage.py createsuperuser
Run the command python manage.py makemigratons,and than python manage.py migrate to sync.
Alternarte Way:
Uninstall Django Module from environment
Edit Requirements.txt a type Django<1.9
Run Install from Requirments option in the enviroment
Try Syncdb again
This worked for me.
I also tried this command. Lastly I found the release note from django
Features removed in 1.9
The syncdb command is removed.
Djnago Releases note 1.9
I had the same problem, the only thing worked for me was this command.
python3 manage.py migrate --run-syncdb
Running this got me this result.
Ranvijays-Mac:djangodemo rana.singh$ python3 manage.py migrate --run-syncdb
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: admin, auth, contenttypes, msg, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Running migrations:
Applying msg.0001_initial... OK

PTVS Django Data Base Migration

Im testing Python Tools For Visual Studio, I create a django project, make a SyncDB and install django admin with no problems, but now Im trying to make Data Base migration like: Django 1.7 Migrations. the point is that i cant figuer out how to do that. I serched in google and find this: How to run django database migrations with PTVS?. So the migration command is not wraped. I tried using Windows Command Prompt and install C:\Python34\;C:\Python34\Scripts; PATHS but when i type a django command like python manage.py runserver appears No module named 'django'. It seems that i am not pointing to my django project virtual env, but i dont know how to do that.
Execute command in my django app env path does not work neither.
Image:
Thanks a lot!
Before using of virtual env you should activate it. Execute env\activate or env\bin\activate. Not a windows guy so I'm not sure which path virtualenv uses on Windows :-)
You have to activate virtualenv. Go to env/Scripts directory and run activate.bat. Then go to your main project directory and try again python manage.py runserver. If you still see No module named 'django' make sure that django is installed in this environment try pip install django.

What's the proper way to run a south schemamigration in a Django package?

I'm working with a third-party Django package, and I'm not sure how to create a schemamigration. What's the equivalent of:
./manage.py schemamigration <app_name> when I don't have a ./manage.py?
While I don't think we can create South migrations without build a real django site(btw, you also need the django site for testing). Just treat your package like other django packages, and run schemamigration <your_app_name> to create migrations for it.
You only need to let django store migrations under your package's migrations directory instead of 'env/lib/pythonXX/site-packages/' You need to install your app with pip's editableā€ mode.
pip install -e local_path/to/your_package

Adding South to Django project, development & production

Adding South to an existing Django project. I have it installed on both the development machine and the "production" server.
I've done the following on the development machine, then: added South app to settings.py,
python manage.py syncdb
python manage.py convert_to_south myproject.myapp
then changed some models, then
python manage.py schemamigration myproject.myapp --auto
python manage.py migrate myproject.myapp
Seems to work so far. What I am now not so sure about is what to do on the production server. Just repeat all these steps manually? Upload modified settings.py, do syncdb, convert_to_south, upload modified models.py, do schemamigration, migrate? Something different? The tutorial here says something about adding migrations to the version control, so, presumably, they should be uploaded and somehow applied on the production server?
Furthermore, right now I am using sqlite3 on the development machine and mysql on the server - does it make things any different south-wise?
My guide says:
Install South on server. import south from shell just to make sure you are using the same python env.
Add 'south' to INSTALLED_APPS in settings.py.
Upload settings.py.
Restart server
python manage.py syncdb.
Upload new app/models.py and app/migrations/ dir.
Restart server.
python manage.py migrate app --fake 0001
python manage.py migrate app
To make sure the south migration table exists,
python manage.py syncdb
and then
python manage.py migrate myproject.myapp --fake 0001
python manage.py migrate myproject.myapp
That's what's worked for me. :)
No need to do this in Django >= 1.7
i am stuck on this more then 1 hour :)
and at last find 1.7 and more have in build upgrading-from-south
for more info https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-south
may be this one help you