Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How do I access my MySQL DB through command line?
So I'm working on this Django project, with MySQL as DB engine. I made some sort of mistake, and now I have to drop a table I accidentally created. So I'm trying to access the DB through command line, but cannot figure out how. Could anyone help? Or is there a better way of dropping a table in MySQL DB?Thanks in advance. -
Problem with serializing object field Django
I am not a newbie in Django REST Framework, but still not understand something in serialization. For example, I need to serialize a object field that is an object too. From this object field I need only one field (e.g "title"). I know, that is possibly to create the following to solve my project: class CarSerializer(serializers.ModelSerializer): class Meta: model = Car fields = ('id', 'title') class GarageSerializer(serializers.ModelSerializer): class Meta: depth = 1 model = Garage fields = ('id', 'title', 'address', 'car_set') car_set = CarSerializer(many=True) This serializer will return { "id": 1, "title": "MyGarage", "address": "Paris", "car_set": [ { "id": 1, "title": "Lamborghini" } ] } But I want to find way how to point on fields of child field like this: Car.objects.filter(garage__title='MyGarage') How can I make it? -
Session expired auto logout doesn't reload the page in Django
I have followed some of SO's answers about the Django session. Many of them are Django session in 5minutes and SESSION_EXPIRE. The code I tried works when I reload the page after the set of specific times. I got two problems here: It doesn't auto-reload the page and doesn't go back to the login page. It forces to logout after set time despite doing any activity on the page Settings.py INACTIVE_TIME = 1*60 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_COOKIE_AGE = INACTIVE_TIME SESSION_IDLE_TIMEOUT = INACTIVE_TIME middleware.py from django.contrib.auth import logout import datetime from settings import SESSION_IDLE_TIMEOUT class SessionIdleTimeout(object): def __init__(self, get_response): self.get_response = get_response def __call__(self, request): if request.user.is_authenticated: current_datetime = datetime.datetime.now() if 'last_active_time' in request.session: idle_period = (current_datetime - request.session['last_active_time']).seconds if idle_period > SESSION_IDLE_TIMEOUT: logout(request, 'base/login.html') request.session['last_active_time'] = current_datetime response = self.get_response(request) return response What i expect. Auto reload the page if the page remains inactive of certain INACTIVE_TIME Whenever I do any activity on the page it doesn't force me to logout Any help will be appreciated. -
Django-tag shown in the form of writing not in a Django-forms
I'm using javascripts to show a new form every time the user click on the button the javascripts code work perfectly, but it only showed me the forms like this {{form}} the function in the django-side code work perfectly I don't know what I' missing or what I should add this is my html file <script src="{% static '/js/onclick.js' %}"></script> <title>add apointement </title> </head> <body> <div class="container"> <button name="type" class="button1" id="button1">register patient</button> <button name="type" class="button2" id="button2">non register patient</button> <div id='form'> </div> </div> and this is the javascripts file document.addEventListener('DOMContentLoaded', function showAppointementForm() { document.getElementById("button1").onclick = function() { document.getElementById("form").innerHTML = ` <!--<form action="{% url 'create_appointement_register_patient' %}" method="POST">--> <p> <label for="patients">select a patient</label> <select name="patients" id="patients"> <option value="">-- select a patient --</option> {% for patient in patients %} <option value="{{patient}}">{{patient}}</option> {%empty%} <option value="nothing">nothing</option> {% endfor %} </select> </p> {{ form.media }} {{ form.as_p }} {% csrf_token %} <button type="submit" value="create_appointement_register_patient"> ok </button> </form> ` } document.getElementById("button2").onclick = function() { document.getElementById("form").innerHTML = ` <!--<form action="{% url 'create_appointement_non_register_patient' %}" method="POST">--> {{ form.media }} {{ form.as_p }} {% csrf_token %} <button type="submit" value="create_appointement_non_register_patient"> ok </button> </form> ` } }) and this is the 2 function that should work with the forms whene ever i click on … -
How do I implement one to many relationship in django?
So I have a case where I have to use one to many relationship in django, I don't know how to use it. I want to implement one to many relationship in order(one) to product(s) which could be many. My code is like: class Product(models.Model): name = models.CharField(max_length=200) price = models.IntegerField() image = models.ImageField() category = models.ForeignKey(Category, on_delete=models.CASCADE, blank=True, null=True) created_at = models.DateField(auto_now_add=True) def __str__(self): return self.name class Order(models.Model): order_id = models.CharField(max_length=20) user = models.ForeignKey(User, on_delete=models.CASCADE) -
Protect Django media files per user basis and also under NGINX
i have a project that create qrcode per user one to one relation, i discover that this media qr iame can be access if url is known . Can somone please help me with best practice to Protect Django media files per user basis and also under NGINX for later production Please advice Thanks -
Trying to export fields using django celery in django admin model actions but don't get response
I am trying to export data from Django models using Django celery but it doesn't respond with the file. Here is my code that I am using. @task(name=u'generate_file') def generate_file(self, request, queryset): meta = self.model._meta field_names = [field.name for field in meta.fields] response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename={}.csv'.format(meta) writer = csv.writer(response) writer.writerow(field_names) log.info("Exporting Started") for obj in queryset: row = writer.writerow([getattr(obj, field) for field in field_names]) return response def export_as_csv(self, request, queryset): log.info("Start") data_set = generate_file.delay() data_set.get() log.info("End with") return data_set export_as_csv.short_description = "Export as CSV" AdminModel class VideoPlayLogAdmin(admin.ModelAdmin): list_display = (fields) search_fields = [fields] actions = [export_as_csv] So what should I do to get the file? -
How to I flatten nested values with Django?
I'm trying to get a flat list of site names associated with each user. The results will be written to a CSV file: email,sites a@b.com,site1|site2|site3 b@b.com,site3 The expression "usersite__site__name" works when I don't try to aggregate, exporting one row for each user site. With or without ExpressionWrapper, it throws an error that 'WhenNode' object has no attribute 'copy'. Simplified code: users = ( account.get_users() .annotate( sites=ExpressionWrapper(StringAgg('usersite__site__name', delimiter="|"), output_field=CharField()), ) .values_list( "email", # "usersite__site__name", "sites", ) .order_by("email") ) class UserSite(): class Meta(object): unique_together = ("user", "site") user = models.ForeignKey(User, on_delete=models.CASCADE) site = models.ForeignKey(Site, on_delete=models.CASCADE) This is the query logged by Django, when I don't flatten the site name: SELECT "user"."email", "index_site"."name", FROM "user" INNER JOIN "index_userprofile" ON ("user"."id" = "index_userprofile"."user_id") LEFT OUTER JOIN "index_usersite" ON ("user"."id" = "index_usersite"."user_id") LEFT OUTER JOIN "index_site" ON ("index_usersite"."site_id" = "index_site"."id") WHERE "index_userprofile"."account_id" = 1 ORDER BY "user"."email" ASC -
Slicing the content of a TextField()
I'm working on a Django blog and there is a html page where blog entries are shown alongside their titles and date. But the blog entries on this page are supposed to be summaries (first 700 characters of the actual blog body). So, there's a model called 'Post' with 'title, 'date' and 'body' objects but the problem is getting the first 700 characters of the 'body' object to show in the view for all the blog entries. After iterating over Post.objects.all() only the last blog entry content (700 characters) is displayed in the view. There are 4 blog entries in my DB. Meanwhile, I get the exact result I want in the terminal when I run print(desc). Here is the code. models.py class Post(models.Model): title = models.CharField(max_length=140) body = models.TextField() date = models.DateTimeField() def __str__(self): return self.title views.py def body_summary(request): gen = Post.objects.all().order_by("-date")[:25] for summary in gen: desc = summary.body[:700] print(desc) return render(request, 'blog/blog.html', {'gen': gen, 'desc': desc}) blog.html {% for post in gen %} <h5 > {{ post.date|date:"Y-m-d" }} <a href="/blog/{{ post.id }}">{{ post.title }}</a> </h5> <h6 >{{ desc }} <a href="/blog/{{ post.id }}">[...]</a></h6> {% endfor %} -
Django redirect is not redirecting
I'm new to Django and instead of using Django forms ,I'm using bootrap forms with user model that I have created I have to check the login details before giving access to the user dashboard . Here's the code: def login(request): if request.method=="POST": email=request.POST.get('email') password=request.POST.get('password') if email=="cool@c.com" and password=="567": return redirect('dashboard') else: context="Provide Valid Credentials" return render(request."login.html",context) Also below one is also not working def login (request): if request.method=="POST": email=request.POST.get('email') password=request.POST.get('password') user=authenticate (request,email=email, password=password) if user is not None: login(request,user) return redirect ('dashboard') else: context="Provide Valid Credentials" return render(request."login.html",context) It's not redirecting me to the dashboard . And also how to set cookies , sessions but I'm not using the default admin or user model for anything . I'm a website for a client plz give me suggestions based on this not as a project . -
Error - Property 'categoryItem' has no initializer and is not definitely assigned in the constructor
Problem I am trying to import a categoryItem property from the parent component into the child component and populate the fields in the child component from my model. I keep receiving this error and I don't know how to fix it - "Property 'categoryItem' has no initializer and is not definitely assigned in the constructor." Here is my Code - Child Component: department-item.component.ts import { Input } from '@angular/core'; import { Component, OnInit } from '@angular/core'; import { Category } from '../../../models/Category'; @Component({ selector: 'app-department-item', templateUrl: './department-item.component.html', styleUrls: ['./department-item.component.css'] }) export class DepartmentItemComponent implements OnInit { @Input() categoryItem: Category constructor() { } ngOnInit(): void { } } department-item.component.html <a href="javascript:void(0)" class="card-block-link cards-padding" title="TShirt"> <div class="card shadow card-default text-center"> <div class="card-body pt-5 pb-5"> <i class="mb-4 fa fa-tshirt fa-3x" aria-hidden="true"></i> <h4>Test</h4> </div> </div> </a> Parent Component department.component.ts import { Component, Input, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { CookieService } from 'ngx-cookie-service'; import { ApiService } from 'src/app/api.service'; import { Category } from '../../models/Category'; @Component({ selector: 'app-department', templateUrl: './department.component.html', styleUrls: ['./department.component.css'] }) export class DepartmentComponent implements OnInit { categoryList: Category[] = []; constructor( private cookieService: CookieService, private apiService: ApiService, private router: Router) { } ngOnInit(): void { … -
Django: issue displaying login form within another view
I'm building a Django app where I show a landing page if there's no user logged in. I've followed setup steps and the default login page works like a charm, accessed from: accounts/login/. Now I'd like to display that login form from within my landing page view. I tried adding a context processor, but it's not working yet. Here's all the info: The file structure inside my templates directory is: myapp /landing.html registration / login.html In landing.html, I have something like this: {% block content %} Welcome message, blah blah {% include "registration/login.html"%} More contents, etc {% endblock content %} The issue: When I open the landing page, the "login" button is displayed but not the input fields! When I inspect the DOM, the table is there but the td elements are empty (see differences below). One other difference I see in Chrome inspector (not sure if it's important): in my landing.html it shows Shadow Content (User Agent) after each input element Login form used on the (working) default login page: <form method="post" action="/accounts/login/"> <input type="hidden" name="csrfmiddlewaretoken" value="wxidpSfyGmszybrJC38AC8kA8BTylBwiwVONPotCIqOYbkDF54Gwu1ME3lRLTxGw"> <table> <tbody><tr> <td><label for="id_username">Username:</label></td> <td><input type="text" name="username" autofocus="" autocapitalize="none" autocomplete="username" maxlength="150" required="" id="id_username"></td> </tr> <tr> <td><label for="id_password">Password:</label></td> <td><input type="password" name="password" autocomplete="current-password" required="" … -
Django how to get URL of object and pass it to the context to use in a template
The situation is the next: I have a template blog.html displaying blogs entries. I also have a template results.html in which I'm displaying the blogs according to various queries. For each blog displayed on the template results.html i want to create a link to the object URL on blog.html. So users can click on the link and they'll be redirected to the actual object URL. The URL of blog.html won't be always the same as I'm paginating each 3 blogs. Note that my URLs look like this so i can't pass parameters path('', views.blogListView.as_view(), name='blog'), In short, I'd like to get the URL of each object in the View and pass it to the context so i can use it as <a href=""> -
Heroku app deploy problem with main domain url
I've bought a domain and I'm trying to deploy my first web. On local environment, when I runserver, the IP http://127.0.0.1:8000/ shows my index. On production mode, when I call https://micromundos.herokuapp.com/ it give an error: Using the URLconf defined in micromundos.urls, Django tried these URL patterns, in this order: admin/ micromundos/ ^static/(?P.*)$ The empty path didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. I do understand that on production the DEBUG needs to be True. DEBUG = config('DJANGO_DEBUG', default=True, cast=bool) Any input to fix this problem? https://micromundos.herokuapp.com/micromundos works properly showing the index. This is the urls.py urlpatterns = [ path('admin/', admin.site.urls), path('micromundos/', include("myapp.urls")), path('', views.index, name="index") ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) -
Saving instance results in duplicate
So I have a CreateView that is actually a UpdateView . I want the not yet saved instance to be used to add other objects to it. That is why I override get_object(self) def get_object(self): form = self.get_form() form.instance.is_stub = True form.instance.created_by = self.request.user form.instance.save() return form.instance When save & continue editing is pressed form_valid() is called: def form_valid(self, form): form.instance.is_stub = False if form.is_valid(): self.object = form.save() self.object.save() return redirect(self.get_success_url()) However form_valid creates a new instance and it loses the related fields that were linked. How do I prevent this? I manually link related fields in the UpdateView for example: Add author to publication.authors. But the publication gets incremented and the data is lost after form_valid. -
Fix all problems with Django, DRF, Serve static files on Heroku when DEBUG=False with SQLite3
I start learning Django, DRF about a few months ago. After finishing a simple eCommerce project I wanna deploy it on Heroku because it is free. But on Heroku, I got several problems as a beginner as usual. Serving static files on Heroku when DEBUG=FALSE on setting.py file. It takes about 1 week to solve how to do it properly with any additional static or media files (AWS s3, Nginx, apache server). Because I read several StackOverflow articles, websites, Youtube videos, Django official website that how to serve static files. Some link is here: https://docs.djangoproject.com/en/3.2/howto/static-files/ https://docs.djangoproject.com/en/3.2/howto/static-files/deployment/ https://docs.djangoproject.com/en/3.2/ref/contrib/staticfiles/ above all links did not fix my issue In Stackoverflow everybody says Django doesn't serve static files on production anymore when DEBUG=False. So you have to use this and that in this or that way. I try a lot but finally failed whether in the local development server or Heroku production server. After that, A senior Django developer help to fix this. So I think it will help those who are in same situation just stop using this way of serving images, or static files: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # if settings.DEBUG: # urlpatterns += static(settings.MEDIA_URL, # document_root=settings.MEDIA_ROOT) ** … -
ModuleNotFoundError at / No module named 'punctuator.punc'; 'punctuator' is not a package - Heroku, django
So my django app works fine locally and it gets deployed also. However when I try to access my site via the code I get the following error. Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 959, in _find_and_load_unlocked <source code not available> During handling of the above exception (module 'punctuator' has no attribute '__path__'), another exception occurred: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/app/.heroku/python/lib/python3.7/site-packages/django/core/handlers/base.py", line 100, in _get_response resolver_match = resolver.resolve(request.path_info) File "/app/.heroku/python/lib/python3.7/site-packages/django/urls/resolvers.py", line 544, in resolve for pattern in self.url_patterns: File "/app/.heroku/python/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/app/.heroku/python/lib/python3.7/site-packages/django/urls/resolvers.py", line 588, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/app/.heroku/python/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/app/.heroku/python/lib/python3.7/site-packages/django/urls/resolvers.py", line 581, in urlconf_module return import_module(self.urlconf_name) File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import <source code not available> File "<frozen importlib._bootstrap>", line 983, in _find_and_load <source code not available> File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked <source code not available> File "<frozen importlib._bootstrap>", line 677, in _load_unlocked <source code not available> File "<frozen importlib._bootstrap_external>", line 728, in exec_module <source code not available> File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed … -
Django custom template tags
Why my custom templatetag doesn`t work? templatetags.py: from django import template from ..models import User register = template.Library() @register.inclusion_tag('main/post_detail.html', takes_context=True) def get_user_liked_posts(): request = context['request'] user = User.objects.get(username=request.user.username) liked_posts = [] for post in user.liked_posts.all(): liked_posts.append(post.name) return {'liked_posts': liked_posts} post.html: {% load static %} {% load templatetags %} <nav class="blog-pagination" aria-label="Pagination"> <span id="likes_count">{{ post.likes_count }}</span> {% if post.name in liked_posts %} <button id="like_button" class="btn btn-outline-primary btn-primary text- white">Like</button> {% else %} <button id="like_button" class="btn btn-outline-primary">Like</button> {% endif %} </nav> I want to check if post is in liked post of curent user, but it doesn`t work -
First Django Project For Beginners
I'm learning python and want to build a real-world project with the Django framework. It will be great if anyone would suggest a project definition. I want to build an application that covers most of the important topics of Python and Django which are commonly used by companies. I am thinking about creating a public repo. of this project which helps me to get a job as a Python Developer. Thanks In Advance. -
django-environ - Managing LDAP DN in .env
I have a django web app, with a middleware that intercepts incoming requests, extracts user details (added to header by upstream middleware) in the request header, and checks if user is authorized to access the page if user is member of a distribution group. I'm using django-environ to manage my environment variables so i can modify the list of DL Groups which can access my page without changing the code. # in Middleware, only included important part of code from django.conf import settings MINIMAL_MEMBERSHIP = settings.AUTHORIZED_MEMBERSHIP_REQUIREMENT # This should pass in as a list server_object = Server(LDAP_SERVER) conn = Connection(server_object, LDAP_USER, LDAP_PASS, client_strategy=SAFE_SYNC, auto_bind=True) status, result, response, _ = conn.search( search_base=requester_dn, search_filter = '(objectClass=User)', attributes = ['memberOf'] ) authorized = False requester_membership_list = response[0]['raw_attributes']['memberOf'] for membership in requester_membership_list: ad_group_name = membership.decode('utf-8') if ad_group_name in MINIMAL_MEMBERSHIP: authorized = True break # In settings.py AUTHORIZED_MEMBERSHIP_REQUIREMENT = env.list('AUTHORIZED_MEMBERSHIP_REQUIREMENT') # In .env AUTHORIZED_MEMBERSHIP_REQUIREMENT="CN=Virtualisation team,OU=Distribution Group,OU=Exchange,OU=APPS,DC=xxx,DC=xxx,DC=xxx,DC=com", According to django-environ, you can read .env as a list like # .env LIST_ENV=one,two,three,four # settings.py LIST_ENV=env.list(LIST_ENV) print(LIST_ENV) # outputs ['one', 'two', 'three', 'four'] But understandably ldap DN format will break this as a full DN is already delimited by commas, so: # .env DN_LIST="CN=1,OU=1,OU=1,OU=1,DC=xxx,DC=xxx,DC=xxx,DC=com","CN=2,OU=2,OU=2,OU=2,DC=xxx,DC=xxx,DC=xxx,DC=com" # settings.py DN_LIST=env.list(DN_LIST) # … -
How do you hide Django model fields with foreign keys?
I have a seminar that has several multiple choice questions. Here is the seminar model: class Seminar(models.Model): seminar_name = models.CharField(max_length = 60) is_active = models.BooleanField(default = True) seminar_date = models.DateField(null=True, blank=True) And here is the model for the multiple choice questions: class Page(models.Model): seminar = models.ForeignKey(Seminar) multiple_choice_group = models.ForeignKey(MultipleChoiceGroup, null=True, blank=True, verbose_name="Multiple Choice Question") page_id = models.IntegerField(verbose_name="Page ID") I have the following in admin.py: class PageInline(admin.StackedInline): model = Page extra = 0 def get_ordering(self, request): return ['page_id'] # Limit the multiple choice questions that match the seminar that is being edited. def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "multiple_choice_group": try: parent_obj_id = request.resolver_match.args[0] kwargs["queryset"] = MultipleChoiceGroup.objects.filter(seminar = parent_obj_id) except IndexError: pass return super(PageInline, self).formfield_for_foreignkey(db_field, request, **kwargs) class SeminarAdmin(admin.ModelAdmin): model = Seminar inlines = (PageInline,) list_display = ('seminar_name', 'is_active') def get_ordering(self, request): return ['seminar_name'] This is how the seminar appears: enter image description here As shown in the screenshot, I'd like to hide some of the fields from the Seminar model and make some of them read-only. Any help would be appreciated. -
Docker: Cannot use ImageField because Pillow is not installed
I have a problem with my Docker. In my dev version of Docker it's working but when I've created prod version it says that Pillow is not installed. I've been searching for solution since yesterday, but none of given is working for me. Thanks in advance. When I'm running flake8 there are a strange errors about some line breaks before binary operator and whitespaces in Pillow. version: '3.7' services: backend: build: context: ./backend/carrent dockerfile: Dockerfile.prod container_name: django-backend command: gunicorn carrent.wsgi:application --bind 0.0.0.0:8000 ports: - 8000:8000 env_file: - ./.env.prod depends_on: - db db: image: postgres:12.0-alpine volumes: - postgres_data:/var/lib/postgresql/data/ env_file: - ./.env.db.prod volumes: postgres_data: Dockerfile.prod ########### # BUILDER # ########### # pull official base image FROM python:3.8.3-alpine as builder # set work directory WORKDIR /usr/src/backend # set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # install Pillow dependencies RUN apk add libpng-dev tiff-dev libjpeg gcc libgcc musl-dev RUN apk add jpeg-dev zlib-dev RUN apk add --no-cache --virtual .build-deps build-base linux-headers # install psycopg2 dependencies RUN apk update \ && apk add postgresql-dev gcc python3-dev musl-dev # lint RUN pip install --upgrade pip COPY . . # install dependencies COPY ./requirements.txt . RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/backend/wheels -r requirements.txt ############## … -
Django: python manage.py runserver is not working
Out: Python I'm having a problem with Django, like in the picture, when I try to start the server or make a migration, I just get the output: "python" back. I'm using Windows 10 and Python 3.8. -
Django unable to create multiple databases for test in circleci
I have a Django project which uses 6 databases. For CI/CD, I am using CircleCI. I have written some unit test cases which works fine on my machine (local environment). But when I try to run it in the CircleCI environment, it fails. The reason of failing is Django creates only one database from the six (that also random i.e different one every time). I am not sure what I am doing wrong. Here is the config, I am using for CircleCI version: 2.1 orbs: python: circleci/python@0.2.1 jobs: test-job: docker: - image: circleci/python:3.8 environment: DATABASE_URL: mysql://root@127.0.0.1:3306/db0 DB1_DATABASE_URL: mysql://root@127.0.0.1:3306/db1 DB2_DATABASE_URL: mysql://root@127.0.0.1:3306/db2 DB3_DATABASE_URL: mysql://root@127.0.0.1:3306/db3 DB4_DATABASE_URL: mysql://root@127.0.0.1:3306/db4 DB5_DATABASE_URL: mysql://root@127.0.0.1:3306/db5 ALLOWED_HOSTS: localhost CORS_ORIGIN_WHITELIST: http://localhost:8080 CONN_MAX_AGE: 150 DEBUG: False QRCODE_URL: http://test.com/ - image: circleci/mysql:8.0.18 command: [--default-authentication-plugin=mysql_native_password] environment: MYSQL_DATABASE: db0 steps: - checkout - python/load-cache - python/install-deps - python/save-cache - run: command: python manage.py test name: Run Test workflows: main: jobs: - test-job: filters: branches: only: - add_test_to_circleci Any help would be highly appreciated. Thanks in advance! -
how can we get gps data of user's mobile and tablets in our django application?
In my django application I need to store the GPS data of all users to track them especially mobile and tablets how can I do so?