Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
djnago wizzard form - how to redirect, and how to secure the second step?
I have two forms in a row, and I need to send the data from the first to the model in order to save it, then the user has to fill in another form which also sends a part to the model based on the answer. And then his answer in the second form should be combined with the id of the first model. I don't know how to save the data, then redirect to the second step and after sending to make the second step no longer available, it is no longer possible to return to it. views.py: # import models from .models import Profil,Quiz # / import models / # import formulars from .forms import ProfilReg, QuizReg from formtools.wizard.views import SessionWizardView # /import formulars/ # Create your views here. FORMS = [("registrace", ProfilReg), ("quiz", QuizReg)] TEMPLATES = {"registrace": "registrace.html", "quiz": "quiz.html",} class RegWizzard(SessionWizardView): instance = None def get_form_instance(self,step): if self.instance is None: self.instance = Profil() return self.instance def done(self, form_list, **kwargs): project = self.instance project.save() def get_template_names(self): return [TEMPLATES[self.steps.current]] urls.py: from .views import RegWizzard, FORMS from .forms import ProfilReg, QuizReg app_name = 'lide' urlpatterns = [ url('id=(?P<id_uz>\w+)', views.profily, name="profil"), url('registrace', RegWizzard.as_view(FORMS), name="registrace"), url('q', views.quiz, name="quiz"), ] -
How to connect ReactJS via Content Relationship with NOSQL access?
I'm having difficulties to find out how to connect my components throughout api's. I worked before with Microsoft SQL and I, back then, was using foreign key for this stuff, but now I'm really stuck in here. Here are the examples below. Getting all hotels from api endpoint. [ { "id": 51, "name": "Hotel Hollywood", "city": "Sarajevo", "country": "Bosnia & Herzegovina", "image": "http://127.0.0.1:8000/media/images/no-img.jpg", "stars": 4, "date": "2020-09-08 12:22:53", "description": "Hotel Hollywood provides free, secured private parking on site. It also offers 18 conference and meeting rooms.", "price": 1500.0, "likes": 0, "dislikes": 0, "user": [ 1 ], "location": "1.2" } ] Getting all hotel favorites from api endpoint. [ { "id": 5, "name": "Art Hotel", "city": "Belgrade", "country": "Serbia", "image": "/media/images/art.jpg", "stars": 1, "date": "2017-07-04 10:50:12", "description": "Featuring an on-site restaurant and Situated on Belgrade's impressive pedestrian street and shopping zone, Art Hotel's décor is inspired by Italian style. The property offers individually designed, air-conditioned rooms and suites with minibar, free high-speed WiFi, free sauna and hairdryers.\r\n\r\nOffering views of the vibrant Knez Mihailova Street, the elegant Mosaic Restaurant & Bar serves a selection of quality wines and various specialities made from seasonal ingredients, a variety of coffees and homemade desserts, including … -
Django default forms altering
I am trying to change the all the text from the login and registration forms that are generated from Django. Here I want to remove the Username* and Password* text and put them in the input box with different string value. This is how my HTML looks: {% extends 'store/reg.html' %} {% block title %} Login {% endblock %} {% load crispy_forms_tags %} {% block content %} <div class="container"> <form method="post" class="form-signin"> <img class="mb-4" src="/media/logo/log.png"> {% csrf_token %} {{form | crispy}} <button type="submit" class="btn btn-info">Login</button> <p>Don't have an action? Create one <a href="/register">here</a></p> </form> </div> {% endblock %} Similarly I want to change the default text for password validation here Again the Htmlis the same: {% extends 'store/reg.html' %} {% load crispy_forms_tags %} {% block content %} <form method="POST" class="form-group"> <img class="mb-4" src="/media/logo/log.png"> {% csrf_token %} {{form| crispy}} <button type="submit" class="btn btn-info">Sign up</button> </form> {% endblock %} Any suggestions? -
Get database object value in template using Ajax when adding values
I want to fetch database object values. I know one possible solution could be Ajax, but I don't know how to get about it. Below is the code, please help with the implementation. AJAX <script type='text/javascript'> $(document).ready(function () { $(document).on('submit', '#post-form', function (e) { e.preventDefault(); $.ajax({ type: 'POST', url: '{% url "create" %}', data: { title: $('#title').val(), description: $('#description').val(), csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(), action: 'post' }, success: function (data) { $('#message').html("<h2>Contact Form Submitted!</h2>"); } }); }); }); </script> Views.py class postClass(CreateView): template_name = 'create_post.html' form_class = postForm def create_post(self, request): if request.POST.get('action') == 'post': title = request.POST.get('title') description = request.POST.get('description') Post.objects.create( title=title, description=description, ) Template part <div id='message'>{{ i.title }}</div> Models.py class Post (models.Model): title = models.CharField(max_length=50) description = models.TextField() -
Which is the best way to encode videos into multiple resolutions in django? Should we create a single celery task or to have multiple tasks to encode?
Hey guys Which is the best way to encode videos using ffmpeg into multiple resolutions in django? Should we create a single celery task which encodes the video and save in database or to have multiple tasks to encode video into various resolutions? I am new to all these, so any help regarding the best way is highly appreciated. I have two tasks here to encode into 480 and 1080p..so is it possible to run both in 1 task or the best way is to encode separately? Also how does websites like youtube encode? @task(name= 'task_video_encoding_480p') def task_video_encoding_480p(video_id): logger.info('Video Processing started') try: video = input_file_path = output_file_480p_path = for i in range(1): new_video_480p = subprocess.call([ffmpeg, {process},output_file_480p_path]) if new_video_480p == 0: video.save() logger.info('Video Processing Finished') #video.temp_file.delete() else: logger.info('Proceesing Failed.') # Just for now except: raise ValidationError('Something went wrong!') task 2 @task(name= 'task_video_encoding_1080p') def task_video_encoding_1080p(video_id): logger.info('Video Processing started') try: video = input_file_path = output_file_1080p_path = for i in range(1): new_video_1080p = subprocess.call([ffmpeg, {process},output_file_1080p_path]) if new_video_1080p == 0: video.save() logger.info('Video Processing Finished') video.temp_file.delete() else: logger.info('Proceesing Failed.') # Just for now except: raise ValidationError('Something went wrong!') Thank you. Highly appreciate the help. -
re_path unresolved regex (\d[1,2])
Please let me know why my regular expression cannot be resolved, I just copied and paste from one of the Django book, and tried to passing the parameter re_path(r'^time/plus/(\d[1,2])/$', hours_ahead). Just tried to passing parameter additional hours to current time. http://127.0.0.1:8000/time/plus/2 then I got the page not found (404) error.The current path, time/plus/2, didn't match any of these. I don't understand what is the issue here. please help, thanks. -
Error when installing django on windows using `pip install django`
I get an error when installing django like ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts. We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default. drf-yasg 1.17.0 requires six>=1.10.0, but you'll have six 1.9.0 which is incompatible. can anyone help? Thanks in advance -
Django get selected value without Django forms
I have a select form in template which want to get the selected value and update it to item_option field of OrderItem model while running the add to cart function in veiws.py, how can I do it without Django forms? models.py: class product_option(models.Model): option_name = models.CharField(max_length=200) option1 = models.CharField(max_length=200) ... def __str__(self): return self.option_name class Product(models.Model): .... product_option = models.ForeignKey(product_option, on_delete=models.SET_NULL, blank=True, null=True) def __str__(self): return self.product_name def get_add_to_cart_url(self): return reverse("add_to_cart", kwargs={'slug': self.slug}) class OrderItem(models.Model): ... item_option = models.CharField(null=True, max_length=200) template: {% for detail in products %} <a class="btn btn-outline-dark mt-2 mb-3" href="{{ details.get_add_to_cart_url }}"><i class="fas fa-cart-plus mr-2"></i>add to cart</a> <select class="form-control d-inline-block w-50"> <option value="{{ details.product_option.option1 }}">{{ details.product_option.option1 }} </option> <option value="{{ details.product_option.option2 }}">{{ details.product_option.option2 }} </option> .... </select> {% endfor %} views.py def add_to_cart(request, slug): item = get_object_or_404(Product, slug=slug) order_item, created = OrderItem.objects.get_or_create( .... ) order_qs = Order.objects.filter(user=request.user, ordered=False) if order_qs.exists(): order = order_qs[0] if order.items.filter(item__slug=item.slug).exists(): .... order_item.item_option = request.GET.get('value') order_item.save() ... else: .... else: .... return redirect('product_detail', slug=slug) -
Reverse for 'delete' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P<pk>[0-9]+)/delete$']
First time writting to stack. If this problem is so stupid, don't condemn me pls. I need to delete the task from main page. I will be so grateful for the help! Traceback > > Template error: In template > C:\Users\dkaza\Desktop\taskmanager\templates\base.html, error at line > 6 Reverse for 'delete' with arguments '('',)' not found. 1 > pattern(s) tried: ['(?P<pk>[0-9]+)/delete$'] > Exception Type: NoReverseMatch at / Exception Value: Reverse for > 'delete' with arguments '('',)' not found. 1 pattern(s) tried: > ['(?P<pk>[0-9]+)/delete$']` urls.py path('<int:pk>/delete', TaskDelete.as_view(), name='delete'), models.py class Task(models.Model): title = models.CharField(max_length=50) content = models.TextField() created_at = models.DateTimeField(auto_now_add = True) def __str__(self): return self.title class Meta: verbose_name = 'Task' verbose_name_plural = 'Tasks' ordering = ['-id'] views.py class TaskDelete(DeleteView): model = Task template_name = 'task/del_task.html' success_url = reverse_lazy('home') context_object_name = 'task' index.html <a href="{% url 'delete' task.id %}" class="btn btn-primary">Delete</a> del_task.html {% csrf_token %} <form method='post'> <h1>Do you want delete the «{{object.title}}»?</h1> <p><button class="btn btn-danger" type='submit' valeu='Yes'/>Yes</button> <a class="btn btn-light" href='{% url 'home' %}'>Cancel</a></p> -
Confused with Stripe payment_method
I have been using Stripe inside my Django project with no problems so far, everything is working, however I am confused about the payment_method parameter. At the moment I have it set to pm_card_visa because that's what the documentation told me to do, however I believe this is causing me problems as when I put in a dummy Mastercard number that Stripe gives you, it is still defaulting to use the default 4242 4242 4242 card. How can I dynamically set the payment_method variable? -
How to use the value of "userinput" in the Finalresult function. And how to convert userinput tointeger so i can divide the client value by 2
def step2(request): return render(request, 'step2.html') def step3(request): enteredtxt = request.GET.get('userinput', 'default') return render(request, 'step3.html') def step4(request): return render(request, 'step4.html') def Finalresult(request): return render(request, 'Finalresult.html') enter image description here -
Django file upload per user
I'm trying to create a form that will upload file per user, and i need to set the default names of the files id or something. for example, if 2 users will upload a CV with the same name 'sampleCV.pdf' i need them to be in a seperated files, by ID or something, i tried to use self.name in the upload, but it did not work, because self is still not recognized at this point.. Is there a default way to set the file upload name? Model class Candidate(models.Model): name = models.CharField(max_length=200, null=True) ... candidate_cv = models.FileField(upload_to=f'uploads/',null=True) ... Form: class CandidateForm(ModelForm): class Meta: model = Candidate fields = '__all__' view: @login_required(login_url='login') def create_candidate(request): form = CandidateForm() if request.method == 'POST': form = CandidateForm(request.POST,request.FILES) if form.is_valid(): form.save() context = {'form': form} return render(request, 'dashboard/form.html', context) Form HTML: {% block content %} <center> <hr> <form enctype="multipart/form-data" action="" method="POST"> {% csrf_token %} {{form.as_p}} <input class='btn btn-sm btn-danger' type="submit" name="Submit"> </form> <hr> </center> {% endblock %} -
Can't get to boxes to align next to each other when there is a button with a link
I want to align two boxes horizontal to each other, but when i add a button with a link. The are align vertical. .box-element{ box-shadow:hsl(0, 0%, 80%) 0 0 16px; background-color: #fff; border-radius: 4px; padding: 10px; } <div class="col-lg-6"> <div class="box-element"> <hr> <h3>Order Summary</h3> <hr> <div class="cart-row"> <div style="flex:2"><img class="row-image" src="{% static 'images/placeholder.png' %}"></div> <div style="flex:2"><p>Product 1</p></div> <div style="flex:1"><p>$20.00</p></div> <div style="flex:1"><p>x2</p></div> </div> <h5>Items: 2</h5> <h5>Total: $4</h5> </div> </div> result: : https://i.stack.imgur.com/cs67Y.png <div class="col-lg-6"> <div class="box-element"> <a href="{% url 'cart' %}" class="btn btn-outline-dark" >&#x2190; Back to Cart</a> <hr> <h3>Order Summary</h3> <hr> <div class="cart-row"> <div style="flex:2"><img class="row-image" src="{% static 'images/placeholder.png' %}"></div> <div style="flex:2"><p>Product 1</p></div> <div style="flex:1"><p>$20.00</p></div> <div style="flex:1"><p>x2</p></div> </div> <h5>Items: 2</h5> <h5>Total: $4</h5> </div> </div> enter image description here thank you in advanced:) -
How to implement a Django model that has a many-to-many relationship with 'tags' but also counts of how many times it was tagged with something?
So I have three relevant models here: Word, Definition, and Tag. Words have a one to many relationship with Definition; many users can posts definitions for the same word. I want to add a tagging feature so that when users submit their definition they can include Tags. These Tags apply to the Word they are defining, not the definition itself. A Word can have more than one Tag, but the same Tag can also apply to more than one word, so Words should have a many-to-many relationship with Tag. I also want to store how many times a Word has been tagged with something. Every time a user submits definition for word X and includes tag Y, I want to increment that Word's count for how many times its been tagged with Y. What would be the best way to setup such a schema? I'm kind of lost here. The only solution I can think of is to store an extra textfield in Word and store num_{tag}=X for each of the tags associated with it. I could also store the tags as part of the Definitions, but to find the number of times a word has been tagged with something … -
Can html5 integrate django rest api?
Can we use only django rest api for backend; html and css for frontend for a webapp, without using django views, only using djnago rest api... -
IntegrityError: UNIQUE constraint failed: accounts_account.user_id, accounts_account.type_of_account
I have a model called account which has a field called type_of_account, I also have another class called safelocks which is inheriting from the account model (the account model is a foreign key). I'm trying to change the type_of_account of all safelock accounts, and I'm doing something like safelocks = SafeLock.objects.all() for a in safelocks: a.account.type_of_account=1 a.account.save() but when I run this, I get this error Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/home/agozie/Documents/projects/savest_backend/safelocks/management/commands/deposit_to_direct.py", line 17, in handle a.account.save() File "/home/agozie/Documents/projects/savest_backend/accounts/models.py", line 61, in save super(Account, self).save(*args, **kwargs) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/db/models/base.py", line 741, in save force_update=force_update, update_fields=update_fields) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/db/models/base.py", line 779, in save_base force_update, using, update_fields, File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/db/models/base.py", line 851, in _save_table forced_update) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/db/models/base.py", line 900, in _do_update return filtered._update(values) > 0 File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/db/models/query.py", line 760, in _update return query.get_compiler(self.db).execute_sql(CURSOR) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1426, in execute_sql cursor = super().execute_sql(result_type) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1097, in execute_sql cursor.execute(sql, params) File "/home/agozie/miniconda3/envs/savests/lib/python3.7/site-packages/django/db/backends/utils.py", line 99, in execute return super().execute(sql, … -
Django: Need help for solve an issue
I have a Model called PoductPurchase with some model attibutes of Product . In this model I will keep quantity of purchased products. I have 2 others Models called RetailInventory and WholesaleInventory . Suppose I bought a product called XYZ and the quantity of that product is 400 ,now I want to divide the quantity of that product in Retail 300 piece and Wholesale 100 piece.I will just give the value in a input field and click 'give to retail' or 'give to wholesale' button and it will update the quantity . how can I do this? help will be highly appreciated. (N.B check the attachment)enter image description here -
Django row level access control approach for ERP app
I am considering using Django to develop an app revolving around case management and accounting, but I am unsure because of security concerns. What I would ideally need is real row level security at the database level, which I can't get with django (or can I?) Let's say I have a model called 'Authority' which represent a firm (it acts as a 'Groups' table). All users belong to one Authority. All other model tables have a 'authority_id' foreign key. I want to make sure no user will ever be able to retrieve rows linked to an authority different than theirs. No admin has access to all the data, at least not via the django app. Anonymous users only access the login/logged-out pages. Solution A is to write a manager function that takes request.user as a parameter and return a filtered query set. Then, use this function everywhere. This seems to be the right way to go, but this solution seems a bit too high level. In case of a coding mistake somewhere, like calling clients.objects.all() instead of clients.objects.for_user(request.user), someone would be getting access to someone else sensitive information. Solution B involves a middleware hack to get access to request.user from … -
Django handling multiple apps in a same project
Lately I started a Django project, I created an app and started to add my models and views in it, as time passed the project get bigger and bigger, more than 20 models, serializations, and a huge views file containing thousands of code lines was the result, in the other hand some of the models (like user profile) might be useful in other projects as well, so I decided to create some new apps (like userprofile) and move related codes to my new app. the problem is my main app is dependent on userProfile app but I cant import it into my main app, I added my new apps into installed apps of settings.py but it didn't affected -
How can we store previous value of some variable in some other variable in python?
Well I want to access previous value of num1 in other function by storing that in other variable. I have tried many ways but can you guys help me. import random num2 = 3 def token(): global num2 print (num2) #It should print previous value of num1 (it is not giving previous value but giving me the same value with num1 every time ) num1 = random.randint(40,90) print(num1) num2= num1 def vcode(): print(num2) #want to access here the previous value of num1 print(token(),vcode()) -
Django cannot recognize package specified in application's __init__.py if i reorganize my applications to an apps folder
I have a Django3 project, let's say "blog". Typical folder structure for applications is: /blog/ /article/ /users/ ... blog/ __init__.py asgi.py settings.py urls.py wsgi.py manage.py I want to let the structure to be clean so I put all applications into a apps folder. So now the structure looks like the following: /blog/ apps/ __init__.py article/ users/ ... blog/ __init__.py asgi.py settings.py urls.py wsgi.py manage.py I want to use signal function in article apps/application, so the files in article are /blog/ apps/ __init__.py article/ migrations/ __init__.py admin.py apps.py models.py signals.py tests.py views.py users/ ... blog/ __init__.py asgi.py settings.py urls.py wsgi.py manage.py in apps/article/signal.py file: from django.db.models.signals import pre_save from django.dispatch import receiver from django.utils.text import slugify from core.utils import generate_random_string from apps.article.models import Article @receiver(pre_save, sender=Article) def add_slug_to_question(sender, instance, *args, **kwargs): if instance and not instance.slug: slug = slugify(instance.content) random_string = generate_random_string() instance.slug = slug + "-" + random_string in apps/article/apps.py file: from django.apps import AppConfig class ArticleConfig(AppConfig): name = 'article' def ready(self): import apps.article.signals in apps/article/init.py file: default_app_config = "apps.article.apps.ArticleConfig" if I restart my server, it shows the error: django.core.exceptions.ImproperlyConfigured: Cannot import 'article'. Check that 'apps.article.apps.ArticleConfig.name' is correct. I also tried several settings in apps/article/init.py file like: default_app_config = "article.apps.ArticleConfig" … -
Class diagram of deep learning model deployed in django
i m working on project that is stock market price prediction using deep learning.The Model is then deployed into django framework where the actual and predicted price is shown in graphical form. Anyone can help me in making the uml class diagram of whole project.Thanks -
How to set order_by only on ManytoManyfield in detailview (Django)?
I have 2 models Class and Student. One field within the Class mdel has a ManytoManyField relationship with Student. I want to order the manytomanyfield with first_name in the template. How can I do it? models.py class Student(models.Model): user = models.OneToOneField(CustomUser, on_delete=models.CASCADE, primary_key=True) first_name = models.CharField(max_length=100) class Class(models.Model): student = models.ManyToManyField(Student) subject = models.CharField(max_length=150, unique=True) # many other fields views.py class Class_detailView(LoginRequiredMixin, DetailView): login_url = '/' model = Class template_name = "attendance/content/teacher/class_detail.html template <div class="row ml-auto mr-auto"> <h6>{{ object.subject }}</h6> {% for student in object.student.all %} <h6 id="class-detail-text" class="mt-2"> {{student.first_name}} <-- want to order here </h6> {% endfor %} </div> right now the names render like this: Freaky Albon Bucky I want it to order like this: Albon Bucky Freaky -
Django ORM join on foreign keys that don't point at each other
tl;dr I'm trying to skip a superfluous join while using Django's ORM Let's say I have models like: # Recipe model not shown, not necessary. class RecipeIngredient(IngredientMixin, models.Model): recipe = models.ForeignKey( Recipe, on_delete=models.CASCADE, related_name='recipeingredients') ingredient = models.ForeignKey( Ingredient, on_delete=models.CASCADE, related_name='recipeingredients') class Ingredient(models.Model): # ...other fields... # M2M field that stores a hierarchy of ingredients. Ingredients can # have multiple parents. parents = models.ManyToManyField( 'self', blank=True, through='IngredientParent', symmetrical=False, ) class IngredientParent(models.Model): ingredient = models.ForeignKey(Ingredient, on_delete=models.CASCADE, related_name='+') parent = models.ForeignKey(Ingredient, on_delete=models.CASCADE, related_name='+') And I'm trying to figure out which Recipes contain a certain ingredient, but also include Recipes if the parent of an ingredient is our chosen ingredient. For example, "cheese" might be a parent of "cheddar" and if someone selects "cheese", I want to show them all recipes with cheese, but also with cheddar, etc. ANYWAY, I do this: i = Ingredient.objects.get(name='cheese') recipes = Recipe.objects.filter( Q(recipeingredients__ingredient=i) | Q(recipeingredients__ingredient__parents=i) ) print(recipes.query) which gives me the SQL: SELECT -- all Recipe fields FROM "core_recipe" INNER JOIN "core_recipeingredient" ON ("core_recipe"."id" = "core_recipeingredient"."recipe_id") INNER JOIN "core_ingredient" ON ("core_recipeingredient"."ingredient_id" = "core_ingredient"."id") LEFT OUTER JOIN "core_ingredientparent" ON ("core_ingredient"."id" = "core_ingredientparent"."ingredient_id") WHERE ("core_recipeingredient"."ingredient_id" = <ingredient_id> OR "core_ingredientparent"."parent_id" = <ingredient_id>) Looks good. But actually, that INNER JOIN to core_ingredient … -
Django 3.1 TemplateNotFound Exception when Template is Present
I am trying to work towards deploying my application and have done most of my work on Windows. However now that I have moved it over to AWS it does not work anymore. Before anyone links other articles here is a list of all the things I have tried: Adding os.path.join(BASE_DIR,'templates') to TEMPLATE_DIR Changing the permissions of my template My app is in my INSTALLED_APPS variable I have checked that all my render methods are formatted correctly Re-downloaded my project completely Like I said earlier, it works on my Windows machine, just not on AWS or my Mac. Even more strange is that the error says Django tried loading these templates, in this order: Using engine django: * django.template.loaders.filesystem.Loader: /opt/bitnami/apps/django/django_projects/goFiles/uploads/templates/uploads/base.html (Source does not exist) * django.template.loaders.app_directories.Loader: /opt/bitnami/apps/django/django_projects/goFiles/uploads/templates/uploads/base.html (Source does not exist) * django.template.loaders.app_directories.Loader: /opt/bitnami/python/lib/python3.8/site-packages/django/contrib/admin/templates/uploads/base.html (Source does not exist) * django.template.loaders.app_directories.Loader: /opt/bitnami/python/lib/python3.8/site-packages/django/contrib/auth/templates/uploads/base.html (Source does not exist) And /opt/bitnami/apps/django/django_projects/goFiles/uploads/templates/uploads/base.html is the correct absolute path to the template I am looking for. If I try to cat that file, using that absolute path, it prints to stdout. All this being said I will include some of my code for critical review. views.py def get(self, request, *args, **kwargs): paste = None return render(request, 'uploads/index.html', …