Re: __unicode__() addition not working in basic poll application.
Hello, I am having the same problem while working through the tutorial. have searched these forums and tried everything that was recommended. My spacing is good also - I checked that. I am still getting the same output: >>> Poll.objects.all() [] Any ideas on how to fix my issue? On Jun 5, 11:20 am, EPS wrote: > Hi, i found this post when try to solve same problem: my trouble was a > "spaces" in models.py. > in your first message it seems to be ok, but you must really check > spaces in your class > describe.http://mail.python.org/pipermail/tutor/2007-January/051903.html > > On May 17, 4:59 pm, maaz muqri wrote: > > > > > im just getting "Pollobject" as output > > > On May 17, 1:14 pm, Roman Klesel wrote:> > > 2011/5/16 maaz muqri : > > > > > I am getting this > > > > Poll.objects.all() > > > > [] > > > > What do you get when you do: > > > > print unicode(Poll.objects.all()[0]) > > > > ? > > > > Regards > > > Roman- Hide quoted text - > > - Show quoted text - -- 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.
Need help with tutorial
I'm trying to work my way through the tutorial 1 but am getting stuck. I am using python 2.7 and am using SQLite3 like the tutorial recommended for beginners I am at the step where I am changing the models.py file to add the _unicode_ methods to display the Poll Object I believe I have the NAME in the settings.py file set up correctly. I first set did 'NAME': 'database.db', to create my database file, then I changed it to the path to that file. Anyways, after I modified the models.py file to display the question... >>> Poll.objects.all() [] I am still getting >>> Poll.objects.all() [] as the output. Any help would be greatly appreciated. Thanks, Kyle -- 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: Need help with tutorial
I understand your frustration. I'm sorry for not posting my code with my first post. my settings.py file (only up to the part I changed) is below: # Django settings for mysite project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Name', 'n...@email.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'C:/Django/django/bin/mysite/ database.db', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } My models.py file is: from django.db import models import datetime # Create your models here. class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def _unicode_(self): return self.question def was_published_today(self): return self.pub_date.date() == datetime.date.today() class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def _unicode_(self): return self.choice Thanks for your help. On Jun 15, 10:55 am, "Cal Leeming [Simplicity Media Ltd]" wrote: > Please please please please PLEASE, always post the code you are having > trouble with. I've lost track on the amount of times people have to be told > this :/ It's like saying "I made a change to this file, but it didn't work, > why not?" Come on man. > > > > > > > > On Wed, Jun 15, 2011 at 5:48 PM, Kyle Latham wrote: > > I'm trying to work my way through the tutorial 1 but am getting stuck. > > I am using python 2.7 and am using SQLite3 like the tutorial > > recommended for beginners > > > I am at the step where I am changing the models.py file to add the > > _unicode_ methods to display the Poll Object > > > I believe I have the NAME in the settings.py file set up correctly. I > > first set did > > 'NAME': 'database.db', > > to create my database file, then I changed it to the path to that > > file. > > > Anyways, after I modified the models.py file to display the > > question... > > >>> Poll.objects.all() > > [] > > > I am still getting > > > >>> Poll.objects.all() > > [] > > > as the output. > > > Any help would be greatly appreciated. > > > Thanks, > > > Kyle > > > -- > > 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. -- 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: Need help with tutorial
Wow. I feel like a dumbass haha. That worked! Thank you so much for your help! On Jun 15, 11:15 am, "Cal Leeming [Simplicity Media Ltd]" wrote: > No problem. > > You need to use __unicode__, not _unicode_ :) > > Cal > > > > > > > > On Wed, Jun 15, 2011 at 6:02 PM, Kyle Latham wrote: > > I understand your frustration. I'm sorry for not posting my code with > > my first post. > > > my settings.py file (only up to the part I changed) is below: > > > # Django settings for mysite project. > > > DEBUG = True > > TEMPLATE_DEBUG = DEBUG > > > ADMINS = ( > > # ('Name', 'n...@email.com'), > > ) > > > MANAGERS = ADMINS > > > DATABASES = { > > 'default': { > > 'ENGINE': 'django.db.backends.sqlite3', # Add > > 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. > > 'NAME': 'C:/Django/django/bin/mysite/ > > database.db', # Or path to database file if using > > sqlite3. > > 'USER': '', # Not used with sqlite3. > > 'PASSWORD': '', # Not used with sqlite3. > > 'HOST': '', # Set to empty string for > > localhost. Not used with sqlite3. > > 'PORT': '', # Set to empty string for > > default. Not used with sqlite3. > > } > > } > > > My models.py file is: > > > from django.db import models > > import datetime > > > # Create your models here. > > class Poll(models.Model): > > question = models.CharField(max_length=200) > > pub_date = models.DateTimeField('date published') > > > def _unicode_(self): > > return self.question > > > def was_published_today(self): > > return self.pub_date.date() == datetime.date.today() > > > class Choice(models.Model): > > poll = models.ForeignKey(Poll) > > choice = models.CharField(max_length=200) > > votes = models.IntegerField() > > > def _unicode_(self): > > return self.choice > > > Thanks for your help. > > > On Jun 15, 10:55 am, "Cal Leeming [Simplicity Media Ltd]" > > wrote: > > > Please please please please PLEASE, always post the code you are having > > > trouble with. I've lost track on the amount of times people have to be > > told > > > this :/ It's like saying "I made a change to this file, but it didn't > > work, > > > why not?" Come on man. > > > > On Wed, Jun 15, 2011 at 5:48 PM, Kyle Latham > > wrote: > > > > I'm trying to work my way through the tutorial 1 but am getting stuck. > > > > I am using python 2.7 and am using SQLite3 like the tutorial > > > > recommended for beginners > > > > > I am at the step where I am changing the models.py file to add the > > > > _unicode_ methods to display the Poll Object > > > > > I believe I have the NAME in the settings.py file set up correctly. I > > > > first set did > > > > 'NAME': 'database.db', > > > > to create my database file, then I changed it to the path to that > > > > file. > > > > > Anyways, after I modified the models.py file to display the > > > > question... > > > > >>> Poll.objects.all() > > > > [] > > > > > I am still getting > > > > > >>> Poll.objects.all() > > > > [] > > > > > as the output. > > > > > Any help would be greatly appreciated. > > > > > Thanks, > > > > > Kyle > > > > > -- > > > > 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. > > > -- > > 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. -- 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.
Question about Displaying a Table
Hello, I am pretty new to Django and Python. I'm wanting to create a Django app that displays different tables in my MySQL database, and the user can search through the tables for info they want. I haven't written any code yet, I'm doing research on the approach I have to take. Is the only way I am able to display a table from the MySQL database in Django by creating a template and importing the data to the template? Is there a another/better approach towards displaying a MySQL table in the Django app? Thank you, Kyle -- 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.
ImportError: No module named site
I searched this group for that error, and browsed through several pages and dozens of posts...but none of them helped me solve my error. Yesterday I had my server up and running, and I left it running overnight. I do not remember changing anything in any of my .py files, but when I shut down my server to restart it, I was getting an error: "Import Error: No module named site" I have no idea what is going wrong, but here is all my code thus far (I'm following the tutorial to create my own app that will display various material measurements) --- models.py --- from django.db import models # Create your models here. class adhesive(models.Model): measurement_id = models.CharField(max_length = 200) material_id = models.CharField(max_length = 200) program_name = models.CharField(max_length = 200) date = models.DateField() measurement_method = models.CharField(max_length = 30) frequency_low = models.IntegerField() frequency_high = models.IntegerField() class ceramic(models.Model): measurement_id = models.CharField(max_length = 200) material_id = models.CharField(max_length = 200) program_name = models.CharField(max_length = 200) date = models.DateField() measurement_method = models.CharField(max_length = 30) frequency_low = models.IntegerField() frequency_high = models.IntegerField() class composite(models.Model): measurement_id = models.CharField(max_length = 200) material_id = models.CharField(max_length = 200) program_name = models.CharField(max_length = 200) date = models.DateField() measurement_method = models.CharField(max_length = 30) frequency_low = models.IntegerField() frequency_high = models.IntegerField() --- settings.py --- DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'materials', # Or path to database file if using sqlite3. 'USER': 'root', # Not used with sqlite3. 'PASSWORD': 'x', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } ... ROOT_URLCONF = 'material_measurements/urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/ django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. "C:/Django/material_measurements.materials" ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'material_measurements.materials', # 'django.contrib.messages', # 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', ) --- urls.py --- from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'material_measurements.views.home', name='home'), # url(r'^material_measurements/', include('material_measurements.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/(.*)', admin.site.root), ) Thanks for the help! -- 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.