from django.http import HttpResponse import datetime def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpResponse(html)
this is what it looks like....its exactly how they tell me to show it....Python located my hello module before so I cant understand why this is not working...The code is absolutely correct and python is able to read otehr modules except tusing datetime. although in the python shell datetime works. On Jun 14, 12:57 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Mon, Jun 14, 2010 at 12:31 PM, JRMAbock <joshua.matl...@comcast.net>wrote: > > > > > > > Traceback: > > File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in > > get_response > > 91. request.path_info) > > File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in > > resolve > > 214. for pattern in self.url_patterns: > > File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in > > _get_url_patterns > > 243. patterns = getattr(self.urlconf_module, "urlpatterns", > > self.urlconf_module) > > File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in > > _get_urlconf_module > > 238. self._urlconf_module = > > import_module(self.urlconf_name) > > File "C:\Python26\lib\site-packages\django\utils\importlib.py" in > > import_module > > 35. __import__(name) > > File "C:\Users\Josh\Django-1.2.1\django\bin\mysite\..\mysite\urls.py" > > in <module> > > 2. from mysite.views import current_datetime > > > Exception Type: ImportError at /time/ > > Exception Value: cannot import name current_datetime > > > this is the traceback i get........when the code is correct > > > let me just say that my python26 directory is: > > C: Python26/lib/site-packages > > and my Django-1.2.1 directory is: > > C:user/Josh/Django-1.2.1 > > > is this the problem, if so how should I fix this? > > The Python interpreter is reporting that it cannot find anything named > current_datetime in the mysite.views module. Somehow what you think is in > the mysite views.py file is not what Python is finding. The code you showed > previously in the thread had an indentation error, so certainly what you > showed earlier is not being found by Python. Possibly the indentation > problems are more extensive than could be seen in what you posted, and > current_datetime in views.py is placed in some way (with some indentation) > that is making it entirely invisible to Python. You need to double and > triple check that what you have put in views.py is indented properly (the > def of the function should not be indented at all, it mut not be nested > inside any other function definition, and the function body itself needs to > be consistently indented). > > Karen > --http://tracey.org/kmt/- 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-us...@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.