Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
in macos, why nginx unix socket not work?
I'm trying to build my own web server with django, nginx, uwsgi. I want to use unix socket. without unix socket, it works. using tcp port. but only unix socket not work. upstream django { #server 127.0.0.1:8001; server unix:///Users/name/Desktop/venv/projectname/projectname.sock; } this is part of .conf file. it won't work when i want to use unix socket. but this is work server 127.0.0.1:8001; #server unix:///Users/name/Desktop/venv/projectname/projectname.sock; what is happend? is there anything that i can use unix socket? -
How to Set up Comment System in Wagtail?
I have made a website in Wagtail, I have been working in Django for quite some time but still, I am not able to properly implement a Comment system on each blog page in Wagtail. Please help me find a direction to approach this problem. --models.py-- from wagtail.core.models import Page from wagtail.core.fields import RichTextField from modelcluster.fields import ParentalKey from wagtail.core.models import Orderable from wagtail.admin.edit_handlers import FieldPanel,PageChooserPanel from wagtail.images.edit_handlers import ImageChooserPanel class HomePage(Page): """Home Page Model""" templates="home/home_page.html" max_count = 1 --blog/models.py-- from django.db import models from wagtail.core.models import Page from wagtail.admin.edit_handlers import FieldPanel,RichTextField from wagtail.images.edit_handlers import ImageChooserPanel # Create your models here. # class Comments(models.Model): # texts=models.CharField(max_length=100) class BlogPage(Page): """Blog Page Class""" template="blog/blog_page.html" subtitle=models.CharField(max_length=100,blank=False,null=True) body_content=RichTextField(blank=False) author_name=models.CharField(max_length=100,blank=False,null=True) representative_image = models.ForeignKey( "wagtailimages.Image", null=True, blank=False, on_delete=models.SET_NULL, related_name="+" ) content_panels=Page.content_panels + [ FieldPanel("subtitle"), FieldPanel("body_content"), FieldPanel("author_name"), ImageChooserPanel("representative_image"), ] I am a beginner in wagtail. So please help me with the solution considering the same. Thank You. If the Solution to this problem is way hard for me to solve. It will be very helpful if there is a alternative solution to this. However this method will be preferable. -
How to run webpack in production or development with Django + React
I'm making a open-source project (this is repository) and I followed some tutorials to integrate Django with React because I never tried. Most of them just create a webpack.config.js inside the frontend, but looking at other projects on Github I see that they usually create a webpack.config.prod.js and a webpack.config.dev.js. So I set about creating two files because I think it's good practice. However, I don't know how to make sure that the right one (dev or prod) is running. My files: frontend/package.json "name": "frontend", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start:dev": "webpack-dev-server --config webpack.config.dev.js --port 3000", "clean:build": "rimraf ../static && mkdir ../static", "build": "webpack --config webpack.config.prod.js", "prebuild": "run-p clean:build", "postbuild": "rimraf ../static/index.html", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "Ale Rodríguez", "license": "ISC", "devDependencies": { "@babel/core": "^7.10.5", "@babel/node": "^7.10.5", "@babel/preset-env": "^7.10.4", "@babel/preset-react": "^7.10.4", "babel-eslint": "^10.1.0", "babel-loader": "^8.1.0", "babel-polyfill": "^6.26.0", "css-loader": "^3.6.0", "cssnano": "^4.1.10", "eslint": "^7.4.0", "eslint-loader": "^4.0.2", "eslint-plugin-import": "^2.22.0", "eslint-plugin-react": "^7.20.3", "eslint-plugin-react-hooks": "^4.0.8", "file-loader": "^6.0.0", "html-webpack-plugin": "^4.3.0", "mini-css-extract-plugin": "^0.9.0", "npm-run-all": "^4.1.5", "postcss-loader": "^3.0.0", "react": "^16.13.1", "react-dom": "^16.13.1", "redux-immutable-state-invariant": "^2.1.0", "rimraf": "^3.0.2", "sass": "^1.26.10", "sass-loader": "^9.0.2", "style-loader": "^1.2.1", "terser-brunch": "^4.0.0", "url-loader": "^4.1.0", "webpack": "^4.43.0", "webpack-cli": "^3.3.12", "webpack-dev-server": "^3.11.0" }, "dependencies": { "react-router": … -
Why is the user logged out after submitting a form in django?
When I submit a form as a logged in user, I am suddenly logged out, as shown below. I'm not able to embed images yet because I don't have 10 reputation. Here are the linked images: Submitting the Form After submitting the form views.index from django.db import IntegrityError from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render from django.urls import reverse from .models import User, Bid, Auction, Comment def index(request): if request.method == "POST": title = request.POST["title"] bid = int(request.POST["startingBid"]) category = request.POST["category"] image = request.POST["img"] description = request.POST["description"] listing = Auction(name=title, bid=bid,description=description,url=image, category=category) listing.save() listings = Auction.objects.all() #user.is_authenticated == True here return render(request, "auctions/index.html", { "listings": listings, "user": request.user.username, }) return render(request, "auctions/index.html") urls.py from . import views urlpatterns = [ path("home", views.index, name="index"), path("login", views.login_view, name="login"), path("logout", views.logout_view, name="logout"), path("register", views.register, name="register"), path("create", views.create, name="create"), ] index.html {% extends "auctions/layout.html" %} {% block body %} <h2>Active Listings</h2> {% if not user.is_authenticated %} Please login to see active listings. {% endif %} {% if user.is_authenticated %} {% for listing in listings %} <div class="card bg-light"> <div class="card-body"> <div class="row"> <div class="col-sm"> <img src="{% url 'listing.url' %}" class="img-fluid" alt="Listing image"> </div> <div class="col-sm"> <div class="row"> <div class="col"> <h2>{{ listing.name }}</h2> … -
Django Custom Filter Tag Returns Nothing
I want to filter the objects in a model using custom filter tag, but I got nothing. Here is the profile_tag.py in the templatetags folder. from django import template register = template.Library() from ..models import Profile @register.inclusion_tag('register/profile.html') def filter_profile(request): profile = Profile.objects.filter(user=request.user) return {'profile' : profile} I loaded the tag in the html file: {% load profile_tags %} Then I tried to print {{profile.user}} in different ways, but nothing is showing up. If I have an error, can you fix it or can you give me another solution to filter the model by the user. note: I don't want to use the Profile.objects.filter(user=request.user) in the views.py file. Thanks. -
can I use html , css and javascript as an interface for django webapp
I have a question which you can tell from the title : can I use html , css and javascript as an interface for django webapp ? , if I can how ? -
wsgi autoreload for django on windows subsystem for linux
I am trying to get WSGI to auto-reload after any changes to the code in my django project. Everything is set up and the website runs without errors however for some reason when I modify a python code file (e.g. views.py) the website simply doesn't update. I followed this article: https://modwsgi.readthedocs.io/en/develop/user-guides/reloading-source-code.html Which entails creating a monitor.py containing: # Apache WSGI monitor script for django #--------------------------------------- # monitors django app and reloads apache2 if any python files are changed # written for Python 3 # to use - import into wsgi.py import os import sys import time import signal import threading import atexit import queue _interval = 1.0 _times = {} _files = [] _running = False _queue = queue.Queue() _lock = threading.Lock() def _restart(path): _queue.put(True) prefix = 'monitor (pid=%d):' % os.getpid() print('%s Change detected to \'%s\'.' % (prefix, path), file=sys.stderr) print('%s Triggering process restart.' % prefix, file=sys.stderr) os.kill(os.getpid(), signal.SIGINT) def _modified(path): try: # If path doesn't denote a file and were previously # tracking it, then it has been removed or the file type # has changed so force a restart. If not previously # tracking the file then we can ignore it as probably # pseudo reference such as … -
django-admin.py does nothing when I execute it in visual studio
I'm typing django-admin.py startproject project in my vscode terminal on windows, but when I do it just flashes a screen then closes and the project isn't created. It asked me what to open with and I chose python, but the command doesn't do anything. I'm not getting errors either -
Debugging dockerized Django in VS Code results in error "Timed out waiting for launcher to connect"
I want to debug my Django application using a docker container in Visual Studio Code. Microsoft published a guide how to do that, which I followed step by step: https://code.visualstudio.com/docs/containers/quickstart-python But when I try to run the debugger, I get the following error message: Timed out waiting for launcher to connect Here is what I did step by step: I initialized a simple Django application using django-admin startproject helloworld In VS Code I opened the folder including the manage.py Opened Command Palette Ctrl + Shift + P, and then selected Docker: Add Docker Files to Workspace... Select Application Platform Python: Django Include Docker Compose files No Relative path to the app's entrypoint manage.py What ports does your app listen on? 8000 VS Codes then creates several files (see below). When I try to start the debugger (like in the guide), I get the following error message: The terminal doesn't show any error messages, but the commands executed: .vscode/launch.json: { "configurations": [ { "name": "Docker: Python - Django", "type": "docker", "request": "launch", "preLaunchTask": "docker-run: debug", "python": { "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "/app" } ], "projectType": "django" } } ] } .vscode/tasks.json: { "version": "2.0.0", "tasks": [ { "type": "docker-build", … -
Django admin: how to dynamically hide and show a field
I have made a model in my Django app as follows: class SomeModel(models.Model): field1 = models.TextField() author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) I've also registered this model in admin.py. Now when I use Django admin pages for adding a new SomeModel object, I see the author field as well. I want to disable this when adding a new object and want to set the current logged in user as the author. When the object has successfully been saved to the DB using the current logged in user as the author, I want to enable the edit or change options for "that" specific SomeModel object to be available to only the user that added it and of course, to the superusers. TLDR: Want a Django model to take the current user as a ForeignKey object of a custom Django model while preventing user1 from editing/deleting the object added by user2. -
How to display html content of an EmailMultiAlternatives mail object
When sending EmailMultiAlternaitves: from django.core.mail import EmailMultiAlternatives subject, from_email, to = 'hello', 'from@example.com', 'to@example.com' text_content = 'This is an important message.' html_content = '<p>This is an <strong>important</strong> message.</p>' msg = EmailMultiAlternatives(subject, text_content, from_email, [to]) msg.attach_alternative(html_content, "text/html") msg.send() How do I display the "text/html" alternative when calling the object? E.g. msg.html_content -
Django open pdf on certain page number
I am trying to create a PDF analysis web app and I am stuck. I want to allow the user to open a certain page of the pdf that have over 300 pages in it. So, can anyone tell me how to use Django to open the pdf in a new tab on a specific page? -
Listing my tasks under my projects in Django
I am new to Django (and programming in general) and could use help with something possible very simple but I can't figure it out. Currently I am working on a Project Manager app in Django for my portfolio. But I am stuck with creating list of the different project and their tasks. I would like to create something like this: Project_1 task item 1 (of project_1) task item 2 (of project_1) Project_2 task item 1 (of project_2) task item 2 (of project_2) Project_3 task item 1 (of project_3) task item 2 (of project_3) task item 3 (of project_3) Currently I have the following: view.py: def project(request): """ Show all Projects""" projects = Project.objects.order_by('date_added') project = Project.objects.get(id=1) tasks = project.task_set.order_by('date_added') context = {'projects': projects, 'tasks': tasks} return render(request, 'tasks/project.html', context) project.html {% extends "tasks/base.html" %} {% block content %} <p>Projects</p> <ul> {% for project in projects %} <li>{{project}}</li> <ul> {% for task in tasks %} <li>{{task}}</li> {% empty %} <li>No tasks added </li> {% endfor %} </ul> {% empty %} <li>No projects have been added yet.</li> {% endfor %} </ul> {% endblock content %} models.py class Project(models.Model): """A project the user is working on.""" text = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) def … -
django select_related() and django-mptt. How to fetch all the child pages at once
I'm trying to fetch all the child pages of the parent page. The Page model looks like this: class Page(MPTTModel): title = models.CharField(max_length=255) slug = models.SlugField(max_length=255, blank=True) # changing to CharField from SlugField markdown = models.TextField() parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children') The code for fetch all the child pages looks like this: pages = page.get_siblings(include_self=True) The problem is that the above code hits the database for each page. So If there are 50, it would result in 50 queries. I have tried to solve the problem using select_related() but to no avail. Here is what I tried. pages = page.get_siblings(include_self=True).select_related() and this pages = page.get_siblings(include_self=True).select_related('parent') -
Set request.session before we
I am now coding along with a course to build a eCommerce website. When it comes to the cart part, it talked about the session. Then I have below question: In below code, why do we have to write this " request.session['cart_id'] = '12' "? I can't see the point to set up the cart_id before we try to see if it exists. If we set up in advance, it won't be None, then why do we need to do the if/else loop? I just can't really realize what's the target of this part please anyone enlighten! Thank you really so much! def cart_create(user=None): cart_obj = Cart.objects.create(user=None) return cart_obj def cart_home(request): request.session['cart_id'] = '12' cart_id = request.session.get("cart_id",None) qs = Cart.objects.filter(id=cart_id) if qs.count()==1: cart_obj = qs.first() print('Card ID exist') print(request.session.cart_id) else: cart_obj = cart_create() request.session['cart_id'] = cart_obj.id print('New Cart ID created') print(request.session.cart_id) return render(request,"carts/home.html",{}) -
Memory Error when installing torch from requirements.txt
I am trying to deploy my Django app on AWS. It works fine locally, and it works fine when I remove the torch from requirements.txt and comment out the code that depends on it. However, when trying to deploy the full app, I run into a memory error trying to install torch. Here is a link to my requirements.txt file and the eb logs. I thought upgrading from a T2.micro instance to a T2.small instance would do the trick, but it did not. Anyone have advice where I should go from here? -
Django int() argument must be a string, a bytes-like object or a number, not 'OrderItem'
I am coding for a online store, and the views cannot get the parameter. Where did I go wrong? Models.py has 3 models, the product model, order model and order_item model for creating order and save to cart: class Product(models.Model): product_name = models.CharField(max_length=200) price = models.DecimalField(decimal_places=2, max_digits=10, blank=True) created = models.DateTimeField(auto_now=True) img = models.ImageField(upload_to='product', height_field=None, width_field=None, max_length=100, default='https://res.cloudinary.com/hsvaxmvxo/image/upload/v1594136644/product/coming_soon_uqxysa.jpg') description = models.TextField(blank=True, null=True) Hot = models.BooleanField(default=False) type = models.CharField( max_length=2, choices=PRODUCT_CHOICES, default=DECORATION, ) status = models.IntegerField(choices=STATUS, default=0) slug = models.SlugField(max_length=200, unique=True) def __str__(self): return self.product_name def get_absolute_url(self): return f"{self.slug}" def get_add_to_cart_url(self): return reverse("add_to_cart", kwargs={'slug':self.slug}) def remove_from_cart_url(self): return reverse("remove_from_cart", kwargs={'slug':self.slug}) class OrderItem(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True) item = models.ForeignKey(Product, on_delete=models.CASCADE) quantity = models.IntegerField(default=1) ordered = models.BooleanField(default=False) def __str__(self): return f"{self.quantity} of {self.item.product_name}" def get_total_price(self): return self.quantity * self.item.price class Order(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True) items = models.ManyToManyField(OrderItem) start_date = models.DateTimeField(auto_now_add=True) ordered_date = models.DateTimeField() ordered = models.BooleanField(default=False) def __str__(self): return self.user.username The add to cart function in views.py: def add_to_cart(request, slug): item = get_object_or_404(Product, slug=slug) order_items = OrderItem.objects.get_or_create( item=item, user=request.user, ordered=False ) 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_items.quantity += 1 order_items.save() else: order.items.add(order_items) return redirect('product_detail', slug=item.slug) else: ordered_date = timezone.now() order = Order.objects.create(user=request.user, … -
PGAdmin4 not creating table after postgreSQL migrate
I am new to Django and trying to migrate my PostgreSQL query to PGAdmin4. Everything is working fine - the makemigrations command, the sqlmigrate command, and even the migrate command is not producing any errors. But I can't see my table in PGAdmin4 on refreshing. My settings.py file's Database part is as DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'demo', 'USER': 'postgres', 'PASSWORD': 'password', 'HOST': 'localhost' } } migrate is creating no errors as Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, travel Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying admin.0003_logentry_add_action_flag_choices... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying auth.0010_alter_group_name_max_length... OK Applying auth.0011_update_proxy_permissions... OK Applying sessions.0001_initial... OK Applying travel.0001_initial... OK The user has all the privileges, my \du command is resulting in List of roles Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- Swati | Superuser, Create role, Create DB | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} swati | Superuser | {} travel | | {} Any help shall be appreciated. -
pythonanywhere not displaying css right
I am having difficulties with python anywhere where my css is not loading or not laoding correctly any assistance What it looks like on localhost What it looks like On pythonanywhere. http://bcalitz.pythonanywhere.com/ [ Static Files: Settings.py STATIC_URL = '/static/' STATIC_ROOT = '/home/BCalitz/Blog/static' -
Django: not logout when web browser tab is closed even with settings SESSION_EXPIRE_AT_BROWSER_CLOSE = True
I did not manage logout behavior in my django project as you can see below, I want user to be force to authentified every time he quit the web application or after 15 minutes of inactivity inactivity behavior works but not when web browser tab is close settings.py # paramètres utilisés pour middleware personalisé AutoLogout en cours d'écriture TIME = 15*60 # 15 minutes : 15*60 or your time in seconds SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' SESSION_COOKIE_AGE = TIME # change expired session SESSION_IDLE_TIMEOUT = TIME # logout SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_SAVE_EVERY_REQUEST = True -
Storing authentication among apps
Likely quite a simple problem and I assume I am not understanding the routing of Django correctly. I have a project with 2 apps: app1 is the django Graph tutorial found here This should deal with all my authentication as it needs to use Azure AD as the app will be locked outside our tenant users app2 is the first app to add functionality for the users, at present I simply have it select 40 rows from a table held in PostGres. This feature works and displays the results on the page, however, I shouldn't be able to see it if I am not logged in. When I include the LoginRequiredMixin to my CBV like class ModuleListView(LoginRequiredMixin,ListView): paginate_by = 10 model = Module template_name = 'cpd/modules.html' context_object_name = 'modules' ordering = ['-date_due'] def get_context(self): context = initialize_context(self) return context When visited I get the following Trace Page not found (404) Request Method: GET Request URL: http://localhost:8000/accounts/login/?next=/cpd/modules/ Using the URLconf defined in ops_team_site.urls, Django tried these URL patterns, in this order: [name='home'] about/ [name='about'] login/ [name='login'] signin [name='signin'] signout [name='signout'] callback [name='callback'] cpd/ branches/ admin/ The current path, accounts/login/, didn't match any of these. I understand enough to know it is … -
How to communicate between C++ and django channels?
Iam doing django project using django channels. In my project I need to integrate and communicate between C++ code. In between i have to send some values to C++ I checked without django channels and it is working fine,Can any one help me out how can I implement below code in consumers.py of django channels proc = subprocess.Popen(["/home/dev/integrated_module/front-face-camera/rest_project/CameraApplication/MakoContinuousFrameGrabberConsoleApplication" + ' ' + team_name + ' ' + user_name + ' ' + media_path],shell=True,preexec_fn=os.setsid,stdout=subprocess.PIPE,stderr=subprocess.PIPE) -
Django make migrations and migrate without restarting the server
I know that people in the past have asked this question a lot and this question might be considered a duplicate but I never really found what I've been looking for. I want to setup my project in such a way that my client is able to add, remove or modify table columns and or drop and create tables themselves in the database right from the Django app itself. I understand that when we modify the models in Django, we need to make migrations and migrate then restart the server use those migrations. For most that would be alright but I'm looking for zero downtime. I can use Django channels to transmit information to the view they're on that the server is restarting and for them to please but let's say someone gets impatient or accidentally reloads the page while the server is restarting, they'll be taken to a nginx error page that shows that the server is down and that's what I want to avoid. I was brain storming ideas to basically not affect the front-end while the back-end is restarting. Obviously, the easy way out would be a way to use the newly made migrations without restarting the … -
How to Implement Breadcrumbs for Categories in Django
I am trying to implement breadcrumbs from https://djangopy.org/how-to/how-to-implement-categories-in-django/ tutorial. I have created one parent category and three nested sub categories under the parent category in single hierarchy like Country -> State -> City -> Area. Problem no. 1 The second last tail of the breadcrumbs hierarchy City when clicked is throwing 404 not found. Problem no. 2 Also I can't see the '->' separator in frontend which is although visible in admin panel. Problem no. 3 The last category breadcrumb Area when clicked should show Article linked with Area which has no further category nesting. Please help me. Note- I am using Python 3.8 and Django 3.0.8 Here is my models.py class Category(models.Model): name = models.CharField(max_length=200) slug = models.SlugField() parent = models.ForeignKey('self',blank=True, null=True ,related_name='children', on_delete=models.PROTECT) class Meta: #enforcing that there can not be two categories under a parent with same slug # __str__ method elaborated later in post. use __unicode__ in place of # __str__ if you are using python 2 unique_together = ('slug', 'parent',) verbose_name_plural = "categories" def __str__(self): full_path = [self.name] k = self.parent while k is not None: full_path.append(k.name) k = k.parent return ' -> '.join(full_path[::-1]) class Article(models.Model): author = models.ForeignKey("auth.User",on_delete = models.CASCADE, default=1) title = models.CharField(max_length … -
my question is straightforward. i want to display number of views for a specific post for specific user in a table using django
i want to display number of views in a table for a specific post. I already have the data stored in db. it seems that print statement print('count', context['count_view']) is working inside get_context_data but it is not working as expected in the template. Anyone helpenter image description here models.py class ObjectViewed(models.Model): user = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE) ip_address = models.CharField(max_length=220, blank=True, null=True) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) # User, Blog, or any other models object_id = models.PositiveIntegerField() # User id, Blog id, or any other models id content_object = GenericForeignKey('content_type', 'object_id') timestamp = models.DateTimeField(auto_now_add=True) views.py def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs) post=Post.objects.filter(author=self.request.user) c_type = ContentType.objects.get_for_model(Post) for p in post: context['count_view'] = ObjectViewed.objects.filter(content_type=c_type, object_id=p.id).count() print('count',context['count_view']) return context postList.html {% for post in posts %} {% if post.status == 'Draft' %} {% else %} <tr> <th scope="row">{{ forloop.counter }}</th> <td><a style="color:blue" href="{% url 'edmin:post_detail_view' pk=post.pk %}">{{ post.title }}</a></td> <td>{{ post.banner_title }}</td> <td>{{ post.created }}</td> <td>{{ count_view }}</td> <td>{{ post.status }}</td> <td><a href="{% url 'edmin:post_update_view' pk=post.pk %}" class="btn btn-outline-dark btn-sm">Edit</a></td> <td><a href="" class="btn btn-outline-danger btn-sm">Delete</a></td> </tr> {% endif %} {% endfor %}