Django and VS Code intelligence + Pylance

Hi,

I use VS Code with Django and Pylance extensions installed. For unknown reason, my intellisense stopped to work and when I need to access to models class like the following:

from django.db import models

# Create your models here.

class Account_Type(models.Model):
    account_type = models.CharField(max_length=50)

class Users_Account(models.Model):
    username = models.CharField(max_length=255) #Can be an email address
    password = models.CharField(max_length=80)
    email = models.EmailField(max_length=254)
    account_type = models.ForeignKey(Account_Type, on_delete=models.PROTECT)
    is_active = models.BooleanField(default=True)

as you can see colors stopped to be used for the class I created and mon_delete does not provide me with PROTECT, CASCADE or anything else, when I just type “models.”

so why colors are not anymore displayed for this model class and why values like CASCADE or PROTECT are not suggested when I type “models.” ?

Side note: Please do not post images of code here. Copy/paste the code into the body of your post surrounded by lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```.

Why do you have:
account_type = models.models.ForeignKey(...
instead of:
account_type = models.ForeignKey(...
which matches the pattern you’re using for the other fields?

I’ve seen this issue, and this is from intellisense too. each time it does the same and I have to correct it manually.

However this is another issue with my VS Code intellisense right now as I do not understand why pylance and VS Code intellisense do not work well together as I wrote before.

Ok, I found the issue.

My venv was outside the project folder and VS Code nees the venv folder inside the project folder. Now it works.

This is not an accurate statement. VS Code will support the venv directory anywhere within the file system - you just need to configure it to identify its location.