I'm trying to develop and deploy django app on azure web apps.
While following the tutorial on azure website, after cloning the basic project to my local machine (using git) and creating the virtual environment, I'm trying to run the createsuperuser commend, and getting this error:
C:\Users\tutzy\Desktop\newtest\amir1>env\scripts\python manage.py createsuperuser
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 52, in execute
return super(Command, self).execute(*args, **options)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\core\management\base.py", line 413, in execute
translation.activate(saved_locale)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\__init__.py", line 154, in activate
return _trans.activate(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 216, in activate
_active.value = translation(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 205, in translation
_translations[language] = DjangoTranslation(language)
File "C:\Users\tutzy\Desktop\newtest\amir1\env\lib\site-packages\django\utils\translation\trans_real.py", line 118, in __init__
raise IOError("No translation files found for default language %s." % settings.LANGUAGE_CODE)
IOError: No translation files found for default language en-us.
It seems that your issue was similar with the other SO thread No translation file found for domain 'django' if you clone the Azure offical sample for Django like this. There is a *.mo line at the 49th line of .gitignore file. Please try to add the missing .mo file and do the createsupersuer operation again.
Hope it helps.
Related
I am attempting to migrate my changes with command
python manage.py migrate
I have already ran the command,
python manage.py makemigrations accounts
which successfully returns,
Migrations for 'accounts':
accounts/migrations/0001_initial.py
- Create model CustomUser
Then in attempting to run python manage.py migrate I recieve this error...
Traceback (most recent call last):
File "/home/mycroft/C/news/manage.py", line 22, in <module>
main()
File "/home/mycroft/C/news/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 95, in handle
executor.loader.check_consistent_history(connection)
File "/home/mycroft/.local/share/virtualenvs/news-ToLZWqxe/lib/python3.9/site-packages/django/db/migrations/loader.py", line 302, in check_consistent_history
raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency accounts.0001_initial on database 'default'.
I am very new to django and can't seem to figure out just what I am doing wrong. Any help would be greatly appreciated!
Maybe you made some changes to you models.py file and these changes aren't sitting well with the inital db structure. If you can track and undo the recent changes it may help, else you'll have to drop your database, delete all migration files your account app. Then repeat the makemigration, migrate, and createsuperuser processes.
I am in the process of moving the django page to a new server. Due to complications in the apache server configuration, I used mod_wsgi-express integrated into virtualenv python. According to the instructions found on this page: https://pypi.org/project/mod-wsgi/#description , I added mod_wsgi.server to installed Django applications and run the command python manage.py runmodwsgi. Unfortunately, in response I get an error which pastes below. I would be very grateful for any help and explanation why this problem appeared.
Traceback (most recent call last):
File "SAGI-B/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/g####/.venvs/sa###/local/lib/python2.7/site-packages/mod_wsgi/server/management/commands/runmodwsgi.py", line 71, in handle
fields = wsgi_application.split('.')
AttributeError: 'NoneType' object has no attribute 'split'
The Django version I use is 1.10.7 (I know, I should upgrade - I'm in the process). In the settings.py configuration file I didn't find the line with WSGI_APPLICATION = 'xyz.wsgi.application'. Could this be the cause of the error?
The absence of a line with WSGI_APPLICATION = ... in the settings.py file was the reason for the failure.
Environment :
python 2.7.10
django 1.8.6(copied from site-package folder)
I copied the django distribute into my project folder.
Thinking it will work well
It works perfectly in one of my machine, but throw an error below in another one
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "cmdb_lib/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "cmdb_lib/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "cmdb_lib/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "cmdb_lib/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "cmdb_lib/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "cmdb_lib/django/core/management/base.py", line 458, in execute
translation.activate(saved_locale)
File "cmdb_lib/django/utils/translation/__init__.py", line 146, in activate
return _trans.activate(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 222, in activate
_active.value = translation(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 206, in translation
_translations[language] = DjangoTranslation(language)
File "cmdb_lib/django/utils/translation/trans_real.py", line 115, in __init__
self._init_translation_catalog()
File "cmdb_lib/django/utils/translation/trans_real.py", line 153, in _init_translation_catalog
translation = self._new_gnu_trans(localedir, use_null_fallback)
File "cmdb_lib/django/utils/translation/trans_real.py", line 136, in _new_gnu_trans
fallback=use_null_fallback)
File "/usr/local/lib/python2.7/gettext.py", line 472, in translation
raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: u'django'
But in my settings.py I set LANGUAGE_CODE = 'en-us' as default!
How could this throw an error?
I tried to pip install django, problem solved ,but I still want to include the django package in my project.
How can I achieve this?
I think I got the solution , my .gitignorefile ignored the .mo file , I added it and everything 's OK now
If you are using git, check your .gitignore file and comment*.mo
add the missing .mofile ,and things will be good
When I execute python manage.py runserver command for my django_test projects I get following error:
System check identified no issues (0 silenced).
June 14, 2015 - 20:43:03
Django version 1.8.2, using settings 'django_test.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 49, in execute
super(Command, self).execute(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in handle
self.run(**options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 97, in run
autoreload.main(self.inner_run, None, options)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 323, in main
reloader(wrapped_main_func, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 289, in python_reloader
reloader_thread()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 265, in reloader_thread
change = fn()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 190, in inotify_code_changed
update_watch()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 184, in update_watch
wm.add_watch(path, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1903, in add_watch
exclude_filter)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1822, in __add_watch
wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 150, in inotify_add_watch
return self._inotify_add_watch(fd, pathname, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 245, in _inotify_add_watch
return self._libc.inotify_add_watch(fd, pathname, mask)
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: expected CString instance instead of c_char_Array_64
I have never had this problem before and my code always worked fine until I moved the project from one laptop to the other and can not execute it here.
Originaly, it worked fine but the system crashed and it is first time when I am trying to run the code on the new machine. I use virtualenv so I would expect everything to work smoothly but it does not ...
Is it a problem with python itself ?
It looks like you're running against the system version of python on the new laptop, rather than the virtualenv, so it is probably a different version. You can check this by looking at the version of Python on the virtualenv in the old laptop and the new laptop with python --version - I've seen this error happen in this case to people before.
Your best bet is to create a new virtualenv on the new laptop, and reinstall your packages (hopefully, you have a requirements.txt handy). If you need the same version of Python on the new laptop, you'll have to explore getting that version installed on your new laptop (do not overwrite the system version!), and pointing your virtualenv to the install. Good luck.
Before I get started please excuse the complete newbie question (request for dummy steps). I recently started learning Python and the Django framework using tools like Codecademy and Pluralsight and was hoping to dig into this by running Pinry (a Pinterest clone) using PyCharm, my IDE of choice for Python and work on modifying it with what I've learned so far to see what happens. Unfortunately, I download the latest version of Pinry and when I try to run it in PyCharm on my local machine I get all sorts of errors.
Here are the steps I take:
Python, Django, PyCharm are all installed and configured.
Download a new copy of Pinry and open the directory in PyCharm
Click on Run - Edit Configuration
Click on the + button to add a new configuration and check Run browse, select the Python interpreter (with Django) and click on Fix to enable Django support for the project
In the Project - Django settings, add the Django project root, settings and manage script
Finally hit alt/option + R and runserver to get the app started
At this point I would expect the package to run but instead I get the list of errors below.
Has anyone had any success in running Pinry in PyCharm without making any code modifications? I am just not sure if these are issues with the package or if its settings in PyCharm that need to be modified to make this work. Any insights?
THANK YOU!
File "/Applications/PyCharm.app/helpers/pycharm/django_manage.py", line 23, in <module>
run_module(manage_file, None, '__main__', True)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 176, in run_module
fname, loader, pkg_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/hussein/Desktop/pinry-master/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 279, in execute
saved_locale = translation.get_language()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 154, in get_language
return _trans.get_language()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 52, in __getattr__
if settings.USE_I18N:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 151, in __init__
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
In PyCharm "Project settings/Django" specify "settings/development.py" in "settings" field.