I'm doing a slight variation on my urls.py from the tutorial where I have the following -
mysite/urls.py -
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^TidalDEV/', include('TidalDEV.urls')),
)
TidalDEV/urls.py -
from django.conf.urls import patterns, url
from TidalDEV import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index')
url(r'^(?P<pk>[0-9]+)/$', views.tesxml, name='tesxml'),
)
And this is the view in views.py -
def tesxml(self, request, pk, format=None, renderer_context=None):
"""
returns an XML of a jobmst listing
"""
template_vars['jobmst'] = (queryset1, [pk])
template_vars['jobdtl'] = (queryset2, [pk])
template_vars['jobdep'] = (queryset3, [pk])
t = loader.get_template('TidalAPI/templates/xml_template.xml')
c = Context(template_vars)
return HttpResponse(t.render(c), mimetype="text/xml")
When I try to hit my url at http://localhost:8080/TidalDEV/10081/
I get invalid syntax. What is the problem here?
Essentially I need the view to populate a template XML file I built.
You are missing a comma after your index view in TidalDEV/urls.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With