Hello, I am new to Django, and trying to figure out how best to use  
it. My immediate problem is that I'm trying to figure out how to use  
raw SQL in combination with the model layer. Here are the issues I've  
run into:

1) How do I turn a row into a model object? There is some discussion  
of writing raw SQL in the docs (http://docs.djangoproject.com/en/dev/ 
topics/db/sql/#topics-db-sql), but I didn't see anything on turning  
the row into a model object. Do I need to create a dict from the row  
values and then call the model object's __init__ method? Or is there  
something simpler that I'm missing?

2) If the model object as a ForeignKey, then the construction of a  
model object is trickier. From playing around, it appears to be the  
case that the dict must have an object of the referenced type, not  
the value of the foreign key. This could make manual construction of  
model objects difficult. I must be doing something wrong -- forcing  
creation of the related objects seems wasteful, especially as it  
could propagate, (if the referenced object has its own FKs).

Jack Orenstein

--~--~---------~--~----~------------~-------~--~----~
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 
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