Django doesn’t support multiple primary keys.  unique_together just adds an 
extra constraint to the table.

Since you didn’t specify a primary key, id was added for you by default.  

Sent from my iPad

> On Nov 14, 2018, at 1:55 AM, 胡超 <herohu...@gmail.com> wrote:
> 
> 
> class QdProjectAssist(models.Model):
>     '''
>     页面推荐
>     '''
>     # id = models.AutoField('主键', primary_key=True)
>     project_id = models.ForeignKey('QdProject', verbose_name='项目', 
> on_delete=models.CASCADE)
>     assist_id = models.ForeignKey('QdAssist', verbose_name='正文', 
> on_delete=models.CASCADE)
>     sort = models.PositiveIntegerField('排序', blank=True, null=True)
>     addtime = models.PositiveIntegerField('添加时间')
>     uptime = models.DateTimeField('更新时间', auto_now=True)
> 
>     class Meta:
>         managed = False
>         db_table = 'qd_project_assist'
>         unique_together = ('project_id', 'assist_id')
>         verbose_name = '页面推荐'
>         verbose_name_plural = verbose_name
> 
> I export the table with two primary keys from mysql.
> 
> Reporting errors in the course of use
> 
> django.db.utils.InternalError: (1054, "Unknown column 'qd_project_assist.id' 
> in 'field list'")
> -- 
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/117bd094-09bd-429c-a289-0074de2374f5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8E2B53CE-4BBD-4531-A7EB-AEDF6C428BAF%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to