add item to existing table in migration

1 view
Skip to first unread message

Soulburner

unread,
Dec 6, 2009, 8:15:38 PM12/6/09
to South Users
i new to south and i was wondering if the following was supported

heres my models

class Action(models.Model):
name = models.CharField(max_length=255)

class AuthorisedAction(models.Model):
userClass = models.ForeignKey(UserClass)
action = models.ForeignKey(Action)

class UserClass(models.Model):
name = models.CharField(max_length=64)
power = models.BooleanField()
priority = models.IntegerField()

and in my migration in the forwards function im trying to add a new
item
qManger = orm.UserClass.objects.get(name="Quarantine
Manager")
rAction = orm.Action.objects.get(name =
actions.ECFQuarantineManager_Refresh.name)
refreshAction = orm.AuthorisedAction.objects.get_or_create
(userClass = qManger, action = rAction)
#refreshAction = orm.AuthorisedAction(userClass = qManger,
action = rAction)


so both get_or_create and trying to just instatiate a AuthorisedAction
object fail.


o yeah i know that you could achieve this with a fixture but the
project im working on has a hand crafted fixture like thing that i
don't want to have to rewrite (though i might try making my own
fixture for just this thing)

Andrew Godwin

unread,
Dec 7, 2009, 6:59:25 AM12/7/09
to south...@googlegroups.com
That should be alright; what's the error you're getting when using
get_or_create / direct instantiation?

Andrew
> --
>
> You received this message because you are subscribed to the Google Groups "South Users" group.
> To post to this group, send email to south...@googlegroups.com.
> To unsubscribe from this group, send email to south-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/south-users?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages