Hi
I'm using PyAMF with Django. I've just got started with it. My
Django CMS I've setup currently exports XML using render_to_response
to a template in my views.py:
import django.http as http
import django.shortcuts as shortcuts
import models
def xml(request):
# References to Model
about = models.About.objects.order_by('copy')
contact = models.Contact.objects.order_by('address')
categories = models.Category.objects.order_by('name')
clients = models.Client.objects.order_by('name')
items = models.Item.objects.order_by('name')
press = models.Press.objects.order_by('name')
return
shortcuts.render_to_response("/home/benmarinic/webapps/
betty_soldi_django/templates/portms/data.xml", dict(about=about,
contact=contact, categories=categories, clients=clients, items=items,
press=press))
However I would like to be able to pass a parameter to views.py and
return a property of the method. For example my Model.py has the
following method:
class Contact(models.Model):
name = models.CharField(maxlength=100)
address = models.TextField()
phone = models.CharField(maxlength=30)
fax = models.CharField(maxlength=30)
email = models.CharField(maxlength=100)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "Contact"
class Admin:
pass
I would like to pass 'phone' and have return the phone entry rather
than the Contact object. How would I modify contact =
models.Contact.objects.order_by('address') to do this.
Thanks
Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---