Ive also tried

class License(models.Model):
   license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'license_id')
   license_authority = models.ForeignKey(License_authoritie,  on_delete = 
models.PROTECT)
   product = models.CharField(max_length = 20)
   
   class Meta:
      managed = False
      db_table = 'licenses'
      ordering = ['product']

   def __unicode__(self):  # Python 3: def __str__(self):
      return self.product

class LicenseAssignments(models.Model):
    license = models.ForeignKey(License, db_column="license_id")
    vm_license = models.ForeignKey(Vm_license, db_column="vm_license_id")

    class Meta:
        db_table = "license_assignments" 
           
class Vm_license(models.Model):
   vm_license_id = models.BigIntegerField(primary_key = True, editable = 
False, db_column = 'vm_license_id')
   license = models.ManyToManyField(License, through="LicenseAssignments")
   vm = models.ForeignKey(Vm,  on_delete = models.PROTECT)
   
   class Meta:
      managed = False
      db_table = 'vm_licenses'
          
but when i sync the db i get the following error

    self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 284, in execute
    self.validate()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 310, in validate
    num_errors = get_validation_errors(s, app)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", 
line 34, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 
196, in get_app_errors
    self._populate()
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 
75, in _populate
    self.load_app(app_name, True)
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 
99, in load_app
    models = import_module('%s.models' % app_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", 
line 40, in import_module
    __import__(name)
  File "/home/grant/workspace/Django 
Projects/trunk/holon/portal/models.py", line 411, in <module>
    class LicenseAssignments(models.Model):
  File "/home/grant/workspace/Django 
Projects/trunk/holon/portal/models.py", line 413, in LicenseAssignments
    vm_license = models.ForeignKey(Vm_license, db_column="vm_license_id")
NameError: name 'Vm_license' is not defined


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/32a569f4-9a9c-447d-a311-ec1b4cfdc829%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to