Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Possible to use distinct() with attributes created via extra() in Django ORM?
Let's say you have the following Django ORM query: cars = CarModel.objects.only( 'car__car_id', 'car__cardate', 'car__title', 'car__location', 'car__quote', 'car__key', 'car__cartype_id', 'maker__lastname', 'maker__firstname', 'maker__middlename', 'maker__nickname', ).select_related( 'car', 'maker', ).extra( select={ 'is_position_paper': 'cartype_id = 7', 'is_null_date': 'cardate IS NULL', 'shorttitle': extra, }, ).filter(**kwargs).distinct(sort_order_for_distinct, 'car__car_id').order_by(sort_order, 'car__car_id') My understanding is that, whatever I've included in order_by() I have to also include, in the same order, in distinct(). However, distinct doesn't like the attributes being created in extra(). If I try and include these attributes in the order_by() as I would like, such as: .order_by('is_position_paper', 'is_null_date', sort_order, 'car__car_id') I get the error: Cannot resolve keyword 'is_position_paper' into field So that means that the attributes created via extra() just aren't going to be available to use with distinct()? Is there any alternative approach here? Really all I'm trying to do is dedupe this entire queryset by car__car_id, that's it, whilst having order_by('is_position_paper', 'is_null_date', sort_order, 'car__car_id') Unfortunately I'm stuck on Django 2.1 with this. Also, using Postgres as the db. -
How can i have multiple dictionaries inside dictionary with same key? [closed]
Title: multiple dictionaries inside dictionary with same key example: all_dict={'a':{{'id':1},{'id':2},{'id':3}}} -
How to check multiple states before transition in python django finite state machine
Below is my code a.py: from django.db import models from django_fsm import transition, FSMIntegerField from django_fsm import FSMField, transition import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") import django django.setup() from django.core.management import call_command class Order(models.Model): STATUS_STARTED = 0 STATUS_SLOW =1 STATUS_FAST=2 STATUS_JUMP=3 STATUS_CHOICES = ( (STATUS_STARTED, 'STARTED'), (STATUS_SLOW,'SLOW') (STATUS_FAST,'FAST') (STATUS_JUMP,'JUMP') ) product = models.CharField(max_length=200) status = FSMIntegerField(choices=STATUS_CHOICES, default=STATUS_STARTED, protected=True) A person STARTED from a point & he is either FAST or SLOW. @transition(field=status, source=[STATUS_STARTED], target=STATUS_FAST) def fast(self): print("person run fast") @transition(field=status, source=[STATUS_STARTED], target=STATUS_SLOW) def slow(self): print("person run slow ") Person in FAST state can switch to SLOW state & can JUMP: @transition(field=status, source=[STATUS_FAST], target=STATUS_SLOW) def switch(self) print("state switched") @transition(field=status, source=[STATUS_FAST, STATUS_SLOW], target=STATUS_JUMP) def jump(self) print("person jumpped") but I have condition that person who STARTED from the point with SLOW state cannot JUMP. from FAST state, he can SLOW & JUMP, but not directly from STARTED--> SLOW-->JUMP is possible. But when i run above code: >>person = Order() #input >>person.slow() # Input >> person run slow # output >>person.jump() # Input >>person jumpped # output but expected transition error. And i found that its because, FSM will maintain the last state alone & as per jump(), from SLOW to JUMP get executed.. Got stuck … -
Conection Agular 10 + Django Api Rest no render objetcs
im trying use Django rest + angular 10, i will show a list of providers in the browser, could someone explain to me why my django api rest objects are not rendering? appear in console but not in html. im using angular 10, django 2.7, cors, and my localhost. this is my code. // app-routing.module.ts import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = []; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { } //app.component.html <div *ngFor='let provider of providers'> <h2>{{ provider.name | uppercase }}</h2> <p>{{ provider.procedence }}</p> <p>{{ provider.email }}</p> <p>{{ provider.telephone }}</p> </div> // app.component.ts import { Component, OnInit } from '@angular/core'; import { ProviderService } from './provider.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { title = 'conexion'; providers: any[] = []; constructor( protected ProviderService: ProviderService ) { } ngOnInit() { this.ProviderService.getProviders() .subscribe( (data) => { // Success this.providers = data['results']; console.warn(data) }, (error) => { console.error(error); } ); } } // app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { HttpClientModule} from '@angular/common/http'; import { ProviderService } from './provider.service'; import { AppComponent } from … -
Relational field not updating from Django view
Foreign Key field doesn't update from django view. When i run my test cases, all model test cases runs successfully. When same code is utilized in view, my test case Fail. What am I doing wrong ? I'm using django 3.1.1 and djangorestframework 3.11.1. # models.py class Request(models.Model): status = models.CharField(max_length=1, choices=( ('I', 'Initiating'), ('C', 'Connecting'), ('P', 'Peered')), default='I') class Client(models.Model): name = models.CharField(max_length=100, blank=False, null=False) request = models.ForeignKey(Request, on_delete=models.CASCADE, related_name='clients') class Server(models.Model): type = models.CharField(max_length=100, blank=False, null=False) client = models.OneToOneField(Client, on_delete=models.CASCADE) # views.py # view path ( app_name:path_name ) --> domain:server-peer-request class ServerViewSet(viewsets.ViewSet): model = models.Server .... @action( detail=True, methods=['post',], url_name='peer-request', url_path='peer-request') def peer_server_to_clientrequest(self, request, pk): """This view updates a server instance underlying request status""" server = get_object_or_404(self.model, pk=pk) server.client.request.status = 'P' server.client.request.save() print(server.client.request.status ) # outputs **P** return Response(status=status.HTTP_200_OK) # test_models.py class ServerModelTestCase(TestCase): def setUp(self): # some model instances here e.g (self.client_one -- Client model), (self.request -- Request model) def test_relational_fields_can_update(self): server = models.Server.objects.create(type='microT2', client=self.client_one) self.assertEqual(server.client.request.status, 'I') # 'I' is the default, so test passes server.client.request.status = 'P' server.client.request.save() self.assertEqual(server.client.request.status, 'P') # This test pass # These other test are just to confirm the the instance is updated globally self.assertEqual(self.request.status, 'P') # This test pass self.assertEqual(self.client.request.status, 'P') # … -
django adds unwanted key to my users table. How do I get rid of it at the source?
Latest Django. When I look at the database I see the following keys created for my users table: I am responsible for explicitly adding the user_unique_email_delete_token using the UniqueConstraint on my User model -- as my Users are soft-delete, but I have no idea where users_email_key comes from or how I can stop it from being created. It gets in the way of me having two records with identical email but different delete_token (on soft deleted rows). This should be perfectly ok in my app. Any ideas how I can get rid of this key, and not by modifying the database schema externally? I need it not to be created in the first place with migrate. -
AWS-Xray SDK is not getting disable in Python
I have a XRAY_RECORDER dict in the setting.py file of Django. Where I have different settings for AWS Xrays like Daemon address, tracing name etc. In the same dict I also mentioned 'AWS_XRAY_SDK_ENABLED': False. In short, I want to disable AWS Xray SDK for my application. But it still sends traces in spite of setting it to False. Although I can turn it off using global_sdk_config.set_sdk_enabled(False) but due to requirements constraint, I have to enable or disable it via environment variables. Can anyone please suggest a solution to turn it off? -
Getting error as: SchoolDetailsView is missing or override SchoolDetailsView.get_queryset, what should I fix in below code?
Model.py class School(models.Model): name = models.CharField(max_length=256) principal = models.CharField(max_length=256) location = models.CharField(max_length=256) def __str__(self): return self.name class Student(models.Model): name = models.CharField(max_length=256) age = models.PositiveIntegerField() school = models.ForeignKey(School, related_name='students', on_delete=models.CASCADE) def __str__(self): return self.name Views.py class SchoolDetailsView(DetailView): context_object_name = 'school_detail' models = models.School template_name = 'basic_app/school_details.html' html code code looks like below mentioned in comments Can anyone suggest what am I missing here? -
How to add a ForeignKey to an unmanaged model in Django?
I have 2 models as shown below: class Client(models.Model): name = models.CharField(max_length=50) class Meta: managed=False class Store(models.Model): name = models.CharField(max_length=50) match = models.ForeignKey('Client', on_delete=models.CASCADE) When I run migrations, I get the below error. django.db.utils.ProgrammingError: relation "client" does not exist How can I fix this? I am using django 3.1 and Postgres 12 as my production db. -
Django how to change a form field based on failed validation
I'm trying to protect a signup process in Django using Recaptcha. Currently I am using the django-captcha library for this. Unfortunately v2 of ReCaptcha annoys a lot of people, why I switched to v3. Now looking for the form to adopt based on a failed score in Recaptcha v3 to fall back to v2. Code looks currently something like this: from captcha.fields import ReCaptchaField from captcha.widgets import ReCaptchaV3 class AccountForm(forms.ModelForm): name = forms.CharField(validators=[MinLengthValidator(3)], error_messages={'invalid':_("Please enter a name.")}) terms = forms.BooleanField() # ReCaptcha v2 #captcha = ReCaptchaField( # public_key= settings.RECAPTCHA_PUBLIC_KEY, # private_key= settings.RECAPTCHA_PRIVATE_KEY, #) # Recaptcha v3 captcha = ReCaptchaField( public_key=settings.RECAPTCHA_PUBLIC_KEY_V3, private_key=settings.RECAPTCHA_PRIVATE_KEY_V3, widget=ReCaptchaV3( attrs={ 'required_score': 1.0, } ) ) So nothing there yet. What I try to achieve is a failing v3 to show the v2 instead. This is more a general question if it is possible and where to start. Thanks -
Angular universal SSR not displaying the angular assets folders images while serving it from Django
I have used Angular Universal for SSR(Server Side Rendering) of my angular application. The steps that I followed so far: First I created my angular app and then add angular universal and run "npm run build:ssr" to build it and "npm run serve:ssr" to test it. Untill this point all good. I got 2 folders namely "browser" "server" and "server.js" file. Browser folder contents are equivalent to dist folder content what we usually get by ng build --prod. But I have done the same but using Angular Universal. Now coming to the Django part: STATIC_URL = '/static/' MEDIA_URL = '/media/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATICFILES_DIRS = [ os.path.join(BASE_DIR, '<my_proj_dir>/static'), ] I have also created a simple app to render the index.html page of angular: class FrontEndRenderView(TemplateView): def get(self, request, **kwargs): return render(request, 'index.html', context=None) Next I copy my browser i.e dist folder content inside the above app template(only the index.html) and static files(different js scripts) Next I ran the python manage.py collectstatic to get all my static files into the root directory static folder which I already set in the settings.py and serve it from there. Modified the index.html: {% load static %} <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> … -
Getting function from model and putting it to serializer
I have Django project. I have model and serializer and I'm trying to send the result of my function "increase_id" from model to serializer. What I'm doing wrong? How I can to implement it? class Person(models.Model): age = models.PositiveIntegerField() first_field = models.CharField() second_name = models.CharField() def increase_id(self): own_id = self.id magnifier = own_id + 50_000 return magnifier serializer: class PersonSerializer(serializers.ModelSerializer): magnifier = serializers.IntegerField(source='increase_id') class Meta: model = Person fields = ('id', 'first_name', 'second_name', 'age', 'magnifier') -
Sidebar not working fine in Django html template
Problem - When i reload the web page first the menu of sidebar will display then proper view of sidebar will display. how to overcome this problem . i'm not able to post the code because its too complex . if any body have an idea about the issue please suggest me -
Django session-timeout page refresh
I'm using a package for my Django project that after a certain amount of time logs out the user. The package works perfectly save for one thing, when it timesout, the page is not refreshed. So what this does is change the url path back to the login page and only when I try to navigate to a further link it brings me back to the login. This is a problem because I don't want the sensitive information open for someone to look at until they try to navigate from that page. Can I refresh the page in this middleware so it kicks the user back to login immediately? if session_is_expired: request.session.flush() redirect_url = getattr(settings, "SESSION_TIMEOUT_REDIRECT", None) if redirect_url: return redirect(redirect_url) else: return redirect_to_login(next=request.path) -
Django cannot find one template out three - strange behavior
I am currently going through the Django tutorial and when I tried to run the webserver at the middle of part 4 I stumbled accross this error: TemplateDoesNotExist at /polls/2/ The strange thing is that the other two file work fine, just not the detail.html (see screenshots) I checked the spelling over and over as well als polls/view.py and polls/url.py - but I have no clue as to origin of this seemingly erratic behavior. I also the polls/pycache content after reading about that in another post. Nothing. And btw, the same behavior occurs on my local machine as well as on pythonanywhere.com What did I do wrong? Thanks. Oh, is there anything you need like the views.py, urls.py ...? -
How to use Datatables Scroller in Angular
I'm using the server-side Datatables to get a large amount of data from the Django RestAPI (+500,000 rows) to Angular. When I set a limit to 1000 rows, everything works perfectly but when I remove the limit nothing is shown on the screen. Here's what I've tried: Admin.component.ts ngOnInit(): void { this.dtOptions = { pagingType: 'full_numbers', pageLength: 10, deferRender: true }; this.http.get<any>(this.Authservice.getApiUrl() + 'societes/list/?page=') .subscribe(persons => { this.persons = persons; console.log("Persons == ", this.persons); this.dtTrigger.next(); }); } And here's my views.py @api_view(['GET','POST','DELETE']) def list_societes(request): if request.method == 'GET': societes = Societe.objects.all().order_by('-id') try: page = int(request.GET.get('page')) except Exception: page = 1 societes_data = SocieteSerialize(societes.all(), many=True) return Response(societes_data.data, status.HTTP_200_OK) From what I've searched online, I found that I need to use the Datatables Scroller, but I didn't find a clear documentation for Angular. -
JavaScript set a form fields initial value, to the same value of another field?
I am trying to handle some JavaScript work, which i don't have much experience with. I have a 2 part form where a user enters their personal info, and then company info. I am trying to set some of the company fields to what they already entered in their personal info. I don't want the user to have to retype address, email, etc. for example I have... <div class="form-group"> <label for="email">Email<span>*</span></label> <input name="email" type="text" class="form-control required" id="email"placeholder="Email" value=". {{email}}"> <span id="span_email" class="error-msg"></span> And... <div class="form-group"> <label for="comp_email">Company Email<span>*</span></label> <input name="comp_email" type="text" class="form-control required" id="comp_email"placeholder="Email" value="{{comp_email}}"> <span id="span_email" class="error-msg"></span> How would I be able to set that second comp_email field to initially have the email info, so the user doesn't have to retype, unless they actually wanted to change the comp_email to another email address? EDIT It is all in one form, just separated by div's. Initially when the page is loaded, the account section div is displayed, when the user hits next, it triggers the display of the business info. <input type="button" onclick="nextFormPage(); window.scrollTo(0, 100)" class="btn btn-danger btn-block" value="Next"> The nextFormPage() function just hides the first div, and displays the second div. -
How to update relation field in override save
How to update relation OneToOneField field in override save update working in object.create() but not working in .save() def save(self, *args, **kwargs): self.wallet.wallet_inventory = 50 self.wallet.save() super(MonthlyBuyerOrder, self).save(*args, **kwargs) custom save function also does not work -
Make change to selected object in many to many fields
I have a Order model and item model with many to many relationship, but I just want to make change to selected items for each Order, How can I do that? As when I get order.items.all will affect all the items in the Order. Model.py: class OrderItem(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True) item = models.ForeignKey(Product, on_delete=models.CASCADE) quantity = models.IntegerField(default=1) ordered = models.BooleanField(default=False) being_delivered = models.BooleanField(default=False) being_delivered_date = models.DateTimeField(null=True) Received = models.BooleanField(default=False) Received_date = models.DateTimeField(null=True) def __str__(self): return f"{self.quantity} of {self.item.product_name}" class Order(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True) items = models.ManyToManyField(OrderItem) ordered = models.BooleanField(default=False) being_delivered = models.BooleanField(default=False) being_delivered_date = models.DateTimeField(null=True) Received = models.BooleanField(default=False) Received_date = models.DateTimeField(null=True) def __str__(self): return self.user.username Views.py def update_to_recevied(request, id): order_item = get_object_or_404(OrderItem, id=id) order_item.Received = True order_item.Received_date = timezone.now() order_item.save() return redirect(...) html: {% for item in order.items.all %} <a href="{% url 'update_to_recevied' id=item.id %}" class="btn btn-primary mb-1">Received<br><span>{{ item.item.product_name }}</span></a> {% endfor %} -
How to implement a DDos protection page in Python
I am wondering on how to implement a DDos protection page using Python and exactly Django 3.0 Framework, if anyone has any solutions please let me know on how at least i can restrict all pages or use a middle-ware just like in Laravel PHP. -
Apache - Error 403 Forbidden when deploying Django app
I am trying to deploy my Django application in Apache but it is impossible. When I enter the url it says 403 Forbidden and nothing happens. I have tried watching many tutorials but have not been able to fix my error. I'm using CentOS 7. This is my site.com.conf => /usr/local/apache/conf.d/vhost/myproject.com.conf <VirtualHost myprojectIP:8181> ServerName myproject.com ServerAlias www.myproject.com ServerAdmin myproject@myproject.com DocumentRoot /var/www/html/myproject UseCanonicalName Off ScriptAlias /cgi-bin/ /home/admin/public_html/cgi-bin/ <IfModule mod_setenvif.c> SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on </IfModule> <IfModule mod_userdir.c> UserDir disabled UserDir enabled admin </IfModule> <IfModule mod_suexec.c> SuexecUserGroup admin admin </IfModule> <IfModule mod_suphp.c> suPHP_UserGroup admin admin suPHP_ConfigPath /home/admin </IfModule> <IfModule mod_ruid2.c> RMode config RUidGid admin admin </IfModule> <IfModule itk.c> AssignUserID admin admin </IfModule> <Directory /var/www/html/myproject> Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch SSLRequireSSL </Directory> <Directory /var/www/html/venv> Require all granted </Directory> Alias /static /var/www/html/myproject/templates/static <Directory /home/admin/public_html/myproject/templates/static> Require all granted </Directory> WSGIProcessGroup remesas WSGIScriptAlias / /var/www/html/myproject/remesas/wsgi.py </VirtualHost> This is my site.com.ssl.conf => /usr/local/apache/conf.d/vhost/myproject.com.ssl.conf <VirtualHost myprojectIP:8443> ServerName myproject.com ServerAlias www.myproject.com ServerAdmin myproject@myproject.com DocumentRoot /var/www/html/myproject UseCanonicalName Off ScriptAlias /cgi-bin/ /home/admin/public_html/cgi-bin/ #SSL CONFIGURE HERE #################### <IfModule mod_userdir.c> UserDir disabled UserDir enabled admin </IfModule> <IfModule mod_suexec.c> SuexecUserGroup admin admin </IfModule> <IfModule mod_suphp.c> suPHP_UserGroup admin admin suPHP_ConfigPath /home/admin </IfModule> <IfModule mod_ruid2.c> RMode config RUidGid admin admin </IfModule> <IfModule itk.c> AssignUserID admin … -
failing to install mysqlclient on python 3.7.9
I have python 3.7.9 and I am trying to install mysqlclient package if I give "pip install mysqlclient" it gives below error ERROR: Command errored out with exit status 1: /usr/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-72vmg7v7/mysqlclient/setup.py'"'"'; file='"'"'/tmp/pip-install-72vmg7v7/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-j125wcaz/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/sachin/.local/include/python3.7m/mysqlclient Check the logs for full command output. When I try to install off line and download cp37 version for my python 3.7.9 and run below command pip install mysqlclient-2.0.1-cp37-cp37m-win_amd64.whl It gives error ERROR: mysqlclient-2.0.1-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform. My python is 64 bit and I am using Ubuntu 20.04.1 LTS import struct print(struct.calcsize("P") * 8) Pls help! Thanks in advance. -
Django error smtplib.SMTPAuthenticationError: (535, b'Incorrect authentication data') while sending email
Hi i am trying to execute the following code on terminal with django.core.mail send_mail send_mail('some title','some text','myemail@gmail.com',['otheremail@gmail.com']) but after execution the console is showing this error Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/adjtlikp/virtualenv/globalit-web/3.7/lib/python3.7/site-packages/django/core/mail/__init__.py", line 61, in send_mail return mail.send() File "/home/adjtlikp/virtualenv/globalit-web/3.7/lib/python3.7/site-packages/django/core/mail/message.py", line 284, in send return self.get_connection(fail_silently).send_messages([self]) File "/home/adjtlikp/virtualenv/globalit-web/3.7/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages new_conn_created = self.open() File "/home/adjtlikp/virtualenv/globalit-web/3.7/lib/python3.7/site-packages/django_smtp_ssl.py", line 14, in open self.connection.login(self.username, self.password) File "/opt/alt/python37/lib64/python3.7/smtplib.py", line 730, in login raise last_exception File "/opt/alt/python37/lib64/python3.7/smtplib.py", line 721, in login initial_response_ok=initial_response_ok) File "/opt/alt/python37/lib64/python3.7/smtplib.py", line 642, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'Incorrect authentication data') my settings.py EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend' EMAIL_HOST_PASSWORD = 'pass' EMAIL_HOST_USER = 'myemail@gmail.com' EMAIL_USE_SSL = True EMAIL_PORT = 465 MAILER_EMAIL_BACKEND = EMAIL_BACKEND EMAIL_HOST = 'smtp.gmail.com' DEFAULT_FROM_EMAIL = EMAIL_HOST_USER i tryed to change the EMAIL_PORT and the EMAIL_HOST but nothing changed the intersting is that in localhost the code work perfect but when i am using the host the errors came to me) sorry for my bad english ) -
Django Python - Add table values inside common header
Maybe trying to do something not possible but basically, I created a file header.html that I include all other my html pages e.g. {% include "project/header.html" %} This works fine the challenge is that on header.html I want to put a dropdown menu with values coming from a model. it works fine if I invoke directly header.html but not when inside other page. header.html ... <ul> {% for club in clubs.all %} <li> <a href="#">{{ club.name }}</a></li> {% endfor %} ... views.py from django.http import HttpResponse from django.shortcuts import render from .models import Club def index(request): clubs = Club.objects return render(request, 'project/index.html',{'clubs':clubs}) Is this even possible? Thanks in advance -
How to make a "public" API using Django Restfull: no authentication and rendering a default json format (not using browsable API)?
I am neewbie in DRF. I have implemented DRF API following quikstart exemple on my own data and deploy my app on pythonanywhere. It works and I can access browsable API (users). To resume, in one hand I have a Django web app with a Django Rest API app layer. In the other hand, I have a Flutter mobile app. I would like users to be able to connect to web app or mobile app with the same account (shared database). A solution mentionned in this forum would be my Flutter web app to be able to recover data from django web app using the DRF API. And I would like api to be accessible without authentication and directly rendered in json format. But I face 2 problems. All tutorial I've seen for now show the browsable API. I've read about JsonRenderer but not sure how to implement this solution (renderer_classes = [JSONRenderer] ?). To have access to API, I need to be authenticated. I've read about token that seems to be the solution but how to implement it? thanks to lead me to the way to do that...