On Sat, Sep 27, 2014 at 9:02 AM, John <john-dja...@martinhome.org.uk> wrote:
> Do you have a URL conf that matches the /get_xsd/ccd-description.xsl > <http://192.168.1.9:8080/get_xsd/ccd-description.xsl> stylesheet? You > have to match and serve that as well. > > Taking a step back though. It looks like you are serving static files that > would be best served from a webserver, perhaps with some symlinks, so that > the overhead of Django is not required at all. > > John > This gave me the hint in a solution. The overhead isn't a big deal in this use case so using Django is easier and more portable (I think). I created a URL: url(r'^get_xsd/ccd-description.xsl', "ccdgen.views.get_xsl") and the associated view: def get_xsl(request): CWD = os.getcwd() if CWD == '/': # Live site xslfile = "/home/ccdgen/ccdlib/ccd-description.xsl" else: # development xslfile = "ccdlib/ccd-description.xsl" xsl = open(xslfile,encoding='utf-8') response = HttpResponse(mimetype="text/xsl") for line in xsl: response.write(line) xsl.close() return response Thanks for the nudge in the right direction. > > > On 27/09/14 12:37, Timothy W. Cook wrote: > > Some details I forgot are that this is Django 1.6.4, Python 3.4.1. > The 404 error is on http://192.168.1.9:8080/get_xsd/ccd-description.xsl > > On Sat, Sep 27, 2014 at 8:10 AM, Timothy W. Cook <t...@mlhim.org> wrote: > >> I have a view that opens an XML file (it happens to be a schema but >> that doesn't matter) that specifies a stylesheet. >> It works as expected when opening the XML file locally. >> >> The stylesheet isn't applied when viewing the file via Django and I >> see in Firebug that I am getting a 404 on the stylesheet. The stylesheet is >> in the same directory as the XML file. >> >> So how do I setup a view or add this file to my existing view so it is >> found? >> >> The view: >> def get_ccddetails(request, id): >> >> ccd = CCD.objects.get(pk=id) >> ccdid= ccd.ct_id >> >> CWD = os.getcwd() >> if CWD == '/': # Live site >> frm_dir = "/home/ccdgen/ccdlib/CCD_"+ ccdid >> else: # development >> frm_dir = "ccdlib/CCD_"+ ccdid >> >> filename = frm_dir+"/ccd-"+ccdid+".xsd" >> if os.path.isfile(filename): >> response = HttpResponse(mimetype="application/xml; charset=utf-8") >> f = open(filename, encoding="utf-8") >> for line in f: >> response.write(line) >> f.close() >> else: >> response = HttpResponseNotFound("<h1>XSD: "+filename+" was not >> found.</h1>") >> return response >> >> The URL: >> url(r'^get_xsd/(?P<id>\d+)$', "ccdgen.views.get_ccddetails", >> name='getxsd'), >> >> >> >> Thanks, >> Tim >> >> >> >> >> >> >> >> ============================================ >> Timothy Cook >> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook >> MLHIM http://www.mlhim.org >> >> > > > -- > > ============================================ > Timothy Cook > LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook > MLHIM http://www.mlhim.org > > -- > 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+unsubscr...@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%2B%3DOU3VLaAHC8bv-S9sQfKLY8efgZOrQjnq4LPUKfB3r%3D3e0_g%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3VLaAHC8bv-S9sQfKLY8efgZOrQjnq4LPUKfB3r%3D3e0_g%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > -- > 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+unsubscr...@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/5426A746.3090605%40martinhome.org.uk > <https://groups.google.com/d/msgid/django-users/5426A746.3090605%40martinhome.org.uk?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- ============================================ Timothy Cook LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook MLHIM http://www.mlhim.org -- 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+unsubscr...@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%2B%3DOU3U7RARO0-T4Mf6gKycFG3TrAxXUvgeL4YUoUOhEpTfxgg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.