Re: howto display table data in html?
"A model class represents a database table, and an instance of that class represents a particular record in the database table." I'm beginning to see some light. What I try to achieve is telling the application that, depending on the user's authority, he may not see some data, and/or may not change some other data: all fields must have an attribute for [visible,changeable], and the forms should be able to handle those attributes. I bet that the generic forms cannot do that - so I'll have to make different forms for all types of user. Is that right? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: howto display table data in html?
> I read there: > from django.shortcuts import render_to_response > from mysite.polls.model import Poll > def index(request): >latest_poll_list = Poll.objects.all() > &c. > > What is 'latest_poll_list'? I assume it is a list, but a list of what? > Records? Can I cycle through that list (for X in latest_poll_list...) > and are the items in the list then again lists that contain the field > data? Yes, you can indeed. It's actually not a list, but a QuerySet that functions as an iterator, so you can happily iterate you way through it in either the views or the templates: http://www.djangoproject.com/documentation/db-api/#retrieving-all-objects The individual items are not lists, but objects, related to your models (there's a reason the syntax is 'Poll.objects.all()'). (In part, this is why the Python shell, started through manage.py, is so handy: you can try out things and see what works and what not.) I would advise you to go through the tutorial until you feel you understand it well enough, and anything you don't understand, try and find it in the documentation. Particularly important to read through are Models section (the first 3 items), the template guide for HTML programmers, and the newforms library (assuming you're using the SVN version). Other interesting parts are the 'URL configuration' and 'Request and response objects'. At least, that's my experience. It's all there, although it may take some searching to find it. Google helps, and there's a Google search box right on the docs page for that purpose. Btw, records don't exist in Python, not with that terminology; and if you think of lists that contain lists with field data, you may need to understand the general Python stuff first. In particular the section on classes: http://docs.python.org/tut/node11.html (but reading *and doing* the whole tutorial doesn't hurt, really). --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: howto display table data in html?
I read there: from django.shortcuts import render_to_response from mysite.polls.model import Poll def index(request): latest_poll_list = Poll.objects.all() &c. What is 'latest_poll_list'? I assume it is a list, but a list of what? Records? Can I cycle through that list (for X in latest_poll_list...) and are the items in the list then again lists that contain the field data? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: howto display table data in html?
> Probably another stupid question (sigh), but looking at views.py and > having read just about all the documentation I could find (including > the Django book), I still do not see how I can get data from a > database into a web page. The Django book explains how it is done > using the live interpreter - but not how it should be done in a view. Did you go through the 3rd part of the tutorial on the djangosite? If you do that, you'll be writing your a views.py and a template as well. In particular: http://www.djangoproject.com/documentation/tutorial03/#write-views-that-actually-do-something Although I do agree that most examples given everywhere are from within the Python shell, and occasionally therefore appear to lack some correspondence with views & templates. After a while though, you get used to it and instantly translate one to the other. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
howto display table data in html?
Probably another stupid question (sigh), but looking at views.py and having read just about all the documentation I could find (including the Django book), I still do not see how I can get data from a database into a web page. The Django book explains how it is done using the live interpreter - but not how it should be done in a view. Where is the documentation I missed? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---