I'm trying to add a translation (localization) layer to my appliaction.
I have tried to follow the instructions from: https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#how-to-create-language-files
But I run in some problems when I tried to run
django-admin.py makemessages -l he
In order to create a translation file for Hebrew.
When I first run this code I got the following error:
CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.
So I run the command:
brew install gettext
But I still got an error:
CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.
So I saw in some places that I need to run:
brew link gettext --force
Now when I try to run the command:
django-admin.py makemessages -l he
I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in <module>
pkg_resources.run_script('Django==1.7.1', 'django-admin.py')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 492, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1350, in run_script
execfile(script_filename, namespace, namespace)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/EGG-INFO/scripts/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 533, in handle
return self.handle_noargs(**options)
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/commands/makemessages.py", line 283, in handle_noargs
potfiles = self.build_potfiles()
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/commands/makemessages.py", line 299, in build_potfiles
file_list = self.find_files(".")
File "/Library/Python/2.7/site-packages/Django-1.7.1-py2.7.egg/django/core/management/commands/makemessages.py", line 358, in find_files
ignored_roots = [os.path.normpath(p) for p in (settings.MEDIA_ROOT, settings.STATIC_ROOT)]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 327, in normpath
initial_slashes = path.startswith('/')
AttributeError: 'NoneType' object has no attribute 'starts with'
I'm using a Mac with Django 1.7 and Python 2.7.6
please help to understand what I'm missing
try for instance python ../manage.py makemessages -l en inside your app
django-admin.py didn't work for me either
You should point django to your project's settings.py file.
export DJANGO_SETTINGS_MODULE=/path/to/settings.py
Related
I'm getting the following error when trying to run
django-admin runserver
PS C:\Users\gasgu\PycharmProjects\djangodennisproj\devsearch> django-admin runserver
Traceback (most recent call last):
File "C:\Users\gasgu\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\gasgu\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\gasgu\PycharmProjects\djangodennisproj\venv\Scripts\django-admin.exe\__main__.py", line 7, in <module>
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
super().execute(*args, **options)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\core\management\commands\runserver.py", line 68, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\conf\__init__.py", line 82, in __getattr__
self._setup(name)
File "c:\users\gasgu\pycharmprojects\djangodennisproj\venv\lib\site-packages\django\conf\__init__.py", line 63, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I have done a clean installation with a virtualenv, then I didi pip install django, created the project and do the runserver.
I'm running this from pycharm community and I read that I should also set an enviroment variable called DJANGO_SETTINGS_MODULE and I should put my project.settings as value. I did that and I still get the error.
I've also tried the same process from outside pycharm and just with command line I still get the same error. is there something I'm doing wrong?
Also as a note: if I do "python manage.py runserver" it does start the server. but I don't know if this is the way it should be done.
your should always use the manage.py utility after first creating the project with django-admin, basically they are the same thing but manage.py have the setting/configurations for that project..so issues like this can be avoided. if your aim of using it is more specific..please notify
For some reasons, I had to reinstall Python on my desktop. Since then, my django applications are not working. I can create one, but as soon as I import a package anywhere in the application, I can't run python manage.py runserver
I can run another python script, I can start Jupyter Notebooks (and import the exact same packages in them). I also tried to create new projects with the "new" python installed, as soon as I add import pandas (or any other packages except django), I have the error.
The error message is quite long :
Watching for file changes with StatReloader
Performing system checks...
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 585, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 570, in start_django
reloader.run(django_main_thread)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 288, in run
self.run_loop()
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 294, in run_loop
next(ticker)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 334, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 350, in snapshot_files
for file in self.watched_files():
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 249, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\djan
go\utils\autoreload.py", line 116, in iter_modules_and_files
if module.__name__ == '__main__':
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\py\_
apipkg.py", line 171, in __getattribute__
return getattr(getmod(), name)
File "C:\Users\MyName\AppData\Local\Continuum\anaconda3\lib\site-packages\py\_
error.py", line 44, in __getattr__
raise AttributeError(name)
AttributeError: __name__
Got this annoying error after aborting an IDE-refactoring.
I suggest the following to reproduce the problem:
Revert git changes.
Make sure there are no cyclic imports in your code.
Reinstall virtual environment.
Unfortunately the error was still there in my case. So I knew the problem must be with python. And indeed:
Reinstalling python 3.7 solved the problem.
Did you pip install django?
I think when you reinstalled Python you didn't installed packaged like Django
Uninstall the current Django package and install Django 2.1.5
Use this command on windows:
pip install --user django==2.1.5
I'm trying to push a commit, but our CircleCI yields the following puzzling error message:
#!/bin/bash -eo pipefail
cd lucy-web
source venv/bin/activate
python manage.py compilescss --verbosity 0
python manage.py collectstatic --clear --no-input --verbosity 0
python manage.py test
Traceback (most recent call last):
File "manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
File "/root/lucy/lucy_web/lucy-web/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/root/lucy/lucy_web/lucy-web/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/root/lucy/lucy_web/lucy-web/venv/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/root/lucy/lucy_web/lucy-web/venv/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/root/lucy/lucy_web/lucy-web/venv/lib/python3.6/site-packages/sass_processor/management/commands/compilescss.py", line 153, in handle
self.parse_source(py_source)
File "/root/lucy/lucy_web/lucy-web/venv/lib/python3.6/site-packages/sass_processor/management/commands/compilescss.py", line 199, in parse_source
tree = ast.parse(open(filename, 'rb').read())
File "/usr/local/lib/python3.6/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 26
<<<<<<< HEAD
^
SyntaxError: invalid syntax
Exited with code 1
It seems like there are git merge conflicts in Python's ast.py. How might this have come about, and how can I fix it?
When I try to migrate my db, I'm getting this error:
Running migrations for easy_thumbnails:
- Nothing to migrate.
- Loading initial data for easy_thumbnails.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
ignore_ghosts = ignore_ghosts,
File "/Library/Python/2.7/site-packages/south/migration/__init__.py", line 233, in migrate_app
migrator.load_initial_data(target, db=database)
File "/Library/Python/2.7/site-packages/south/migration/migrators.py", line 222, in load_initial_data
self.post_1_6(target, db)
File "/Library/Python/2.7/site-packages/south/migration/migrators.py", line 240, in post_1_6
old_cache = django.db.models.loading.cache
AttributeError: 'module' object has no attribute 'loading'
Apps versions are:
Django 1.6.2
Easy thumbnails 1.4
Mptt 0.5.5
Pymorphy 0.5.6
Python 2.7.5
Pytils 0.3dev
South 0.8.4
Suit 0.2.5
It's looks like not easy_thumbnails problem, because when I try to migrate my django-allauth it raises the same error.
Please, help me!
It seems like your django package was broken. Check that there is python2.7/site-packages/django/db/models/loading.py file in your environment. Or just reinstall django package.
pip install -U --force-reinstall django
I have a simple django project. Installed python,django and mysql database in my ubuntu to run this project. In order to run my project I am trying to sync database first. But when I am trying command "python manage.py syndb" I am getting following errors:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 429, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 252, in fetch_command
app_name = get_commands()[subcommand]
File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 101, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 139, in __init__
logging_config_func(self.LOGGING)
File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib/python2.7/logging/config.py", line 562, in configure
'filter %r: %s' % (name, e))
ValueError: Unable to configure filter 'require_debug_false': Cannot resolve 'django.utils.log.RequireDebugFalse': No module named RequireDebugFalse
I am very new to python and django. doing it first time..
django.utils.log.RequireDebugFalse appeared in Django 1.4.0. Could it be you have an older Django version installed ?
As you stated in the comment, you installed Django from your distro's repository. Those versions are often old, and indeed it looks like you have installed version 1.3, which is now three versions out of date.
You should remove that version (with apt-get remove) and install the current version from the Python package index, via pip install django. You will probably need to install pip first, which you can do with apt-get.