Duh!
Never mind. Sorry for the trouble.
Simple Python goof.
> {% for quotes in object_list %}
> <li>{{ table1.source2 }}</li>
Should be <li>{{ quotes.source2 }}</li>
Sorry for the intrusion.
RD
On Dec 26, 10:43 am, Rick Dooling <[email protected]> wrote:
> I'm trying to use Django to manage an existing sqlite3 database of
> quotations. I used inspectdb to generate the models. Everything
> works fine, until I attempted my first generic view and first
> template. Everything executes according to plan, but I get no data
> outputted into the fields using object list.
>
> Here is the model:
>
> class Table1(models.Model):
> mainsource = models.IntegerField(null=True,
> db_column=u'MainSource', blank=True) # Field name made lowercase.
> topic1 = models.IntegerField(null=True, db_column=u'Topic1',
> blank=True) # Field name made lowercase.
> topic2 = models.CharField(max_length=255, db_column=u'Topic2',
> blank=True) # Field name made lowercase.
> source1 = models.CharField(max_length=255, db_column=u'Source1',
> blank=True) # Field name made lowercase.
> source2 = models.TextField(db_column=u'Source2', blank=True) #
> Field name made lowercase. This field type is a guess.
> quote = models.TextField(db_column=u'Quote', blank=True) # Field
> name made lowercase. This field type is a guess.
> quality = models.IntegerField(null=True, db_column=u'Quality',
> blank=True) # Field name made lowercase.
> author_id = models.IntegerField(null=True, db_column=u'Author_ID',
> blank=True) # Field name made lowercase.
> id = models.IntegerField(primary_key=True, db_column=u'ID') #
> Field name made lowercase.
>
> class Admin: pass
>
> class Meta:
> db_table = u'table1'
>
> Here is urls.py
>
> from django.conf.urls.defaults import *
> from mysite.views import current_datetime, hours_ahead
> from django.views.generic import list_detail
> from mysite.quotes.models import Table1
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> table1_info = {
> "queryset" : Table1.objects.all(),
> #"template_object_name" : "table1_info",
>
> }
>
> urlpatterns = patterns('',
> (r'^time/$', current_datetime),
> (r'^time/plus/(\d{1,2})/$', hours_ahead),
> # Example:
> # (r'^mysite/', include('mysite.foo.urls')),
> # Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
> # to INSTALLED_APPS to enable admin documentation:
> #(r'^admin/doc/', include('django.contrib.admindocs.urls')),
> # Uncomment the next line to enable the admin:
> (r'^admin/(.*)', admin.site.root),
> (r'^quotes/$', list_detail.object_list, table1_info)
> )
>
> Here is template:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
> <html lang="en">
> <head>Some quotes</head>
> <body>
>
> {% block content %}
>
> <h2>Quotes</h2>
> <ul>
> {% for quotes in object_list %}
> <li>{{ table1.source2 }}</li>
> {% endfor %}
> </ul>
> {% endblock %}
>
> </body>
> </html>
>
> I end up with 4000
>
> <li></li>
>
> with now results from the field. Have tried table1.topic2 and all of
> the text fields.
>
> Thanks for any help. About to give up. This is much more demanding
> than I anticipated.
>
> RD
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---