*there's no problem appeared but when I go to my database, there's no
connection with these two table.. there should be a connection between two
same name column.(foreign key)*
Correction with my code above.

*Author_code = models.ForeignKey(Author, to_field='Author_code',
on_delete=models.CASCADE)*
*there's a quotation mark in this column, My fault I forgot to put it
above. *

On Thu, Jan 12, 2017 at 8:18 PM, <jorrit...@gmail.com> wrote:

> What exactly isn't working? Are you getting an error message?
>
> I can see a few potential problems:
>
>    - You're missing a quotation mark around Author_code in the *to_field*
>    parameter;
>    - The fields on both models have the same name, this might cause
>    problems.
>
>
>
> On Thursday, January 12, 2017 at 10:40:43 AM UTC+1, jeffreyequizuvero
> wrote:
>>
>>
>>
>> *This is about the models foreign key, I have two tables and i used
>> foreign key to connect these tables however after i did migration it's not
>> working. Is there any wrong with my code? *
>>
>> *please help, Thanks. *
>>
>>
>> class *Author*(models.Model):
>> *    Author_code = models.CharField(max_length=50,unique=True)*
>>     Author_Fname = models.CharField(max_length=30, blank=True, null=True)
>>     Author_Mname = models.CharField(max_length=30, blank=True, null=True)
>>     Author_Lname = models.CharField(max_length=30, blank=True, null=True)
>>
>>     class Meta:
>> #         managed = False
>>         db_table = 'Author'
>>
>>
>> class *Book*(models.Model):
>>
>>     Book_code = models.CharField(max_length=50, blank=True,
>> default=user_code_key,unique=True)
>> *    Author_code = models.ForeignKey(Author, to_field=Author_code',
>> on_delete=models.CASCADE)*
>>     Book_title = models.CharField(max_length=50, blank=True, null=True)
>>
>>     class Meta:
>>  #       managed = False
>>         db_table = 'Book'
>>
>>
>>
>>
>> --
> 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/fb32e401-f1a6-4180-a49a-12c86b09bed5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fb32e401-f1a6-4180-a49a-12c86b09bed5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

*Jeffrey E. Uvero*

*Amellar Solution*

3rd Floor, LGI Building, Ortigas Avenue

Greenhills, San Juan City,

Philippines 1500

*Tel:* (+63) 9776824461

*SkypeID:* jeffrey.uvero

*Email:* j <ca...@jeonsoft.com>effreyequizuv...@gmail.com /
jeffeuw...@gmail.com

-- 
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/CAEtSeGv-2csFBZwaPWH30CqmdjmGA9s4oPhf9vQFohqrPVF2ZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to