Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#11147 closed (invalid) doesn't work with settings directory in pydev

Reported by: Leo Shklovskii Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The fix for #9751 - r10751 - completely broken for our configuration (things are set up this way for pydev):

 |-- app1
 |   |--
 |   |--
 |-- app2
 |   |--
 |   |--
 |-- settings
 |   |--
 |   |--
 |   |--

I now get the following failure - it looks like django is trying to go up a directory too high:

Traceback (most recent call last):
  File "C:\ws\fuzzy\EvoHeart2\src\", line 12, in <module>
  File "C:\Python25\lib\site-packages\django\core\management\", line 360, in execute_manager
  File "C:\Python25\lib\site-packages\django\core\management\", line 343, in setup_environ
    project_module = import_module(project_name)
  File "C:\Python25\lib\site-packages\django\utils\", line 35, in import_module
ImportError: No module named src

PyDev doesn't put an in the root src directory and it seems like there shouldn't be one there (it's a directory on the PYTHONPATH).

Change History (8)

comment:1 Changed 10 years ago by Leo Shklovskii

To clarify, this happens when I try to do runserver

comment:2 Changed 10 years ago by dc

Resolution: invalid
Status: newclosed

Django project is a normal python module and you must have in it.

Please don't use trac for asking for the support questions, use either #django on freenode or django-users mailing list.

comment:3 Changed 10 years ago by Leo Shklovskii

Resolution: invalid
Status: closedreopened

This isn't a support question. Running without a project module is perfectly normal and even advocated by James Bennett -

The change mentioned in the ticket breaks the ability to do this, hence its a regression, hence this ticket.

comment:4 Changed 10 years ago by Ramiro Morales

Replying to Leo:

This isn't a support question. Running without a project module is perfectly normal and even advocated by James Bennett -

Problem is that if you are using then you are using a project.

If you really don't want to use a project do what that article (and other similar blog posts) suggest: Set up things manually so all you apps, your settings and your main URL map (usually are in you Python path and use you Django's django-admin (or similar home-made script) instead.

The change mentioned in the ticket breaks the ability to do this, hence its a regression, hence this ticket.

I'd say that if that worked before it was a another problem and the r10751 corrected it.

comment:5 Changed 10 years ago by Jacob

Resolution: invalid
Status: reopenedclosed

I'm fairly sure this is a PyDev bug because looking at the code there's no way it'll step up *two* directories (it just calls os.path.dirname).

comment:6 Changed 10 years ago by Karen Tracey

Leo, I don't understand why you can't just put an in the src directory? Fine, so Pydev doesn't do it automagically but it's easy enough to add one. Then everything works. I also don't see that this structure is mandated by Pydev -- you do not have to use the Eclipse/Pydev default src directory structure, it's just the default. You can easily override and use your own source tree structure. But given that you want to use that structure, what's the problem with putting an file in the root? wasn't needed in the root when you used a settings directory prior to r10751 because the code was incorrectly figuring the 'project' dir WAS the settings dir. And things like startapp would create subdirectories in the settings dir, instead of the root project dir. Now the project dir is being figured out correctly, it needs an file.

comment:7 Changed 10 years ago by Leo Shklovskii

Thanks for all of the feedback. The workaround suggested by kmtracey is fine for now. From an more theoretical standpoint, its just a bandaid, since 'src' is already on the pythonpath and is not an importable package (/lib/site-packages wouldn't have an either) but that's just a handwavy argument.

jacob: It doesn't actually go up two directories. It assumes 'src' is the project name and attempts to import it (which doesn't work in the existing case since its a root pythonpath and not a package).

What ramiro says makes a lot of sense here, since I'm not using a project I shouldn't expect to work - although it would be nice if it did :-)

The one small qualm I have here is that if we assume a project layout, will always be in the project directory and that directory is available on the pythonpath since its the cwd when is run. There's probably use cases that I'm totally not aware of but from the ones I understand there's no need to explicitly import the project package.

Regardless, I'm fine with either abandoning going forward (since we're not using projects) or putting the files in for now.

Thanks again for the comments.

comment:8 Changed 7 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top