0

開発環境では、URL パターンが 1 つのディレクトリに限定されている限り、静的ファイルは適切に提供されます。サブディレクトリは css を失います。たとえば、次の URL に添付されたテンプレートの css プロセス:

//localhost:8000/create/

ただし、これ:

//localhost:8000/edit/2/

同じテンプレートであっても css を提供しません。

url.py コードは次のとおりです。

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

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

ビューコードは次のとおりです。

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})

私は何かを逃していますか?

4

1 に答える 1

0

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)

于 2009-12-23T15:00:40.783 に答える