Re: Different Database object behavior on Production and Development servers.
Alex: I tried another custom widget method earlier today without any effect, then I tried yours as outlined in your blog, there are no errors but there is no change in how the field is displayed. It makes me wonder if there is another step involved (CSS?) with this, or if there is something I must do on the template to get the custom widget method to work? Any pointers appreciated --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
> and when I try changing it to > {% for field in formsets %} > i get an error message saying formset is not iterable I was able to get closer the results I want by simply changing the html template from > {% for field in forms %} to {% for form in formset.forms %} {{ form.selected }}{{ form.author }}{{ form.title }} {% endfor %} Now though the Author and Title field appear as editable, is there anyway of getting these values to simply appear as text or as some other kind of read only display? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
On Tue, 2009-03-10 at 04:07 -0700, NoviceSortOf wrote: > Thanks Malcom, > > I re-read the links you sent along on forms and formsets. > > I'm now working with a form but instead of > ___ > > > [ ] Stevenson Collected Works > > > [ ] Stevenson Treasure Island > > > [ ] Stevenson Wild West Stories > > > [Submit] > > I get a blank instance of the model reflected in the browser. rather > than a list of books...ie Which means you haven't populated your form with any initial data (search for the term "initial" in the form documentation). > ___ > Author : [] > Title : [] > Select : [ ] > [Submit] It also seems to me that this isn't what you were after initially. You were wanting a form that contained a single checkbox as the field, where the field label was a book title. Not a form for every field in the model so that the model could be edited. Take a few steps back from your code and remember the problem you were trying to solve. It sounded like you wanted a form with a single checkbox field. So why not start from there? > > I've tried working with formsets but > {% for field in forms %} > returns blanks > > and when I try changing it to > {% for field in formsets %} > i get an error message saying formset is not iterable > > What am I missing? Why are you trying to iterate over a formset instead of displaying it automatically (it's designed to encapsulate the behaviour of displaying forms individually)? There's nothing in the documentation that suggests doing that. I would first concentrate on getting a single form working that displays a single instance of the model. Once you understand how to display that and process the result, then moving onto multiple instances at once. Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
Thanks Malcom, I re-read the links you sent along on forms and formsets. I'm now working with a form but instead of ___ > > [ ] Stevenson Collected Works > > [ ] Stevenson Treasure Island > > [ ] Stevenson Wild West Stories > > [Submit] I get a blank instance of the model reflected in the browser. rather than a list of books...ie ___ Author : [] Title : [] Select : [ ] [Submit] I've tried working with formsets but {% for field in forms %} returns blanks and when I try changing it to {% for field in formsets %} i get an error message saying formset is not iterable What am I missing? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
So this is the first time you've explained the real problem you're trying to solve. It certainly helps explain, a little bit, at least, which direction to point you for solutions. On Tue, 2009-03-10 at 02:28 -0700, NoviceSortOf wrote: > > It's clear now that __str__(self) or __unicode__ > return a usable string to the view. > > But this does not on the surface appear to be a > workable instance of the model itself, Right. If you want to access the model itself, pass the model to the template, not the output of __unicode__. The __unicode__ method returns a string (a Python unicode object). > that would return fields that I can work with in the template...and/or > i haven't figured how to get a handle on it. > > ie... > to list titles by Stevenson and checkbox titles to be borrowed. > ...which in the browser I'd hope would present something like > ___ > ... > [ ] Stevenson Collected Works > [ ] Stevenson Treasure Island > [ ] Stevenson Wild West Stories > ... > [Submit] Looking at Django's forms module would help you here. There are lots of classes and functions for creating HTML forms and converting models to forms. > > here is the code i'm trying... > __ > # models.py > class Titles(models.Model): > > author = models.CharField(max_length=100) > > title = models.CharField(max_length=254) > > select = models.BooleanField() > > def __unicode__(self): > return u'%s = %s' % (self.author, self.title) > > # views.py > def checkout_book_view(request) > from books.models import Titles > > titles_list =Titles.objects.filter(author="Stevenson") > > template_Name='checkoutbook.htm' > template_Context = Context( { 'titles_list': titles_list }) > >return render_to_response(template_Name,template_Context) > > # then in template checkoutbook.html list as > {% for titles_list in titles_list %} > {{ title.select }} > {{ title.author }} > {{ title.title }} > {% endfor %} It looks like this should be working fine, printing out the values of each of those attributes. It sounds like you were hoping the BooleanField attribute would display as a checkbox, but it's not a form field. It's model field: so it holds data and can be used to access that data. If you want a checkbox, you'll need to create a form object (you could do that manually in HTML, but it's much easier to use django.forms). > > with unicode though all i'm able to get is the single string defined > by def ___unicode___ and no check box. i'm suprised > that the query set or list is not able to store more fields. What do you mean by "more fields"? The queryset returns a bunch of model instances and you can access everything in the model. What else are you after here? Have a read through all of the documentation under http://docs.djangoproject.com/en/dev/topics/forms/ and see if that helps you do what you're after. Regards, Malcolm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
It's clear now that __str__(self) or __unicode__ return a usable string to the view. But this does not on the surface appear to be a workable instance of the model itself, that would return fields that I can work with in the template...and/or i haven't figured how to get a handle on it. ie... to list titles by Stevenson and checkbox titles to be borrowed. ...which in the browser I'd hope would present something like ___ ... [ ] Stevenson Collected Works [ ] Stevenson Treasure Island [ ] Stevenson Wild West Stories ... [Submit] here is the code i'm trying... __ # models.py class Titles(models.Model): author = models.CharField(max_length=100) title = models.CharField(max_length=254) select = models.BooleanField() def __unicode__(self): return u'%s = %s' % (self.author, self.title) # views.py def checkout_book_view(request) from books.models import Titles titles_list =Titles.objects.filter(author="Stevenson") template_Name='checkoutbook.htm' template_Context = Context( { 'titles_list': titles_list }) return render_to_response(template_Name,template_Context) # then in template checkoutbook.html list as {% for titles_list in titles_list %} {{ title.select }} {{ title.author }} {{ title.title }} {% endfor %} with unicode though all i'm able to get is the single string defined by def ___unicode___ and no check box. i'm suprised that the query set or list is not able to store more fields. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
It's clear now that __str__(self) or __unicode__ return a usable string to the view. But this does not on the surface appear to be a workable instance of the model itself, that would return fields that I can work with in the template...and/or i haven't figured how to get a handle on it. ie... to list titles by Stevenson and checkbox titles to be borrowed. ...which in the browser I'd hope would present something like ___ ... [ ] Stevenson Collected Works [ ] Stevenson Treasure Island [ ] Stevenson Wild West Stories ... [Submit] here is the code i'm trying... __ # models.py class Titles(models.Model): author = models.CharField(max_length=100) title = models.CharField(max_length=254) select = models.BooleanField() def __unicode__(self): return u'%s = %s' % (self.author, self.title) # views.py def checkout_book_view(request) from books.models import Titles titles_list =Titles.objects.filter(author="Stevenson") template_Name='checkoutbook.htm' template_Context = Context( { 'titles_list': titles_list }) return render_to_response(template_Name,template_Context) # then in template checkoutbook.html list as {% for titles_list in titles_list %} {{ title.select }} {{ title.author }} {{ title.title }} {% endfor %} with unicode though all i'm able to get is the single string defined by def ___unicode___ and no check box. i'm suprised that the query set or list is not able to store more fields. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
Ramiro: You put me onto something, the only model that returns coherent data on the command line has str defined for model ie. class Book(models.Model): title = models.CharField(max_length=100) authors = models.ManyToManyField(Author) publisher = models.ForeignKey(Publisher) def __str__(self): return '%s %s' % (self.author,self.title) The other model classes do not have such a method assigned. I'll double check production server and development server both but it seems the __str__ method or unicode method you mentioned (or lack of) could very well be the problem. Thanks --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
On Mon, Mar 9, 2009 at 12:03 PM, NoviceSortOf wrote: > > > On the command line I'm unable to get a coherent return on my data > object filters or fetches, > > Instead of getting any detail I get a dictionary with nothing but the > words UserProfile, > UserProfile object where Field name and value should be. > > ie. > g = UserProfile.objects.filter(email = "dljonsson2...@gmail.com") > [, object>] > > instead of something like > g = UserProfile.objects.filter(email = "dljonsson2...@gmail.com") > [username : DLJ99, email : "dljonsson2...@gmail.com] > > other tables as well in the database have the same behavior, others do > not. This might be related to these models haveing or not a __unicode__ method. See http://docs.djangoproject.com/en/dev/intro/tutorial01/#playing-with-the-api and http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.__unicode__ > > my production server does not seem to have a problem with this, but > development server does. i've double checked model and postgres sql > server stuctures. > > Any clues why my development server fetches and filters will not > return coherent > data? > It's not cleat to me what does the development server have to do with this. Could you explaining it a bit further. -- Ramiro Morales http://rmorales.net --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Different Database object behavior on Production and Development servers.
On Mon, Mar 9, 2009 at 9:03 AM, NoviceSortOf wrote: > > > On the command line I'm unable to get a coherent return on my data > object filters or fetches, > > Instead of getting any detail I get a dictionary with nothing but the > words UserProfile, > UserProfile object where Field name and value should be. > > ie. > > >>>g = UserProfile.objects.filter(email = "dljonsson2...@gmail.com") > [, object>] > > instead of something like > > >>>g = UserProfile.objects.filter(email = "dljonsson2...@gmail.com") > [username : DLJ99, email : "dljonsson2...@gmail.com] > > other tables as well in the database have the same behavior, others do > not. > > my production server does not seem to have a problem with this, but > development server does. i've double checked model and postgres sql > server stuctures. > > Any clues why my development server fetches and filters will not > return coherent > data? > > > > > > > What you've pasted so far doesn't say anything about the data itself, all it indicates is your __unicode__ method isn't returning anything of interest. Are you sure all your source files made it into production fine? Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Different Database object behavior on Production and Development servers.
On the command line I'm unable to get a coherent return on my data object filters or fetches, Instead of getting any detail I get a dictionary with nothing but the words UserProfile, UserProfile object where Field name and value should be. ie. >>>g = UserProfile.objects.filter(email = "dljonsson2...@gmail.com") [, ] instead of something like >>>g = UserProfile.objects.filter(email = "dljonsson2...@gmail.com") [username : DLJ99, email : "dljonsson2...@gmail.com] other tables as well in the database have the same behavior, others do not. my production server does not seem to have a problem with this, but development server does. i've double checked model and postgres sql server stuctures. Any clues why my development server fetches and filters will not return coherent 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---