Answer the question
In order to leave comments, you need to log in
How to set up urls correctly so that when a GET request to api does not give an error code 404?
I have a django + vue project. I start the local server, I start the client. The page is displayed, the server is started. Vue elements send a GET request to the server, which produces the following log:
Not Found: /api/mark_read
[19/Apr/2018 09:35:43] "GET /api/mark_read?id=%7B%7D HTTP/1.1" 404 2205
http GET "http://localhost:8000/api/v1/messages
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^api/v1/', include('webapp.urls')),
url(r'^admin/', admin.site.urls),
url(r'^api-auth/', include('rest_framework.urls')),
from rest_framework import routers
from .views import MessageViewSet
# Создаем router и регистрируем наш ViewSet
router = routers.DefaultRouter()
router.register(r'message', MessageViewSet)
# URLs настраиваются автоматически роутером
urlpatterns = router.urls
from __future__ import unicode_literals
from django.db import models
# Модель - "СообщениеИзКосмоса"
class Message(models.Model):
msg_date = models.DateTimeField(auto_now_add=True)
text = models.TextField()
readed = models.BooleanField()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question