Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Specified EMAIL_FILE_PATH and render_to_string
I've specified my EMAIL_FILE_PATH in settings.py, and made a view containing following: message = render_to_string('activation-mail.html', { ***more irrelevant code*** }) But when I then execute the function, I get the error that django.template.exceptions.TemplateDoesNotExist: activation-mail.html The path for my mails are from settings.py BASE_DIR = os.path.dirname(os.path.dirname(__file__)) CONTENT_DIR = os.path.join(BASE_DIR, 'content') EMAIL_FILE_PATH = os.path.join(CONTENT_DIR, 'tmp/emails') The path to my mail template is content/tmp/emails/activation-mail.html Where did I mess up? -
list_filter in admin not working for MultiSelectField
I have used MultiselectField in my models.py and I am trying to use list_filter in admin.py for that particular field. It is dispaying the filter but the filter is not fetching any objects in short it is not working for me. models.py: slate_ch=( ('Location A','Location A'), ('Location B','Location B'), ('OTHER','OTHER') ) class Support_Staff(models.Model): Name=models.CharField(max_length=20,blank=True) Work=models.CharField(max_length=40, default="", choices=work_ch) contact=PhoneNumberField(null=True,help_text="Use +91 in start. example: +919245613248") Persona=models.FileField(upload_to='Persona/') Slate=models.CharField(max_length=40,default="ZILINGO", choices=slate_ch) class Meta: verbose_name_plural="Support Staff" def __str__(self): return self.Name admin.py: class Support_Staff_admin(admin.ModelAdmin): list_display=('Name','Work','Slate','contact') list_filter=('Work','Slate') search_fields=('Name','Work') I read in some old questions that list_filter does not work very well for MultiSelectField but in a discussion on github by author they seem to have made it work. Here is the discussion link:https://github.com/goinnn/django-multiselectfield/issues/49 Then what might be the issue that its not working? Also what can be the alternatives to this so that I don't face the same problem of filtering. -
jquerry.gannt plugin wrongly calculating width of the elements
I am using jquerry.gantt plugin to render some extremely basic gantt charts. If I put it on the page on its own, it renders everything well. If I include this rendered page in my Django page as an IFRAME it also renders well, but I would like to avoid IFRAMes even though they are both on the same site. If I try to render inside my page it clash with cirrus-ui css, generally I see in debug that it wrongly calculates widths of the panels (called dataPanel i jquerry.gantt). I have tried to hac css a little bit, but the widths are calculated from JS, and i would like to avoid digging deep inside jquerry.gantt if possible. Has anyone encountred something similar? Any tip? -
django.template.library.InvalidTemplateLibrary: Invalid template library specified.&cannot import name 'six' from 'django.utils
File "/usr/local/lib/python3.8/dist-packages/django/template/backends/django.py", line 123, in get_package_libraries raise InvalidTemplateLibrary( django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'leaflet.templatetags.leaflet_tags': cannot import name 'six' from 'django.utils' (/usr/local/lib/python3.8/dist-packages/django/utils/init.py) installed six and imported it but still got the same error any suggestions -
Django: Is it wrong to create a new application that uses the same models?
I'm new to coding Django and try to build my first website, a little RP game to play in school. It is a hero who plays an adventure and must make the right decisions. Now that I want to create a second adventure, I ask myself the question: should I continue on the same application or create a second one? I know that I should continue on the same application since my models.py file would be a simple copy (with new instances), but I find a lot of advantages in separating the two. It seems to me that my requests would be simplified and that it would be easier to give permission to this adventure. Is it a problem to always create a new application? Do you advise me to keep only one app? Thx a lot! -
Axios patch with Django/React: Form-data with non-Form, won't update DB, Postman works fine
I am working on project with Django as backend(REST API), and React JS as frontend, using Axios to get from my API. I tried to PATCH data with imgs and JSON (Form data along with Non-Form data). It works fine in POSTMAN by choosing img files. However in my React codes, it cannot update DB. What will be the problem? Thanks a lot! Here's my React codes: //init state const initialState = { location: "", avatar: null, }; const [dbData, setDbdata] = useState(initialState); -------- //upload img and setState let file = event.target.files[0]; setDbdata({ ...dbData, avatar: file, }); //Axios call axios.patch( `api/user/update/username=${state.username}`, dbData, { headers: { "content-type": "multipart/form-data;" }, }) .then((res) => { console.log(dbData.avatar) }) .catch((err) => console.log(err.response)); -
How filter objects in django views?
How can I filter two parameter in django views ? for example my code is : **Views : ** def products_filter(request, product, selling): all_product = Product.objects.filter(product=product).filter(selling=selling) -
How to call a class based view by another class base
One of my view should call a view function of a differnt class. views.py: class VehicleSearch(FormView): template_name = 'vehicle_search_template.html' ctx = { 'Search_by_VIN': Search_by_VIN(), 'Search_by_Plate': Search_by_Plate(), 'header': "Fahrzeugsuche", } def get(self, request, *args, **kwargs): if request.GET: q = request.GET q = q.dict() v = find_vehicle(q) if v: # here I want to redirect to another view to show details of my selected obj return Vehicle.render_vehicle(self, request, v) else: return HttpResponse(status_code=404) return render(request, self.template_name, self.ctx ) class Vehicle(View): template_name = 'vehicle_template.html' def get(self, request): return render(request, self.template_name) def render_vehicle(self, request, obj, *args, **kwargs): print("Huhu") print(self.template_name) ctx = { 'vehicle': obj, } return render(request, self.template_name, ctx ) but that doesn't work. I can not access the self object of the Vehicle class. Instead the template of the VehicleSearch Class will be rendered. How can I call the function "render_vehicle" in the class "VehicleSearch"? -
Query doesn't exist in Django
So eventually I was trying to run this command on my shell TodoList.objects.get(id=1) and then I got this error: raise self.model.DoesNotExist( main.models.TodoList.DoesNotExist: TodoList matching query does not exist. I even created one instance for this. Here's my models.py file: from django.db import models # Create your models here. class TodoList(models.Model): name = models.CharField(max_length=250) def __str__(self): return self.name class Item(models.Model): todoList = models.ForeignKey(TodoList, on_delete=models.CASCADE) text = models.CharField(max_length=300) complete = models.BooleanField() def __str__(self): return self.text Does anyone know why am I not able to see my instance when I type that command? Regards -
How can I connect from Django to Docker Redis Container?
I am currently working on a Django project, which is supposed to send messages to a mobile app via websockets. For the Django project I used Docker to put it online. Now I want to send planned messages for the first time, for this I use Apscheduler or django-apscheduler. I try to save the jobs in my Redis container. But for some reason the connection is denied. Am I basically doing something wrong or does it hang somewhere? Dockerfile: FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code COPY requirements.txt /code/ RUN pip install -r requirements.txt COPY . /code/ RUN pip install -r requirements.txt docker-compose.yml version: '3' services: redis: image: redis command: redis-server ports: - '6379:6379' - '6380:6380' web: build: .\experiencesampling command: python manage.py runserver 0.0.0.0:8000 volumes: - .:\code ports: - "8000:8000" # worker_channels: # # build: .\experiencesampling # command: python manage.py runworker channels # volumes: # - .:\code # links: # - redis channels: build: .\experiencesampling command: daphne -p 8001 experiencesampling.asgi:application volumes: - .:\code ports: - "8001:8001" links: - redis jobs.py (trying connect to redis), I have already tried 0.0.0.0, localhost, redis://redis for the "host" jobstores = { 'default': RedisJobStore(jobs_key='dispatched_trips_jobs', run_times_key='dispatched_trips_running', host='redis', port=6380) } executors = { 'default': … -
Convert QuerySet of Dicts into List of IDs for use in another QS
I have a list of "Most Viewed Videos" that is arranged in the following format: class Video(models.Model): .... class Viewcount(models.Model); video = models.ForeignKey(Video) date = models.DateField I'm trying to generate code to display the "Most Viewed Videos in Past 30 days". This is my code so far: today = datetime.date.today() thirty_days_ago = today - datetime.timedelta(days=30) mostviewed = View.objects.filter(date__gte=thirty_days_ago).values('video').order_by('video').annotate(vidcount=Count('video')).order_by('-vidcount') Which outputs: <QuerySet [{'video': 9130}, {'video': 1}, {'video': 9138}, {'video': 9170}, {'video': 3}, {'video': 9135}]> How can I turn this into a simple list for use in a template? Such as: {% for video in new_list %} {{video}} would output video #9130, then #1, then #9138, etc. {% endfor %} Basically I want to steal the list of IDs generated by my mostviewed list, and use those to display that list of videos. I'd like the order to be preserved, as well. Thanks! -
How do I use aChoiceForm on a list of objects within another list of objects and store each choice independently
I am working on creating a website to complete and store checklists. Each location has a list of sets of items. Each item will have a boolean attribute, which should be unique between the same items at different locations. I want to be able to set each item to a boolean value and change the value independently of other items/locations. Right now, I have the choice selector and submit form working, but when I change the value for one item, it makes the same change for all of the items in the list: models: class item(models.Model): item_desc = models.CharField(max_length=100) item_vpn = models.CharField(max_length=10) item_crc = models.CharField(max_length=7) item_is_displayed_y_n = ( ('0', 'No'), ('1', 'Yes'), ) item_is_displayed = models.CharField(max_length=1, choices=is_displayed_y_n, default='0') def __str__(self): return self.item_desc class pop(models.Model): pop_desc = models.CharField(max_length=20) pop_is_displayed_y_n = is_displayed_y_n = ( ('0', 'No'), ('1', 'Yes'), ) pop_is_displayed = models.CharField(max_length=1, choices=is_displayed_y_n, default='0') objects = models.Manager() def __str__(self): return self.pop_desc class sets(models.Model): set_name = models.CharField(max_length=200) items_in_set = models.ManyToManyField(item) pop_in_set = models.ManyToManyField(pop) objects = models.Manager() def __str__(self): return self.set_name class Checklist(models.Model): store_name = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') list_of_sets = models.ManyToManyField(sets) objects = models.Manager() def __str__(self): return self.store_name forms: item_is_displayed_y_n = ( ('0', 'No'), ('1', 'Yes'), ) class itemDisplayedForm(forms.Form): item_is_displayed = forms.ChoiceField(choices … -
search object in Django with many field
i have many data to search, Some of them must be exactly the same and Some of them search between several field for example data = { 'user__seller_profile__city_name': city, 'category': cat, user__seller__order_condition = condition, user__buyer__sellerCompany__id = company_id } This information above should be exactly the same And may change in each post And the rest of the information has to be searched between several fields for example item__slug__icontains= search order__slug__icontains = search, .... How can I get the right query? can i Use Q in dict ? -
In Python 3.7/Django 3, how can I get the rendered HTML of a page in a web browser?
I'm using Python 3.7 with Django 3. I currently use the following code for generating a web browser with a given URL filePath = '/tmp/cat_and_dog.webp' searchUrl = 'http://www.google.hr/searchbyimage/upload' multipart = {'encoded_image': (filePath, open(filePath, 'rb')), 'image_content': '', } response = requests.post(searchUrl, files=multipart, allow_redirects=False) fetchUrl = response.headers['Location'] webbrowser.open(fetchUrl) How do I get the HTMl of the rendered DOM? Note that this is different than what "view source" reveals. I'm more interested in getting a version of the DOM that I see when I run "Inspect Element" in my browser. I may be using improper terminology but hopefully it is clear the actual HTML I wish to extract what the browser renders. -
How to make Jquery datatable work on 'n' number of columns?
I am making Django web app. I used this datatable in it. My page has four datatable in it. All of them working but on definite number of columns say 6. When I insert 7th column, searching and pagination gets dissapear from that table. I am confused that whether this issue is datatable specific or there is wrong with something else. In this code given below, pagination and searching gets dissapeared but when I remove last column and last column data, it appears. <table id="confirmedDeliveries" class="ui celled table responsive nowrap unstackable" style="width:100%"> <thead> <tr> <th>Requested By</th> <th>Contact</th> <th>Date Requested</th> <th>From</th> <th>To</th> <th>Required Delivery Date</th> <th align="center" colspan="2">Action</th> </tr> </thead> <tbody class="new_requests"> {% for delivery in confirmed %} <tr> <td>{{delivery.request.user}}</td> <td>{{delivery.request.contact}}</td> <td>{{delivery.request.date_requested}}</td> <td>{{delivery.request.from_address}}</td> <td>{{delivery.request.to_address}}</td> <td>{{delivery.request.required_delivery_date}}</td> <td><button class="btn btn-danger btn-sm" id="cancel_request" data-id="{{delivery.id}}">Cancel</button></td> <td><button class="btn btn-info btn-sm" id="done_request" data-id="{{delivery.id}}">Delivered</button></td> </tr> {% endfor %} </tbody> </table> Any insights would be appreciable. -
How to hide an external url from my user in a Django project?
I have a model in my django project that uses the UrlField to keep external urls files. I use the @login_required in my view to prevent anonymous users to get access to this content. But, in this case, a logged-in user can retrieve this information and post anywhere for everyone to use. My intention was to create a specific path on my urls.py, with the model id as one of the parameters, and in the view called by this url it would fetch the content in the UrlField and serve the user without display any external link. Something like a proxy or mask for external urls. Does anyone know how to do this? I've tried to use HttpResponseRedirect, but in the end the browser keep showing the url I want to hide. -
How to sum fields with ForeignKey?
Expert fills out Blank_list with choosen Employee. 5 Experts, there will be 5 Blank_list. How to sum five Blank_list? models.py: ANSWER_TYPES = ( (0, 0), (1, 1), ) class Expert(models.Model): expertname = models.CharField(max_length=200, null=True) position = models.CharField(max_length=200, null=True) class Employee(models.Model): employeename = models.CharField(max_length=200, null=True) position = models.CharField(max_length=200, null=True) class Blank_list(models.Model): expert_name = models.ForeignKey(Expert, null=True, on_delete=models.SET_NULL) employee_name = models.ForeignKey(Employee, null=True, on_delete=models.SET_NULL) lvl_1 = models.IntegerField('Indicator1:1', choices=ANSWER_TYPES, blank=0) lvl_2 = models.IntegerField('Indicator1:2', choices=ANSWER_TYPES, blank=0) lvl_3 = models.IntegerField('Indicator1:3', choices=ANSWER_TYPES, blank=0) class EmployeeCard(models.Model): blank_list = models.ManyToManyField(Blank_list, null=True, ) #there is a list of Blank_list #don't know if blank_list a correct field? employee_name = models.ForeignKey(Employee, null=True, on_delete=models.SET_NULL) sum_of_all_blank_list = ... -
Django many to many field,when will the association data write?
Suppose I had a model A,and a model B. class A(models.Model): name=models.IntegerField() class B(models.Model): sheet=models.ManyToManyField(A) I want to do something when create a B,so I use @receiver(post_save, sender=B) def save_handler(sender, instance, created, **kwargs): print(instance.sheet.all()) But when it firstly created,it will always be none,but when I click "save" in admin(the data was existed),it worked correctly. -
Django: MultiValueDictKeyError as I attempt to access an uploaded file
I'm trying to make a simple Django webapp that, when you send two images, it creates another image file that has both images one next to the other (the join_pics()) script below. For simplicity's sake, I just want to fetch the uploaded file, run the script, and return the file to the user as a download. No saving files to SQL or server. I know that I have to check the file format and size, and etc. This is all dealt with by using JS and a failsafe in the Python script (to be implemented). The problem is that I can't seem to access the uploaded files. I've tried several methods, looked at various tutorials and other posts here in StackOverflow and other sites, etc. Here's my code: # forms.py class ThingyForm(forms.Form): file1 = forms.CharField(label="file1", widget=forms.FileInput(), required=False) file2 = forms.CharField(label="file2", widget=forms.FileInput(), required=False) pwd1 = forms.CharField(label='Pwd1', max_length=32, widget=forms.PasswordInput(), required=False) pwd2 = forms.CharField(label='Pwd2', max_length=32, widget=forms.PasswordInput(), required=False) # views.py: def thingy(request): form = ThingyForm(request.POST or None, request.FILES or None) if str(request.method) == 'POST': if form.is_valid(): print('Form Validated.') # Just to know that pwd1 = form.cleaned_data['pwd1'] #a password in case the user wants to zip the file with a password pwd2 = form.cleaned_data['pwd2'] #the … -
Using Python to build an Elasticlunr text search index?
Is there any way to use Python to build a search index for Elasticlunr? I have a Python/Django based website which renders templates for a static website with thousands of pages. In other words, the backend is dynamic, but the publicly accessible frontend is static. So I'm not reliant on search engines like Google, which don't tend to index all pages, I'd like to implement browser-based text search so a user can have guaranteed access to search all pages. From what I can tell, Elasticlunr fits the client-side part of that exactly, but still seems to require running all the server-side components from NodeJS or some other server-side Javascript implementation. I'm fluent in Javascript, but for simplicity, I'd rather try to use something that could easily work with my Python backend and Django ORM. Since it looks like Elasticlunr builds an index file on the server side, which is then loaded client-side, is there any way to build that index in Python? -
Using subdomains with Nuxt
I have a Django app which currently changes the subdomain from example.com to dashboard.example.com when the user is logged in. I'm in the process of converting the front end to Nuxt but I can't work out how to serve some pages from the dashboard.example.com subdomain and I can't seem to find any docs about it. Anyone got any ideas or am I going to need to abandon Nuxt? -
Inclusion tag: a part to content block, and a part to scripts block
Django 3.0.8 The chosen commenting system needs something like this: <div id="anycomment-app"></div> <script> AnyComment = window.AnyComment || []; AnyComment.Comments = []; AnyComment.Comments.push({ "root": "anycomment-app", "app_id": 15, "track_get_params": true, "language": "en" }) var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = "https://cdn.anycomment.io/assets/js/launcher.js"; var sa = document.getElementsByTagName("script")[0]; sa.parentNode.insertBefore(s, s.nextSibling); </script> That is it needs a div, and a script. I'd prefer to put the scripts at the end of the body even if async is turned on. @register.inclusion_tag('scripts/scripts.html') def comments(context) -> str: html_tag = '<div id="anycomment-app"></div>' scripts_str = ' <script> AnyComment = window.AnyComment || []; AnyComment.Comments = []; AnyComment.Comments.push({ "root": "anycomment-app", "app_id": 15, "track_get_params": true, "language": "en" }) var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = "https://cdn.anycomment.io/assets/js/launcher.js"; var sa = document.getElementsByTagName("script")[0]; sa.parentNode.insertBefore(s, s.nextSibling); </script> ' return {"html_tag": html_tag, "scripts": scripts_str,} base.html {% load static %} {% load general %} {% load scripts %} {% include 'general/header.html' %} <body> {% everywhere position="body_start" %} {% social_subscribe %} {% block breadcrumbs %} {% endblock %} <div class="content"> {% block content %} {% endblock %} </div> {% include 'general/footer.html' %} footer.html {% load scripts %} {% block scripts %} {% endblock %} </body> </html> post.html {% extends 'general/base.html' %} … -
DRF - Paginate a Serializer without a Model
I wrote the following code: class RateViewSet(viewsets.ViewSet): serializer_class = RateSerializer permission_classes = [permissions.IsAuthenticated] def per_league(self, request): league_id = request.query_params.get('league') if(league_id): rates = [] for market in Market.objects.all(): total = len(Prediction.objects.filter(market=market, fixture__league__id=league_id).all().exclude(status='Win')) hits = 0 if(total): hits = round(len(Prediction.objects.filter(market=market, fixture__league__id=league_id, status="Win").all()) / len(Prediction.objects.filter(market=market, fixture__league__id=league_id).all().exclude(status='Win')), 2) rates.append({'market': market, 'rate': hits}) page = self.paginate_queryset(rates) if page is not None: serializer = self.get_serializer(page, many=True) return self.get_paginated_response(serializer.data) serializer = self.get_serializer(fixtures, many=True) return Response(serializer.data) return HttpResponseServerError class RateSerializer(serializers.Serializer): market = MarketSerializer(read_only=True, many=False) rate = serializers.DecimalField(max_digits=4, decimal_places=2) When I send a request to this endpoint I get the following back: "'RateViewSet' object has no attribute 'paginate_queryset'" which makes sense but I can't seem to figure out how I can paginate the result when the serializer has no model attached. I do have the following custom pagination class: class PaginationSerializer(pagination.PageNumberPagination): page_size_query_param = 'page_size' def get_paginated_response(self, data): return Response({ 'next': self.get_next_link(), 'previous': self.get_previous_link(), 'count': self.page.paginator.count, 'pages': self.page.paginator.num_pages, "page_size": settings.REST_FRAMEWORK["PAGE_SIZE"], 'results': data }) Who can help me out with this? -
In FactoryBoy, how do I setup my factory with an empty many-to-many member field?
I'm using Django 3 with Python 3.8. I have the following model ... class Coop(models.Model): objects = CoopManager() name = models.CharField(max_length=250, null=False) types = models.ManyToManyField(CoopType, blank=False) addresses = models.ManyToManyField(Address) enabled = models.BooleanField(default=True, null=False) phone = models.ForeignKey(ContactMethod, on_delete=models.CASCADE, null=True, related_name='contact_phone') email = models.ForeignKey(ContactMethod, on_delete=models.CASCADE, null=True, related_name='contact_email') web_site = models.TextField() I have created the following factory (using Factory boy) to attempt create the model in a test ... class CoopFactory(factory.DjangoModelFactory): """ Define Coop Factory """ class Meta: model = Coop name = "test model" enabled = True phone = factory.SubFactory(PhoneContactMethodFactory) email = factory.SubFactory(EmailContactMethodFactory) web_site = "http://www.hello.com" @factory.post_generation def addresses(self, create, extracted, **kwargs): if not create: # Simple build, do nothing. return if extracted: # A list of types were passed in, use them for address in extracted: self.addresses.add(address) else: address = AddressFactory() self.addresses.add( address ) @factory.post_generation def types(self, create, extracted, **kwargs): if not create: # Simple build, do nothing. return if extracted: # A list of types were passed in, use them for type in extracted: self.types.add(type) else: print("Creating type ...\n") type = CoopTypeFactory() self.types.add( type ) but I'm having trouble creating a factory with a many-to-many field (types) that is empty. I tried the below @pytest.mark.django_db def test_coop_create_with_no_types(self): """ Test customer … -
No Product matches the given query. Django
I created BlogPost class. Then created ListView BlogPostListView and blogpost_detail. When I clicked to post name I was redirected to the valid url. But I received error instead product_detail page: Page not found. http://127.0.0.1:8001/blog_post/1/ Raised by: blog.views.product_detail. No Product matches the given query. I can't understand why product_detail() called instead of blogpost_detail() Also error text said about Product (Product - is name of another model in my app. But I was calling BlogPost (not Product) I tried python manage.py flush # clear database Review my changes. But did not find calls of product_detail() I think that error deals with invalid urls My code views.py class BlogPostListView(ListView): model = BlogPost template_name = 'blog/post_list.html' page_kwarg = 'blog_post' context_object_name = 'blog_posts' def blogpost_detail(request, **kwargs): post = get_object_or_404(BlogPost, pk=kwargs["pk"]) return render(request, 'blog/post_detail.html', {'post': post}) urls.py urlpatterns = [ path('', HomePageView.as_view(), name='main_list'), path('search/', SearchResultsView.as_view(), name='search_results'), path('search_shop/<slug:slug>/', ProductListView.as_view(), name='search_shop'), path('search_shop_results/<slug:slug>/', ProductSearchResultsView.as_view(), name='search_shop_results'), path('<slug:slug>/<int:pk>/', views.product_detail, name='product_detail'), path('shops/', ShopListView.as_view(), name='shop_list'), path('contacts/', views.contacts, name='contacts'), path("robots.txt", TemplateView.as_view(template_name="blog/robots.txt", content_type="text/plain")), url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^favicon\.ico$', RedirectView.as_view(url='/static/favicon.ico'), name='favicon'), path('register/', views.RegisterFormView.as_view(), name="register"), path('login/', views.LoginFormView.as_view(), name="login"), path('logout/', views.LogoutView.as_view(), name="logout"), path('blog_posts/', views.BlogPostListView.as_view(), name='post_list'), path('blog_post/<int:pk>/', blogpost_detail, name='blogpost_detail'), ] post_list.html {% for post in blog_posts %} <a href="{% url 'blogpost_detail' post.pk %}" style="text-decoration: none;color:inherit;"> {{post.title}} </a> <p>{{post.prev_text}}</p> …