process to load database in django project - django

what is the correct process to move a django cms_project to the server?
I create the database from my project like this
./manage.py dumpdata > resource/ddbb/20160817_db.json
I save inside the project in resource file
I move the entire project to the server and after that I execute that command
python manage.py loaddata resource/ddbb/20160817_db.json
But I obtain this error
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/usr/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named djangocms_admin_style
any idea how to solvent?
Thanks in advances

This error means django cannot find a package named djangocms_admin_style. It seems like you are using django-admin-shortcuts. In that case you have to make sure that djangocms_admin_style and djangocms_admin_style to INSTALLED_APPS of your settings.py after installing djangocms_admin_style with pip`. Use command below to install djangocms_admin_style
pip install djangocms_admin_style
as per docs add 'djangocms_admin_style' to your INSTALLED_APPS just before 'django.contrib.admin'

Related

How to ignore or handle django-hijack from the command line?

I'm writing some unit tests for an existing django project that has had no unit tests to date.
When I run the tests from the command line using
./manage.py test
I get
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named hijack
Now hijack is actually installed as I can use it from the browser when I run the server using
./manage.py runserver
The contents of manage.py is
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mtmdjango.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
So ... how I can disable the reference for hijack when running tests or how can I enable hijack to be available under the command line when running tests?
(can someone create and add the tag django-hijack)
I worked through the tutorials at
https://docs.djangoproject.com/en/1.10/intro/tutorial01/ through https://docs.djangoproject.com/en/1.10/intro/tutorial05/
It turned out my command line was wrong.
python manage.py test contacts
gives me the output I was expecting.

django-admin --version error

I was working on a Django project and I ran to the error below please help.
I tried to check my django version with the " django-admin --version " command and i ran into this error below.
Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 11, in <module>
sys.exit(execute_from_command_line())
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 86, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named south
You have include south in your INSTALLED_APPS settings, but it is not installed.
From the traceback, it looks as if you are using Django 1.7 or later, so South is no longer required. You should remove it from INSTALLED_APPS in your settings.

Error when importing south with django after install

This is my first time using Django and South.
I installed South V1.01 with pip, but when I run
manage.py schemamigration myapp --initial
I get
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py",
line 385, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py",
line 354, in execute
django.setup()
File "/Library/Python/2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 85, in
populate
app_config = AppConfig.create(entry)
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 87, in
create module = import_module(entry)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name)
I have added myapp under INSTALLED_APPS in settings.py and I can see South installed correctly.
I would appreciate if anyone can tell my where to look for the fix.

Django Suit: ImportError: No module named suit

Any suggestions?
I have added this code in settings.py after I install pip install django-suit and ./manage.py collectstatic. Not sure of the error.
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP
TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
)
# Application definition
INSTALLED_APPS = (
'suit',)
**error**
heroku run ./manage.py syncdb
Running `./manage.py syncdb` attached to terminal... up, run.8285
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 280, in execute
translation.activate('en-us')
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 130, in activate
return _trans.activate(language)
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 188, in activate
_active.value = translation(language)
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
ImportError: No module named suit
In case, someone in stuck in the same issue and adding the line "django-suit==0.2.7" in requrements.txt did not work, then please try adding the latest django-suite version name in the requirements.txt file and it should work.
So, your requirements.txt file will have the following line.
django-suit==0.2.13
And then run the following command.
pip install -r requirements.txt
And now, it should work!! ;)
Issue fixed. I add django-suit==0.2.7 in requirements.txt
Don't forget make migrate:
python manage.py migrate

Google App engine, django, userena, database setup

I am trying to build a web app with GAE, Django. The user registration would be userena. I already use the django-nonrel and all the setup to get the first part working and I am trying to syncdb for userena. I am keep getting this errors, Could you please help me on this.
BB8265:epapyri-django$ sudo django-admin.py syncdb
Password:
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "/Library/Python/2.7/site-packages/django/core/management/sql.py", line 6, in <module>
from django.db import models
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 11, in <module>
if DEFAULT_DB_ALIAS not in settings.DATABASES:
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
settings.py and manage.py are in the same directory and I did not have this issue before adding this plugin.
the settings.py for database section is as follows:
# Activate django-dbindexer for the default database
DATABASES['native'] = DATABASES['default']
DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}
AUTOLOAD_SITECONF = 'indexes'
INSTALLED_APPS = (
# 'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'djangotoolbox',
'autoload',
'dbindexer',
# social_auth
'httplib2',
'openid',
'oauth2',
'social_auth',
#userena
'userena',
'guardian',
'easy_thumbnails',
'accounts',
# djangoappengine should come last, so it can override a few manage.py commands
'djangoappengine',
)
and this is once I runserver
BB8265:epapyri-django$ sudo django-admin.py runserver
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 8, in <module>
from django.core.servers.basehttp import AdminMediaHandler, run, WSGIServerException, get_internal_wsgi_application
File "/Library/Python/2.7/site-packages/django/core/servers/basehttp.py", line 26, in <module>
from django.views import static
File "/Library/Python/2.7/site-packages/django/views/static.py", line 95, in <module>
template_translatable = ugettext_noop(u"Index of %(directory)s")
File "/Library/Python/2.7/site-packages/django/utils/translation/__init__.py", line 75, in gettext_noop
return _trans.gettext_noop(message)
File "/Library/Python/2.7/site-packages/django/utils/translation/__init__.py", line 48, in __getattr__
if settings.USE_I18N:
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
[edited]
I remove the non django project from INSTALL_APP, import the django.models to my accounts/MyProfile, and chmod 777 on the .datastore since it shouldn't ask for permission every time modify it.
{File "/git/ePapyri/epapyri-django/djangoappengine/db/base.py", line 160, in _value_for_db
raise DatabaseError("Only strings and positive integers "
django.db.utils.DatabaseError: Only strings and positive integers may be used as keys on GAE.}
Why are you using django-admin.py to run syncdb and runserver? You should be using manage.py.
And you should definitely not be using sudo to run either of these.
(Also note your INSTALLED_APPS seems to be nonsense: it contains a whole lot of plain Python libraries like httplib2 and oauth2 which have no business at all being there.)
Edited
Firstly, you should have edited your question to add the traceback.
Secondly, the error message is very clear: you have not imported django.db.models in your accounts/models.py file.
Thirdly, it is still nonsense to include non-Django libraries in INSTALLED_APPS. There is simply no need to do so. And your datastore should not have been created with sudo in the first place - either delete and recreate it, or use chmod to make it accessible to a normal user.
I find out the problem is solved by adding a PIL to libraries in GAE, and yaml file would solve the issue, since it was complaining about image library in python. the link to all supported libraries for django is https://developers.google.com/appengine/docs/python/tools/libraries27, so add all the needed libraries to .yaml file and to the INSTALL_APP.