Reputation: 3
I am coding python in Eclipse using PyDev.
Some code errors can not be detected, I can only know them when I tried to run the code. Is it normal? Are there some methods that can show this kind of error when I code? Thank you in advance!
For example, for the code below, I will get "NameError: name 'User' is not defined" only when I run the code.
from django.db import models
# Create your models here.
class Board(models.Model):
name = models.CharField(max_length=30,unique=True)
description = models.CharField(max_length=100)
class Topic(models.Model):
subject = models.CharField(max_length=225)
last_update = models.DateTimeField(auto_now_add=True)
board = models.ForeignKey(Board,models.DO_NOTHING,related_name='topics')
starter = models.ForeignKey(User,related_name='topics')
Upvotes: 0
Views: 252
Reputation: 25332
It does work for me, so, I think this is probably some misconfiguration of the PYTHONPATH.
In particular, your source code must be under a source folder for the code analysis to work (a source folder is the folder which is added to the PYTHONPATH).
Please see: http://www.pydev.org/manual_101_project_conf2.html for details on how to configure the source folders.
If you believe this is not the problem, please also include in your screenshot the PyDev Package explorer (expanded up to the related file).
Upvotes: 1