Jedi-vim: Autocomplete Django Models

Created on 8 Aug 2014  Â·  14Comments  Â·  Source: davidhalter/jedi-vim

In the following code I am not getting the auto complete suggestions for all of Model.Objects. When I use Pycharm it shows the auto complete, So I am not sure why I don't see it with jedi-vim. Here is an example image of pycharm on top and vim on bottom. http://i.imgur.com/pwWl7UK.png

from django.db import models
class Apple(models.Model):
name = models.CharField(max_length=30)

class Orange(models.Model):
name = models.CharField(max_length=30)

def get_top_apple(self):
    #I want .objects to autocomplete
    return Apple.objects.first()
jedi-issue

Most helpful comment

@gun1x guess which year it is :grin: :grin: :grin:

All 14 comments

Well, models.Model is a meta class. Jedi doesn't understand meta classes. That's why you don't get that completion.

Now how does PyCharm do this? They check for django models and just have their own custom code (to basically imitate the meta class). Jedi might do that in the future, but IMHO it's not that important. I'm basically waiting for someone to step in and do it.

Cool, Thanks for the fast response!

Are there any updates regarding this issue?

With Ubuntu 16.04, vim comes by default with python3 (no more manual compilation is required) and right now it's really easy to set up an environment. It would be great to get Jedi to autocomplete Meta classes, because it would provide a perfect IDE out of the box.

No. Nobody has tackled this.

Hey Flavio,

I didn't track this issue. It will probably get developed in the future, if
there are enogh vim django devs.

If you really need this, think about helping the community and sponsoring
jedi support for meta classes.

If this doesn't get done till 2019, I will probably try to sponsor this,
since by then I will have a big Django project and I would rather use vim
than any other IDE.

Best Regards,
gxgung

On Fri, Jul 28, 2017 at 9:37 PM, Flávio Juvenal da Silva Junior <
[email protected]> wrote:

I know Jedi doesn't support metaclasses, and Django use metaclasses to
link managers and querysets. But how python manage.py shell (with ipython
installed) can autocomplete queryset methods?
[image: screen shot 2017-07-28 at 15 33 36]
https://user-images.githubusercontent.com/397989/28731446-52e5c9ba-73aa-11e7-87b5-8e7fa20b2e0e.png

Does anyone know if Django somehow give hints to Jedi?

The regular usage only gives autocompletion only for manager methods:

In [13]: import jedi
...:
...: source = '''
...: from django.contrib.auth.models import User
...:
...: user = User.objects.'''
...:
...: script = jedi.Script(source, 4, 20)
...: script.completions()
...:
Out[13]:
[,
,
,
,
,
,
]

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/davidhalter/jedi-vim/issues/298#issuecomment-318731069,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKkrdNcleLTNt1FtE3hG8psTVnldPiAuks5sSipegaJpZM4CVlqw
.

@gun1x guess which year it is :grin: :grin: :grin:

@gun1x guess which year it is

:rofl: :rofl: :rofl:

Yea, in the meantime I started to work with go and vim-go works really well. But still... it's too late to edit or delete my comment. :rofl:

How much would the development cost?

That depends on what you want :) If you're really interested in this (don't feel forced) and would like to sponsor this, please contact write an email and I will see what I can do.

@davidhalter I don't know how much work will it take to implement this, but I think it would be a popular feature request. What do you think about organizing a crowdfunding event for this, just like what Tom Christie did with django rest framework? Maybe based on the fund that is collected we could add support for other projects like flask too

PyCharm Professional edition supports this python frameworks: Django, Flask, Pyramid, Web2Py & Google App Engine

@sazary I'm considering crowdfunding, but you cannot do crowdfunding every half a year. Since I don't care too much about Django (Even though I'm writing Django code almost daily), I definitely don't care that much about the other frameworks. I feel like what Jedi needs is (in order):

  1. Bugfixes for current open issues
  2. Performance Issues
  3. A Database Index for Usages
  4. A Plugin System for Django, etc.

For 2./3., I'm considering a rewrite in Rust and that's also where I would start a fundraiser. My personal motivation is to improve Jedi's core into a good place.

And for anyone that wants to help, there's always https://github.com/davidhalter/jedi/issues/1401, where you guys could start working on it.

Apparently https://github.com/davidhalter/jedi/issues/1401 was fixed/implemented. How would one take advantage of this with jedi-vim?

Jedi 0.17.1 has not been released yet, so you need to wait for a bit.

Was this page helpful?
0 / 5 - 0 ratings