Advertisement
Guest User

Untitled

a guest
Jul 31st, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. This is the content of the models.py of my app. When i run syncdb or sql <appname> command, I'm getting error that Tags is not defined. Please help.
  2. -----------------------------------------------------------------
  3.  
  4. from django.db import models
  5.  
  6. # Create your models here.
  7.  
  8. class Customer(models.Model):
  9. name = models.CharField(max_length = 50)
  10.  
  11. class Tweet(models.Model):
  12. content = models.CharField(max_length = 140)
  13. pub_date = models.DateTimeField()
  14. author = models.ForeignKey(Customer)
  15. tag_user = models.ForeignKey(Tags)
  16. tag_company = models.ForeignKey(Tags)
  17.  
  18. class Tags(models.Model):
  19. company_tags = models.CharField(max_length = 25)
  20. user_tag = models.CharField(max_length = 25)
  21. -----------------------------------------------------
  22.  
  23. getting this error when i run the above file:
  24. -----------------------------------------------------
  25. aravind@aravindPC:~/djan-apps/twijango$ python manage.py sql tweetrack
  26. Traceback (most recent call last):
  27. File "manage.py", line 10, in <module>
  28. execute_from_command_line(sys.argv)
  29. File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
  30. utility.execute()
  31. File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
  32. self.fetch_command(subcommand).run_from_argv(self.argv)
  33. File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
  34. self.execute(*args, **options.__dict__)
  35. File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 231, in execute
  36. self.validate()
  37. File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 266, in validate
  38. num_errors = get_validation_errors(s, app)
  39. File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 30, in get_validation_errors
  40. for (app_name, error) in get_app_errors().items():
  41. File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 158, in get_app_errors
  42. self._populate()
  43. File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 64, in _populate
  44. self.load_app(app_name, True)
  45. File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 88, in load_app
  46. models = import_module('.models', app_name)
  47. File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
  48. __import__(name)
  49. File "/home/aravind/djan-apps/twijango/tweetrack/models.py", line 8, in <module>
  50. class Tweet(models.Model):
  51. File "/home/aravind/djan-apps/twijango/tweetrack/models.py", line 12, in Tweet
  52. tag_user = models.ForeignKey(Tags)
  53. NameError: name 'Tags' is not defined
  54.  
  55. self.load_app(app_name, True)
  56. File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 88, in load_app
  57. models = import_module('.models', app_name)
  58. File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
  59. __import__(name)
  60. File "/home/aravind/djan-apps/twijango/tweetrack/models.py", line 8, in <module>
  61. class Tweet(models.Model):
  62. File "/home/aravind/djan-apps/twijango/tweetrack/models.py", line 12, in Tweet
  63. tag_user = models.ForeignKey(Tags)
  64. NameError: name 'Tags' is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement