Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using a frozen model to create foreign key
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Justin  
View profile  
 More options Dec 1 2009, 8:15 pm
From: Justin <stryder...@gmail.com>
Date: Tue, 1 Dec 2009 17:15:30 -0800 (PST)
Local: Tues, Dec 1 2009 8:15 pm
Subject: Using a frozen model to create foreign key
Hello!

I'm loving South right now, it's made my life so much easier.

I"m running into this problem. Here's the models.

In app entity:
class Company(models.Model):
    name = models.CharField()
    ...

In app matchmaking:
class CompanyProfile(models.Model):
    company = models.OneToOneField(Company)
     ...

I'm working with the matchmaking app and I've frozen the entity app.

Here's my migration:

def forwards(self, orm):
        "Write your forwards migration here"
        for company in orm['entity.Company'].objects.all():
             CompanyProfile.objects.get_or_create(company=company)

I'm getting an error that I need to pass in a Company object.
ValueError: Cannot assign "<company: company object>":
"CompanyProfile.company" must be a "Company" instance.

Am I doing this wrong? Any ideas?

Thanks!
Justin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jukka Välimaa  
View profile  
 More options Dec 2 2009, 3:57 am
From: Jukka Välimaa <valimaa.ju...@gmail.com>
Date: Wed, 2 Dec 2009 10:57:04 +0200
Local: Wed, Dec 2 2009 3:57 am
Subject: Re: Using a frozen model to create foreign key

My hunch is that you should also freeze the matchmaking app to the migration
with "--freeze", and use the frozen orm in getting company profile. The
frozen orm models are not the same classes that you get by importing.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Godwin  
View profile  
 More options Dec 4 2009, 4:52 am
From: Andrew Godwin <and...@aeracode.org>
Date: Fri, 04 Dec 2009 09:52:40 +0000
Local: Fri, Dec 4 2009 4:52 am
Subject: Re: Using a frozen model to create foreign key
Yes, Jukka is entirely right. You have to use the frozem version of
Company - i.e. orm['entity.Company'] - as it's a different model to the
one you imported (and for good reason - you might change Company in the
future).

Andrew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »