Hi,

to access a model in the view, simply import it into you view.
Something along the lines:

from yourapp.models import Place
from django.http import HttpResponse

def some_view(request):
    OBJECT_ID = 1 # put here the id of the object
                            # or give it as a function argument
    place = Place.object.get(id=OBJECT_ID)
    coordinates= place.coordinates()
    return HttpResponse("The coordinates of the place number %s are:
%s"\
                               % (OBJECT_ID, coordinates) # assuming
Location has
 
# a string representation

You can also use django.db.models.get_model, which returns a model
class from a app_label, model_name tuple, although i would only use it
when the model names is not known at the compiling time.

Hope it helps.

Alendit.

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