Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to get the selected foreign key's value?
Models: class Item(models.Model): name = [...] # unique quantity = [..integer_field..] class Sales(models.Model): sold_to = [...] sold_item = foreign key to Item sold_quantity = [..integer field..] I want to make sure that if the selected Item has the quantity of 5, and you pass 6 or more to the sold_quantity, throw a validation error saying "You have only X in stock and wanted to sell Y". I tried to override the save method, but however I try to do so, it changes nothing. When I try to access self.sold_item, it returns the name of the selected item. When I try to do item.objects.get(name=self.sold_item), whatever I do it returns just the name of the item and I can't access other fields (known as Quantity). Conc: Item.objects.get(name=self.sold_item) returns the name of the item. using the same but Filter instead of Get returns a queryset, which contains <Item: the items name> and I can't access other fields of it. -
How to show terminal result into HTML in Django? [duplicate]
terminal shows hello I want to put "hello" on HTML. def test(request): cmd = './hello.sh {}'.format(res) subprocess.run(cmd, shell=True) return HttpResponse() -
Django aggregation for 3 related tables with one to one and one to many relation
I have 3 django models (tables), let's say singer, album, and song. singer has columns id, album_id (foreign key to album table), first_name, last_name album has columns id, title, num_of_album_wishlist, num_of_album_stars song has columns id, album (foreign key to album table) num_of_streams, song_duration_in_secs Singer has one to one relation with album and album has one to many relation with song. these tables are just a dummy representation and don't necessarily makes sense but adequately demonstrate the problem. Have to create a queryset where for each singer (in the queryset), have to find out sum of num_of_album_wishlist, num_of_album_stars from song table, as well as total_num_of_songs for the user, sum of num_of_streams and song_duration_in_secs in a single queryset. Singer.objects.annotate( wishlist=Sum('album__num_of_album_wishlist'), stars=Sum('album__num_of_album_stars'), streams=Sum('album__song_group__num_of_streams'), duration=Sum('album__song_group__song_duration_in_secs') ) The query above gives wrong results pertaining to one to many relation of album table with song table. subq = Singer.objects.annotate( streams=Sum('album__song_group__song_duration_in_secs'), duration=Sum('album__song_group__song_duration_in_secs') ).filter(pk=OuterRef('pk')) queryset = Singer.objects.prefetch_related( 'album').annotate( streams=Subquery(subq.values('streams')), duration=Subquery(subq.values('duration')), wishlist=Sum('album__num_of_album_wishlist'), stars=Sum('album__num_of_album_stars'), ) Using Subquery to tackle this works but generates different blocks for joining in SQL query (which further results in a long time to execute the query) Any suggestions on how to tackle this problem? -
Django application fails with error "NameError: name '_mysql' is not defined" [closed]
With Python 3.7.9, our Django application always fails with the error "NameError: name '_mysql' is not defined". We tried to install and uninstall multiple YUM packages, but the error stays in the same way. Please see the pip package list attached in the Details section below, and let me know if you need to see the yum package information. We highly appreciate your help. The pip list: amqp==5.0.2 anyjson==0.3.3 appdirs==1.4.4 arrow==0.13.2 asgiref==3.3.1 attrs==20.3.0 backcall==0.2.0 backports.functools-lru-cache==1.6.1 beautifulsoup4==4.9.3 billiard==3.6.3.0 caniusepython3==7.2.0 celery==5.0.4 certifi==2020.12.5 chardet==3.0.4 click==7.1.2 click-didyoumean==0.0.3 click-plugins==1.1.1 click-repl==0.1.6 decorator==4.4.2 distlib==0.3.1 Django==3.1.4 django-cors-headers==3.5.0 django-debug-toolbar==3.2 django-easy-pjax==1.3.0 django-rest-auth==0.9.5 djangorestframework==3.12.2 fake-factory==9999.9.9 fissix==20.8.0 gunicorn==20.0.4 idna==2.10 importlab==0.5.1 importlib-metadata==3.1.1 ipython==7.19.0 ipython-genutils==0.2.0 jedi==0.17.2 kombu==5.0.2 line-profiler==3.1.0 lxml==4.6.2 mock==4.0.2 modernize==0.8.0 mysqlclient==2.0.1 networkx==2.5 ninja==1.10.0.post2 packaging==20.7 parso==0.7.1 pexpect==4.8.0 pickleshare==0.7.5 Pillow==8.0.1 pip==21.0 pip-review==1.1.0 pipdeptree==1.0.0 prompt-toolkit==3.0.8 ptyprocess==0.6.0 Pygments==2.7.3 pyparsing==2.4.7 python-dateutil==2.8.1 pytype==2020.12.2 pytz==2020.4 PyYAML==5.3.1 qrcode==6.1 requests==2.25.0 setproctitle==1.2.1 setuptools==51.3.3 six==1.15.0 soupsieve==2.0.1 sqlparse==0.4.1 traitlets==5.0.5 typed-ast==1.4.1 urllib3==1.26.2 vine==5.0.0 wcwidth==0.2.5 wheel==0.36.2 yet-another-django-profiler==1.1.0 zipp==3.4.0 -
django celery queue task
api View class IsBuyNowAvailable(APIView): permission_classes = [RazorpayPermission] def post(self, request, format=None): data = request.data res = buy_now_available.delay(data) print("Celery res", res) if res.get("success"): return Response(res, status=status.HTTP_200_OK) else: return Response(res, status=status.HTTP_400_BAD_REQUEST) celery task from celery import Celery from settings.settings import CELERY_BROKER_URL app = Celery("celery_app") app.config_from_object("django.conf:settings", namespace="CELERY") app.autodiscover_tasks() @app.task() def buy_now_available(data): asset_id = data.get("asset_id") asset = Asset.objects.filter(id=asset_id).get() return {"success": True, "asset_id": asset.id} web | Celery res b926b9b1-a3cd-4461-a73f-5baf8f7e51c9 celery_1 | [2022-04-14 05:17:03,198: INFO/MainProcess] Task api.tasks.buy_now_available[b926b9b1-a3cd-4461-a73f-5baf8f7e51c9] received celery_1 | [2022-04-14 05:17:03,254: INFO/ForkPoolWorker-1] Task api.tasks.buy_now_available[b926b9b1-a3cd-4461-a73f-5baf8f7e51c9] succeeded in 0.05360425729304552s: {'success': True, 'asset_id': 425} Here i am able to see the task in celery but it returns task id and in celery the response is generating . I wants to make it delay and wait till the response ready and the reponse should come inside my view not only in celery task so that i can send that response to user . The reason i want this becvause i am implementing queue task. If 10 users called that api same time then it will wait for next user untill first one is complete. and put rest request in queue before the first request is complete. Please take a look and tell me how can i achive this -
Django deploy Heroku error 500 Debug = False
Im trying to deply my django application Main tools that im utilizing that i dont know if require a special configuration: Stripe (Payment Method - but its not in my index page so It shouldnt be because of it) Mailgun(but i commented in my settings and im also not utilizing in Index page, so probably couldn't be it) Procfile release: python3 manage.py migrate web: gunicorn store.wsgi --preload --log-file – My Env Variable setters: from store.settings.base import * env = environ.Env() DEBUG = env.bool("DEUBG", False) SECRET_KEY = env("SECRET_KEY") DATABASES = { 'default': env.db(), } My settings: import django_on_heroku import os import environ from pathlib import Path BASE_DIR = Path(__file__).resolve().parent.parent.parent DEBUG = True ALLOWED_HOSTS = ['afternoon-brook-19806.herokuapp.com', '127.0.0.1', 'localhost'] STATIC_URL = '/static/' STATIC_ROOT = BASE_DIR / 'static' STATICFILES_DIRS = [BASE_DIR / 'templates/static'] STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" # BUG MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media' CART_SESSION_ID = 'cart' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' PUBLISHED_KEY = 'pk_live_xxxxxxx' STRIPE_SECRET_KEY = 'sk_live_xxxxxxxxx?' STRIPE_ENDPOINT_SECRET = 'xxxxxxx?' django_on_heroku.settings(locals()) Where I get the error 500 in Heroku Logs: 2022-04-14T04:33:35.002535+00:00 heroku[router]: at=info method=GET path="/account/login/" host=afternoon-brook-19806.herokuapp.com request_id=ac9b6df0-3598-427e-a672-9519419de8b3 fwd="177.124.150.24" dyno=web.1 connect=0ms service=68ms status=500 bytes=451 protocol=https 2022-04-14T04:33:35.003893+00:00 app[web.1]: 10.1.51.13 - - [14/Apr/2022:01:33:35 -0300] "GET /account/login/ HTTP/1.1" 500 145 "https://afternoon-brook-19806.herokuapp.com/account/register/" "Mozilla/5.0 (Windows NT … -
When sorting the chained queryset, 'itertools.islice' object has no attribute 'next'
Thanks to this article https://stackoverflow.com/questions/431628/how-can-i-combine-two-or-more-querysets-in-a-django-view#:~:text=Use%20union%20operator%20for%20queryset,querysets%20by%20using%20union%20operator.&text=One%20other%20way%20to%20achieve,to%20use%20itertools%20chain%20function. I use QuerySetChain class to concatenate multiple queryset class QuerySetChain(object): """ Chains multiple subquerysets (possibly of different models) and behaves as one queryset. Supports minimal methods needed for use with django.core.paginator. """ def __init__(self, *subquerysets): self.querysets = subquerysets def count(self): """ Performs a .count() for all subquerysets and returns the number of records as an integer. """ return sum(qs.count() for qs in self.querysets) def _clone(self): "Returns a clone of this queryset chain" return self.__class__(*self.querysets) def _all(self): "Iterates records in all subquerysets" return chain(*self.querysets) def __getitem__(self, ndx): """ Retrieves an item or slice from the chained set of results from all subquerysets. """ if type(ndx) is slice: return list(islice(self._all(), ndx.start, ndx.stop, ndx.step or 1)) else: return islice(self._all(), ndx, ndx+1).next() Now I pick up some tables md = sm.Message.history.all() sw = sm.Worker.history.all() st = sm.Template.history.all() gp = sm.GlobalParam.history.all() matches = QuerySetChain(md, sw, st,gp) # it makes one queryset successfully result_list = sorted( #error occurs here matches, key=lambda instance: instance.updated_at) When I am trying to sort the items, The error occurs like this below. 'itertools.islice' object has no attribute 'next' when sorting chained object Is it possible to sort this? -
Should I compress python files in Django?
I know that I should compress frontend files (HTML, CSS, JS) to increase the security and loading speed of a website. But how about the backend files (for example Python)? Should I compress them too? Do I get any benefits from doing that? -
Django hot reload only working on certain files
I have this weird issue where not all file edits are being picked up by the hot reloader for Django. I have this structure: / app/ ... apps in here. config/settings.py manage.py Now, any changes to config/settings.py or manage.py will result in the django runserver reloading. But any changes to files inside app/... don't trigger a reload - I have to go and add a newline to manage.py and save (quite irritating). Any ideas why this might be? At first I thought it was a docker thing, and it was only picking up files in the base dir, but then changes to config/settings.py also trigger the reload, so clearly it can see deeper. -
python image scrapper become base64 not real urls
I have scrapper tools, but my code are always scrap base64 instead of real urls,here is my code: import requests from bs4 import BeautifulSoup baseurl = "https://www.tes.com/search?q=tes" headers = {"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0"} r = requests.get(url=baseurl, headers=headers) soup = BeautifulSoup(r.content, 'lxml') for product_images in soup.findAll('div', attrs={'class': 'ArOc1c'}): print (product_images.img['src']) the result is something like: data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== I also use "soup = BeautifulSoup(r, 'html.parser')" but it is still the same. -
How can i using the setting of CKEDITOR_CONFIGS in class ckeditor?
i have already set CKEDITOR_CONFIGS in settings.py but when i try to use <td><textarea class="ckeditor" name="remark" id="test1" cols="30" rows="10"></textarea></td> both are different style how can i make ckeditor in class using the style i have set in CKEDITOR_CONFIGS -
How to create key to get a request to Django API?
I am creating a database with Django, and I am accesing it with Excel and Apps Script. I can't log in into my superuser account (the only account I'll be having). Therefore, I want to know if there is a way to set a key, or a password, passed through an HTTP header, that I can use to access my API. Currently I only have one API get method, but I'll have more create, update, etc., and I want to be able to use the same key for these as well. It is a really simple Django application deployed in heroku, so I am not using django-REST-framework, nor graphene-django. So if the solution can come without installing anything else, it would be nice. However, if this is not possible, it is better if the solution comes through graphene-django, since I have used it before, and I am more familiar with it. It is important to notice that both the excel file and the apps script are private, since I am using django as a database manager for a small, personal project. Thank you very much in advance! -
How do i change what django looks for in .filter()?
take this example code: from .models import Employees filters = { "name" : request.GET.get("name"), "work_place" : request.GET.get("work_place_filter") } for index, item in enumerate(filters): key = list(filters.keys())[index] value = filters[item] flykninger = Employees.objects.filter(key = value) what im trying to do here is to change what key the filter() function compares the value to if the input fields are not None. But whenever i try to run my own code that includes this snippet, i get Cannot resolve keyword 'key' into field. Choices are: alder... How do i do this? is there another way to do it that i'm not aware of? Thanks -
Is it possible to edit the page_obj before passing template?
I can catch <class 'django.core.paginator.Page'> in get_context_data function of django view class. What I want to do is alter the showing item and get it back to <class 'django.core.paginator.Page'> again. django.core.paginator.Page source code is here. https://docs.djangoproject.com/en/4.0/_modules/django/core/paginator/ I found it has object_list,so I try to change def get_context_data(self): temp = super().get_context_data() print(type(temp['page_obj'])) #<class 'django.core.paginator.Page'> new_object_list = [] for t in temp['page_obj'].object_list:## I can iterate the item here. # make new_object_list here temp['page_obj'].object_list = new_object_list print(temp) # nothing changes return temp However object_list doesn't change. -
no module error on python when I connect EC2 with ssh
I am a junior(more like kindergarten to be specific) web developer and I get some project which already exists. it is deployed on EC2 and I had to deal with some python files. I wanted to execute python files, So I connect project with ssh via key files. and I tried to execute python files but I couldn't and get a message like this. ModuleNotFoundError: No module named 'bs4' Well, I thought I could run a file because modules are already downloaded on EC2server?? how can I solve this and run python file on ssh? ps. when I make a new python file and run print("pypy") It runs OK thx for reading, your help will be appreciated. -
How to host multiple docker apps on one AWS Lightsail instance
Is it possible to host multiple docker services in one lightsail instance? I want to deploy an NGINX proxy, Django Web App, and Strapi server in the same instance. My project is developed using docker-compose. What is the recommended way in this scenario? Thanks in advance. -
If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import
i got:django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'bookstore.urls' from 'C:\blog\bookstore\urls.py'>' does not appear to have any patterns in it. If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import. my urls.py in blog is: from django.contrib import admin from django.urls import include, path urlpatterns = [ path('admin', admin.site.urls), path('' , include('bookstore.urls')) ] my code in view.py is: from django.http import HttpResponse from django.shortcuts import render def home(request): return HttpResponse('Home Page') def users(request): return HttpResponse('users Page') def info(request): return HttpResponse('info Page') my code in bookstore.urls.py is: from django.urls import path from bookstore import views URLPatterns = [ path('home/' ,views.home), path('users/' ,views.users), path('info/' ,views.info), ] and thank you for your help -
Show MQTT data in django template
I'm using paho-MQTT and I'm able to receive messages. When I receive a message, I want to display the data in a template, but am unable to do so. Below is the code I have. import paho.mqtt.client as mqtt import json def on_connect(client, userdata, flags, rc): print("Connected with result code "+str(rc)) client.subscribe("mhub/hr") def on_message(client, userdata, msg): x = (msg.payload) print(x) client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message client.connect("mqtt.eclipseprojects.io", 1883, 60) I have been following the tutorial. How can I show new data from MQTT in the html template I have created? -
Getting redirected to wrong url in django
I am trying to send an account verification email and redirect to the login page def signup(request): custom_user_id = ''.join(random.choices(string.ascii_uppercase+string.digits,k=10)) if request.method=="POST": form = RegistrationForm(request.POST) if form.is_valid(): first_name = form.cleaned_data['first_name'] last_name = form.cleaned_data['last_name'] email = form.cleaned_data['email'] password = form.cleaned_data['password'] username = form.cleaned_data['username'] user = Account.objects.create_user(user_id=custom_user_id,first_name=first_name,last_name=last_name,email=email,username=username,password=password)#this method is present in models.py file user.save() """ User activation mail """ current_site = get_current_site(request) mail_subject = "Please activate your fundaMental account" message = render_to_string('account_verification_email.html',{ 'user':user, 'domain':current_site, 'uid':urlsafe_base64_encode(force_bytes(user.pk)), 'token':default_token_generator.make_token(user), }) to_email = email send_email = EmailMessage(mail_subject,message,[to_email]) send_email.send() It is supposed to redirect to '127.0.0.1:8000/account/login/?command=verification&email=+email' but instead it gets redirected to '127.0.0.1:8000/account/signup/account/login/?command=verification&email=+email' return redirect('account/login/?command=verification&email='+email) else: form = RegistrationForm() context = { 'form':form, } return render( request,"signup.html",context) Here is my urls.py file from django.urls import path from . import views urlpatterns = [ path('signup/',views.signup,name='signup'), path('login/',views.login,name='login'), path('logout/',views.logout,name='logout'), path('activate/<uidb64>/<token>',views.activate,name='activate'), ] Here is my project level urls.py from django.contrib import admin from django.urls import path, include from . import views urlpatterns = [ path('admin/', admin.site.urls), path('',views.home,name='home'), path('account/',include('account.urls')), ] -
AttributeError: 'ForeignKey' object has no attribute 'choice_1'
Why this error when trying to migrate this portion of the model Vote: choices=[election.choice_1, election.choice_2] models.py class Election(models.Model): custom_user = models.ForeignKey(CustomUser) vacant_office = models.CharField() choice_1 = models.CharField() choice_2 = models.CharField() class Vote(models.Model): custom_user = models.ForeignKey(CustomUser) election = models.ForeignKey(Election) vote = models.CharField( choices=[election.choice_1, election.choice_2]) A better way? -
Django Stripping Blanks In Between Words When Generating Blanks
I am working on a Hangman game using Django and I'm having some trouble generating the blanks from the words if the answer is two words, such as a first and last name. It seems to be something with Django stripping spaces and I have tried playing around with some solutions I found elsewhere, but unsuccessfully. Here I've changed admin.py1 Here I've created a fields.py 2 Where I probably am lost is how I'm linking it back in models.py or displaying it in the template. My logic is solid, I can replicate outside of Django, so it is something model related. Any help or guidance would be greatly appreciated! -
django templatees dissapearing on refresh
I have constructed a news aggregator website which shows 10 headlines with corresponding images, scraped from https://thestar.com ( The Toronto Star ) , using bs4. Here's a photo for reference: However, the major problem is, Everytime i refresh the page, all of the elements dissapear, As seen in the photo below : Anyone know what the problem is? Here is the element where my variables are stored: <div class="col-6"> <center><i><u><h3 class="text-centre">Live News from The Toronto Star</h3></u></i></center> {% for n, i in toronto %} <img src="{{i}}"> <strong><h5>{{n}}</h5></strong> <hr> {% endfor %} <br> </div> and here's my views.py file : from django.shortcuts import render import re import json import requests from bs4 import BeautifulSoup import itertools # Getting news from The Toronto Star toi_r = requests.get("https://www.thestar.com/?redirect=true") toi_soup = BeautifulSoup(toi_r.content, 'html.parser') toi_headings = toi_soup.find_all('h3') toi_headings = toi_headings[0:10]# removing footers toi_news = [] for th in toi_headings: toi_news.append(th.text) #Getting news from the NY Times ht_r = requests.get("https://www.nytimes.com/") ht_soup = BeautifulSoup(ht_r.content, 'html.parser') ht_headings = ht_soup.findAll('h3') ht_headings = ht_headings[0:8] + ht_headings[10:12] + ht_headings[19:21] ht_news = [] for hth in ht_headings: ht_news.append(hth.text) # Getting Images from The Toronto Star tor_r = requests.get("https://www.thestar.com/") data = re.search(r"window\.__PRELOADED_STATE__ = (.*)", tor_r.text) data = json.loads(data.group(1)) def find_images(d): if isinstance(d, dict): for … -
Django Python3 can't open file 'manage.py': [Errno 2] No such file or directory
I am sure this question has already been asked several times but I find myself unable to make migrations and have tried numerous commands to go to the right directory yet I have been unsuccessful. This is my tree as per the image below: Could someone tell me the right command to make my migrations ? -
Why is Django is not loading my template view but it once was
My view was running fine until Ill tried to override an admin view. Which i eventually got to work. However in the process I broke the path to my view that was working. The admin view had nothing to do with my originally working view. Now I copied my view into every possible level of my project structure. Yet the django template loader fails to find my order_input.html The error shows the correct path to my order_input.html. I made copies of order_input.html at every single possible level of my project... but django still cant find it. APP - URLS.PY from django.conf.urls import url from . import views urlpatterns = [ url(r'^hw/$', views.helloworld, name='helloworld'), url(r'^order_input/$', views.order_input, name='order_input'), url(r'^time/$', views.today_is, name='time'), url(r'^$', views.index, name='index'), ] SETTINGS.PY # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', # 'django.contrib.staticfiles', 'import_export', 'hw_app', ] PROJECT URLS.PY urlpatterns = [ url('r', include('hw_app.urls')), url('admin/', admin.site.urls), path('clearfile', views.clearfile), path('readfile', views.readfile), path('writefile', views.writefile), path('helloworld', views.helloworld), path('order_input', views.order_input), path('ajax_view', views.ajax_view), ] -
How do I use start-app template context in a template file?
I have the current setup for a Django app template which I pass to start-app like so: python3 manage.py start-app --template template/ myapp With a directory structure like this: template/ templates/app_name/ page.html ... app.py app.py uses the template context passed when start-app is run, and works fine! # app.py from django.apps import AppConfig class {{ camel_case_app_name }}Config(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = '{{ app_name }}' However, I'm trying to get similar behaviour out of page.html, to no avail. {% extends "{{ app_name }}/otherpage.html" %} {% block content %} <p>Hello from {{ camel_case_app_name }}!</p> {% endblock %} If I run start-app like normal, the template is copied over and the app name is not inserted. If I try to run start-app with --extension py,html I don't get the expected behaviour either, because the template is rendered. Is there a way to convert the {{ app_name }} calls in page.html without attempting to render the entire template?