<http://www.djangobook.com/en/2.0/_images/book_editform1.png> I will start by saying I have an existing database, for the purpose of my question it has three tables: Vm Vm_licenses Licenses
This database is per-existing before we decided to make a django web-portal. Basically licenses is a database that contains all possibile licenses, and Vm contains all the vms under our architecture. We then have a table vm_licenses, where it has a unique index vm_license_id, and two other columns vm_id with is the primary key for VM and license_id which is the primary key for licenses. I want to use the admin page to be able to edit the vm_licenses that way when i select a vm from vm_licenses on the admin page I can select from a list of licenses which licenses go with that vm. The only problem is the database already exist and as far as I can tell the relationship between the tables doesn't exist in a way django can do this with. I have the following model set up: 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 Vm_license(models.Model): vm_license_id = models.BigIntegerField(primary_key = True, editable = False, db_column = 'vm_license_id') license= models.ForeignKey(License, on_delete = models.PROTECT) vm = models.ForeignKey(Vm, on_delete = models.PROTECT) class Meta: managed = False db_table = 'vm_licenses' class Vm(models.Model): vm_id = models.BigIntegerField(primary_key = True, editable = False, db_column = 'vm_id') vm_mor = models.CharField(max_length = 20) vm_name = models.CharField(max_length = 256) vm_group= models.ForeignKey(Vm_group, on_delete = models.PROTECT) vm_display_name = models.CharField(max_length = 30) datacenter= models.ForeignKey(Datacenter, on_delete = models.PROTECT) vcd_managed = models.CharField(max_length = 60) class Meta: managed = False db_table = 'vms' def __unicode__(self): # Python 3: def __str__(self): return self.vm_name My admin page is : class vm_license_admin(admin.ModelAdmin): > list_display = ('vm', 'vm_license_id') > search_fields = ('vm__vm_name',) > ordering = ('vm',) > #filter_horizontal = ('license',) > it says I need a manytomany relationship so I cahnged license= models.ForeignKey(License, on_delete = models.PROTECT) license= models.ManyToManyField(License) but then it says it cant find the table or view from oracle when I change it.. How do I fix this I want to be able to assign licenses like the following picture: -- 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/6ce2267b-6618-4ada-b83b-d612c5911d8b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.