If all comment have to have a park and user. 

I would have a ForeignKey to Park and User in the Comments model, and no 
Foreign key in the Parks model.

As such a comment will always need to be linked to an existing park and 
user object, but a park can be created without needing a comment.

JD

On Sunday, May 13, 2012 7:53:58 PM UTC-6, psychok7 wrote:
>
> yes, like a park doesn't have to have comments, but all the comments must 
> have an associated park and user all the time.
>
> what is the django syntax for me to achieve this?
>
> On Monday, May 14, 2012 2:49:18 AM UTC+1, jondykeman wrote:
>>
>> As far as I understand it the ForeignKey will have to be unique=True and 
>> null=False.
>>
>> I want to get a better sense of what you are trying to achieve. Is it 
>> that you want to link comment and park only some of the time?
>>
>> JD
>>
>> On Sunday, May 13, 2012 7:41:39 PM UTC-6, psychok7 wrote:
>>>
>>> so i have this 2 models (Comment and Park)
>>>
>>> Comment has a foreign key to USER and PARK
>>>
>>> PARK has a foreign key to Comment
>>>
>>> my question is, isn't there going to be a deadlock if i don't have a 
>>> comment or a park created? i mean , in order to create a Park i need to 
>>> have a comment, and in order to create a comment i need a park and a user.
>>>
>>> is there a way for me to fix my problem? like allowing the foreign key 
>>> to be null or something like that?
>>>
>>> thanks in advance
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ArUqOsM142QJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to