Django无法在PostgreSQL中创建表

时间:2019-06-17 11:24:57

标签: python django python-3.x postgresql psycopg2

我在ubuntu 18.04中使用 django == 2.2.1 postgres == 10.8 psycopg2 == 2.8.1 。当我运行makemigrationsmigrate时,它已成功运行,但更改未出现在postgres中。

它给了我错误:

django.db.utils.ProgrammingError: column ip_management_ipmanage.userTeam_id does not exist
LINE 1: ...k_id", "ip_management_ipmanage"."userGateway_id", "ip_manage...

这是我的模型代码:

('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('userName', models.CharField(max_length=200, verbose_name='User Name')),
('userGateway', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='gateway_info', to='ip_management.Gateway', verbose_name='Gateway')),
('userHostName', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='host_name_info', to='ip_management.HostName', verbose_name='Host Name')),
('userIpAddress', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ip_address_info', to='ip_management.IPAddress', verbose_name='IP Address')),
('userIpAddressOld0', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ip_address_info_0', to='ip_management.IPAddress', verbose_name='IP Address Old 0')),
('userIpAddressOld1', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='ip_address_info_1', to='ip_management.IPAddress', verbose_name='IP Address Old 1')),
('userPatchNumber', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='patch_number_info', to='ip_management.PatchNumber', verbose_name='Patch')),
('userSubnetMask', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='subnet_mask_info', to='ip_management.SubnetMask', verbose_name='Subnet mask')),
('userSwitch', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='switch_info', to='ip_management.Switch', verbose_name='Switch')),
('userSwitchPort', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='switch_port_info', to='ip_management.SwitchPort', verbose_name='Switch Port Number')),
('userTeam', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='team_info', to='ip_management.Teams', verbose_name='Team')),

showmigrations results

0 个答案:

没有答案