Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Integrating Scrapy into Django/React application
I'm trying to build a site with Django and React, where you can create watchlists with companies. If you view the watchlist, you'll be able to see the price of given companies. In Django I have a model for the companies, but these are without price (since it has to be reasonably up-to-date). So you'll load a list of companies using their models, then use the symbol to get the price from somewhere else. I've looked into API's, but I couldn't find an API (for free) where a can get an variable list of companies with their price. So I thought maybe getting the data myself by scraping it would be an option. Haven't done much scraping, but is it possible to scrape data on the client side (implementing it in React)? And/or how would you approach this? -
How do I whitelist this URL on pythonanywhere
please how can I add below website endpoints to whitelist, thank you https://kingsvtu.com/app/api/v1/products/airtime https://kingsvtu.com/app/api/v1/products/data https://kingsvtu.com/app/api/v1/products/cable https://kingsvtu.com/app/api/v1/products/exam https://kingsvtu.com/app/api/v1/products/power this is the link to the API documention below https://documenter.getpostman.com/view/12161048/Tzm3oxwr#d5672aa5-32ad-4118-bd46-080799fbfd68 -
In a learning example: Djangos DRF can't get parameters when vue AXIos uses POST? thank you
vue.js code: enter image description here django drf: enter image description here -
Integrating Django with AG Grid
Good evening folks, I am trying to represent a relatively simple excel document as part of a grid using the plain JavaScript version of AG Grid community. I have a couple functions to get the header row and the data, as below: def get_excel_data_headers(): path = Path("/Users/excel_doc.xlsx") df = pd.read_excel(path, header=0) return df.columns def get_excel_data(): path = Path("/Users/excel_doc.xlsx") df = pd.read_excel(path, header=0) cell = [] for rowIndex, row in df.iterrows(): #iterate over rows for columnIndex, value in row.items(): #print(value, end="\t") cell.append(value) return cell and my views.py class excel(ListView):#The project detailed view of all submitted info model = Project template_name = "home/grid_upload.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['headers'] = get_excel_data_headers() context['row_data'] = get_excel_data() return context However I am unsure how to represent this in the template. I can get the header row to work however I don't know the best approach to add the data as the argument requires the header row to be specified for each row data item but this is set as part of a different for loop, below is my current template code however it docent render correctly and I am lost in the direction to properly implement this, <script type="text/javascript" charset="utf-8"> // specify the columns … -
Do I need to install MySQL Server for each of my pipenv virtual Environments?
I have installed mysql in my ubuntu 22 and it is running, when I try to install msqlclient in my virtual environment, it gives the following error. error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [16 lines of output] /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-install-rsjsl_3h/mysqlclient_0fd0dd46119841d69cac324129f28afd/setup.py", line 15, in <module> metadata, options = get_config() File "/tmp/pip-install-rsjsl_3h/mysqlclient_0fd0dd46119841d69cac324129f28afd/setup_posix.py", line 70, in get_config libs = mysql_config("libs") File "/tmp/pip-install-rsjsl_3h/mysqlclient_0fd0dd46119841d69cac324129f28afd/setup_posix.py", line 31, in mysql_config raise OSError("{} not found".format(_mysql_config_path)) OSError: mysql_config not found mysql_config --version mariadb_config --version mysql_config --libs [end of output] Is it because I didnt install mysql in the active virtual environment? -
Ad security checks in graphene resolver
I am using Django and Graphene to serve a graphql endpoint and I have hit a bit of a Problem I cant seem to figure out. I have following resolver: class Query(ObjectType): trainingSession = Field(TrainingSessionType, id=graphene.ID()) trainingSessions = DjangoFilterConnectionField(TrainingSessionType) @staticmethod def checked_trainingsession(trainingsession,info): # returns the trainingsession if a certain logic is fulfilled # else None def resolve_trainingSessions(root, info,**kwargs): ids= kwargs.get('discipline__id') all = TrainingSession.objects.all() result = [] for trainingSession in all: trainingSession = Query.checked_trainingsession(trainingSession,info) if trainingSession != None: result.append(trainingSession) return result together with the Objects types and Filters: class TrainingSessionFilter(FilterSet): discipline__id = GlobalIDMultipleChoiceFilter() class Meta: model = TrainingSession fields = ["discipline__id"] class TrainingSessionType(DjangoObjectType): class Meta: model=TrainingSession fields="__all__" filterset_class = TrainingSessionFilter interfaces = (CustomNode,) class CustomNode(graphene.Node): """ For fetching object id instead of Node id """ class Meta: name = 'Node' @staticmethod def to_global_id(type, id): return id however when I try to execute a query query Sessions{ trainingSessions(discipline_Id:[2,3]){ edges{ node{ dateTime, discipline{ id } } } } } I get the Error: Traceback (most recent call last): File "D:\Ben\GitHub-Repos\dojo-manager\env\lib\site-packages\promise\promise.py", line 489, in _resolve_from_executor executor(resolve, reject) File "D:\Ben\GitHub-Repos\dojo-manager\env\lib\site-packages\promise\promise.py", line 756, in executor return resolve(f(*args, **kwargs)) File "D:\Ben\GitHub-Repos\dojo-manager\env\lib\site-packages\graphql\execution\middleware.py", line 75, in make_it_promise return next(*args, **kwargs) File "D:\Ben\GitHub-Repos\dojo-manager\env\lib\site-packages\graphene_django\fields.py", line 176, in connection_resolver iterable = queryset_resolver(connection, … -
Where to Host Django Rest API
I am having a Django Rest API for my Business and I want to host it live. I am getting confused with AWS or GCP or Heroku paid services. I need something easy to use like Heroku and Robust like GCP. What do the you recommend? also how can I get the best deal in no time??? -
Django / OnetoMany relation within the same class
Here is my models.py class Scenes(models.Model): name = models.SlugField('Scene name', max_length=60,unique=True) record_date = models.DateTimeField('Scene date') manager = models.ForeignKey( settings.AUTH_USER_MODEL, blank=True, null=True, on_delete=models.SET_NULL) description = models.TextField(blank=True) previous = models.OneToOneField( 'self', blank=True, null=True, related_name='next', on_delete=models.SET_NULL ) I have started with one instance : Scene1 The problem is I want to have on to many choices and not one to one like explained below Nevertheless, When I change to previous = models.ManyToManyField( Then I also get an error about on_delete : TypeError: init() got an unexpected keyword argument 'on_delete' What would be the best djangonic way ? -
IntegrityError NOT NULL constraint failed: even though I have already overriden the form_valid?
So I'm trying to create a simple Comment feature for a blog app. In the Class-based views, if you are using a Foreign Key in your model, I know that you have to override the def form_valid: in order for the Comment to be posted by the current logged-in User. If you don't, you get the IntegrityError I did this for the Blog model in my app, and it works just as intended, however, when I try to do the same with the CommentCreateView, I get the error. Here's my code so far views.py class PostCreateView(LoginRequiredMixin, CreateView): model = Post fields = ['title', 'content'] def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) class CommentCreateView(LoginRequiredMixin, CreateView): model = Comment fields = ['title', 'content'] template_name = 'issues/add_comment.html' def form_valid(self, form): form.instance.name = self.request.user return super().form_valid(form) models.py class Comment(models.Model): post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments') name = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=100, null=True) content = models.TextField() date = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title def get_absolute_url(self): return reverse('issue-detail', kwargs={'pk': self.pk}) class Issue(models.Model): title = models.CharField(max_length=100) content = models.TextField() date_posted = models.DateTimeField(default=timezone.now) author = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): return self.title def get_absolute_url(self): return reverse('issue-detail', kwargs={'pk': self.pk}) What did I do wrong? -
Django: Permission denied when loading a Font using xhtml2pdf
An error occurs when trying to load a TTF font within an HTML file that is to be converted to PDF using xhtml2pdf. The error only occurs when loading fonts, and doesn't occur with other types of static files. I need to load a font because I'm using Arabic in my PDF and it is appearing as blocks instead (English is fine). The error is coming from the "reportlab" portion of the plugin. The Error: TTFError at /ar/task/statements/preview/1 Can't open file "C:\Users\DESTRO~1\AppData\Local\Temp\tmpq5b82hlj.ttf"` Screenshot of the error: Screenshot Screenshot of why I need to install another font (if you have an alternative solution): The blocks are Arabic characters incorrectly displayed -
I am facing issue while executing JSONRenderer.render(serialized_student_data.data) in Django
Whenever i execute the line json_data = JSONRenderer.render(serialized_student_data.data) it gives me error like TypeError: render() missing 1 required positional argument: 'data' #Here is code in the models.py class StudentModel(models.Model): name = models.CharField(max_length=100, default='user') roll_no = models.IntegerField(default=1) city = models.CharField(max_length=100, default='Ahmedabad') #Here is code in the serializers.py class StudentSerializer(serializers.Serializer): name = serializers.CharField(max_length=100) roll_no = serializers.IntegerField() city = serializers.CharField(max_length=100) #Here is code in the views.py def student_view(request): student_object = StudentModel.objects.get(id=3) serialized_student_data = StudentSerializer(student_object) json_data = JSONRenderer.render(serialized_student_data.data) return HttpResponse(json_data, content_type='application/json') -
Got Error while installing mysqlclient in django project on cPanel
Requirements.txt contains: asgiref==3.4.1 Django==3.2.9 django-isbn-field==0.5.3 mysql-connector-python mysqlclient phonenumberslite==8.12.42 Pillow==9.0.1 python-decouple==3.6 python-stdnum==1.17 pytz==2021.3 six==1.16.0 sqlparse==0.4.2 Got error: Error ERROR: Failed building wheel for mysqlclient ERROR: Command errored out with exit status 1: /home/bookbestie/virtualenv/bookbestie/3.8/bin/python3.8_bin -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nk4wll31/mysqlclient_306f3e44780f440a9c0a625d98f95d89/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nk4wll31/mysqlclient_306f3e44780f440a9c0a625d98f95d89/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-frd2zcuu/install-record.txt --single-version-externally-managed --compile --install-headers /home/bookbestie/virtualenv/bookbestie/3.8/include/site/python3.8/mysqlclient Check the logs for full command output. WARNING: You are using pip version 21.3.1; however, version 22.0.4 is available. You should consider upgrading via the '/home/bookbestie/virtualenv/bookbestie/3.8/bin/python3.8_bin -m pip install --upgrade pip' command. Please help!! what to do. I am beginner first time hosting. I got guide from you will be precious for me. I was browsed other questions posted but not worked. Please help. -
Django Pushing JSON formatted data to TimeLine Google Chart visual - converted date to New Date()
I've seen some posts about this but it's still unclear to me how to get this done. I have a Django application that queries a SQL database. I bring this data in and convert it from a pandas dataframe to a JSON format: tempdata = json.dumps(d, cls=DjangoJSONEncoder) return render(request, 'notes/gantt.html', {'data': tempdata}) JSON looks like this: [["id", "title", "created", "est_completion"], ["3", "Add new Security Group", "2022-04-25", "2022-05-05"]] I tried to pass this into the google chart visual but I'm getting an error: Invalid data table format: column #2 must be of type 'date,number,datetime'. Its my understanding the date format is specific to google charts and needs to be set to new Date(2016, 11, 31) My question is how can i do that? Is there a for loop I have to run? or is there an easier more straightforward way to do it? google.charts.load("current", {packages: ["timeline"]}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var container = document.getElementById("timeline"); var chart = new google.visualization.Timeline(container); var dataTable = google.visualization.arrayToDataTable({{ data|safe }}); var options = { timeline: {showRowLabels: false}, animation: { startup: true, duration: 1000, easing: "in" }, avoidOverlappingGridLines: true, backgroundColor: "#e8e7e7", }; chart.draw(dataTable, options); -
How to render user profile (actual image) instead of filename in a Django form which basically update user-account
I am following a Django course on youtube, and I need a small change in my Django form. The form looks like: html of the form field which I want to change: <div class="form-input"> <label for="id_Avatar">Avatar</label> Currently: <a href="/images/1044-3840x2160.jpg">1044-3840x2160.jpg</a> <br> Change: <input type="file" name="avatar" accept="image/*" id="id_avatar"> </div> So in Avatar Currently: <filename>, I want actual image to display here. So basically I want my template html like this: <div class="form-input"> <label for="id_Avatar">Avatar</label> Currently: <img src="/images/1044-3840x2160.jpg"> <br> Change: <input type="file" name="avatar" accept="image/*" id="id_avatar"> </div> which will display user profile image. I think maybe I need to change my forms.py to generate tag instead if tag but I don't know how to do this. models.py class UserModel(AbstractUser): name = models.CharField(max_length = 90) email = models.EmailField(unique = True) about = models.TextField(blank = True, null = True) avatar = models.ImageField(null=True, default="avatar.svg") USERNAME_FIELD = 'email' and forms.py is: class UserForm(forms.ModelForm): class Meta: model = UserModel fields = ['avatar', 'name', 'username', 'email', 'about'] and in views.py the update function is: def editUserProfile(request): user = request.user form = UserForm(instance=user) if request.method == 'POST': form = UserForm(request.POST, request.FILES, instance = user) if form.is_valid(): form.save() return redirect('chat:userProfileView', uname = user.username) context = { 'form' : form } return render(request, … -
How to show foreign key data values instead of urls in Django api?
I have the following codes in models.py class Tag(models.Model): name = models.CharField(max_length=40) def __str__(self): return self.name class Post(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True) likes = models.IntegerField() popularity = models.FloatField() reads = models.IntegerField() tags = models.ManyToManyField(Tag) class User(models.Model): name = models.CharField(max_length=40) def __str__(self): return self.name but in localhost:8000/posts, I found out something weird: those foreign keys are shown as the urls, for example { "url": "http://127.0.0.1:8000/posts/1/", "likes": 3, "popularity": 0.25, "reads": 59, "author": "http://127.0.0.1:8000/users/1/", "tags": [ "http://127.0.0.1:8000/tags/1/", "http://127.0.0.1:8000/tags/2/" ] } So in this case, how can I change the displayed api into something like "author":"Any Name" and "tags": ["tag1","tag2"] instead? -
socket.gethostbyname(host_name) working in terminal but not working in Django?
I am trying to find out my ip using socket library in my Django project using this script. import socket host_name = socket.gethostname() ip_address = socket.gethostbyname(host_name) I get this error: socket.gaierror: [Errno -2] Name or service not known Error is pointing to line ip_address = socket.gethostbyname(host_name). But, I do not get this error while running this same script in terminal. >>> import socket >>> hostname = socket.gethostname() >>> ip = socket.gethostbyname(hostname) >>> >>> ip '192.168.191.5' This is my /etc/hosts #127.0.0.1 localhost #127.0.1.1 softcell-Latitude-3510 # The following lines are desirable for IPv6 capable hosts #::1 ip6-localhost ip6-loopback #fe00::0 ip6-localnet #ff00::0 ip6-mcastprefix #ff02::1 ip6-allnodes #ff02::2 ip6-allrouters I have commented out everything because I want socket to return the System IP. Why is this not working in Django but giving correct output in Terminal? -
Python Import not working at the top of file but works inside function
I was using django and ran into the following problem just wondering why Python acts this way. I was importing a function and I had the import at the top of the file with my other imports and my tests keep failing but my tests passes after I move the import statement to inside the function I was working on. Has anyone encountered such problems ? -
Setting limit on models
How to set limits on models without using any package like django-limits, if the model limit is 4 then only 4 models could be created Models class Post(models.Model): #limit = 4 title = models.CharField(max_length=200, null=True, blank=True) -
The problem that javascript cannot be applied depending on whether the URL parameter is
There are a drop down list (select option) to select whether to is_recruiting, a radio option to select 'Total' or 'Period', and input tag of 'from_date' and 'to_date' to set the date when selecting 'Period'. When the radio option is centered and 'Total' is selected, the date input tag is prevented from being input, and the recruiting option can be selected. Conversely, if the 'Period' is selected, the recruiting option is blocked and the period(from_date & to_date) can be set. <form action="/chart" method="GET"> <select name="is_recruiting" id="is_recruiting" class="ml-4"> <option value="A" {% if is_recruiting == "A" %} selected {% endif %}>A</option> <option value="B" {% if is_recruiting == "B" %} selected {% endif %}>B</option> <option value="ALL" {% if is_recruiting == "ALL" %} selected {% endif %}>ALL</option> </select> <div class="radio" style="display: inline"> <label><input type="radio" name="optionRadios" value="total" {% if option_radio != 'period' %} checked {% endif %}/> Total </label> </div> <div class="radio" style="display: inline"> <label><input type="radio" name="optionRadios" value="period" {% if option_radio == 'period' %} checked {% endif %}/> Period : </label> <input autocomplete="off" class="datepicker" name="from_date" id="fromDate" value={{from_date|default_if_none:''}}> <label> ~ </label> <input autocomplete="off" class="datepicker" name="to_date" id="toDate" value={{to_date|default_if_none:''}}> </div> <button class="btn btn-primary btn-xs mb-1" type="submit">Submit</button> </form> <script> $('input[type=radio][name=optionRadios]').on('click',function () { var chkValue = $('input[type=radio][name=optionRadios]:checked').val(); var recruitingSelect = … -
How to shrink time-series data query in django?
I'm currently working a project on collecting gps time series data, and the interval is very short, every 10th of a second. When I query based on a time range, the query is significantly heavy and too large for making graphs. I've seen good solutions: Annotating queryset with modulus https://stackoverflow.com/a/56487889 or.. another approach using a third party postgresql extension https://stackoverflow.com/a/25212750/12913972 The problem with the first solution is that it's not compatible for all query sizes, for instance a query with very short or long interval. If I want to group incremental rows, considering drastic changes in lat/long coordinates, is there a known way or existing function to do this? Or do I have to create the logic from scratch based on my needs? I'm using django 4.*, postgresql if that helps. Any suggestions is appreciated. Thanks! -
Reverse for 'classroom' with arguments '('',)' not found. 1 pattern(s) tried: ['classroom/(?P<classroom_id>[0-9]+)/\\Z']
I got the error in my django project. Base on what i have searched, the problem seems related to url thingy but my url seems right. My view: def student(request, student_id): student = get_object_or_404(Student, pk=student_id) faculty = Faculty.objects.filter(student=student) course = Course.objects.all() classroom = Classroom.objects.all() return render(request, 'polls/student.html', {'student': student,'faculty': faculty, 'courses':course,'classrooms':classroom}) My templates: {% block body %} <h2>{{ student.fname }} {{ student.lname }}</h2> <h3>Faculty</h3> {% if faculties %} {% for faculty in faculties %} <p><a href="{% url 'faculty' faculty.id %}">{{ faculty.name }}</a></p> {% endfor %} {% else %} <p> </p> {% endif %} <h3>Course</h3> {% for course in courses %} <p><a href="{% url 'course' course.id %}">{{ course.name }}</a> </p> {% endfor %} <h3>Class</h3> {% if classrooms %} {% for class in classrooms %} <p><a href="{% url 'classroom' classroom.id %}">{{ class.name }}</a> </p> {% endfor %} {% else %} <p> </p> {% endif %} </p> {% endblock %} My url: urlpatterns = [ path('admin/', admin.site.urls), path('', views.index, name = 'index' ), path('classroom/<int:classroom_id>/', views.classroom, name='classroom'), path('student/<int:student_id>/', views.student, name='student'), path('teacher/<int:teacher_id>/', views.teacher, name='teacher'), path('faculty/<int:faculty_id>/', views.faculty, name='faculty'), path('course/<int:course_id>/', views.course, name='course'), path('create_class/', views.add_class,name = "create_class"), path('', include("django.contrib.auth.urls")), ] Can any django expert help me to see what i do wrong ? -
Django deserializing data with natural keys
I'm having some trouble loading a fixture generated using natural keys. My models are: class ChildNameManager(models.Manager): def get_by_natural_key(self, name): return self.get(name=name) class ChildName(models.Model): name = models.CharField(max_length=64, db_index=True, unique=True) objects = ChildNameManager() def __str__(self): return self.name def natural_key(self): return (self.name,) And class SpecialVideoManager(models.Manager): def get_by_natural_key(self, code): return self.get(code=code) class SpecialVideo(models.Model): code = models.CharField(max_length=32, unique=True, db_index=True) child_names = models.ManyToManyField(ChildName, related_name="special_videos") objects = SpecialVideoManager() def natural_key(self): return (self.code,) I generated a fixture with natural keys that looks like this: [ { "model": "pensum.specialvideo", "fields": { "code": "553076706", "child_names": ["amy"] } }, { "model": "pensum.specialvideo", "fields": { "code": "553072042", "child_names": ["alfred"] } }, { "model": "pensum.specialvideo", "fields": { "code": "553088795", "child_names": ["jhonatan", "jonatan", "jonathan", "yonatan"] } } ] The problem is, when I try to load the fixture it raises the following error: django.core.serializers.base.DeserializationError: Problem installing fixture 'test.json': ["'amy' value must be an integer."]: (testapp.specialvideo:pk=None) field_value was 'amy' -
Profile picture does not update after form submitted in django
I also created UserUpdateForm class which i did not include here and if i try to change my name and email through UserUpdateForm class it works but if try for profile picture it did not works views.py from django.shortcuts import render, redirect from .forms import ProfileUpdateForm def editprofile(request): if request.method == 'POST': p_form = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile) if u_form.is_valid(): p_form.save() return redirect('profile') else: p_form = UserRegisterForm(instance=request.user.profile) context = { 'p_form': p_form, } return render(request, 'users/editprofile.html', context) forms.py from django import forms from .models import Profile class ProfileUpdateForm(forms.ModelForm): class Meta: model = Profile fields = ['image'] html template <form class="form" action="" method="post" enctype="multipart/form-data"> {% csrf_token %} <div class="form__group form__avatar"> <label for="avatar">Upload Avatar</label> <input class="form__hide" required type="file" name="avatar" id="avatar" accept="image/png, image/gif, image/jpeg, image/jpg"/> </div> </form> -
Images are not rendering on Django template from a multi-model view
Problem: I cannot get images to appear on my template plant_detail.html. I think I'm calling on variables incorrectly, but not sure what to change. Context: I created a model PlantImage, that allows me to associate multiple images within my model Plant. I then created a class-based view PlantDetailView to link the two models, PlantImage and Plant together. However, now when I try to display those images in the template plant_detail.html, nothing will appear. How can I get images to appear on my template? I tried reading through the Django documentation, reading articles, and watching youtube videos, but I'm not sure what I'm missing or need to edit. My files: plants/models.py class Plant(models.Model): name = models.CharField(max_length=120) slug = models.SlugField(null=False, unique=True) description = models.TextField() def __str__(self): return self.name def get_absolute_url(self): return reverse("plant_detail", kwargs={"slug": self.slug}) class PlantImage(models.Model): plant = models.ForeignKey(Plant, default=None, on_delete=models.CASCADE) images = models.ImageField(upload_to = 'images/') def __str__(self): return self.plant.name plants/views.py def plant_index(request): plant_objects = Plant.objects.all() context = {'plant_objects': plant_objects} return render(request, 'plants/plant_index.html', context) class PlantDetailView(DetailView): model = Plant template_name = 'plants/plant_detail.html' slug = 'slug' def get_context_data(self, **kwargs): context = super(PlantDetailView, self).get_context_data(**kwargs) context['plant_images'] = PlantImage.objects.all() return context plant_detail = PlantDetailView.as_view() plants/urls.py from django.urls import path from .views import plant_index, plant_detail app_name = … -
can't find where django endpoint redirects to
I am very new to django and I am porting over a flask webapp I made to django. The specific endpoint I am trying to find is the /redirect endpoint's code. The specific problem I am trying to find out where Microsoft/Azure places you once you completed the sign-in process. I want to find out where this endpoint's code is so I can force it to redirect to an endpoint called /closeauth. /closeauth is an html file I made that will do a try block to see if you are using outlook, if you are not using outlook, but are using the web, it will kick you out to the normal / home endpoint. However, if you are using outlook, it will send a message back to the parent webpage to let outlook know that authenciation is succesful, then the parent webpage will try to go to /. To understand what I mean, here is an example in flask with the app.config file and the redirect endpoint which is the exact code I am looking for django: app_config.py: import os REDIRECT_PATH = "/getAToken" app.py for flask example @app.route(app_config.REDIRECT_PATH) def authorized(): try: cache = _load_cache() result = _build_msal_app(cache=cache).acquire_token_by_auth_code_flow( session.get("flow", {}), request.args) …