0

I am using pycharm for a django project. I made an app named 'music' and there I created a model named 'Album'.

Inside Views I am using a for loop to get to the details stored in the database like this

all_albums = Album.objects.all()
for album in all_albums:
    album.artist

however when I type album. I don't get autocomplete suggestions for artist or anything else that I have defined in that class.

How to make pycharm include my own modules in the autocomplete?

Ishan
  • 3,303
  • 5
  • 29
  • 47

1 Answers1

0

One way, using docstrings:

for each in qs:
    payment = each
    """@type : Payment """
    print payment.deadline

Another way, using assert:

for each in qs:
    assert isinstance(each, Payment)
    print each.deadline

You can Google 'pycharm type hinting' or similar to find out more.

Lauri Elias
  • 1,231
  • 1
  • 21
  • 25
  • Thanks for your answer, but I was not looking to set the type manually using either of the both ways. After reading this http://stackoverflow.com/a/35368305/1641882 I figured that this was the problem with my setup and indeed it was. I set the correct settings file and everything is working. Thanks for the help though. – Ishan Jun 03 '16 at 15:26