Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Sorting and pagintion and searching produces problemes #133

Open
TheNerdy97 opened this issue Jun 30, 2022 · 0 comments
Open

Sorting and pagintion and searching produces problemes #133

TheNerdy97 opened this issue Jun 30, 2022 · 0 comments

Comments

@TheNerdy97
Copy link

I followed the doc tutorial and the data tables worked, but when I sort or chose a different page or search for values I get the problem

@izimobil

Test-Case
https://codepen.io/TheNerdy97/pen/gOvNeeo?html-preprocessor=pug

models.py

from unittest.util import _MAX_LENGTH
from django.db import models

#from django.utils.translation import gettext as __



# Create your models here.

class Fresh(models.Model):
    code = models.CharField(("code"), max_length=255)
    orbs = models.IntegerField(("orbs"))
    orbs_display = models.CharField(('orbs_display'), max_length=255)
    price = models.IntegerField(("price"))
    price_display = models.CharField(('price_display'), max_length=255)
    images = models.CharField(("images"), max_length=10000000)
    date = models.CharField(("date"), max_length=255)


    class Meta:
        ordering = ['code', 'orbs', 'price']


    
    def __str__(self):
        return self.code

views.py

from django.shortcuts import render
from accounts.models import  Fresh, Orbs
from rest_framework import viewsets
from accounts.serializers import FreshSerializer
from django.core import serializers


# Create your views here.
def index (request):
	return render(request, 'index.html')

class FreshViewSet(viewsets.ModelViewSet):
	queryset = Fresh.objects.all().order_by('price')
	serializer_class = FreshSerializer

urls.py

import accounts
from . import views
from django.urls import path, include, re_path
from rest_framework import routers
from main import views
from rest_framework import routers


router = routers.DefaultRouter()
router.register(r'fresh', views.FreshViewSet)
router.register(r'orbs', views.OrbsViewSet)


urlpatterns = [
    path('', views.index, name='index'),
    path('fresh', views.fresh, name='fresh'),
    re_path('^api/', include(router.urls)),
]
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant