4
我有一個django web服務,它在本地完美運行,但只要我將它上傳到heroku,當我嘗試發佈帖子時,不斷收到405錯誤,無論我在哪裏發帖。 我已將csrf_exempt添加到我的所有帖子視圖中。這些都是基於課堂的觀點。 例如:405使用django在heroku上不允許使用POST方法
class ApplyForRental(View):
def post(self, request, rentalID):
#user = User.objects.filter(pk = rentalID)
#filtered = Contentfile.objects.filter(file_owner = user, published=True)
rental = RentProperty.objects.get(pk = rentalID)
applicant = User.objects.get(pk=request.POST.get('interested_renter'))
rental.interested_renters.add(applicant)
jsonDict = {"success":True}
data = json.dumps(jsonDict)
return HttpResponse(data, content_type='application/json')
@csrf_exempt
def dispatch(self,*args,**kwargs):
return super(ApplyForRental, self).dispatch(*args,**kwargs)
任何理由它不會在Heroku上工作,但會在當地工作?
我的網址文件: 主要
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'homerun.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^rentals/', include('rentals.urls', namespace="rentals")),
url(r'^users/(?P<userID>\w+)/$', views.UserInfo.as_view(), name='getUser'),
(r'^grappelli/', include('grappelli.urls')),
url(r'^admin/', include(admin.site.urls)),
)
應用
urlpatterns = patterns('',
url(r'^create/$', views.CreateRental.as_view(), name='createRental'),
url(r'^(?P<rentalID>\w+)/$', views.RentalInformation.as_view(), name='getrental'),
url(r'^users/(?P<userID>\w+)/$', views.UserRentals.as_view(), name='userrentals'),
url(r'^(?P<rentalID>\w+)/uploadimage/$', views.UploadImage.as_view(), name='uploadimage'),
url(r'^(?P<rentalID>\w+)/apply/$', views.ApplyForRental.as_view(), name='applyforrental'),
url(r'^$', views.RentalsList.as_view(), name='getRentals'),
#url(r'^filesInfoByOwner/(?P<userName>\w+)/pk/(?P<pk>\d+)/$', views.FileInfo.as_view(), name='filesByOwnerAndPK'),
#url(r'^filesContentByOwner/(?P<userName>\w+)/pk/(?P<pk>\d+)/$', views.GetFileContent.as_view(), name='fileContent'),
)
非職位工作的非本地。
請發表您的相關網址的conf,以及URL你試圖張貼到。 –
@YuvalAdam添加了urls.py –