Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Uncaught ReferenceError: $ is not defined - error in console
I'm getting this error in my console, and it relates to a js script i'm using (Trumbowyg WYSIWYG: http://alex-d.github.io/Trumbowyg/) Here's a picture of the browser console with the error: https://i.imgur.com/etk5VJf.png When I click on (index):166, it shows this in the source: https://i.imgur.com/Pj4yC9p.png id_content is the id for the WSYIWYG editor, and this is the required function in my js file to make it work: $('#id_content').trumbowyg({ }); I've looked at other solutions and they say to load the jquery script before every other js script, but I'm already doing that and it doesn't solve anything. Does anyone have any idea what the problem is? By the way, I'm using this package to integrate it with django: https://github.com/sandino/django-trumbowyg, not sure if that changes anything. I just load the widget in my forms like this: class PostForm(forms.ModelForm): content = forms.CharField(widget=TrumbowygWidget(), required=False) -
Django WebSocket Tutorial
I'm developing a simple online game In Django. I've searched a lot, but was not able to find an step by step tutorial on how to use WebSockets in Django. I'll appreciate it if you suggest me a tutorial. -
Django shortcuts.redirect NoReverseMatch
I'm getting NoReverseMatch from the below view: def new_room(request): label="test" return redirect(chat_room, label=label) # this didn't work either: # return redirect('chat_room', label=label) def chat_room(request, label): ... My urls.py looks like this: from django.conf.urls import url, include from messaging import views app_name="messaging" urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^new/$', views.new_room, name='new_room'), url(r'^(?P<label>[\w-]{,50})/', views.chat_room, name='chat_room'), ] Going straight to messaging/test/ will load the page correctly. It's only the redirect that is causing the issue. Full stacktrace: Environment: Request Method: GET Request URL: http://127.0.0.1:8000/messages/new/ Django Version: 1.10.5 Python Version: 3.5.2 Installed Applications: ['messaging', 'dal', 'dal_select2', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',, 'channels'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "g:\Python\lib\site-packages\django\core\handlers\exception.py" in inner 39. response = get_response(request) File "g:\Python\lib\site-packages\django\core\handlers\base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "g:\Python\lib\site-packages\channels\handler.py" in process_exception_by_middleware 240. return super(AsgiHandler, self).process_exception_by_middleware(exception, request) File "g:\Python\lib\site-packages\django\core\handlers\base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "g:\Git\Jam\messaging\views.py" in new_room 26. return redirect('chat_room', label=label) File "g:\Python\lib\site-packages\django\shortcuts.py" in redirect 56. return redirect_class(resolve_url(to, *args, **kwargs)) File "g:\Python\lib\site-packages\django\shortcuts.py" in resolve_url 147. return reverse(to, args=args, kwargs=kwargs) File "g:\Python\lib\site-packages\django\urls\base.py" in reverse 91. return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))) File "g:\Python\lib\site-packages\django\urls\resolvers.py" in _reverse_with_prefix 392. (lookup_view_s, args, kwargs, len(patterns), patterns) Exception Type: NoReverseMatch at /messages/new/ Exception Value: Reverse for … -
DJANGO how to handle two forms in one form tag
I have two form Postform and Fileform and i am placing both forms in one tag. but when i press submit button nothing happens. and i also made file field not required but it is still not working. but when i give input to both forms only then it work. i want if file is not present it should work and just save post form. form.py class PostForm(forms.ModelForm): choice = ( ('post','post'), ('anouncement','anouncement'), ('question', 'question') ) title = forms.CharField(widget=forms.TextInput(attrs={'class':'mdl-textfield__input','id':'s1'})) content = forms.CharField(widget=forms.Textarea(attrs={'class':'mdl-textfield__input','id':'sample5','rows':'3'})) post_type = forms.ChoiceField(choices = choice, widget = forms.Select(attrs={'class':'mdl-selectfield__select', 'id':'post_type'})) class Meta: model = Post fields = [ "title", "content", "post_type", ] class FileForm(forms.ModelForm): file = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True,'class':'none','id':'file_input_file','required':'False'}), required = False ) class Meta: model = file fields = [ "file" ] def __init__(self, *args, **kwargs): # first call parent's constructor super(FileForm, self).__init__(*args, **kwargs) # there's a `fields` property now self.fields['file'].required = False views.py: form = PostForm(request.POST or None) fileForm = FileForm(request.POST or None, request.FILES or None) context.update({'form':form, 'fileform':fileForm}) print(fileForm.is_valid()) if form.is_valid() and fileForm.is_valid(): instance = form.save(commit=False) instance.user = request.user slug = create_slug(instance) instance.slug = slug instance.save() print(request.FILES) if request.FILES : for f in request.FILES.getlist('file'): print(f) file.objects.create(Post = instance, file=f) return HttpResponseRedirect('/%s/post/%s/'%(request.user.username,slug)) template: <form enctype="multipart/form-data" action="" method="POST"> {% csrf_token … -
How to Synchronize Game Clients in Django?
I am developing an online Knapsack game in Django that dynamically groups clients into groups of players, then randomly takes pairs from each group to compete on solving a visual Knapsack problem. A single-player version of my game is available here. In the multiplayer version, I have difficulty synchronizing pairs of players, i.e., when one of them starts the game, the other one starts after one or two seconds. I was wondering if there is any library that can help me with synchronizing the players. -
Adding a mixin causes LookupError while making migrations
Djanto 1.11 Could you help me understand what is going on here. When I comment the mixin out (see below - working subtitle), everything works. I mean: python manage.py makemigrations Adding a mixin seems to ruin everything. tree . │ ├── frame_person │ ├── frame_person │ │ ├── admin.py │ │ ├── apps.py │ │ ├── __init__.py │ │ ├── migrations │ │ │ ├── __init__.py │ │ │ └── __pycache__ │ │ │ └── __init__.cpython-36.pyc settings INSTALLED_APPS = [ 'frame_person.frame_person', ] Working: class FramePerson(#CommonUrlMethodsMixin, models.Model): dd = models.CharField(max_length=100) Not working class FramePerson(CommonUrlMethodsMixin, models.Model): foo = models.CharField(max_length=100) Traceback: Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 177, in handle migration_name=self.migration_name, File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 47, in changes changes = self._detect_changes(convert_apps, graph) File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/db/migrations/autodetector.py", line 152, in _detect_changes model = self.new_apps.get_model(al, mn) File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/apps/registry.py", line 205, in get_model return app_config.get_model(model_name, require_ready=require_ready) File "/home/michael/workspace/venv/photoarchive/lib/python3.6/site-packages/django/apps/config.py", line 172, in get_model "App '%s' doesn't have a '%s' model." % (self.label, model_name)) LookupError: App 'frame_person' doesn't have a … -
Django poll adaptation
I wish make some adjustment on the poll apps https://github.com/divio/django-polls I've got a probleme with the ligne selected_choice = p.choice_set.get(pk=request.POST['choice']) from my views.py because, everything i do, i don't pass the try, and a have every time the exception who is raise. So i don't understand why i don't have my object choice, it's exactlly the same code as the poll tuto. thanks for your help from django.db import models from django.core.validators import MinValueValidator, MaxValueValidator class Question(models.Model): date_creation = models.DateTimeField(auto_now_add=True, auto_now=False, verbose_name="Creation date") date_update = models.DateTimeField(auto_now_add=False, auto_now=True, verbose_name="last change date") auteur = models.CharField(max_length=42, default="Team DEC Attitude") class Qcm(Question): the_qcm_question = models.CharField(max_length=200, default="Question invalide", verbose_name = "QCM Question") def __str__(self): return self.the_qcm_question class Choice(models.Model): qcm = models.ForeignKey(Qcm) choice_text = models.CharField(max_length=200) good_choice = models.BooleanField(default=False) votes = models.IntegerField(default=0)#pour les tests def __str__(self): return self.choice_text my urls.py from django.conf.urls import patterns, url, include from django.views.generic import ListView from django.views.generic import TemplateView from . import views from .models import Qcm urlpatterns = patterns('', url(r'^question_qcm/(?P<qcm_id>\d+)$', views.one_questionnaire, name='url_question_qcm'), url(r'^reponse_qcm/(?P<qcm_id>\d+)$', views.reponse_qcm, name='url_reponse_qcm'), ) my views.py def one_questionnaire(request, qcm_id): try: qcm = Qcm.objects.get(id=qcm_id) except Qcm.DoesNotExist: raise Http404 return render(request, 'questionnaire/qcm_question.html', {'qcm': qcm}) def reponse_qcm(request, qcm_id): p = get_object_or_404(Qcm, pk=qcm_id) try: selected_choice = p.choice_set.get(pk=request.POST['choice']) except (KeyError, Choice.DoesNotExist): # Redisplay the … -
Checkboxes and Radio buttons in Django ModelForm
Welcome friends, I'm a newbie in Django. I need your help. Seriously. I want to add checkboxes and radio button in my form. I would like to use "Rendering fields manually" too. I know there are Widgets on https://docs.djangoproject.com/en/1.11/ref/forms/widgets/, but I do not know how to use them in practice. Should I change the ModelForm in the Forum. Why? How? Any help will be appreciated. models.py from django.db import models from shop.models import Product class Order(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) email = models.EmailField() address = models.CharField(max_length=250) postal_code = models.CharField(max_length=20) city = models.CharField(max_length=100) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) paid = models.BooleanField(default=False) class Meta: ordering = ('-created',) def __str__(self): return 'Order {}'.format(self.id) def get_total_cost(self): return sum(item.get_cost() for item in self.items.all()) forms.py from django import forms from .models import Order class OrderCreateForm(forms.ModelForm): class Meta: model = Order fields = ['first_name', 'last_name', 'email', 'address', 'postal_code', 'city'] create.html {% extends "shop/base.html" %} {% block title %} Checkout {% endblock %} {% block content %} <h1>Checkout</h1> <form action="." method="post" class="order-form"> {{ form.as_p }} <p><input type="submit" value="Place order"></p> {% csrf_token %} </form> {% endblock %} Please help. Any suggestions are welcome. -
Django channels sessions
I use Django Channels in combination with a seperate Javascript frontend. Websockets work fine. What I now want to do is: when user opens website, backend generates a specific id. The backends saves that id in the session with message.channel_session['my_id'] on subsequent calls to the backend via the websocket, I want to retreive that key from the session. However, sometimes this seems to work, and sometimes I get a KeyError; my_id does not seem to exist. My code: routing.py: from channels.routing import route from chat.consumers import ws_connect, ws_receive channel_routing = [ route("websocket.connect", ws_connect), route("websocket.receive", ws_receive), ] And consumers.py: import uuid from channels.sessions import channel_session @channel_session def ws_connect(message): message.channel_session['my_id'] = str(uuid.uuid4()) @channel_session def ws_receive(message): my_id = message.channel_session['my_id'] # this one sometimes fails... Any ideas? Is there a race condition or something? -
hosting misago on heroku
I am trying to host the Misago Forum ( a forum framework built on Django)) on Heroku. I followed all the steps given to host a Django app on Heroku. The test worked on the local web but after running 'git push heroku master' it showed something like this When I tried to visit the url Thank you for the help! -
django how to create field dependent field
I have a post model in which i have post type field. I want that when user select post type = assignment this it ask for submission deadline other wise it does not ask anything. and how can i display it in template. models.py class Post(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1) title = models.CharField(max_length=120) slug = models.SlugField(unique=True, blank = True) content = models.TextField() choice = ( ('post','post'), ('anouncement','anouncement'), ('question', 'question'), ('assignment', 'assignment') ) post_type = models.CharField(choices = choice, default = 'post', max_length = 12) classroom = models.ForeignKey(Classroom) updated = models.DateTimeField(auto_now=True, auto_now_add=False) timestamp = models.DateTimeField(auto_now=False, auto_now_add=True) def __unicode__(self): return self.title def __str__(self): return self.title @property def comments(self): instance = self qs = Comment.objects.filter_by_instance(instance) return qs @property def get_content_type(self): instance = self content_type = ContentType.objects.get_for_model(instance.__class__) return content_type def get_absolute_url(self): return reverse("posts:detail", kwargs={"slug": self.slug}) -
HttpResponseRedirect that will redirect you to your second last page
I'd like to ask a questions. is there any way to use HttpResponseRedirect that will redirect you to your second last page. I'm trying to use HttpResponseRedirect(request.META.get('HTTP_REFERER')) however it only redirects me to the last page. -
Can anybody help me in running this Django Python Github Project on windows
The Github link is - https://github.com/pgaspar/Social-Movie-Database Please tell tools and steps to run this project from beginning. -
(Django + External JavaScript) not working
I have a simple project that is using Django 1.11 and Javascript that is not working. When I run the js within the HTML, the json loads and javascripts works, but when I put all of this into the static folder, the javascript loads but nothing is executed. I have configured the static folder and it loads CSS configurations but is not working for javascript. I also run the collectstatics without success. Could you pls help? js: (function(){ 'use strict'; window.onload = function(){ alert("Hi there"));} var SentimientosApp = angular.module('SentimientosApp', []); SentimientosApp.controller('SentimientosCtrl', function ($scope, $http){ $http.get("../externalfiles/countries.json").success(function(data) { $scope.datos = data; }); }); }()); web/sentimientos/index.html: {% load static %} <html ng-app="SentimientosApp"> <head> <meta charset="utf-8"> <title>Angular.js JSON Fetching Example</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> <link rel="stylesheet" href="{% static 'css/css.css' %}"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script> <script type="text/javascript" src="{% static 'js/sentimientos.js' %}"></script> </head> {% block content %} <body ng-controller="SentimientosCtrl"> {% block title %}Articles for {{ year }}{% endblock %} <h2>Angular.js JSON Fetching Example</h2> <table> <tr> <th>Code</th> <th>Country</th> <th>Population</th> </tr> <tr ng-repeat="d in datos"> {% verbatim %} <td>{{d.code}}</td> <td>{{d.name}}</td> <td>{{d.population}}</td> <td><input type="text" ng-model="new_title"/>{{ new_title }}</td> {% endverbatim %} </tr> </table> </body> {% endblock %} </html> JSON is located in a folder in statics with this same structure: http://ladimi.com/bigdata/externalfiles/countries.json -
Django Rest Framework: Issue with extended User model and serialization
I' extending the default Django user model to make a customised user profile with additional fields.The following are the related components. models.py class CandidateProfile(models.Model): user = models.OneToOneField( User, on_delete=models.CASCADE, related_name="user") exp = models.IntegerField(null=True, blank=True) serilaizers.py class CandidateProfileSerializer(serializers.ModelSerializer): id = serializers.IntegerField(source='pk', read_only=True) username = serializers.CharField(source='user.username') email = serializers.CharField(source='user.email') groups = serializers.RelatedField(read_only=True) password = serializers.CharField(max_length=128, source='user.password,read_only=True') class Meta: model = CandidateProfile fields = ('id', 'username', 'password', 'email', 'groups') depth = 1 def update(self, instance, validated_data): print("In Update" + '*' * 50) user = User.objects.get(pk=instance.user.pk) user = instance.user user.email = validated_data.get('user.email', user.email) user.first_name = validated_data.get('user.first_name', user.first_name) user.last_name = validated_data.get('user.last_name', user.last_name) user.save() instance.gender = validated_data.get('gender', instance.gender) instance.save() return instance def create(self, validated_data): print('*' * 100) print(validated_data) user_data = validated_data.pop('user') print(user_data) user = User.objects.create_user(**user_data) g = Group.objects.get(name="Candidate") g.user_set.add(user) user.save() print(validated_data) print('*' * 100) profile = CandidateProfile.objects.create(user=user, **validated_data) return user views.py class CandidateRegister(APIView): def get(self, request, format=None): candidate_list = User.objects.filter(groups=Group.objects.get( name="Candidate")) serializer = CandidateProfileSerializer(candidate_list, many=True) return Response(serializer.data) def post(self, request, format=None): serializer = CandidateProfileSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) I've succcessfully created the user profile as well as the extended Candidate profile.But i'm encoutering an error on doing the same as follows : Got AttributeError when attempting to get a value for … -
How to update one-to-one relationship model?
I have a model that has a one-to-one relationship with the User. I created a form that creates the model, but if that form is submitted again it gives "UNIQUE constraint failed". How can i make it so the data gets updated instead of it trying to create a new one? models.py class Userprofile (models.Model): user = models.OneToOneField(User, related_name='profile', primary_key=True,) address = models.CharField(max_length=100) zip = models.CharField(max_length=100) forms.py class Profile(forms.ModelForm): class Meta: model = Userprofile fields = ['address', 'zip'] views.py def changeprofile(request): form = Profile(request.POST or None, request.FILES or None) if form.is_valid(): profile = form.save(commit=False) profile.user = request.user profile.save() return render(request, 'myaccount.html', {"Profile":form}) -
Django CMS Placeholder Within Template Block Not Displaying
I am following this tutorial on building a basic blog using the Django CMS and am encountering a strange behavior. It all started when I discovered that the Content area was not being created in the Structure section of the CMS. While investigating it, I discovered the strange behavior. Here it is. base.html: <!-- Main Content --> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> {% block content %}{% endblock %} </div> </div> </div> <hr> content.html: {% extends "base.html" %} {% load cms_tags %} {% block content %} {% placeholder content or%} {% endplaceholder %} {% endblock content %} This configuration above displays no Content block on the Structure page of the CMS. However, if I change the base.html snippet to the following, it works. base.html: <!-- Main Content --> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> {% placeholder content or%} {% endplaceholder %} </div> </div> </div> <hr> Could someone tell me why this happens? What am I missing in how Django handles the template blocks? It appears to me that the two cases should be treated identically. Yet, the result is obviously different. The tutorial claims that I should be changing the content.html side. However, as … -
csrf_token of Django into Vuejs when seperate them
I am using ajax request to send POST but it got response 403 because of csrf_token. I divide the frontend just using Vuejs and backend using Django to just reponse API only so I can't use Django template to render {% csrf_token %}. Is there anybody face this problem like me and got some solutions ? So thank you if you can help me this. -
How do use Foreign Key in slug django
My Models: class Faculty(models.Model): name = models.CharField(max_length=30) class Program(models.Model): name = models.CharField(max_length=30) faculty = models.ForeignKey(Faculty) class Student(models.Model): name = models.CharField(max_length=30) slug = models.SlugField(max_length=30, unique=True) faculty = models.ForeignKey(Faculty) program = models.ForeignKey(Program) my Views def profile(request, slug, faculty, program): template_name = 'profile.html' infor = get_object_or_404(Candidate, slug=slug, faculty=faculty, program=program) context = {'title': infor.name} return render(request,template_name,context) Urls url(r'^(?P<faculty>[\w-]+)/(?P<program>[\w-]+)/(?P<slug>[\w-]+)/$', profile, name='profile'), Now I got the profile at host/1/1/sagar-devkota/ what I need is host/science/be/sagar-devkota/ Let assume science is a faculty and be is a program. -
Display JavaScript alert after form submit - Django
Im trying to show an alert if the form submited is valid or not. In the view, I have a hidden input which change the value if form is valid or not. I have this JavaScript: $( document ).ready(function() { if (document.registroForm.alert.value==1){ swal("¡Bien hecho!", "El registro fue exitoso.", "success") } if (document.registroForm.alert.value==0){ swal("¡Oops!", "Algo salió mal.", "error") } }); The problem is that I get the alert every time I refresh the page. And I just wanna do it when the user submit the form and the page is refreshed Thanks. Solved. What I did: views.py def registroUsuario(request): if request.method == "POST": form = registroForm(request.POST or None) if form.is_valid(): alert = 1 instance = form.save(commit=False) instance.is_active = False instance.save() else: alert = 0 else: alert = None form = registroForm() context = { "titulo": "Registrarse", "form": form, "alert": alert, } template = "micuenta/registro.html" return render(request, template, context) and my .html: <form method="POST" action="."> [... some labels and inputs ...] <input type="hidden" name="alert" value="{{alert}}" readonly> </form> <script> $( document ).ready(function() { if (document.registroForm.alert.value==1){ swal("¡Bien hecho!", "El registro fue exitoso.", "success") } if (document.registroForm.alert.value==0){ swal("¡Oops!", "Algo salió mal.", "error") } }); </script> Thanks by the way. -
What does an '_' in django url do?
what does an '_' in django url means like, url(_(r'^mylink/'), include('link5.urls')), _ plus a string should be an error but one public app is using such construct -
Python Django - Uploading a file from the shell
I am trying to upload a file from a shell to one of my django models in the following manner: a = Post(name=name, content=content) a.attachment.save('some.pdf', File(open('some.pdf', 'r'))) But I keep getting the following error: TypeError: must be convertible to a buffer, not FieldFile. I looked at other posts and could not find any solution that solves this problem. I am using Python 2.7 and Django 1.10. I would really appreciate any help. -
django sql translation
I have 2 tables. They are joined by a foreign key relationship. In django, how do i do the equivalent of select col1,col2,col3, table2.* from table1 join table2 on table1.table1id = table2.table2id I am using serializers.serialize and as such values() does not work on the model -
Would posting my code to github affect the security of my application?
background I am writing a simple blog application in Django (data passed through templating language). The owner of the blog will have access to the admin page where they will update the db. Now I understand that in production I will have to hide the security key and turn debug off. question What I am wandering is will pushing the code to github jeopardize the security of the application? -
With Django/Python Open a temp file in memory outside of the function it was created in
I'm having the worst time with this one. In a view I created a csv file that's saved to memory. I need to get that csv file to a utils.py function and post to an external api. I for the life of me can not figure out how to do this and it's really driving me nuts. I originally was just trying to create it in the run_test_suite_in_hatit function below and then somehow open it in the run_all_modal below but that wasn't working. What occurred below was the file (hatit_csv_filename) was now a message object. I don't want to save it to a model as its temporary and is being created purely to be sent right in a api post within HATScript() which is in a utils.py file within the same app in the my project. I'm not sure how to get the file to HATScript() which is just making me nuts. def run_test_suite_in_hatit(request): testrail_suite_id = int(request.GET['suite']) print(testrail_suite_id) testrail_instance = TestRailInstance.objects.first() project = request.user.humanresource.project testrail_project_id = project.testrail.project_id testrail_project = get_testrail_project(testrail_instance, testrail_project_id) testrail_suites = testrail_project.get_suites() testrail_suite = [s for s in testrail_suites if s.id == testrail_suite_id][0] testrail_cases = testrail_suite.get_cases() hatit_csv_filename = bulk_hatit_file_generator(testrail_cases) messages.add_message(request, messages.INFO, hatit_csv_filename) return HttpResponseRedirect('/run_all_modal/') def run_all_modal(request): if request.method …