Django views/templates weirdness

Hi,

Today I've downloaded PyCharm after seeing the Pycon video. So far I am impressed with the very nice Django integration and code intelligence. However, one of the nicest features (code completion inside Django templates for view variables) often does not work, depending on which render function you use and if you use keyword arguments or not.

For example:

return render_to_response('file.html', {'foo':bar})

This works as expected. I can use "jump to source", and inside the template I can autocomplete the "foo" variable.

return direct_to_template(request, 'file.html', {'foo':bar})

I can use "jump to source", but code completion does not work.

return direct_to_template(request, template='file.html', extra_context={'foo':bar})

Neither "jump to source" or code completion works. And this is the one I *always* use for my view functions...

So, I am wondering what the reasoning behind this is. Is there no support for direct_to_template? Also no support for keyword arguments?

Thanks,

Kevin

2 comments
Comment actions Permalink

Hi Kevin,

It definitely looks like a bug. I've filled an issue for that: http://youtrack.jetbrains.net/issue/PY-3145

It will be fixed in next PyCharm update. You can vote to get notifications about a progress.

Thanks,

Dmitry

0
Comment actions Permalink

It's great to see that this will be fixed in the next release. However, I am slowly swiching to Django 1.3's class-based generic views and I've noticed that autocompletion of variables inside templates doesn't work anymore.

class MyView(DetailView):
    template_name = 'template.html'
    model = MyModel
    slug_field = 'my_slug_field'

Inside the template, I now have the variable {{ momodel }}, but autocompletion doesn't work.

0

Please sign in to leave a comment.