Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django not outputting a csrf token when debug=true
When using django's csrf middleware and calling {% csrf_token %} in the form template django will successfully set the hidden input and cookie, both in production and when DEBUG = False on local. However, when DEBUG = True the value of {{ csrf_token }} is returned as NOTPROVIDED and the cookie and hidden input are not set. Nowhere in our code is the debug setting looked at. django.middleware.csrf.CsrfViewMiddleware is in MIDDLEWARE_CLASSES As you can imagine this makes testing forms on local a little tricky... Is this a bug with django itself or am I missing something silly? -
Django form in a table can't get right parameters
<tbody> {% for sec in sec_list %} <tr> <td>{{sec.c_id_id}}.{{sec.sec_id}}</td> <td>{{sec.title}}</td> <td>{{sec.name}}</td> <td>{{sec.time}}</td> <td>{{sec.r_no_id}}</td> <td>{{sec.cur}}/{{sec.capcity}}</td> <td><form method="post" role="form" action=""> {% csrf_token %} <input class="hidden" type="submit" value="{{sec.c_id_id}}.{{sec.sec_id}}" name="course" id="course"> <input class="hidden" type="submit" value="{{sec.cur}}" name="num" id="num"> <input class="hidden" type="submit" value="{{sec.capcity}}" name="limit" id="limit"> <p class="form-action"> <input type="submit" value="选课" class="btn btn-link"> </p> </form></td> </tr> {% endfor %} </tbody> I want to use a hidden form to transfer some parameters in a table.My code is above.But when I use request.POST.get("limit",'') ,I got a null one.How to fix it -
Foreign Key Constraint - Django API
I am trying to set a the id of the user table as foriegn key in the members table but i get the error thrown below. What could i not be doing right here? I seem not to understand the error error `Cannot add or update a child row: a foreign key constraint fails (`peaceapp`.`peace_teammember`, CONSTRAINT `peace_teammember_owner_id_2c587836_fk_auth_user_id` FOREIGN KEY (`owner_id`) REFERENCES `auth_user` (`id`))')` model class PeaceHero(models.Model): first_name = models.CharField(max_length=100, blank=False) last_name= models.CharField(max_length=100, blank=False) owner = models.ForeignKey('auth.User', related_name = 'peacehero', on_delete=models.CASCADE, default='1') class TeamMember(models.Model): first_name = models.CharField(max_length=100, blank=False) last_name= models.CharField(max_length=100, blank=False) owner = models.ForeignKey('auth.User', related_name = 'captain', on_delete=models.CASCADE, default='1') serliazer class PeaceHeroSerializer(serializers.HyperlinkedModelSerializer): owner = serializers.ReadOnlyField(source='owner.id') class Meta: model = PeaceHero fields = ('url','id', 'first_name','last_name','quote','owner') class UserSerializer(serializers.HyperlinkedModelSerializer): peacehero = serializers.HyperlinkedRelatedField(many=True, view_name='peacehero-detail', read_only=True) captain = serializers.HyperlinkedRelatedField(many=True, view_name='team-details',read_only=True) class Meta: model = User fields = ('url','id','username', 'password','peacehero','captain') class TeamMemberSerializer(serializers.HyperlinkedModelSerializer): owner = serializers.ReadOnlyField(source='owner.id') class Meta: model = TeamMember fields = ('id','first_name','last_name','owner') -
Django REST framework range filter
how can I do range filter for dates and number in drf. Other filters(lt, gt etc.) work fine, I tryed many variants sush as: import rest_framework_filters as filters class OrderFilter(filters.FilterSet): total_price__range = filters.RangeFilter(name='total_price') created_at__range = filters.DateFromToRangeFilter(name='created_at') .... class Meta: model = Order fields = { 'created_at__range': ['__all__'], 'total_price__range': ['__all__'], ... } class OrderViewSet(BaseViewSet, viewsets.ModelViewSet): filter_class = OrderFilter .... In the browsable api there are to fields when I click on buttom "Filters", Then url looks like: /orders/?created_at__range_0=2017-05-22&created_at__range_1=2017-05-22, and it doesn't works. I need something like /orders/?created_at__range=2017-05-22,2017-05-24. and same with integer: /orders/?total_cost__range=1000,2000. It was desribed here . What I'm doing wrong? -
Django UnicodeDecode Error
First of all I've tried all the ways I could find out on SO and google but none worked, so asking here. I'm learning djangoand doing a test project. Everything was going well but after creating superuser when I tried to log into admin panel it showed UnicodeDecodeError. I've tried several method but kept getting the error. I'm using django 1.11 on windows 7 32 bit with python 3. I have created an app students and registered the app. Then ran migrate. students/models.py from django.db import models class Students(models.Model): roll = models.IntegerField(primary_key=True) name = models.CharField(max_length=200) dept = models.CharField(max_length=200) inst = models.CharField(max_length=200) def __str__(self): return self.name + "("+ self.dept + ")" students/views.py from django.shortcuts import render from django.views.generic.base import View from students.models import Students class StudentListView(View): def get(self,request): students = Students.objects.all() return render(request,'students/index.html',{'students':students}) urls.py from django.conf.urls import url from django.contrib import admin from students.views import StudentListView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^students/',StudentListView.as_view()), ] Can someone help me to solve the issue? -
Python Django Create Inlineadmin for ManyToMany over OneToOneField
I have the following model structure: from django.db import models class Item(models.Model): name = models.CharField(max_length=100) class Cart(models.Model): items = models.ManyToManyField(Item, through='ItemAssignment') class ItemAssignment(models.Model): item = models.ForeignKey(Item) cart = models.ForeignKey(Cart) count = models.IntegerField() class Consumer(models.Model): name = models.CharField(max_length = 100) cart_a = models.OneToOneField(Cart, related_name='cart_a') cart_b = models.OneToOneField(Cart, related_name='cart_b') class House(models.Model): name = models.CharField(max_length = 100) cart = models.OneToOneField(Cart, related_name='cart_a') How can I create multiple TabularInline Admin tables for the Consumer model, so that I can directly input Items and their count in each cart_a and cart_b when editing a Consumer instance? The OneToOne relations to the Cart model cannot be placed in the Cart model itself, because multiple Cart instances are referenced (2x in Consumer and 1x in House). -
How to write testcases for password in django rest framework?
Kindly provide test case for this. serializers.py class PasswordSerializer(serializers.Serializer): old_password = serializers.CharField(required=True) new_password = serializers.CharField(required=True) password_again = serializers.CharField(required=True) views.py class ChangePassword(generics.UpdateAPIView): serializer_class = ChangePasswordSerializer model = UserProfile permission_classes = (IsAuthenticated,) def get_object(self): obj = self.request.user return obj def update(self, request, *args, **kwargs): self.object = self.get_object() serializer = self.get_serializer(data=request.data) if serializer.is_valid(): self.object.set_password(serializer.data.get("new_password")) self.object.save() return Response("Success", status=status.HTTP_200_OK) return Response(serializer.errors) The above is my code.I need to write test case for this.The test case should contain code for checking the passwords correctly. -
Django Factory boy does not create an entity for parent class
Given the following models: from django.db import models class A(models.Model): foo = models.TextField() # B inherits from A, it's not abstract so it should # create a table with a foreign key relationship class B(A): bar = models.TextField() And the following test with DjangoModel factories: from django.test import TestCase import factory from factory.django import DjangoModelFactory from .models import A, B class AFactory(DjangoModelFactory): foo = factory.Faker('name') class Meta: model = A class BFactory(DjangoModelFactory): bar = factory.Faker('name') class Meta: model = B class BTestCase(TestCase): def test_1(self): b = BFactory() print(b.foo) # prints '' How can I get b.foo to refer to an actual A entity with a valid foo attribute? At the moment b.foo just returns an empty string. But if I create an A entity using the AFactory, the entity has a properly populated foo field: >>> a_ent = AFactory() >>> a_ent.foo 'Nicholas Williams' I would like BFactory to create an A entity for me that b can refer to. -
Unable to find static files in production with Django using whitenoise
Whenever I've deployed my Django app on Heroku, my browser doesn't load the css and images. When I open the console in chrome it says: GET https://MY_URL.com/static/MY_APP/images/MY_PICTURE.jpg 404 (Not Found) I have: whitenoise 3.3.0 include in my requirements.txt whitenoise added as a middleware in my settings.py Added whitenoise to wsgi.py used "python manage.py collectstatic" on both my local computer and on heroku bash My settings.py looks like this (at the bottom of the file:) PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) PROJECT_ROOT2 = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') STATIC_URL = '/static/' # Extra places for collectstatic to find static files. STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT2, 'static'), ) My file structure looks like this: APP_FOLDER WEBSITE_FOLDER > settings > > local.py > > production.py > static > > [useless css file to make directory visible to git] staticfiles > admin > APP_NAME > > images > > > image1.jpg > > > image2.jpg > > style.css -
Django model relationship best solution
I have the following models: Basket and a Fruit A Basket can have multiple Fruit objects in them, and a Fruit belongs to a single Basket. Each Fruit can be ordered manually so that when they're listed, they show the order in which they were saved. So far so good. class Basket: # A fruit basket name = models.CharField(max_length=100) is_virtual = models.BooleanField(default=False) # This is just a badly constructed example of how a list # of basket primary keys are saved when creating the virtual basket # This is only for demonstration purposes to solve the overall modelling issue virtual_baskets = models.TextField(null=True) class Fruit: # The basket this fruit belongs to basket = models.ForeignKey("Basket", related_name="fruits", on_delete=models.CASCADE) # Manually sorted order order = models.PositiveIntegerField(default=0) However, there's a flag on the Basket called is_virtual which allows users to create virtual combo-Baskets out of existing, real Baskets, in which you end up breaking the rules slightly: a virtual basket can in fact combine two existing Baskets and thus Fruits from two baskets. I need to be able to allow users to manually sort and re-order the the Fruits in these baskets without overwriting the ordering in their original baskets. As an example: Basket … -
Django 1.11.1 ImportError while migrating
I am following this book for django development which uses code for Django 0.96 release and I am using 1.11.1 I have added a module in installed apps section in settings and when i try to migrate in the shell it throws me this error:- The Error in the command line I have no clue where I am going wrong please help. Also I have attached the code for my settings as follows My system.py is as follows:- """ Django settings for django_bookmarks project. Generated by 'django-admin startproject' using Django 1.11.1. For more information on this file, see https://docs.djangoproject.com/en/1.11/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '!bm$h#r%60xt=r(9++z_yj8+)%!5#c1^e_(x#n#w5vf0lg*x5-' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles' 'django_bookmarks.bookmarks', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'django_bookmarks.urls' TEMPLATES = [ { … -
django-mongodb-engine-0.6.0 is compatible with django 1.11?
I am using Django 1.11 . I prefer to use mongodb as my db. I try to connect mongodb to django using djangotoolbox-1.8.0 and django-mongodb-engine-0.6.0. python version i am using is python 3.5 From this link I got some idea but i didn't get solution ,there is any way to connect mongodb to django enter link description here -
DictField in django restframework
I am asking if it's possible to create an attribute DictField with DictField in django restframework. If yes! Is it possible to populate it as a normal dictionary in python. I want to use it as a foreign key to store data. -
django-mptt expand/collapse each branch independent
I have been struggeling with a tree model. The exempel code only shows all parent with children. Thw whole tree so to speak. I want them to be collapsed from start with abibilty to expand each individually. Template code {% load mptt_tags %} <ul class="tree"> {% recursetree nodes %} <li> <i class="menu-icon glyphicon glyphicon-chevron-right"></i> <span class="mm-text">{{ node.item_title }}</span> {% if not node.is_leaf_node %} <ul> {{ children }} </ul> {% endif %} </li> {% endrecursetree %} </ul> I have tried to find anything in the documentation for mptt. And of course lots of googling. Must add I'm new to django and python. Just a two weeks in trying to learn. -
Avoid pre-populated items in modelchoicefield
I have a ForeignKey field in a ModelForm. I have a huge list of elements that I manage with AJAX. I want to avoid the initial load of all elements in the select fields. I use this but get: Select a valid choice. 19 is not one of the available choices. Here my code: class FormForm(forms.Modelform): . ...... def __init__(self, *args, **kwargs): super(ParteNuevoForm, self).__init__(*args, **kwargs) # populates the post self.fields['lugar'].queryset = Lugar.objects.none() self.fields['parroquia'].queryset = Parroquia.objects.none() self.fields['concello'].queryset = Concello.objects.none() Ideas? Thx -
Django markers using geoposition
I use django-geoposition to manage my geodata. in my home.html: <!-- Add Google Maps --> <script> function myMap() { {% for posts in post_list %} myCenter=new google.maps.LatLng(34.8402781,135.592376); var myLocation=new google.maps.LatLng({{posts.position.latitude}},{{posts.position.longitude}}); var mapOptions= { center:myCenter, zoom:7, scrollwheel: true, draggable: true, mapTypeId:google.maps.MapTypeId.HYBRID }; var map=new google.maps.Map(document.getElementById("googleMap"),mapOptions); var marker = new google.maps.Marker({ position: myLocation, title:'{{ posts.title }}', draggable: false, }); marker.setMap(map); {%endfor%} } </script> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCB1CA2DoITfJoFY4HWTLTxH4Avx7QWWqA&callback=myMap"></script> But it just shows the fist post's maker on the map. I guess the for loop doesn't work. I don't know what to do. I would appreciate any help! models.py from django.db import models from geoposition.fields import GeopositionField class Post(models.Model): title = models.CharField(max_length=100) introduction = models.TextField(blank=True) reason = models.TextField(blank=True) transportation = models.TextField(blank=True) basic_info = models.TextField(blank=True) photo = models.URLField(blank=True) location = models.CharField(max_length=100) created_at = models.DateTimeField(auto_now_add=True) position = GeopositionField(blank=True) website = models.URLField(blank=True) useful_link = models.URLField(blank=True) def __str__(self): return self.title views.py: from django.shortcuts import render from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from .models import Post def home(request): posts = Post.objects.all() paginator = Paginator(posts, 6) #每页显示十个 page = request.GET.get('page') try : post_list = paginator.page(page) except PageNotAnInteger : post_list = paginator.page(1) except EmptyPage : post_list = paginator.paginator(paginator.num_pages) return render(request, 'attractions/home.html', {'post_list': post_list,}) def post_detail(request, pk): post = Post.objects.get(pk=pk) return render(request, 'attractions/post.html', { … -
django-rest testing views with custom authentication
I try to test view that has custom authentication, mainly because the main auth is based on external login-logout system, utilizing Redis as db for storing sessions. Auth class is checking session id from the request, whether it is the same as in Redis - if yes, succeed. My custom authentication.py looks like: from django.utils.six import BytesIO from rest_framework import authentication from rest_framework import exceptions from rest_framework.parsers import JSONParser import redis class RedisAuthentication(authentication.BaseAuthentication): def authenticate(self, request): print(request.META) token = request.META['HTTP_X_AUTH_TOKEN'] redis_host = "REDIS_IP_ADRESS" redis_db = redis.StrictRedis(host=redis_host) user_data = redis_db.get("user_feature:{}".format(token)) if user_data is None: raise exceptions.AuthenticationFailed('No such user or session expired') try: stream = BytesIO(user_data) # Decode byte type data = JSONParser(stream) # Parse bytes class and return dict current_user_id = data['currentUserId'] request.session['user_id'] = current_user_id except Exception as e: print(e) return (user_data, None) and my views.py looks like: @api_view(['GET', 'POST']) @authentication_classes((RedisAuthentication, )) def task_list(request): if request.method == 'GET': paginator = PageNumberPagination() task_list = Task.objects.all() result_page = paginator.paginate_queryset(task_list, request) serializer = TaskSerializer(result_page, many=True) return paginator.get_paginated_response(serializer.data) elif request.method == 'POST': serializer = PostTaskSerializer(data=request.data) if serializer.is_valid(): user_id = request.session.get('user_id') serializer.save(owner_id=user_id) return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) Manual tests pass, but my current pytests failed after adding authentication.py, and have no clue how I can … -
Django cors not blocking cross site requests
I am trying to use django-cors-headers 2.0.2 to only allow api requests form certain sites, as everything is currently available from anywhere. I've started off by just trying block everything but I can't get this working and I'm still able to make requests from anywhere. My settings file: INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'corsheaders', 'rest_framework', 'django_extensions', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django_otp.middleware.OTPMiddleware', 'admin_ip_whitelist.middleware.AdminAccessIPWhiteListMiddleware' ) CORS_ORIGIN_ALLOW_ALL = False CORS_ORIGIN_WHITELIST = ('my.website.domain',) Am I missing something? -
Django - circular dependency in fixtures
I need to load data from two different JSONs created by dumpdata app1, dumpdata app2. The problem is that both jsons/apps depends on each other. When I try to loaddata app1, it raises error because it needs to app2 to be loaded before and vice versa. How can I solve this issue? Can I load both at once or load first app without commit and then load the second? -
How to use a Django model containing an image with an opencv function that modifies the image according to scroll bar value
I am building a site for my thesis that has images stored in the database and the user uses some scroll bars to change the brightness, contrast and blur of the current image (without refresing the page). I've build the models and show the image in the template using it's ulr. #in models.py: class Sample(models.Model): name = models.CharField(max_length=250) description = models.CharField(blank=True, max_length=700) full_image= models.FileField() I have also written the js needed for the scroll bars and keep each value in a variable: // eg: Focus Control $( function() { $( "#focus-selector" ).slider({ value:100, min: 0, max: 255, step: 5, slide: function( event, ui ) { $( "#focus-amount" ).val( ui.value ); } }) $( "#focus-amount" ).val($( "#slider" ).slider.value ); }); I now need a way to get the variable "focus-amount" and the image from the model and pass it on my open cv function to change the blurriness of the image. I think I need to use JSON but I'm not exactly sure where and how. Also, do I have to save the modified image in my model each time it changes? Or I should save the image to a different variable and display that one? And for these reads and … -
django - initial data in test
Here are two functions in my UserTestCase(APITestCase) class. The capital variables are constant. Is there any way to test api instead of creating too many constants and dumd data like "data" in test_create_user function? def setUp(self): self.client = APIClient() # create staff self.admin = User.objects.create_user(email=ADMIN, password=PASSWORD) self.admin.is_staff = True self.admin.is_active = True self.admin.save() self.user = User.objects.create_user(email=ADMIN, password=PASSWORD) self.user.is_active = True self.user.save() def test_create_user(self): login = self.client.login(email=ADMIN, password=PASSWORD) self.assertTrue(login) data = { 'email': EMAIL, 'password': PASSWORD, 'first_name': FIRSTNAME, 'last_name': LASTNAME, 'nationality': NATIONALITY, 'is_active': True, } # configure urls url = reverse('apiv2:user-list') # url1 = reverse('apiv2:user-detail', args=[self.user.id]) # create new user user = self.client.post(url, data, format='json') self.assertEqual(user.status_code, 201) # login after create login = self.client.login(email=string_normalize( self.data.email), password=PASSWORD ) self.assertTrue(login) self.client.logout() -
Styling BaseFormSet.can_order with a class
How do I style BaseFormSet.can_order or BaseFormSet.can_delete with a class. Where do I place the widget definition? -
Auto-Refreh / getting real time data using javascript
I am trying to get real time data from backend, is it possible with javascript function (that w'll be awesome) If not then how I can auto-refresh a particualar column of the table in which data is loaded. note: I am using Django on backend and don't want a button to perform the refresh action on frontend -
Django - SQL Server Invalid object name 'django_migrations'
I am working with a Django (v1.9.6) project which works with a SLQ Server database. Due to project related reasons, the server that hosts the database has been changed, so I have modified the database configuration (the only change is the host name) of the Django project. DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'database_name', 'USER': 'username@host_name', 'PASSWORD': 'password', 'HOST': 'host_name', 'PORT': '1433', 'CONN_MAX_AGE': None, 'OPTIONS': { 'driver': 'SQL Server', 'MARS_Connection': True, }, } } However, when I run the Django development server, it raises the following error: Unhandled exception in thread started by <function wrapper at 0x03ADE9B0> Traceback (most recent call last): File "c:\path\to\project\env\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "c:\path\to\project\env\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run self.check_migrations() File "c:\path\to\project\env\lib\site-packages\django\core\management\commands\runserver.py", line 163, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "c:\path\to\project\env\lib\site-packages\django\db\migrations\executor.py", line 20, in __init__ self.loader = MigrationLoader(self.connection) File "c:\path\to\project\env\lib\site-packages\django\db\migrations\loader.py", line 49, in __init__ self.build_graph() File "c:\path\to\project\env\lib\site-packages\django\db\migrations\loader.py", line 176, in build_graph self.applied_migrations = recorder.applied_migrations() File "c:\path\to\project\env\lib\site-packages\django\db\migrations\recorder.py", line 66, in applied_migrations return set(tuple(x) for x in self.migration_qs.values_list("app", "name")) File "c:\path\to\project\env\lib\site-packages\django\db\models\query.py", line 258, in __iter__ self._fetch_all() File "c:\path\to\project\env\lib\site-packages\django\db\models\query.py", line 1074, in _fetch_all self._result_cache = list(self.iterator()) File "c:\path\to\project\env\lib\site-packages\django\db\models\query.py", line 128, in __iter__ for row in compiler.results_iter(): File "c:\path\to\project\env\lib\site-packages\django\db\models\sql\compiler.py", line 802, in results_iter results = … -
Register a route for two different viewsets that inheruse the same model
I'm using Django REST framework and I've a configuration like this one: router.register(r'foo', FooViewSet) router.register(r'foo-mini', MinFooViewSet) FooViewSet and MinFooViewSet are pretty identical ("min" hones inherit from the former), use same queryset but simply change the serializer_class. The serializer class used by MinFooViewSet returns less fields from the same model. I've a weird behavior (probably standard but I don't understand it): seems that I can have only one route for every model. In facts the generated API index is like the following: "foo": "http://localhost:8001/api/v1/foo-mini", "foo-mini": "http://localhost:8001/api/v1/foo-mini", So both endpoints point to the same URL, that use the last (MinFooViewSet) configuration. What I'm missing?