Re: Hi All: __unicode__(self)
On Monday 12 Oct 2009 11:25:27 am Russell Keith-Magee wrote: > On Mon, Oct 12, 2009 at 1:44 PM, Kenneth Gonsalves > > wrote: > > On Monday 12 Oct 2009 11:05:38 am Denis Bahati wrote: > >> 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() > >> def was_published_today(self): > >> return self.pub_date.date() == datetime.date.today() > >> was_published_today.short_description = 'Published today?' > > > > please learn some python! > > Kenneth - please learn some manners. You have repeatedly demonstrated > on this list that you have a deep yearning for brevity. However, let > me assure you that it really doesn't take that much effort to write in > whole sentences (with capitalization and everything). If you throw in > some politeness while you are at it, all the better. I think this is uncalled for - granted I tend to be brief. In this case, I replied once, he re-posted and (using the word 'please') I pointed out that his problem is due to lack of python knowledge. What is rude about it? Maybe the solution I gave is wrong. Or maybe I should not have given a solution and just stopped with asking him to learn some python? Anyway, I do not want to make an issue of this - at least I hope *this* post correctly follows grammatical rules. -- regards kg http://lawgon.livejournal.com --~--~-~--~~~---~--~~ 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: Hi All: __unicode__(self)
Thank in advance for the advices. On Mon, Oct 12, 2009 at 8:55 AM, Russell Keith-Magee wrote: > > On Mon, Oct 12, 2009 at 1:44 PM, Kenneth Gonsalves > wrote: > > > > On Monday 12 Oct 2009 11:05:38 am Denis Bahati wrote: > >> class Poll(models.Model): > >> question = models.CharField(max_length=200) > >> pub_date = models.DateTimeField('date published') > >> def __unicode__(self): > >> return self.questiona > >> def was_published_today(self): > >> return self.pub_date.date() == datetime.date.today() > >> def was_published_today(self): > >> return self.pub_date.date() == datetime.date.today() > >> was_published_today.short_description = 'Published today?' > > > > please learn some python! > > Kenneth - please learn some manners. You have repeatedly demonstrated > on this list that you have a deep yearning for brevity. However, let > me assure you that it really doesn't take that much effort to write in > whole sentences (with capitalization and everything). If you throw in > some politeness while you are at it, all the better. > > Yours, > Russ Magee %-) > > > > --~--~-~--~~~---~--~~ 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: Hi All: __unicode__(self)
On Mon, Oct 12, 2009 at 1:44 PM, Kenneth Gonsalves wrote: > > On Monday 12 Oct 2009 11:05:38 am Denis Bahati wrote: >> 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() >> def was_published_today(self): >> return self.pub_date.date() == datetime.date.today() >> was_published_today.short_description = 'Published today?' > > please learn some python! Kenneth - please learn some manners. You have repeatedly demonstrated on this list that you have a deep yearning for brevity. However, let me assure you that it really doesn't take that much effort to write in whole sentences (with capitalization and everything). If you throw in some politeness while you are at it, all the better. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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: Hi All: __unicode__(self)
On Mon, Oct 12, 2009 at 1:35 PM, Denis Bahati wrote: > Hi all, > I have a problem with __unicode__(self) function it doesn't give any changes > to the display of poll list it just display the Poll object when i code like > below: Ok - you need to do two things. 1) Stop posting the same question over and over again. We saw it the first time. 2) Get hold of a good Python tutorial. The official Python tutorial is good [1]; another good one is Dive Into Python [2]. Strange as it may seem, the reason you are getting an error that reads "IndentationError, unexpected indent, models.py line 10" is because you have an indentation error, caused by an unexpected indent, on line 10 of models.py. Django isn't a programming language. It's just a library that uses the Python language. If you're going to write web sites using Django, you really need to understand Python first. So before you try to work through the Django tutorial, work through the Python tutorial. I could give you the answer to your question very easily, but I'm not going to - specifically because you _really_ need to work out this one by yourself. The error message you are getting is 100% correct, and points you to the exact problem. The cause is described in the *introduction* to the official Python tutorial. [1] http://docs.python.org/tutorial/ [2] http://www.diveintopython.org/ Yours Russ Magee %-) --~--~-~--~~~---~--~~ 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: Hi All: __unicode__(self)
On Monday 12 Oct 2009 11:05:38 am Denis Bahati wrote: > 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() > def was_published_today(self): > return self.pub_date.date() == datetime.date.today() > was_published_today.short_description = 'Published today?' please learn some python! 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() def was_published_today(self): return self.pub_date.date() == datetime.date.today() -- regards kg http://lawgon.livejournal.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Hi All: __unicode__(self)
Hi all, I have a problem with __unicode__(self) function it doesn't give any changes to the display of poll list it just display the Poll object when i code like below: from django.db import models import datetime 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() def was_published_today(self): return self.pub_date.date() == datetime.date.today() was_published_today.short_description = 'Published today?' class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def __unicode__(self): return self.choice if i change the code like the one shown below it gives me the traceback about indents, i also included below. from django.db import models import datetime 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() def was_published_today(self): return self.pub_date.date() == datetime.date.today() was_published_today.short_description = 'Published today?' class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def __unicode__(self): eturn self.choice Environment: Request Method: GET Request URL: http://localhost/testproject/admin/polls/poll/5/ Django Version: 1.1 Python Version: 2.5.4 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'testproject.polls'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in get_response 83. request.path_info) File "C:\Python25\lib\site-packages\django\core\urlresolvers.py" in resolve 216. for pattern in self.url_patterns: File "C:\Python25\lib\site-packages\django\core\urlresolvers.py" in _get_url_patterns 245. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Python25\lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module 240. self._urlconf_module = import_module(self.urlconf_name) File "C:\Python25\lib\site-packages\django\utils\importlib.py" in import_module 35. __import__(name) File "C:/xampp/htdocs\testproject\urls.py" in 5. admin.autodiscover() File "C:\Python25\lib\site-packages\django\contrib\admin\__init__.py" in autodiscover 56. import_module("%s.admin" % app) File "C:\Python25\lib\site-packages\django\utils\importlib.py" in import_module 35. __import__(name) File "C:\Python25\lib\site-packages\django\contrib\auth\admin.py" in 128. admin.site.register(Group, GroupAdmin) File "C:\Python25\lib\site-packages\django\contrib\admin\sites.py" in register 90. validate(admin_class, model) File "C:\Python25\lib\site-packages\django\contrib\admin\validation.py" in validate 22. models.get_apps() File "C:\Python25\lib\site-packages\django\db\models\loading.py" in get_apps 100. self._populate() File "C:\Python25\lib\site-packages\django\db\models\loading.py" in _populate 58. self.load_app(app_name, True) File "C:\Python25\lib\site-packages\django\db\models\loading.py" in load_app 74. models = import_module('.models', app_name) File "C:\Python25\lib\site-packages\django\utils\importlib.py" in import_module 35. __import__(name) Exception Type: IndentationError at /admin/polls/poll/5/ Exception Value: unexpected indent (models.py, line 10) Please any 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 -~--~~~~--~~--~--~---