Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
My unit tests don't work with multiple databases
I'm working on a project where there are two databases, and I need to create unit tests for my models and etc. these are my databases: DATABASES = { 'default': {}, 'auth_db': { 'NAME': 'name' 'ENGINE': 'django.db.backends.postgresql', 'USER': 'user' 'PASSWORD': 'password' 'PORT': 5432 'HOST': 'localhost }, 'base': { 'NAME': 'name, 'ENGINE': 'django.db.backends.postgresql', 'USER': 'user', 'PASSWORD': 'password', 'PORT': 5432, 'HOST': 'locahost, } } At first I'm creating only the unit tests of the models from django.test import TestCase from base.models import User class UserModelTest(TestCase): @classmethod def setUpTestData(cls): # Set up non-modified objects used by all test methods User.objects.create(first_name='Big', last_name='Bob') def test_first_name_label(self): author = User.objects.get(id=1) field_label = author._meta.get_field('first_name').verbose_name self.assertEqual(field_label, 'first name') But when I do sudo python3 manage.py test, it returns me the error: AssertionError: Database queries to 'base' are not allowed in this test. Add 'base' to base.tests.test_models.UserModelTest.databases to ensure proper test isolation and silence this failure. When I was working with just one database, it wasn't giving a problem, however, when I separated it, I had this problem. I've looked everywhere and haven't found a solution. -
Disable email for bad request in django but still log to file
Someone recently tried to hack our Django server. They sent a lot of bad requests which triggered a lot of emails. How can we disable the emails but still log the bad requests? We have this the block below for DisallowedHosts so I expect something similar for bad requests. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'null': { 'class': 'logging.NullHandler', }, }, 'loggers': { "django.security.DisallowedHost": { "handlers": ["null"], "propagate": False, }, }, } -
Set Django send_mail backend host with Gmail
I have been trying search many files to set send_mail backend with Gmail host. Here is my settings: EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_HOST_USER = 'myemail' EMAIL_HOST_PASSWORD = 'mypassword' DEFAULT_FROM_EMAIL = 'myemail' It doesn't work...I find someone mentioned to set Gmail Account with "less secure app". So I tried, but it didn't work. On google website, it says:"To help keep your account secure, from May 30, 2022, Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password." (refer to: https://support.google.com/accounts/answer/6010255?hl=en). Regardless of all, I still tried to use python3 manage.py shell, and got the error: SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials jj4-20020a170903048400b0016a2b68823esm9889669plb.141 - gsmtp') Could anyone help me, thanks a lot! -
How to use GROUP BY in Django without using values()?
I am trying to GROUP BY with Django ORM: sub = ( Participant.objects .values('category') .annotate( average=Avg(F('price')), ) ) It works as expected BUT the queryset does not contains instances of the model anymore. If contains dicts because values() has been called. How can do a group by query and get a regular queryset (with model instances) ? -
Django Admin - Change Model Page - URLs with UUID instead of ID
I have a BaseModel class that all my models inherit with a uuid like so: class BaseModel(models.Model): ''' Extension of base model class ''' uuid = models.UUIDField(unique=True, default=uuid4, editable=False) ... How can I change the django admin behavior such that I can access the change page for an instance using the object UUID instead of the ID? Presently: .../admin/my_app/my_model/7/change/ Preferred: .../admin/my_app/my_model/b6a98f1d-6b26-4399-8d68-62ec1ce12c41/change/ -
Django not connecting to PlanetScale , SSL error
Trying to use planetscale for my db platform for a Django app that i am building. However i'm running into some errors django.db.utils.OperationalError: (2026, "SSL connection error: no valid certificates were found, CAFile='*************', CAPath=''. One or more of the parameters passed to the function was invalid. Error 2148074333/0x8009035D") The configuration was copied straight from planetscale DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': env('DB_NAME'), 'HOST': env('DB_HOST'), 'PORT': env('DB_PORT'), 'USER': env('DB_USER'), 'PASSWORD': env('DB_PASSWORD'), 'OPTIONS': {'ssl': {'ca': env('MYSQL_ATTR_SSL_CA')}} } } -
Django REST framework authentication does not work with Class based view
I'm using DRF (3.12.4) with SimpleJWT for authentication. It is working with function based view but not working with Class based view. For Class based view, there is no effect and the request passed without authentication. Here is my function based view @api_view(['POST']) @permission_classes([IsAuthenticated]) def test_function_view(request): return JsonResponse({"message": "test ok"}, safe=False, status=200) Here is my class based view class TestClassView(APIView): authentication_classes = [JWTAuthentication] permission_classes = [IsAuthenticated] def post(request): return JsonResponse({"message": "post ok"}, safe=False, status=200) def get(request): return JsonResponse({"message": "get ok"}, safe=False, status=200) Settings REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.authentication.JWTAuthentication', ], } URLs path('api/v1/agents/performancetest/testclass', TestClassView.post), path('api/v1/agents/performancetest/testfunction', test_function_view), In class based view, the authentication made no effect, so when send GET request without authentication, it passed, and for POST request, it got CRSF error because of no authentication. Forbidden (CSRF cookie not set.): /api/v1/agents/performancetest/testclass HTTP POST /api/v1/agents/performancetest/testclass 403 [0.02, 127.0.0.1:59664] HTTP GET /api/v1/agents/performancetest/testclass 200 [0.00, 127.0.0.1:59664] Is there anything I missed here or any clue? Thank you. -
How to convert a Django UUID to integer within a queryset annotate?
I'm trying to convert UUIDs to integers within an annotate. So like: Item.objects.values_list('pk', flat=True).annotate(int_of_pk=int('pk')) which throws error: ValueError: invalid literal for int() with base 10: 'pk' or like: from django.db.models import IntegerField from django.db.models.functions import Cast Item.objects.values_list('pk', flat=True).annotate( int_of_pk=Cast('pk', output_field=IntegerField()) ) which throws error: File "/path/ve/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.CannotCoerce: cannot cast type uuid to integer LINE 1: ...em"."uuid", ("item"."uuid")::integer ... ^ Any ideas pop out at you? Your time is greatly appreciated! -
Pycharm unable to resolve Django reference
I pulled a project from my GitHub to my laptop. After I install my requirements.txt file Pycharm is giving me an error "unresolved reference 'contrib/middleware'" in settings.py despite having Django installed and support enabled. The project is working in Pycharm, I'm just getting my text highlighted and imports aren't working. I've deleted the virtual environment, deleted the project, and pulled it again and I'm getting the same errors -
What would be the Python cmd to fetch the logged in user 's full name on windows and MAC
I am using PowerShell and executing the below command to find user details through AD. Get-ADUser -Identity username -Server domain I need to find alternate for the above command in python which can be executed to find the first name of the user and lastname. I am using windows domain and MAC . Help will be really appreciated -
Django Rest API JWT authentication - No active account found with the given credentials
I have a question concerning the Django Rest Framework JWT auth protocol. This issue has been coming up a lot but no suggested solution has worked for me yet. When I try this command: http post http://127.0.0.1:8000/api/token/ username=username password=password or curl -X POST -d "username=username&password=password" http://localhost:8000/api/token/ to obtain the access/refresh tokens as suggested in many tutorials, I get this error: { "detail": "No active account found with the given credentials" } I have created a superuser My users are all is_active = True My passwords are hashed in the database I have AUTH_USER_MODEL = 'my_app_name.User' in settings.py The username/password are 100% correct. Here is my User model: class User(LifecycleModelMixin, AbstractUser): public_id = models.UUIDField(unique=True, default=uuid.uuid4, editable=False) company_name = models.CharField(max_length=100, blank=True) job_title = models.CharField(max_length=30, blank=True) street_address = models.CharField(max_length=100, blank=True) street_address2 = models.CharField( verbose_name="Street address 2", max_length=100, blank=True ) city = models.CharField(max_length=100, blank=True) state = models.CharField(max_length=50, blank=True) zip = models.CharField(max_length=50, blank=True) phone_number = PhoneNumberField(blank=True) is_active = models.BooleanField(default=True, null=True, blank=True) email_subscribed = models.BooleanField(default=True, null=True, blank=True) manager = models.ForeignKey( "self", null=True, blank=True, on_delete=models.SET_NULL, related_name="sub_users", ) country = CountryField(blank_label="(select country)", blank=True) contact_info = JSONField("ContactInfo", default=contact_default) My serializer: class UserSerializer(serializers.ModelSerializer): def create(self, validated_data): user = super().create(validated_data) user.set_password(validated_data['password']) user.save() return user class Meta: model = User fields = … -
Django webpack_loader: `Regex` Undefined?
I've updated a Django app to Python 3.9 and Django 4.0, and I'm getting an error on launch: TypeError: expected string or bytes-like object I tracked it down to this function in python3.9/site-packages/webpack_loader/loader.py: def filter_chunks(self, chunks): filtered_chunks = [] for chunk in chunks: ignore = any(regex.match(chunk) for regex in self.config['ignores']) if not ignore: filtered_chunks.append(chunk) return filtered_chunks On the line ignore = any(regex.match(chunk)..., regex is undefined. I ran brew upgrade python, but Homebrew said: Warning: python 3.9.13_1 already installed What am I missing? -
How can I aggregate strings by concatenate in Django annotate?
I have the followed model in Django: class Click(models.Model): url = models.ForeignKey(Url, on_delete=models.CASCADE) browser = models.CharField(max_length=255) platform = models.CharField(max_length=255) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) I want to build a query to get the total clicks per day on the current month, along with browsers and platforms concatenated. For example: [ { 'created_at__day': 28, 'browsers': 'Chrome, Firefox', 'platforms': 'Windows, Linux', 'clicks': 4 } ] What I did until this moment was that query: queryset = Click.objects.filter( url=url_instance, created_at__month=datetime.now().month ).values('created_at__day', 'browser').annotate( clicks=Count('created_at'), ) How can I concat every browser and platform, only grouping by created_at__day? -
Is Django 500 error Invalid HTTP_HOST header a security concern?
I have a custom Django web app sitting behind an NGINX proxy server. I am seeing occasional errors come through from my Django server with messages like Invalid HTTP_HOST header: 'my.domain.com:not-a-port-number'. The domain name provided is not valid according to RFC 1034/1035. where the part after the colon has been a variety of wack garbage like, my.domain.com:§port§/api/jsonws/invoke my.domain.com:xrcr0x4a/?non-numeric-port-bypass my.domain.com:80@+xxxxtestxxxx/ my.domain.com:80@+${12311231}{{12311231}}/ I am able to replicate a similar error using curl where the request url and the host header are different: curl https://my.domain.com --header 'Host: my.domain.com:not-a-port-number' I suspect that these are likely coming from our network security scanning software trying to find vulnerabilities in our custom web apps, but I am a little surprised that NGINX allows these requests to make it through to my Django server, especially if, as the 500 error output suggests, these are invalidly formatted headers. Trying to prepare for the worst, is there anything I should change or be concerned about with this for the sake of security? Is there a best practice for this situation that I am unaware of? Should NGINX be filtering out these sorts of requests? For my own convenience it would be nice to not to see the noise of these … -
Django - how to give Javascript table information to create a network Graph?
I have a model which stores Network Stats including Nodes. I want to display that rendered in HTML. Here is my table interfaceModel Interface IPaddress Hostname AE1 1.1.1.1 A AE1 2.2.2.2 B AE2 3.3.3.3 C AE2 4.4.4.4 D AE3 5.5.5.5 E AE3 6.6.6.6 F I am using highcahrts Network Graph to draw a Network Graph https://www.highcharts.com/blog/tutorials/network-graph/ Here is the Code which displays the following demo graph <style> #container { background: #1f1f1f; min-width: 320px; max-width: 500px; margin: 0 auto; height: 500px; } </style> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/networkgraph.js"></script> <div id="container"></div> <script> Highcharts.chart('container', { chart: { type: 'networkgraph', marginTop: 80 }, title: { text: 'Network graph' }, plotOptions: { networkgraph: { keys: ['from', 'to'], } }, series: [{ marker: { radius: 30 }, dataLabels: { enabled: true, linkFormat: '', allowOverlap: true }, data: [ ['Node 1', 'Node 2'], ['Node 1', 'Node 3'], ['Node 1', 'Node 4'], ['Node 4', 'Node 5'], ['Node 2', 'Node 5'] ] }] }); </script> How can i replace the data in the JS data array looping from my Interfacedatabase hostname? It is a direct single straight connection with no inter connections A>B>C>D>E>F data should look something similar as follows data: [ [A, B], [B, C], [C, D], [D, E], … -
How to make search of list with none english letters?
I am making e-commerce website on ( React.js - client )and ( Python Django - client ). I am trying to make a search feature for list of all products and the queries are none-english. Whenever I try to search, my none-english query gets into hell knows what. For example I input query "текст" and it turns to / search / %D1%82%D0%B5%D0%BA%D1%81%D1%82. Expected: / search / текст. And of course my api cannot find any product with this query.. @api_view(["GET"]) def searchData(request, q): searchedData = Product.objects.filter(Q(title__icontains=q)) data = ProductSerializer(searchedData, many=True).data return Response(data) This is my search view. path('search/<str:q>/', views.searchData) This is my path. I hope for any kind of help. Thanks! -
Model and code changes to get query results from a DB with multiple lookup tables
The Django app I am building manages client information. The short version of this question is how do I build a Django query that equates to this sql statement... select cl.id, cl.first, cl.last, ad.zipcode, ph.phone_number, em.email_address from client.clients as cl join client.addresses as ad on cl.id=ad.client_id join client.phones as ph on cl.id=ph.client_id join client.email_addresses as em on cl.id=em.client_id where cl.status_id=1 and ad.type_id=1 and ph.type_id=1 and em.type_id=1; ...given the following models, starting with an abbreviated client: class Client(models.Model): id = models.IntegerField(primary_key=True) last = models.CharField(max_length=32) first = models.CharField(max_length=32) The address model: class Address(models.Model): id = models.IntegerField(primary_key=True) client = models.ForeignKey( 'Client', on_delete=models.DO_NOTHING, blank=False, null=False) type = models.ForeignKey( AddressType, on_delete=models.DO_NOTHING, blank=False, null=False) street = models.CharField(max_length=32, blank=True, null=True) city = models.CharField(max_length=32, blank=True, null=True) state = models.CharField(max_length=2, blank=True, null=True) zipcode = models.CharField(max_length=10, blank=True, null=True) The phone model: class Phone(models.Model): id = models.IntegerField(primary_key=True) client = models.ForeignKey( 'Client', on_delete=models.DO_NOTHING, blank=False, null=False) type_id = models.ForeignKey( PhoneType, on_delete=models.PROTECT, blank=False, null=False) is_primary = models.BooleanField country_code = models.CharField(max_length=5) phone_number = models.CharField(max_length=16) The email address model: class EmailAddress(models.Model): id = models.IntegerField(primary_key=True) client = models.ForeignKey( 'Client', on_delete=models.PROTECT, blank=False, null=False) type_id = models.ForeignKey( EmailType, on_delete=models.PROTECT, blank=False, null=False) email_address = models.CharField(max_length=128, blank=False, null=False) And finally, the ClientListView that should contain the queryset: class ClientListView(ListView): model = … -
TypeError: test_admin_login() missing 1 required positional argument: 'self'
I'm writing test cases for my Django-based rest APIs. The problem is in the method of testcase class. I want to use test_admin_login method in the setuptestdata method. And I'm unable to do that. I'm getting error that I mentioned in the title. class MyTests(TestCase): allow_database_queries: True client = APIClient() @classmethod def setUpTestData(cls): # client = APIClient() # AUTHENTICATION # response = cls.client.post(reverse('auth'),data={"username":"admin","password":"ppoopp00"},format='json') value = cls.test_admin_login() print(value) cls.auth_token = cls.test_admin_login(cls) # CREATE PROJECT response = cls.client.post( reverse('projects:project_create'), data={"platform_subscriber_entity":"NucoinTest"}, format='json', HTTP_AUTHORIZATION="JWT "+cls.auth_token ) cls.project_key = response.data["platform_subscriber_id"] def test_admin_login(self): """ Ensure we can create a new account object. """ url = reverse('auth') response = self.client.post(url,data={"username":"admin","password":"testpass"},format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(len(response.data), 2) return response.data["access"] -
How to add "AND" clause to OUTER JOIN in Django ORM?
I have a query constructed in Django that is almost correct. Here is my call: all_companies = Company.objects.filter(Q(employees=None) | Q(employees=user.id)).annotate(username=F('employees__auth__username')).all().order_by('id') What this produces is the following: SELECT "main_company"."id", "main_company"."schema_name", "main_company"."name", "main_company"."subdomain", "main_company"."migration_id", "auth_user"."username" AS "username" FROM "main_company" LEFT OUTER JOIN "main_company_employees" ON ("main_company"."id" = "main_company_employees"."company_id") LEFT OUTER JOIN "main_user" ON ("main_company_employees"."user_id" = "main_user"."id") LEFT OUTER JOIN "auth_user" ON ("main_user"."auth_id" = "auth_user"."id") WHERE ("main_company_employees"."user_id" IS NULL OR "main_company_employees"."user_id" = 1) ORDER BY "main_company"."id" ASC; However this query does not work exactly the way I intended. What I would like is this: SELECT "main_company"."id", "main_company"."schema_name", "main_company"."name", "main_company"."subdomain", "main_company"."migration_id", "auth_user"."username" AS "username" FROM "main_company" LEFT OUTER JOIN "main_company_employees" ON ("main_company"."id" = "main_company_employees"."company_id") AND ("main_company_employees"."user_id" = 1) LEFT OUTER JOIN "main_user" ON ("main_company_employees"."user_id" = "main_user"."id") LEFT OUTER JOIN "auth_user" ON ("main_user"."auth_id" = "auth_user"."id") WHERE ("main_company_employees"."user_id" IS NULL OR "main_company_employees"."user_id" = 1) ORDER BY "main_company"."id" ASC; Note the difference in the first LEFT OUTER JOIN. How can this be achieved (other than the obvious raw query which I am trying to avoid)? -
Django auto increment fields
I have 2 columns named Serial and Bag I need them to be auto incremented but based on each other and also based on the user that will update the record, so every bag should have 100 serial and reset the number automatically after reaching 100, then start again with Bag number 2 and put 100 serial in it and reset. Thanks -
Django ViewSet serializer_class is being ignored
I have two models: ModelA and ModelB, with their corresponding serializers ModelASerializer and ModelBSerializer In a specific viewset, called MyViewSet i have the follwing structure: class MyViewSetRoot(viewsets.ModelViewSet): http_method_names = ["get"] # The returned values are of type "ModelA", so I need it to use that serializer serializer_class = ModelASerializer queryset = "" Finally, in my actual view, I do something like this: class MyViewSet(MyViewSetRoot): get(self, request: HttpRequest, *args, **kwargs) -> Response: ModelA_queryset = ModelA.objects.all() return Response( data=ModelA_queryset, status=status.HTTP_200_OK, ) I would expect in that case for the queryset to be serialized using the ModelASerializer that I specified in the serializer_class field. However, I get the error Object of type ModelA is not JSON serializable If I do this instead: class MyViewSet(MyViewSetRoot): get(self, request: HttpRequest, *args, **kwargs) -> Response: ModelA_queryset = ModelA.objects.all() serialized_queryset = ModelASerializer(ModelA_queryset, many=True) return Response( data=serialized_queryset.data, status=status.HTTP_200_OK, ) It works just fine, but I want to avoid serializing explicitly in the view. Any ideas on what could be actually going on? Am I forced to serialize explicitly in this case? -
URLS.PY and VIEWS.PY slug removal
I tried to word this specifically but the dilemma is as follows: The image will not load as the slug is being added on the detail page, but loads fine in the index.html. post.image is the code you should be looking for... works in index.html but not post_detail... Something is off in the views/urls.. tried many combos but still getting my brain wrapped around the intricacies of url patterns. I need the image in the detail to point to http://127.0.0.1:8000/static/placeholder_cake.PNG and not 'http://127.0.0.1:8000/carrot-cake/static/placeholder_cake.PNG (basically without the slug).. Thanks to anyone that assists! index.html <div class="col-md-8 mt-3 left"> {% for post in post_list %} <div class="card mb-4"> <div class="card-body"> <img class="card-img-top" src="{{ post.image }}" alt="Card image cap"> <h2 class="card-title">{{ post.title }}</h2> <p class="card-text text-muted h6">{{ post.author }} | {{ post.created_on}} </p> <p class="card-text">{{post.content|slice:":200" }}</p> <a href="{% url 'post_detail' post.slug %}" class="btn btn-primary">Read More &rarr;</a> </div> </div> {% endfor %} </div> post_detail.html {% extends 'base.html' %} {% block content %} <!-- {% load static %} --> <div class="container"> <div class="row"> <div class="col-md-8 card mb-4 mt-3 left top"> <div class="card-body"> <h1>{% block title %} {{ objest.title }} {% endblock title %}</h1> <p class=" text-muted">{{ post.author }} | {{ post.created_on }}</p> <!-- /carrot-cake/static/placeholder_cake --> … -
Django migrate column is not the same data type as referencing column
I have the below model which is an existing DB model and through Django's inspectdb management command the below model is created. class ExistingLegacyModel(models.Model): period = models.TextField(db_column="Period", blank=True, null=True) key = models.AutoField(db_column="Outloo", primary_key=True) class Meta: managed = False db_table = "table_name" and currently, I'm trying to create a model with a field foreign key reference to the existing legacy DB model class TestModel(models.Model): period = models.ForeignKey( ExistingLegacyModel, on_delete=models.CASCADE, db_column="Key", ) so when I run the makemigrations command the migration file is successfully getting created with no issue. below is the migration file content. class Migration(migrations.Migration): initial = True dependencies = [ ('historical', '0011_phoenixcontractprice'), ] operations = [ migrations.CreateModel( name='TestModel', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('period', models.ForeignKey(db_column='Key', on_delete=django.db.models.deletion.CASCADE, to='app.ExistingLegacyModel')), ], ), ] so now when i run the migrate command now, it is failing and giving the below error. django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Column 'table_name.OutlookKey' is not the same data type as referencing column 'version_testmodel.OutlookKey' in foreign key 'version_testmodel_OutlookKey_eb16c31c_fk_table_name_OutlookKey'. (1778) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Could not create constraint or index. See previous errors. (1750)") I'm stuck with this issue for the past couple of days and I searched all the internet … -
Pagination from django_tables2 not rendering
I am relatively new in Django and could not find any answer here on why my table from django_tables2 is not rendering nice pagination buttons. Here follows the codes: models.py class IDOC(models.Model): on_delete=models.SET_NULL, null=True) sample_id = models.CharField(max_length=200) lon = models.FloatField(null=True, blank=True) lat = models.FloatField(null=True, blank=True) dp_position = models.IntegerField(null=True, blank=True, verbose_name='DP Position [-]') def __str__(self): return self.sample_id tables.py class IDOCTable(tables.Table): sediment_depth_m = NumberColumn() wl_m = NumberColumn() H_m = NumberColumn() idoc_mgl = NumberColumn() temp_c = NumberColumn() idoc_sat = NumberColumn() class Meta: model = IDOC template_name = "django_tables2/bootstrap-responsive.html" views.py def view(): idoc_objects = IDOC.objects.all() idoc_show = flutb.IDOCTable(idoc_objects) context = { 'idoc_table': idoc_show, } return render(request, 'flussdata/query.html', context) flussdata/query.html {% extends 'base.html' %} {% load django_tables2 %} {% block content %} <div class="row"> <div class="col-md"> <div class="row"> <div class="card card-body"> <h3>Intragravel Dissolved Oxygen Content</h3> {% render_table idoc_table %} </div> </div> </div> </div> Then, my tables is rendered like this: Instead of the way it should, which I believe is like this: -
Simple JWT Usage
I have my Django backend authentication working (tested using curl and postman) but something eludes me. When sending test requests, the docs show username and password data being sent: curl \ -X POST \ -H "Content-Type: application/json" \ -d '{"username": "davidattenborough", "password": "boatymcboatface"}' \ http://localhost:8000/api/token/ but, if I try to send email and password instead, the response says that the username is a required field. Where and how can I change that behavior? Thanks!