I'm trying to display a list on a page that is a combination of two
different models. In development I use sqlite and the list works great, but
when I go to MySQL I don't get any results. It's odd because I use
pagination and I can see from my paging items there are some results but I
can't call them from template. I'm not sure if this is considered a bug or
something lacking in features for MySQL. The View, Template and Model info
are below.
I've tried Django 1.0.2 and Django SVN-1.1-10678. Both versions work with
sqlite and both fail with MySQL.
Thanks for any help,
Keith
View:
return render_to_response('ticket/ticket_list.html', {'object_list':
Ticket.objects.all().select_related()})
Template:
{% if object_list %}
{{ object_list.as_table}}
{% for object in object_list %}
{% for load in object.load_set.select_related %}
<tr>
<td><a href=/ticket/edit/{{ object.id }}> {{ object.id }}
</a></td>
<td>{{ object.type }}</td>
<td>{{ object.customer_ticket }}</td>
<td>{{ object.unload_date }}</td>
<td>{{ object.driver }}</td>
<td>{{ load.container_id }}</td>
<td>{{ load.product }}</td>
<td>{{ load.tank }}</td>
<td>{{ load.net_weight }}</td>
<td>{{ load.net_barrels }}</td>
</tr>
{% endfor %}
{% endfor %}
{% endif %}
Model:
class Load(models.Model):
ticket = models.ForeignKey('Ticket')
container_id = models.CharField(max_length=12, blank=True)
entered = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
product = models.ForeignKey('Product')
tank = models.ForeignKey('tank.Tank')
bs_w = models.DecimalField(blank=True, null=True, decimal_places=2,
max_digits=4)
api = models.DecimalField(blank=True, null=True, decimal_places=4,
max_digits=6)
halogens = models.BooleanField(blank=True) #yes/no
tare_weight = models.DecimalField(blank=True, null=True, decimal_places=4,
max_digits=12)
gross_weight = models.DecimalField(blank=True, null=True,
decimal_places=4, max_digits=12)
net_weight = models.DecimalField(blank=True, null=True, decimal_places=4,
max_digits=12)
gross_barrels = models.DecimalField(blank=True, null=True,
decimal_places=4, max_digits=12)
net_barrels = models.DecimalField(blank=True, null=True, decimal_places=4,
max_digits=12)
price = models.DecimalField(blank=True, null=True, decimal_places=4,
max_digits=12) # Price per barrel
total = models.DecimalField(blank=True, null=True, decimal_places=4,
max_digits=12) # Total for load
def __unicode__(self):
return unicode(self.id)
class Ticket(models.Model):
type = models.ForeignKey('LoadType')
entered = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
customer_ticket = models.CharField(max_length=100, blank=True)
inspector = models.ForeignKey('profile.UserProfile', blank=True,
null=True, related_name='inspector', limit_choices_to = {'is_unloader': 1})
transporter = models.ForeignKey('profile.Company', blank=True, null=True,
related_name='transporting_company', limit_choices_to = {'is_transporter':
1})
shipper = models.ForeignKey('profile.Company', blank=True, null=True,
related_name='shipper_name',limit_choices_to = {'is_shipper': 1})
receiver = models.ForeignKey('profile.Company', blank=True, null=True,
related_name='receiving_facility', limit_choices_to = {'is_receiver': 1})
pickup_date = models.DateField(blank=True, null=True)
pickup_time = models.TimeField(blank=True, null=True)
unload_date = models.DateField(blank=True, null=True)
unload_time = models.TimeField(blank=True, null=True)
driver = models.ForeignKey('profile.UserProfile', blank=True, null=True,
related_name='driver_name', limit_choices_to = {'is_driver': 1})
vehicle_id = models.CharField(max_length=100, blank=True)
unloader = models.ForeignKey('profile.UserProfile', blank=True, null=True,
related_name='unloader_name', limit_choices_to = {'is_unloader': 1})
misc = models.TextField(blank=True)
def __unicode__(self):
return unicode(self.id)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---