python - getting error on browser in django -
i beginner in django , dont know how solve problem getting error on browser as:
using urlconf defined in mysite.urls, django tried these url patterns, in order: ^admin/
the current url, api/entry/, didn't match of these.
all files are:
mysite/myapp/models.py
:
from tastypie.utils.timezone import django.contrib.auth.models import user django.db import models django.utils.text import slugify class entry(models.model): user = models.foreignkey(user) pub_date = models.datetimefield(default=now) title = models.charfield(max_length=200) slug = models.slugfield() body = models.textfield() def __unicode__(self): return self.title def save(self, *args, **kwargs): # automatic slug generation. if not self.slug: self.slug = slugify(self.title)[:50] return super(entry, self).save(*args, **kwargs)
mysite/myapp/api.py
:
from tastypie.resources import modelresource myapp.models import entry class entryresource(modelresource): class meta: queryset = entry.objects.all() resource_name = 'entry'
mysite/myapp/urls.py
:
from django.conf.urls.defaults import * myapp.api import entryresource entry_resource = entryresource() urlpatterns = patterns('', # normal jazz here... (r'^blog/', include('myapp.urls')), (r'^api/', include(entry_resource.urls)),
mysite/mysite/urls.py
:
from django.conf.urls import patterns, include, url django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)) )
where 'mysite' project name , 'myapp' app please me out thanks
your project-level urls.py
doesn't include application-level urls.py
. change mysite/mysite/urls.py
this:
from django.conf.urls import patterns, include, url django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^', include('myapp.urls')), url(r'^admin/', include(admin.site.urls)) )
also, rid of (r'^blog/', include('myapp.urls')),
in mysite/myapp/urls.py
.
hope helps.
Comments
Post a Comment