Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve settings detection #2

Closed
aleprovencio opened this issue Jul 21, 2016 · 22 comments
Closed

improve settings detection #2

aleprovencio opened this issue Jul 21, 2016 · 22 comments

Comments

@aleprovencio
Copy link

Like in the cookiecutter project, the settings structure is arranged this way:

settings/
    common.py
    local.py
    production.py
    test.py
@tweekmonster
Copy link
Owner

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?

@aleprovencio
Copy link
Author

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?

@tweekmonster
Copy link
Owner

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?

@aleprovencio
Copy link
Author

This is "vanilla" cookiecutter, where DJANGO_SETTINGS_MODULE points to config.settings.local, organized this way:

...
manage.py
config/
    ...
    settings/

@tweekmonster
Copy link
Owner

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 😅

@tweekmonster
Copy link
Owner

Could you confirm that this is fixed?

@aleprovencio
Copy link
Author

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 !

@tweekmonster
Copy link
Owner

tweekmonster commented Jul 22, 2016

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

tweekmonster added a commit that referenced this issue Jul 22, 2016
@aleprovencio
Copy link
Author

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

@tweekmonster
Copy link
Owner

Nah, the script assumes that the manage.py script exists. Would you mind posting the contents of manage.py?

@tweekmonster
Copy link
Owner

Nevermind, I see the problem now. The cookiecutter project uses single quotes instead of double quotes.

@aleprovencio
Copy link
Author

aleprovencio commented Jul 23, 2016

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: ''

@tweekmonster
Copy link
Owner

Is that the whole exception? It doesn't look like it.

@tweekmonster
Copy link
Owner

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.

@aleprovencio
Copy link
Author

When on config/settings/common.py, config/settings/production.py, etc, b:is_django_settings still does not get set.

@tweekmonster
Copy link
Owner

Ah, yeah it's still expecting to find settings.py. I'll see if that can be changed easily.

tweekmonster added a commit that referenced this issue Jul 24, 2016
@aleprovencio
Copy link
Author

That's awesome @tweekmonster, it does work! Maybe README also deserves update.
Big thanks!

@tweekmonster
Copy link
Owner

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.

@aleprovencio
Copy link
Author

I guess it should mention that the detection method also understands cookicutter-like layouts, that's all :)

@josefson
Copy link

@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

@aleprovencio
Copy link
Author

I'm sorry, have not been using it anymore :/

@KentBrockman
Copy link

@josefson I've been using the plugin. Happy to help out if you'd like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants