I have a django web service that works fine locally, but as soon as I upload it to the hero, I constantly get a 405 error when I try to post, no matter where I send the message. I added csrf_exempt to my entire post. This is a classic look. eg:
class ApplyForRental(View):
def post(self, request, rentalID):
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)
any reason why he will not work for the hero, but will work locally?
my urls files: Basic
urlpatterns = patterns('',
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)),
)
application
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'),
)
Non messaging does not work locally.