我似乎无法弄清楚如何使美味的 URL 工作。当我在浏览器中转到应用程序的根目录时,调试没有列出 url。我错过了什么?
## inventory/models.py
from django.db import models
#
class Server (models.Model):
server_id = models.AutoField(primary_key=True)
server_name = models.CharField("Server Name",max_length=200,unique=True)
server_ip = models.IPAddressField("Server IP")
server_serial = models.CharField("Serial No.",max_length=25,null=True,blank=True)
server_mem = models.PositiveIntegerField("Mem (MB)",null=True,blank=True)
server_architecture = models.ForeignKey(Architecture)
server_os = models.ForeignKey(Operating_System)
server_os_version = models.CharField("OS Version",max_length="25",null=True,blank=True)
server_type = models.ForeignKey(Server_Type,null=True,blank=True)
server_mac = models.ForeignKey(Mac,null=True,blank=True)
server_digi = models.ForeignKey(Digi,null=True,blank=True)
server_digi_port = models.PositiveIntegerField("Digi Port",null=True,blank=True)
server_rack = models.ForeignKey(Rack,null=True,blank=True)
server_kvm = models.ForeignKey(KVM,null=True,blank=True)
def __unicode__(self):
return self.server_name
## inventory/api.py
from tastypie.resources import ModelResource
from inventory.models import *
#
class ServerResource(ModelResource):
class Meta:
queryset = Server.objects.all()
resource_name = 'servers'
## mmi_assets/urls.py
from django.conf.urls import patterns, include, url
#
## our custom stuff
from inventory.api import *
server_resource = ServerResource()
##
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^inventory/', include('inventory.urls')),
url(r'^api/', include(server_resource.urls)),
)