Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Decorator Order signals
I was reading a tutorial for signaling in django and I came across an example @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_profile(sender, instance, **kwargs): instance.profile.save() How do we chose the order or operations? How do we know create_user_profile execs before save_user_profile? If order is decided by declaration , isn't it a bit dangerous when code is merged automatically via git or svn or whatever. -
No module named 'geopandas' Django with Apache
Everything works in python3 manage.py runserver but not working using Apache wsgi I'm using Django and Python 3.6. When i'm running runserver works perfectly ModuleNotFoundError at / No module named 'geopandas' Request Method: GET <VirtualHost *:80> ServerName website.com Alias /static /var/www/teste/static <Directory /var/www/teste/static> Require all granted </Directory> Alias /files /var/www/teste/files <Directory /var/www/teste/files> Require all granted </Directory> <Directory /var/www/teste/app/> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess teste processes=1 threads=15 python-path=/var/www/teste python-home=/var/www/teste/venv WSGIProcessGroup teste WSGIScriptAlias / /var/www/teste/app/wsgi.py ErrorLog /var/log/apache2/error_teste.log CustomLog /var/log/apache2/access_teste.log combined </VirtualHost> -
Django saving images with orm of scrapped images [duplicate]
This question already has an answer here: Django save image from url and connect with ImageField 4 answers I am not getting how to save an image that I scrapped from an external website. for example, the user name is: Jhon Doe and his images is https://randomuser.me/api/portraits/med/men/84.jpg Now I scrapped his images and name but problem is, not getting how to save the images and name with respected models/field. like my models: class Person(models.Model): name = models.CharField(max_length=50) img = models.ImageField(upload_to='somewhere'/) Now I want to upload the image with ORM in the respected user model. I also I write a management script to populate users but is populating name only, not getting how to populate images with images. Can anyone please give me a guide how do you handle this kind of problem? -
'NoneType' object has no attribute 'strip' with DjangoAdmin and Ckeditor
Hello guys I have the following problem I am using django-admin and using ckeditor, when I make a very large post and save in django-admin it gives the following error: 'NoneType' object has no attribute 'strip' # models.py class Posts(models.Model): title = models.CharField(max_length=60, blank=False, null=False, verbose_name='Título') description = models.CharField(max_length=255, blank=False, null=False, verbose_name='Descrição') content = RichTextField(blank=False, null=False, verbose_name='Conteúdo') private = models.BooleanField(blank=False, null=False, default=True, verbose_name='Privado') tags = models.ManyToManyField(Tags, verbose_name='Tags') author = models.ForeignKey(User, default=None, on_delete=models.CASCADE, verbose_name='Autor', editable=False) image = models.ImageField(upload_to='posts_img', blank=False, null=False, default='default.png', verbose_name='Imagem') status = models.ForeignKey(Status, null=False, blank=False, default=None, on_delete=models.CASCADE, verbose_name='Situação') created_at = models.DateTimeField(auto_now_add=True, verbose_name='Data Cadastro') updated_at = models.DateTimeField(auto_now=True, verbose_name='Data Atualização') class Meta: verbose_name_plural = 'Postagens' verbose_name = 'Postagem' def __str__(self): return self.title # admin.py from django.contrib import admin # Register your models here. from post.models import Posts class PostAdmin(admin.ModelAdmin): list_display = ['title', 'description', 'private', 'author', 'created_at', 'updated_at'] # Filters search_fields = ['title', 'description', 'tags', 'author', ] # Paginate per page list_per_page = 15 # No of records per page def save_model(self, request, obj, form, change): if getattr(obj, 'author', None) is None: obj.author = request.user obj.save() admin.site.register(Posts, PostAdmin) -
How to call a Django function from Angular?
I'm new in Angular, since days i'm trying to send a email. In Django, in can do it compiling my function. Now, i want to call this function from Angular. My django function receives a mail address as a parameter (mail to which the message is gonna be send). Please, help me :( -
Does get_queryset process after get_ordering in Django ListView?
I have a list view in which I implemented a search bar feature but it seems that my ordering is now not working. How do I get around this? class MemoListView(LoginRequiredMixin, ListView): model = Memo template_name = 'memos/memos.html' context_object_name = 'memos' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['memo_list'] = Memo.objects.all() return context def get_ordering(self): ordering = self.request.GET.get('ordering', '-date_time') return ordering def get_queryset(self): query = self.request.GET.get('q') if query: memo_list = Memo.objects.filter( Q(title__icontains=query) | Q(content__icontains=query)) else: memo_list = Memo.objects.all() return memo_list One thing to note is that I am implenting a filter ordering feature as well and would like to use the get_ordering method for this. Is there a way to call the get_ordering method after the get_queryset? -
Converting Django project from Python 2 to Python 3: "django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet."
After running 2to3 and installing all packages in settings.py (and requirements.txt), this error appears upon check or runserver. (env) x:languages x$ python3 manage.py check Traceback (most recent call last): File "manage.py", line 11, in <module> execute_from_command_line(sys.argv) File "/project/src/languages/env/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/project/src/languages/env/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute django.setup() File "/project/src/languages/env/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/project/src/languages/env/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate app_config = AppConfig.create(entry) File "/project/src/languages/env/lib/python3.7/site-packages/django/apps/config.py", line 90, in create module = import_module(entry) File "/project/src/languages/env/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 File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/project/src/languages/language/__init__.py", line 3, in <module> from django_comments.models import Comment File "/project/src/languages/env/lib/python3.7/site-packages/django_comments/models.py", line 7, in <module> from .abstracts import ( File "/project/src/languages/env/lib/python3.7/site-packages/django_comments/abstracts.py", line 4, in <module> from django.contrib.contenttypes.fields import GenericForeignKey File "/project/src/languages/env/lib/python3.7/site-packages/django/contrib/contenttypes/fields.py", line 3, in <module> from django.contrib.contenttypes.models import ContentType File "/project/src/languages/env/lib/python3.7/site-packages/django/contrib/contenttypes/models.py", line 133, in <module> class ContentType(models.Model): File "/project/src/languages/env/lib/python3.7/site-packages/django/db/models/base.py", line 103, in __new__ app_config = apps.get_containing_app_config(module) File "/project/src/languages/env/lib/python3.7/site-packages/django/apps/registry.py", line 252, in get_containing_app_config self.check_apps_ready() File "/project/src/languages/env/lib/python3.7/site-packages/django/apps/registry.py", line 135, in check_apps_ready raise AppRegistryNotReady("Apps aren't … -
Communication from Python Desktop app (Client instances) to Django server app
We have Python Desktop app installed on client systems and a web based Django application. We would like to show an alert on Django app to logged in users when the client app on their systems has not been running for let's say over 2 hours. I feel following approach should work: Hitting an API call from desktop app to Django app Storing timestamp at which the api call is received along with the client id Iterating through the active sessions on django app and checking which of the clients had hit API call before X hours and thus showing alert to those clients on web based app. I would like to keep the solution simple thus ignoring sockets as I think they will be overkill for the situation (we are looking at a frequency of checking every hour may be and there will be times when client machine is switched off as well) Can CloudWatch be any help here? Is there a better solution? -
Hide/Show li elements for independent divs
Trying to implement a hide/show results on a search page, what I have right now works, but not in the way I want. As of now, the code is limiting all li's instead of 3 per div let searchResults = document.querySelectorAll('div.test-class-3'); searchResults.forEach(function (searchResult) { console.log('result',searchResult) $(document).ready(function(){[![enter image description here][1]][1] var list = $(".search-results li"); var numToShow = 3; var button = $("#next"); var numInList = list.length; list.hide(); if (numInList > numToShow) { button.show(); } list.slice(0, numToShow).show(); button.click(function(){ var showing = list.filter(':visible').length; list.slice(showing - 1, showing + numToShow).fadeIn(); var nowShowing = list.filter(':visible').length; if (nowShowing >= numInList) { button.hide(); } }); }); }) My console.log returns two divs, these are unique, so basically forEach(searchResult) I want to only display 3 li's, each div should have the show more button. As of now, the code is limiting all li's instead of 3 per div -
Django and login "remember me": How can I view that status for other code?
I am using Django with the Allauth login code (and still a bit wet) to perform authentication. It appears that if you check "remember me", it does the following in the allauth login form: allauth forms.py (class LoginForm) if remember: request.session.set_expiry(app_settings.SESSION_COOKIE_AGE) else: request.session.set_expiry(0) return ret I am trying to use the "remember me" for other features in my app. It appears that the only 'flag' I have to determine if a user wants to be remembered or not is the above value. In my view code, I tried to read this 'flag' with the following command: request.session.get_expiry_age() Unfortunately, it always returns 1209600. Whether the user checks the "remember me" box or not, this value is 1209600. I need to find this flag so that I can use it in several places. What system variable is set and exposed when a user checks this 'Remember me' box that I am not seeing? -
Problem sending POST request image files to Django Rest Framework from React
I am trying to send image files from React to my Django Rest Framework but Django Rest doesn't seem to be picking up my data. I am not sure if it has something to do with my content-type or it's something else. This is my function in React createPainting = (data) => { console.log(data) console.log(JSON.stringify(data)) const endpoint = "/api/paintings/photos"; //notice the endpoint is going to a relative request, (relative to where the final javascript built code will be) const csrfToken = cookie.load("csrftoken"); if (csrfToken !== undefined) { // this goes into the options argument in fetch(url, options) let lookupOptions = { method: "POST", headers: { "Content-Type": "multipart/form-data; boundary=63c5979328c44e2c869349443a94200e", "Process-Data": "false", "Accept": "multipart/form-data, application/json", "X-CSRFToken": csrfToken }, body: JSON.stringify(data), credentials: "include" }; fetch(endpoint, lookupOptions) .then(response => { return response.json(); }) this.clearForm() .catch(error => { console.log("error", error); alert("An error occured, please try again later."); }); } }; The data that comes in looks like this: {srcs: "yacht3.jpeg", title_id: "109"} When I stringify it looks like this: {"srcs":"yacht3.jpeg","title_id":"109"} This is the full error message Traceback (most recent call last): File "/home/hzren/dev/t_and_b_website/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) psycopg2.errors.NotNullViolation: null value in column "title_id" violates not-null constraint DETAIL: Failing row contains (99, default.jpg, … -
Django - limit chooses based on the user
i need to limit the staff chooses base on the user who logged in because the staff created from the user my view is CreateView and i put the user on all models as ForignKey -
GeoDjango can't find gdal on docker python alpine based image
I am creating a geodjango container (based on Python alpine official image) with gdal. When starting the container, I get the following error: >>> from django.contrib.gis import gdal Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/li... django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings. my image contains following gdal libs: # find / -name libgdal* /usr/lib/libgdal.so.20 /usr/lib/libgdal.so.20.5.0 /usr/lib/libgdal.a /usr/lib/libgdal.so Adding GDAL_LIBRARY_PATH='usr/lib/libgdal.so.20' to my django settings didn't solve this problem. My Dockerfile, based on official python3 alpine image. FROM python:alpine ENV PYTHONUNBUFFERED 1 ENV PYTHONDONTWRITEBYTECODE 1 WORKDIR /usr/src/dbchiro COPY requirements.txt /usr/src/dbchiro # GeoDjango Dependencies RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ && apk add --virtual .build-deps zlib-dev jpeg-dev gdal-dev musl-dev postgresql-dev\ alpine-sdk libffi-dev jpeg-dev python-dev zlib-dev libffi gcc \ && apk add --no-cache postgresql-libs geos gdal postgresql-client libpq proj nginx \ && python3 -m pip install --upgrade pip --no-cache-dir \ && python3 -m pip install -r requirements.txt --no-cache-dir \ && python3 -m pip install gunicorn --no-cache-dir \ && apk --purge del .build-deps COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh COPY … -
Best practice for creating and maintaining multiple Python scripts on a server
I have a Ubuntu server with multiple Python scripts. They all run at different times of the days and access our Django database to store values they retrieve from other processes(file scraper for example to save row entries in our DB). Right now we run all our scripts using cron but I wanted to know what the best practice of method of implementing this would be? I was hoping on being able to set it up as a service and have it send out emails if any of the scripts crash and along with that, if they do then auto restart them. Is cron the best way or are there better methods? -
Django "NameError: name 'CarImageForm' is not defined" for self-referencing forms
I'm following this tutorial to create an object creation formset. The goal is to allow multiple images connected to a car object via Foreign object, to be uploaded in a single form. The images use a formset that has one image per field, with as many 'add another image' fields dynamically created. Running the server raises this error: "NameError: name 'CarImageForm' is not defined" when self-referencing the class which encloses the definition. I've looked through the code and found a few minor corrections, but none seem to solve this. forms.py from django.forms import ModelForm, ImageField, CharField, TextInput from .models import Car, Image, CustomUser from django.contrib.auth.forms import AuthenticationForm, UserCreationForm, UserChangeForm from django.forms.models import inlineformset_factory from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Field, Fieldset, Div, HTML, ButtonHolder, Submit from .custom_layout_object import Formset class CarImageForm(ModelForm): class Meta: model = Image exclude = () CarImageFormSet = inlineformset_factory( Car, Image, form=CarImageForm, fields=['car', 'image'], extra=1, can_delete=True ) class CreateCarForm(ModelForm): class Meta: model = Car exclude = ['seller'] def __init__(self, *args, **kwargs): super(CarCreateForm, self).__init__(*args, **kwargs) ... ) ) Models.py (with irrelevant parts omitted) class Car(models.Model): manufacturer = models.ForeignKey('Manufacturer', on_delete=models.SET_NULL, null=True) car_model = models.CharField('Model', max_length=50, null=True) description = models.TextField(max_length=4000) vin = models.CharField('VIN', max_length=17, help_text='Enter the 17 character … -
Integrating an existing Database in MongoDB with Django Using Djongo
I am new to the Djongo and MongoDB framework. I have an existing collection(collection1) which I am trying to integrate with a Django App (the Django app-app1 had model1 with the same attributes as collection1). I followed the instructions in the official Djongo documentation (Zero-Risk procedure). However, I am unable to view the contents of the "__schema__" collection, using the "db.__schema__.find()" command from the mongo shell. This is the error: E QUERY [js] uncaught exception: TypeError: db.__schema__ is undefined : Is there another way to view the contents of the schema? Also, I am trying to update the app1_model1 collection created automatically with the contents of collection1. Is there a clean way to do this? Alternatively, is there a better way to access the contents of an existing mongodb collection using Django+Djongo? -
"Could not load the image" from Django's media folder
I'm trying to display an image from a database (SQLite, Django3.7). These images are stored in root/media/pictures. models.py class News(models.Model): news_id = models.AutoField(primary_key=True, editable=False) news_img = models.FileField(upload_to="pictures/",validators=[FileExtensionValidator(allowed_extensions=['svg'])] ) urls.py urlpatterns = [...] urlpatterns += staticfiles_urlpatterns() urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) settings.py MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' I've try to insert the path in the var in the following methods: template.html {% for news_f in news_f%} <div> <img src="{{ media }}{{news_f.news_img}}"> </div> {% endblock %} and {% for news_f in news_f%} <div> <img src="{{news_f.news_img.url}}"> </div> {% endblock %} When I inspect the element in the browser, I get the correct path to the file. <img src="/media/pictures/file.svg"> But it isn't displayed in the HTML: Could not load the image -
Django Model - how to tell Django to look for a customized ID instead of the default
I have two tables, Team and Voting. For my Team table, I'm using a customized ID called "id". In my Voting table, I have a foreign key named "team" to refer to the Team table. I'm also making that "team" attribute a primary key. The problem is that when I go to the registered route for the Voting table, it gives me an attribute error "Team' object has no attribute 'team_id" I assume it's because by default Django is looking for an ID called "team_id" in my Team table instead of my customized ID called "id". How do I solve this? model.py from django.db import models class Team(models.Model): id = models.CharField(max_length=15, default="", primary_key=True) name = models.CharField(max_length=30) class Voting(models.Model): team = models.ForeignKey(Team, on_delete=models.CASCADE, primary_key=True) thumbUp = models.IntegerField(default=0) thumbDown = models.IntegerField(default=0) -
Django forms - How to change form data with HTML DOM?
I am trying to change a Django form's data by using document.getElementById("id_role").innerHTML = "developer". The CustomUser model has a "role" field that is referenced in the function. By testing the output (with the displayField() function, it appears that document.getElementById("id_role").innerHTML actually references all of the available fields ("choices" given in the models.py). The goal is for the second function, changeField(), to change the selected data on the form (my goal isn't to change the database's stored data at this point, just the selected form's input). My question: How do I use document.getElementById().innerHTML to access the specific value that is shown in the form, instead of all of the options for the field? models.py TECH_OPTIONS = ( ('developer','DEVELOPER'), ('manager','MANAGER'), ('testing','TESTING'), ) class CustomUser(AbstractUser): career = models.CharField(max_length=30) role = models.CharField(choices=TECH_OPTIONS,blank = True, max_length=30) def __str__(self): return self.username html page {% extends "base.html" %} {% load bootstrap3 %} {% block content %} <h1 id="testTag">{{user.username}}'s Info</h1> <input onclick="displayField(); changeField();" type="submit" name="" value="TESTING"> <form method="post"> {% csrf_token %} {% bootstrap_form form %} <input type="submit" value="Save" /> </form> <script type="text/javascript"> function displayField(){ var myFormFields = document.getElementById("id_role").innerHTML document.getElementById("testTag").innerHTML = myFormFields; } function changeField(){ document.getElementById("id_role").innerHTML = "developer" } </script> {% endblock %} -
How to create PDF from HTML if the elements are dragged in Django
I am creating PDF documents from html using Django framework. Library I use for this is WeasyPrint. The problem arises when I need to create a PDF from HTML where elements have been dragged from places which they have in the template. The PDF that is created always remains the same, as if the elements were never moved. I tried scraping using Beautifulsoup. But I quickly realized that this was not the solution. Does anyone have an idea which technique to use. Just a suggestion in which direction to look. -
Every field in Django modelform shows "Select a valid choice. That choice is not one of the available choices."
I've already read many other threads complaining about this error message but I still can't figure this out. I try removing the fields that give the error, and the error message just moves to another field the next time I try to submit. They are CharField, Foreign Key, and other types. forms.py class TemporaryresponseForm(forms.ModelForm): gender_custom = forms.CharField( required=False, label="", ) ethnicity = forms.ModelChoiceField( queryset=Ethnicity.objects.all(), widget=forms.RadioSelect(), empty_label=None, required=True, label="Which of the following best describes your ethnicity?" ) ... class Meta: model = Temporaryresponse fields = [...'gender_custom', 'ethnicity',...] views.py def tr(request): if request.method == "POST": form = TemporaryresponseForm(request.POST) if form.is_valid(): tempresponse = form.save(commit=False) tempresponse.ip = "123456" tempresponse.save() return redirect('politicalpollingapp/index.html') else: form = TemporaryresponseForm() return render(request, 'politicalexperimentpollapp/tr.html', {'form': form}) def nr(request, pk): return render(request, 'politicalexperimentpollapp/nr.html', {'tempresponse': tempresponse}) tr.html template {% extends 'politicalexperimentpollapp/base.html' %} {% block extrahead %} {% load crispy_forms_tags %} {{ form.media }} {% endblock extrahead%} ... <form method="POST"> {% csrf_token %} {{ form.as_p }} <div><br></div> <div class="text-center"><button type="submit" class="save btn btn-primary">CONTINUE</button></div> </form> .. models.py class Ethnicity(models.Model): ethnicity = models.CharField(max_length=200) def __str__(self): return '%s' % (self.ethnicity) ... class Temporaryresponse(models.Model): birth_year = models.PositiveIntegerField() voting_registration = models.ForeignKey(Voting_registration, models.SET_NULL, null=True) party_identification = models.ForeignKey(Party_identification, models.SET_NULL, null=True) gender = models.ForeignKey(Gender, models.SET_NULL, null=True) gender_custom = models.CharField(max_length=200, blank=True) ethnicity … -
How to get list of checked checkboxes in django?
Here, 'arr' is a list passed from a previous view. The values(string type) of this list along with the check boxes are successfully being displayed. <form action="{% url 'prec' %}" method="post"> {% for link in arr %} <input type="checkbox" name="checks[]" value="{{link}}" />{{link}}<br> {% endfor %} <input type="submit" value="Submit"> </form> In views function, I create a list of the fields/boxes checked by the user. (views.py): def prec(request): if request.method == 'POST': var = request.POST.getlist('checks[]') return render(request, 'Link5_prec.html', {'variables':var}) Then, in another template, I want to display the values checked by the user(along with the index of that checkbox like [0,2,3]). But nothing is being displayed. (Link5_prec.html): {% for v in variables %} <h1>{{v}}</h1> {% endfor %} Also, if possible, in the first template, I want to make a checkbox of all the elements in the 'arr' list except the last element. -
How to call specific fields from models.py in the views.py in Django
I want to add a message after a successful form submission, with parts of the message involving parameter values from the apps model. I have tried using method as follows: views.py: class ApplyView(FormView): template_name = 'vouchers/apply.html' model = Voucher form_class = VoucherApplyForm def form_valid(self, form): self.code = form.cleaned_data['code'] now = timezone.now() Voucher.objects.filter(code__iexact=self.code, valid_from__lte=now, valid_to__gte=now, usage_limit=3, active=True) form.apply_voucher() return super(ApplyView, self).form_valid(form) def get_success_url(self, voucher_id): voucher = Voucher.objects.filter(pk=voucher_id) discount_value = voucher.value discount_type = voucher.get_type_display messages.add_message(self.request, messages.INFO, "Congratulations! You've successfully redeemed %s" " %s off the selected item(s)." % ( discount_value, discount_type, )) return reverse('vouchers:apply', kwargs={'voucher_id': self.kwargs['voucher_id']}) urls.py: urlpatterns = [ path('<int:pk>/', views.VoucherDetailView.as_view(), name='detail'), path('<int:voucher_id>/apply/', views.ApplyView.as_view(), name='apply'), ] However, I received a TypeError: return HttpResponseRedirect(self.get_success_url()) TypeError: get_success_url() missing 1 required positional argument: 'voucher_id' Your help is much appreciated. Cheers! -
How can I get the absolute url in save model method DJANGO?
i have this model and I need to get the absolute url in the save() method to perform some http requests, how can I get it ? now I'm using the local address. def save(self, *args, **kwargs): super(Annotation, self).save(*args, **kwargs) id = self.shot.id #FIX THIS url = "http://0.0.0.0:8000/api/annotation?shot_id="+str(id) response = urllib.request.urlopen(url) str_response = response.read().decode('utf-8') obj = json.loads(str_response) -
Using Django with React
Does it matter if i do React in its own “frontend” Django app: load a single HTML template and let React manage the frontend or Django REST as a standalone API + React as a standalone SPA? planning to deploy a web app in the future