React + django, not being able to render detail view

I'm having some trouble fetching data from my modules when it comes to detail views. Basically I have news that are displayed, and then I want the user to be able to click the news and get to a detail view of that news. The fetching works fine when the url is just localhost/Nyheter (news in swedish) but not when I add an id after (localhost/Nyheter/10). This is the relevant code (I hope). I might be missing something very basic, but I've looked around for a while and it can't make it make sense, thanks in advance!


class NewsItem extends Component{
    item: {}

id =;

async componentDidMount(){

    try {

        const res = await fetch("http://localhost:8000/api/news/";
        const item = await res.json();



    function App() {
  return (
          <Navigation />
            <Route path="/" element={<Home />}>
            <Route path="/Nyheter" element={<News/>}>Nyheter</Route>
            <Route path="/Nyheter/:id" element={<NewsItemPage/>}>Nyheter-detaljer</Route>
            <Route path="/om-oss">Om oss</Route>
            <Route path="/kontakt">Kontakt</Route>
          <Footer />

class NewsSerializer(serializers.ModelSerializer):

    class Meta:
        model = News
        fields = '__all__'
        lookup_field = 'id'

def news_list(request):
    if request.method == 'GET':
        data = News.objects.all()

        serializer = NewsSerializer(data, context={'request': request}, many=True)

    return Response(

from hemsida import views

from jk import settings

urlpatterns = [
    path('', TemplateView.as_view(template_name='index.html')),
    re_path(r'^api/news/$', views.news_list),
    re_path(r'^api/news/<int:id>$', views.news_list),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

class News(models.Model):
title = models.TextField(max_length=100)
description = models.TextField()
image = models.ImageField(upload_to="Images/")
created_on = models.DateTimeField(auto_now_add=True)

def __str__(self):
    return self.title

class Meta:
    ordering = ['created_on']
Back to Top