Closed aleprovencio closed 8 years ago
I just looked over the cookiecutter template, and the settings should still be found as long as manage.py
is found. Is it not working?
It doesn't seem to, at least b:is_django_settings
does not get set. Maybe I'm also not getting the correct form of using settings completions, can you please clear that up for me?
Where is manage.py
relative to your settings directory and what's the value of DJANGO_SETTINGS_MODULE
in that script? Could you tell me the layout of the project?
This is "vanilla" cookiecutter, where DJANGO_SETTINGS_MODULE
points to config.settings.local
, organized this way:
...
manage.py
config/
...
settings/
I was asking for your layout (assuming it was slightly different from cookiecutter). Anyways, I made a mistake in my assumption. I think I see why it's not working for you. The completion script is assuming that the scripts are only one directory deep. I misread the source 😅
Could you confirm that this is fixed?
Unfortunately it still does not...Just to make sure I've tested a non-cookiecutter layout which does set b:is_django_settings. However I still wonder what kind of completions I'm able to get from it. Anyways, thank you for your efforts @tweekmonster !
I just tested with an arbitrary path for the settings module. I got the error:
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
After setting SECRET_KEY
it worked. Maybe there's an error you're just not seeing. You can test the script directly with:
env _DJANGOPLUS_MANAGEMENT=/path/to/manage.py python /path/to/django-plus.vim/bin/completions.py
Really at a loss here, maybe a missing else
on your code?
→ env _DJANGOPLUS_MANAGEMENT=manage.py python ~/.vim/plugged/django-plus.vim/bin/completions.py
Traceback (most recent call last):
File "/home/aleprovencio/.vim/plugged/django-plus.vim/bin/completions.py", line 26, in <module>
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
NameError: name 'settings_module' is not defined
Nah, the script assumes that the manage.py
script exists. Would you mind posting the contents of manage.py
?
Nevermind, I see the problem now. The cookiecutter project uses single quotes instead of double quotes.
env _DJANGOPLUS_MANAGEMENT=manage.py python ~/.vim/plugged/django-plus.vim/bin/completions.py
Traceback (most recent call last):
File "/home/aleprovencio/.vim/plugged/django-plus.vim/bin/completions.py", line 31, in <module>
os.chdir(base)
OSError: [Errno 2] No such file or directory: ''
Is that the whole exception? It doesn't look like it.
Have you tried it in Vim? I'll still fix that error, but it should work now since the plugin uses full paths for the completion script.
When on config/settings/common.py
, config/settings/production.py
, etc, b:is_django_settings
still does not get set.
Ah, yeah it's still expecting to find settings.py
. I'll see if that can be changed easily.
That's awesome @tweekmonster, it does work! Maybe README also deserves update. Big thanks!
Great 🙂 What do you suggest should be mentioned in the README? My thought is that it (now) does what the README says in the case for cookiecutter boilerplates.
I guess it should mention that the detection method also understands cookicutter-like layouts, that's all :)
@aleprovencio Are you still using this plugin in a way that perhaps you could help me out with configuring it properly to get queryset completion? ergo: #19
I'm sorry, have not been using it anymore :/
@josefson I've been using the plugin. Happy to help out if you'd like
Like in the cookiecutter project, the settings structure is arranged this way: