Saturday, July 4, 2015

Re: Error :- Debuge= True

what error?

2015-07-04 8:05 GMT+01:00 Wanare Piyush 13MCC1056 <piyush.subhashrao2013@vit.ac.in>:

I am getting this error :-

                                     You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.


My views.py file:-

from django.http import HttpResponse
import datetime
from django.template import Template, Context
from django.template.loader import get_template
from django.http import Http404 

tasks = [
    {
        'id': 1,
        'title': u'Buy groceries',
        'description': u'Milk, Cheese, Pizza, Fruit, Tylenol',
        'done': False
    },
    {
        'id': 2,
        'title': u'Learn Python',
        'description': u'Need to find a good Python tutorial on the web',
        'done': False
    }
 ]

#task_id=='1'
def api(self,task_id):
    #task=[task if task['id']=='task_id' for task in tasks ]
    task = [task for task in tasks if task['id'] == task_id]
    if len(task) == 0:
        raise Http404
    return HttpResponse(tasks)

 My urls.py file:-


"""Dj1 URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
#from App1.views import place_order_form
from App1.views import api

urlpatterns = [
    #url(r'^admin/', include(admin.site.urls)),
    url(r'^api/(\d{1,2})/$',api),
    #url(r'^place_order/$',place_order_form),
]

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9360a7da-f472-4840-9a6b-b71b9c0b5990%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
monoBOT
Visite mi sitio(Visit my site): monobotsoft.es/blog/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BxOsGCJEptTGyDdbP3hrZQ%3DkrafDTozUH7_e7CfNKc2fmnMqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment