How can I build Pinry (Python/Django Pinterest Clone) using PyCharm? - python

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.

Related

After deleting my database and trying to apply a new migrations i get this errors that say django.db.migrations.exceptions.NodeNotFoundError

Am trying to apply a migration to a new database but I keep getting this error, I have deleted all migration files in my old database and also files in the apps. when I tried applying migrations to a new database or running python manage.py runserver then I get this error..? I wonder what might be the problem. am using Django 3.1.1
E:\All django project\Real-Estate-Django-Web-App-master>manage.py migrate
Traceback (most recent call last):
File "E:\All django project\Real-Estate-Django-Web-App-master\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Python38\lib\site-packages\django\core\management\base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 92, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Python38\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Python38\lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
self.build_graph()
File "C:\Python38\lib\site-packages\django\db\migrations\loader.py", line 255, in build_graph
self.graph.validate_consistency()
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 195, in validate_consistency
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 195, in <listcomp>
[n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)]
File "C:\Python38\lib\site-packages\django\db\migrations\graph.py", line 58, in raise_error
raise NodeNotFoundError(self.error_message, self.key, origin=self.origin)
django.db.migrations.exceptions.NodeNotFoundError: Migration auth.0013_user_following dependencies reference nonexistent parent node ('account', '0003_contact')
Well! I was finally able to fix this problem by first uninstalling Django on my virtual env and then redo the installation, but the problem had still persisted, so I just followed my intuition by deleting the whole virtual env, I did the installation of virtualenv and then installed Django and it worked, perfectly. Thank you to all who had tried to help, I really appreciated your answers.
The auth.0013_user_following migration requires the 0003_contact migration which is missing.
Try removing all migrations from all apps and set a new database.
Based on the solution provided by Abubakari UmarblacKrussain Uma, I noticed that packages linked to my virtual environment file were missing/corrupted. When I checked it against my requirements.text file, I noticed that the Django package was replaced by django 2.2.27 (django lowercase), and an entry -jango 3.1.3 was added. I manually edited the requirements.txt file to remove the -jango 3.1.3 entry and replace the django 2.2.27 with Django 3.1.3 and reloaded the virtual environment from requirements.txt. This resolved the error. For good measure I re-generated the requirements.txt file for the virtual environment.

Fail with django app on azure

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.

django and python manage.py runserver execution error

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.

Getting 32/64-bit architecture error in Aptana when launching Django project

Like most other Mac/MySQL users with current versions of OS X, I went through the normal issues of getting Python, MySQL and MySQLdb (MySQL-Python) playing nicely together. That has been working for some time, but I'd like to use Aptana for debugging my work Django projects and when I try running either the debugger or running a project, I'm getting the dreaded "mach-o" error.
The interesting thing is that I've configured Aptana to use the same python I'm using (confirmed with a "which python" both within and outside of Aptana), and I've confirmed that the python that's being invoked by Aptana is 32-bit as it should be (same as system terminal reports). Also, when I use the Terminal in Aptana, using the interactive python shell I'm able to successfully 'import MySQLdb'. So I'm stumped.
Under arguments I'm adding this to program arguments per instructions:
runserver 8081 --noreload
But that shouldn't affect anything AFAIK. I'm at a loss of what to do next. Here is the error that Aptana is throwing when I try to launch:
pydev debugger: starting
Validating models...
Traceback (most recent call last):
File "/Applications/Aptana Studio 3/plugins/org.python.pydev_2.6.0.2012062515/pysrc/pydevd.py", line 1392, in <module>
debugger.run(setup['file'], None, None)
File "/Applications/Aptana Studio 3/plugins/org.python.pydev_2.6.0.2012062515/pysrc/pydevd.py", line 1085, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File "/Users/my/path/project/manage.py", line 14, in <module>
execute_manager(settings)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 67, in handle
self.run(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 78, in run
self.inner_run(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 88, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 28, in get_validation_errors
from django.db import models, connection
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 78, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 33, in load_backend
return import_module('.base', backend_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/db/backends/mysql/base.py", line 14, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/_mysql.so: mach-o, but wrong architecture
Any ideas?
Take a look at: How do I force Python to be 32-bit on Snow Leopard and other 32-bit/64-bit questions on ways to configure Python to run in 32 bits (VERSIONER_PYTHON_PREFER_32_BIT environment variable seems a good choice).
Or maybe:
Troubles with PyDev and external libraries in OS X

Trying to Run Google App Engine behind a proxy, errors received

I am running Python 2.6.1 on my computer, and just installed google App Engine.
As soon as I click on the App Engine Launcher, it gives an error dialog box and asks me to check the GoogleAppEngineLauncher.exe file for more details.
I have appended the log file below:
File "GoogleAppEngineLauncher.py", line 42, in <module>
File "wx\_core.pyc", line 7913, in __init__
File "wx\_core.pyc", line 7487, in _BootstrapApp
File "launcher\app.pyc", line 58, in OnInit
File "launcher\app.pyc", line 152, in _VersionCheck
File "urllib.pyc", line 82, in urlopen
File "urllib.pyc", line 190, in open
File "urllib.pyc", line 338, in open_http
File "urllib.pyc", line 351, in http_error
File "urllib.pyc", line 702, in http_error_407
File "urllib.pyc", line 714, in retry_proxy_http_basic_auth
File "urllib.pyc", line 773, in get_user_passwd
File "urllib.pyc", line 782, in prompt_user_passwd
EOFError: EOF when reading a line
From the file, I get the feeling that it's about giving the right proxy details.
I have checked up http://code.google.com/p/google-appengine-wx-launcher/issues/detail?id=17
and http://code.google.com/p/googleappengine/issues/detail?id=544.
It seems that it is about making some edits to some particular .py file so that I can enter my proxy settings, and username/password.
I have also come across few suggestions telling me to set the proxy in environment variables at the command prompt - but that hasn't worked. Any suggestions, please?
UPDATE:
I came across the following at nomagon dot com /?p=5 I am using it but unable to make sense out of the appcfg.py file
If your're not behind a proxy, then your ok to go! You can use the deploy button inside the App Engine Launcher, however if you're behind a proxy, you will need to set some variables
In a CMD window:
set HTTP_PROXY=<proxy>
set HTTPS_PROXY=<prox>
In a CMD window:
appcfg.py update <path to app>

Categories