开发者

problem serving static files to sub directories

In the development environment, static files are served properly as long as the url pattern is limited to one directory. Sub directories lose the css. For example the css processes for the template attached to the following url:

//localhost:8000/create/

however this:

//localhost:8000/edit/2/

will not provide the css even if it's the same template.

the url.py code is as follows:

site_media = os.path.join( 
  os.path.dirname(__file__), 'site_media'
)

and

(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', 
{ 'document_root': site_media }),

the view code is:

def edit_record(request, id):
        if request.method == 'POST':
                a=ProjectRecord.objects.get(pk=id)
                form = RecordForm(request.POST, instance=a)
                if form.is_valid():
                        form.save()
                        return HttpResponseRedirect('/')
        else:
开发者_开发知识库                a=ProjectRecord.objects.get(pk=id)
                form = RecordForm(instance=a)
        return render_to_response('productionModulewire.html', {'form': form})

am I missing something?


All I can think of here is that your template is using relative paths to include the CSS.

check your <link rel="stylesheet" and make sure they begin with a / (or are a full URL)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜