Loading project into PyCharm

Hi,

I am new to Python and Django development, and PyCharm. I downloaded PyCharm and would like to load an existing Python / Django demo project into it (I have no idea what was used to develop the demo).

The demo is in a folder which contains numerous files, and folders including Apache2, django, mysql, Python26.

Can anyone please provide me with some pointers as to how to approach loading such a project.

Thank you.
7 comments
Comment actions Permalink
Use the "Open Directory" action and point to the directory which contains the source code of the project (normally the directory containing files like settings.py and urls.py).
0
Comment actions Permalink
That worked, thank you very much.
0
Comment actions Permalink
I loaded the project as you directed, yet found that when I initiated execution, an error occurred indicating that there was some problem loading settings.

After digging around I got the idea that I needed to load from a parent folder. Once I initiated execution from there, the error disappeared.

I set a breakpoint in manage.py, at "execute_manager(settings)". The code is as follows:
..
import sys
try:
    execute_manager(settings)
except:
    pass
if sys.argv[1]==....

The application completes "execute_manager(settings), traps an exception, executes "pass", tests the "if sys..." as false, and then terminates with "Process finished with exit code 0".

With my very limited knowledge of these languages and this environment, I guess the above is ok, as the application terminates without error, yet I am wondering what is actually supposed to happen when here.

I am seeing that python.exe runs the project's manage.py code with parameters "runserver" and "8000". Something tells me that I may be missing something, as I expected the debugger would step into application code.

Could it be that PyCharm caters for Python and Django, but not the environment in which the application executes, and that I thus still need to install this.

Some further guidance will be most appreciated.

Many thanks,

Ol.
0
Comment actions Permalink
So what is the exception that you got?
Note that I strongly recommend reading the Django tutorial to get a better understanding of the environment:
https://docs.djangoproject.com/en/1.4/
0
Comment actions Permalink

While stepping through the code, when "execute_manager(settings)" completes, the debugger steps onto "except:". I assumed an exception occurred here, and interpreted the fact that it executes "pass" as "swallowing" the exception. Please excuse my ignorance (mostly due to lack of research) if I am mistaken.

I will work through the tutorial at the link you provided.

Thank you for your responses and assistance.

Ol.
0
Comment actions Permalink
Thus far I have read "Writing your first Django app, part 1" at "https://docs.djangoproject.com/en/dev/intro/tutorial01/"

I did not create a new project as I already have a demo project which I wish to get working.

I read the "How to deploy with WSGI" doc, yet this did not appear to help with setting up WSGI on IIS, which is what I use. I then read "Installing Django on IIS 7 Using PyISAPIe" at "http://www.bardiak.com/2010/12/installing-django-on-iis-7-using.html", and this appears to make some sense wrt IIS.

I successfully ran "python -V" from a command line, it returned Python 2.7.3

Looking at "django-admin.py and manage.py" , I successfully ran "django-admin.py version" from a command line, it returned 1.4.2.

I then attempted "python manage.py runserver". This appear to do nothing. The command prompt is immediately returned.

I guess it has something to do with WSGI, but I am guessing.

Would you please provide some further guidance regarding what I might attempt next.

Many thanks,

Ol.
0
Comment actions Permalink
I have got to a point where I am able to start a WSGI Server from the command line, then browse to the demo site, and use it.

In order to start the demo site, I execute
c:\...\siteroot>python demo_server.py
from the Windows command line.

The demo_server.py file contains the following code, which starts the server:

...
address=tuple(self.address.split(":"))
wserver = wsgiserver.CherryPyWSGIServer(
    (address[0], int(address[1])),
    django.core.handlers.wsgi.WSGIHandler(),
    server_name='www.demo_site.com',
    numthreads = self.numthreads,
    request_queue_size=self.queue_size,
)
try:
    wserver.start()
except KeyboardInterrupt:
    wserver.stop()


In an attempt to run the above from within PyCharm, I opened demo_server.py, right_clicked within the file, and selected "Run". The server started.

I then opened a browser , browsed to the local site:port , and received the following message.

  File "C:\local test site\svr\django\db\__init__.py", line 16, in <module>
    backend = __import__('%s%s.base' % (_import_path, settings.DATABASE_ENGINE), {}, {}, [''])
  File "C:\local test site\svr\django\db\backends\mysql\base.py", line 13, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: Module use of python26.dll conflicts with this version of Python.

The demo site uses Python 2.6.4.

When I open the Python console in PyCharm, it reports the following:
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32

Can someone please provide some guidance as to how I may remedy this situation.

Many thanks in advance,

Ol.
0

Please sign in to leave a comment.