Monday, July 26, 2010

Re: errors serving text files using templates and static files

Oops, swapped it and it still didn't work.  Right now I have it writing to a file and then redirecting and having Apache serve the file which works.  My code looks like this:

def bootmenu(request, username):
    user = User.objects.get(username=username)
    user_bootimage_list = Bootimage.objects.filter(person=user)[:5]
    t = loader.get_template('netboot/menu.cfg')
    c = Context({
        'user_bootimage_list': user_bootimage_list,
    })
    f = open('/home/jboon/Lesson1/templates/netboot/static/dynamicmenu.cfg', 'w')
    menu_file = File(f)
    menu_file.write(t.render(c))
    return HttpResponseRedirect('/netboot/dynamicmenu.cfg')

It works but it's a strange workaround. Serving it directly causes gPXE to break.  Any thoughts?

On Mon, Jul 26, 2010 at 18:04, Dennis Kaarsemaker <dennis@kaarsemaker.net> wrote:
On ma, 2010-07-26 at 09:21 -0700, Josh wrote:
>         return HttpResponse(menu, mimetype="plain/text")
>
> What makes Django's text serving different?  What can I do to
> troubleshoot this issue further?  Am I just missing something about
> how text files are served?

The correct mimetype is text/plain. I don't know how strict gpxe checks
that.
--
Dennis K.

They've gone to plaid!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment