Tom, It fails with both autofield and bigintergerfield
class License(models.Model): license_id = models.AutoField(primary_key = True, editable = False, db_column='license_id') license_authority_id = models.ForeignKey(License_authoritie, on_delete = models.PROTECT, db_column='license_authority_id') 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.AutoField(primary_key = True, db_column='vm_license_id') license_id = models.ForeignKey(License, on_delete = models.PROTECT, db_column='license_id') vm_id = models.ForeignKey(Vm, on_delete = models.PROTECT, db_column='vm_id') class Meta: managed = False db_table = 'vm_licenses' I get the same thing: Request Method: POSTRequest URL: http://127.0.0.1:8000/admin/portal/vm_license/add/Django Version: 1.6.5Exception Type: IntegrityErrorException Value: ORA-01400: cannot insert NULL into ("DEV"."VM_LICENSES"."VM_LICENSE_ID") On Tuesday, July 15, 2014 4:09:29 PM UTC-6, Tom Evans wrote: > > On Tue, Jul 15, 2014 at 10:23 PM, G Z <zuk...@gmail.com <javascript:>> > wrote: > > So I have a database that we are using to collect vm statistics. It is > > always running and writing to a django database. > > I built my models file to resemble the db. However I have run into quite > a > > few issues. I was wondering if anyone else has run into these issues > > and found out how to solve them. > > > > First when I try to add a new entry I get an error returned that the > value > > can't be null for the primary key. > > > > ORA-01400: cannot insert NULL into ("DEV"."VM_LICENSES"."VM_LICENSE_ID") > > > > Isn't django supposed to automatically handle this when you set > primary_key > > = True? > > > > > > > > Also I want to have a list of available licenses from a table called > > licenses, and I want to be able to assign > > them by foreign key to each vm by its foreign key in an intermediary > table > > called vm_licenses. > > > > Here are the model snippets for that process. However, I can't get > > manytomany to work right. > > Bascially our system admins need to be able to manage the associated > > licenses for each vm. I'm trying to allow them to > > do this with the admin page. People keep pointing me to the > documentation > > for manytomany but obviously I can't seem to figure out > > how django uses already established databases. The django documentation > > doesn't really explain how things work. Thus, > > anything outside the basic blog app is unknown territory you just kinda > have > > to plug away in the dark. I'm tired of plugging away > > trying to figure out how this framework works. > > > > I would greatly appreciate it if someone could help me understand how > the > > django framework interacts with already established databases and how > > to do what I want. > > > > > > class License(models.Model): > > license_id = models.BigIntegerField(primary_key = True, editable = > False, > > db_column='license_id') > > Auto increment is a feature of AutoField, not of primary keys. > > https://docs.djangoproject.com/en/1.6/ref/models/fields/#autofield > > BigIntegerField has no auto increment properties. > > Marking a field as a primary key simply means that no AutoField named > id is automatically added to your class, and the SQL generated for > that field will mark it as a primary key. > > Cheers > > Tom > -- 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/65032c69-1139-480c-b739-7c54fc9a1824%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.