for many to many relationships between two tables .. you can make a third
table that only contains the id fields ftom both tables , then you can make
a third model for this table

On Fri, 13 Jul 2018, 22:24 , <lissandratheg...@gmail.com> wrote:

> I tried for hours to get django's migrate/makemigrations function work but
> miserably couldn't so I created my tables in MySQL. Now I'm trying to add a
> ManyToManyField between 2 models but am not sure how the MySQL syntax is
> supposed to look like.
>
> This is my current code:
>
> from django.db import models
>
> class Publication(models.Model):
>     title = models.CharField(max_length=30)
>
> class Article(models.Model):
>     headline = models.CharField(max_length=100)
>
> and I can create a table as follows in MySQL:
>
> CREATE TABLE publication (
>     title varchar(30)
> );
> CREATE TABLE Article (
>     headline varchar(100),
> );
>
> I need to add the ManyToManyField like so:
> class Article(models.Model):
>     headline = models.CharField(max_length=100)
>     *publications = models.ManyToManyField(Publication)*
>
> I'm really running low on time, could someone assist me with what the
> MySQL code is supposed to look like? I will be permanently in your debt.
>
> --
> 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/6f546243-23f0-4760-806b-9fff01d2afd7%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/6f546243-23f0-4760-806b-9fff01d2afd7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CAHV4E-eGQQ3jdwSaa9d9xaxk7rV_Tt-Fqas3OTuhYEYd1%3D8zMA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to