I deployed my Django project to Heroku. Now, I want to add another app to my existing project. How can I do it in a way that a new database is not created- I mean my existing database should not get deleted?
You can just run heroku run python manage.py syncdb after pushing your new app with model definitions. This won't delete your database. Consider installing South though.
Using PyPI
If the app you want to install is available on the Python Package Index, you can add the name of the add and the version you want to use in your requirements.txt file like:
app_name==1.2.3
Then, in your project/settings.py file, add the app_name as a string to the list of INSTALLED_APPS. For instance, if INSTALLED_APPS looks like this:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
then adding the new app will make it:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'package_name',
)
Using git
You can follow the same steps as above, but instead of adding app_name==1.2.3, you add:
git+git://github.com/owner_name/app_name#egg=app_name
replacing owner_name and app_name appropriately. This clones the repository that you point to, so be sure that it's either public or that you have ssh access if it's private.
Related
Tying to register my djano app in the settings section of my django project. but when i run the server i am getting an error in the terminal.
django.core.exceptions.ImproperlyConfigured: 'site1app.apps' does not contain a class 'Site1appConfig'. Choices are: 'Site1AppConfig'.
I dont know what's going wrong as i just added it to the list of installed apps in settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'site1app.apps.Site1appConfig',
]
This looks like a miss on the capitalization for your class
Change:
'site1app.apps.Site1appConfig'
To:
'site1app.apps.Site1AppConfig'
I have no idea why the app is crashing when I try to run:
python manage.py sqlall world
I am taking the django tutorial for geodjango, and my settings contain:
INSTALLED_APPS = (
'django.contrib.admin.apps.AdminConfig',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'world',
)
As the tutorial teaches.
Does anyone has an idea of what might be happening?
I have already uninstalled Django 1.6.1 and installed again.
Thanks
You are not following the tutorial which matches the version of Django you have installed. 'django.contrib.admin.apps.AdminConfig' is only available on master (1.7dev).
I currently have a django app am developing on my PC with data in my db but when i try running this app on a test server i get the error below
DatabaseError: relation "django_site" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
can any one tell me why am getting this error please.thanks
You may be calling a site object before creating site model(before syncdb)
ex: site = Site.objects.get(id=settings.SITE_ID)
This issue continues to plague many, including myself. Although a tedious process, this approach saves me the brain power:
Disable all external apps in your INSTALLED_APPS, except your own apps, like so:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'main', # This is my own app.
# 'compressor',
# 'ckeditor',
# 'imagekit',
# 'debug_toolbar',
# 'rest_framework',
# 'allauth',
# 'allauth.account',
# 'allauth.socialaccount',
# 'allauth.socialaccount.providers.google',
# 'allauth.socialaccount.providers.facebook',
)
Run
python manage.py makemigrations
python manage.py migrate
Then, uncomment all the other apps, then repeat makemigrations and migrate above.
That works all the time for me
I can't see your models or what apps are you using, but my guess is that you are using django_site (Site model) and you don't have 'django.contrib.sites' in the INSTALLED_APPS.
If I'm correct then just add 'django.contrib.sites', to your INSTALLED_APPS.
Had this strange issue while initiating a new database and using django-debug-toolbar. Removed it from the INSTALLED_APPS and was able to run syncdb. Then re-added debug_toolbar and it was still working fine.
If you're using django-debug-toolbar, try to comment out debug_toolbar in your installed apps and try again.
Update: Please follow the steps for the explicit setup: http://django-debug-toolbar.readthedocs.org/en/1.2.2/installation.html#explicit-setup
i have same problem and fixed it like this:
add SITE_ID=1 into settings.py
run this command :
python manage.py migrate
not been able to solve this a django way so i tried using sql, i created a dump of just the database like this.
pg_dump mypgdatabase | gzip -c > mypgdatabase.dump.out.gz
then moved it to the server
scp /path/to/mypgdatabase.dump.out.gz my_remote_server
then recreated it on the server like this
psql -d mypgdatabase -f mypgdatabase.dump.out
then run
./manange.py migrate --all
and all when well.
Couple of things you can try and check:
Your settings.py should have a SITE_ID usually = 1
Change order of your INSTALLED_APPS in your settings.py and try temporarily commenting items out.
As Geo said, check that you're not calling a site object before creating site model (ex: site = Site.objects.get(id=settings.SITE_ID)).
Once you got it working, remember to manage.py makemigrations APP_NAME as I found cases where it seem to have then avoided the commenting out step.
I overcame this issue with the following order in INSTALLED_APPS:
INSTALLED_APPS = (
'django.contrib.sites',
'allauth',
'allauth.account',
# my other apps,
)
My "commenting out" pattern was slightly different than the accepted answers (as shown below). That is to say, it might be unique depending on the values of various dependencies scattered throughout your app. If commenting out the values above throws an error message, I recommend commenting out the apps that throw the error message and uncommenting accordingly until it works for you. This may be a little "brute force" but it should get the job done.
INSTALLED_APPS = [
# django native apps
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
"django.forms",
'django.contrib.gis',
# 'django.contrib.flatpages',
#third party apps
#django-allauth apps
'allauth',
# 'allauth.account',
# 'allauth.socialaccount',
# 'allauth.socialaccount.providers.facebook',
# 'allauth.socialaccount.providers.google',
# 'allauth.socialaccount.providers.twitter',
# 'allauth.socialaccount.providers.github',
# my apps
'app0',
'app1',]
#MIGRATION_MODULES = {"sites": "mysite.contrib.sites.migrations"}
Also make sure SITE_ID = 1 comes before the DATABASE definition in settings.py
so here is my problem - the gravatar app (from google projects - here! http://code.google.com/p/django-gravatar/) in my django project crashed everything on startup.
i get this error Error: No module named gravatar
this is my installed apps:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'dumpstown.dumpstownapp',
'bootstrap_toolkit',
'registration',
'gravatar'
)
and from the console when i run this:
>> import sys
>> print sys.path
['', 'C:\\development\\python\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg',
'C:\\development\\python\\lib\\site-packages\\pip-1.1-py2.7.egg', 'C:\\developm
ent\\PycharmProjects\\lib\\gravatar', 'C:\\Windows\\system32\\python27.zip', 'C:
\\development\\python\\DLLs', 'C:\\development\\python\\lib', 'C:\\development\\
python\\lib\\plat-win', 'C:\\development\\python\\lib\\lib-tk', 'C:\\development
\\python', 'C:\\development\\python\\lib\\site-packages']
what am i missing here?
UPDATE
huh, weird. I've checked the gravatar folder, and i have
templatetags dir
__init__.py
models.py
views.py
also, if i change the installed apps section to read:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'dumpstown.dumpstownapp',
'bootstrap_toolkit',
'registration',
'templatetags'
)
then the server starts up fine and runs. But i... i'm all confused now! Am i meant to import the templatetags? or something else? how do i refer to the gravatar stuff if i'm importing templatetags??
EDIT: Solved.
I just don't understand how python works, it would seem! I was totally adding the wrong item to the pythonpath - i was adding C:\\development\\PycharmProjects\\lib\\gravatar, where i should have really been adding C:\\development\\PycharmProjects\\lib
this solved the problem, and now i can use gravatar as i want. The settings.py entry is as above in my first example (that is, just 'gravatar') and the way i use it is i just {% load gravatar %}
hurrah!
Possibly you checked out the trunk folder and have a structure like ..\gravatar\gravatar? The setup.py script should install it somewhere your path but you could also try changing C:\developm ent\PycharmProjects\lib\gravatar to C:\developm ent\PycharmProjects\lib\gravatar\gravatar
Totally adding the wrong item to the pythonpath - i was adding C:\development\PycharmProjects\lib\gravatar, where i should have really been adding C:\development\PycharmProjects\lib
Now I create project by using jython 2.5.2b2 and django1.1.1 (lucid) , after download sqlitejdbc-v056.jar and do some syncdb task it's shown
"zxJDBC.Error: auth_permission.content_type_id may not be NULL [SQLCode: 0]"
but still can runserver, anyone has some great example for this situation?
Try to reorder django.contrib.auth in INSTALLED_APPS in settings.py
From
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
)
To
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.auth',
)
I have recreated this error on OS X with Jython 2.5.2 and Django 1.1.1. However the documentation for the 'django-jython' package (which provide the glue between Django on Jython and various databases) has the following on SQLite3 support:
SQLite3
Experimental. By now, use it only if you are working on improving it.
Or if you are really adventurous.