On Wed, 2007-10-31 at 16:56 +0000, Dan Ellis wrote:
> I have a model that contains a field, severity, that is a ForeignKey.
> When I create a new instance, I'd like that field to have the id of
> the Severity instance with the name 'Low'. What is the best way to do
> this? Putting default=1 in the model breaks encapsulation. I could
> manually set it to Severity.objects.get(name="Low").id in the view
> that creates it, which is a bit better, but not much.
> 
> What's the right thing to do?

Set it in your model's save() method.

Regards,
Malcolm

-- 
Telepath required. You know where to apply... 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to