I need to make the fixtures for the redirect app. For site I use:
python3 manage.py dumpdata sites --indent 2 > fixtures/sites.json
So I tried to use the code below to make the fixtures for redirect:
python3 manage.py dumpdata redirect --indent 2 > fixtures/redirect.json
But I see the error below:
CommandError: No installed app with label 'redirect'.
I need to make the fixtures for all standard app, like migrations and the others in the image below.
I have a function that generates a bash script file '.sh' to create a django project and a few apps.
This is the bash file I generate:
#! /bin/bash
cd projectx
source projectxenv/Scripts/activate
python manage.py startapp app1
python manage.py startapp app2
deactivate
When I execute the bash I generated, it gives me the following errors:
django.core.management.base.CommandError: 'app1' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.
django.core.management.base.CommandError: 'app2' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.
I don't think app1 and app2 are existing modules, and also, I tried running these commands manually and they work, but when I try ./bash.sh, it doesn't work.
GitHub repository
When I send a post request I get this.
I previously try
python manage.py syncdb
./manage.py migrate
python manage.py migrate
python manage.py createsuperuser
python manage.py makemigrations
python manage.py migrate
but I still got an error. The Git Hub link is above please help me.
Django looks for models in a models.py file or models directory, not 'model.py'.
I'd strongly suggest you use django-admin startproject name [directory] when creating new projects or django-admin startapp name [directory] when creating new apps in order for a consistent directory structure to be generated.
Also try and follow the naming conventions in Django. For example employeeModel could rather be Employee, empName rather employee_name, TradeInfo rather trade_info, etc.
The problem causes this error when I try to use south:
$ python manage.py schemamigration
You must provide an app to create a migration for.
$ python manage.py schemamigration myapp --initial
OSError: [Errno 13] Permission denied: '../myapp/migrations'
$ sudo python manage.py schemamigration myapp --initial
ImportError: No module named django.core.management
$ python
>>> import south
>>> import django.core.management
>>> south.__file__
'/home/mydev/venv/lib/python2.7/site-packages/south/__init__.pyc'
>>> django.__file__
'/home/mydev/venv/lib/python2.7/site-packages/django/__init__.pyc'
It seems to me that manage.py schemamigration generates an error message that appears to be returned by schemamigration. But schemamigration and other south commands cannot find django once they are called.
'/home/mydev/venv/lib/python2.7/site-packages/' is on my sys.path. The /south folder is a sim link to the actual south package which is in a /dist-packages folder. I did put a sim link in the actual /south folder back to the the django package, but that didn't solve anything.
What could be wrong?
The problem is due to permissions and use of virtualenv. You got the 'permission denied' error as your current user does not have write permissions for this project.
You can change the permissions for the entire project and make you current user as the owner of all files and folders in the project
sudo chown -R <username>:<username> <project_folder>
When you tried running migration using sudo it was not able to find django package as it lies in the virtualenv which has been activated by normal user. I guess these steps should solve this incase you don't want to change the permissions.
sudo -i
source /<virtualenv_path>/bin/activate
This should activate the virtualenv for sudo and now you'll be able to access all packages in the virtualenv
I think you should go the permissions way
My problem is in getting manage.py syncdb to run within a virtualenv.
It was working fine at one point, but seems to have broken sometime around when I installed South and updated pip and distribute.
Anyways, when the virtualenv is activated, I can import apps fine within the interactive interpreter. Running through mod_wsgi, the apps are imported as well, and the site can run.
When I run manage.py syncdb, it fails to find any app in INSTALLED_APPS that is in my virtualenv. It picks up system-installed apps fine, but fails when it tries to import virtualenv only apps.
Hi This is an old question, but saw its not answered. Not sure what you are attempting to do, but there are basically two modes you can use virtualenv,
For development, to create self-contained environments
For deployment, to create self-contained environments
In the first case, you need to first Activate your virtualenv with source venv/bin/activate, for when you deploy, you need to ensure that the virtualenv is activated for your website code. Personally i prefer the following approach to ensuring your path is set correctly. (I also add this to my manage.py when doing development, so i dont have to worry about activating the environment first.
Modified manage.py
#!/usr/bin/env python
import os.path
# Cater for Virtual env, add to sys.path
pwd = os.path.abspath(os.path.dirname(__file__))
project = os.path.basename(pwd)
new_path = pwd.strip(project)
activate_this = os.path.join(new_path,'venv','bin','activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
execute_manager(settings)
This works, due to how i structure my projects, you would have to change it to your directory structure. My projects are structured like so:
TopLevelDir
|
|- Project DIR
|- venv
|- requirements
|- deployment configs
I have a simple solution to this
Just launch manage.py from the python in the bin of your virtual environment.
So say your python is here /home/tom/environments/my_env/bin/python you could launch manage.py like so:
/home/tom/environments/my_env/bin/python manage.py syncdb
then just create a symlink to the virtual environment's python inside your django project and call it env_python then you can do this:
./env_python manage.py syncdb