Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django linking pages that display elements from a model
I am trying to create webpages that link to each other with Django. I created a model with several elements: title, summary, description01, description02. On the first page, the home page, I display the title and summary, this seems to work fine. However, I want a link after the title and summary that links to a page with description01 and then a link to a page with description02. This is where I am having issues. I created a file for description01.html, I created a function for it in views.py, a path in urls.py, and added a link to home. When I try to open the home page, I get error: NoReverseMatch at / Reverse for 'description01' with arguments '(3,)' not found. 1 pattern(s) tried: ['articles/$'] Code and Screenshots: home.html <h1>home</h1> {% for outline in outline %} {{ outline.title }}<br> {{ outline.summary }}<br> <a href="{% url 'description01' outline.id %}">LInk</a> {% endfor %} viwes.py from django.shortcuts import render from .models import Outline def home(request): outline = Outline.objects.all() return render(request, 'articles/home.html', {'outline': outline}) def description01(request): outline = Outline.description01 return render(request, 'articles/description01.html', {'outline': outline}) urls.py from django.contrib import admin from django.urls import path, include from django.conf.urls.static import static from django.conf import settings from articles … -
How to test save Django model method with pytest?
What I have I've overwritten the save method of my User model to be able to change the first and last name with the first letter in capital. User model from django.contrib.auth.models import AbstractBaseUser class User(AbstractBaseUser): name = models.CharField( verbose_name=_("Name"), max_length=30, ) last_name = models.CharField( verbose_name=_("Last Name"), max_length=50, ) # ...other fields def save(self, *args: Any, **kwargs: Any) -> None: """Always have the name and last_name first letter in uppercase""" for field_name in ["name", "last_name"]: val = getattr(self, field_name, False) if val: setattr( self, field_name, string.capwords(val.lower()), ) super(User, self).save(*args, **kwargs) I'm using pytest and factory_boy to test my models. First I've created a Factory to create users: Factory from factory import DjangoModelFactory, Faker class UserFactory(DjangoModelFactory): """Define User Factory""" name = Faker("first_name", locale="es") last_names = Faker("last_name", locale="es") # ...other fields class Meta: model = get_user_model() I make my factory available for all my tests by putting it in a fixture in conftest.py: from app_name.users.tests.factories import UserFactory @pytest.fixture def user() -> User: """Create user for testing.""" return UserFactory() The problem I want to test my save method but when I try to access my user's name or last_name fields in the test it already comes with the first letter capitalized. I would … -
How to get extra data with django's orm?
How can I get extra data when returning query results, I want to know if the currently logged in user has liked the post or not, I think the solution would be something like this: return Post.objects.all().annotate(like_count=Count('likers'), liked=(len(Like.objects.filter(user=info.context.user, post=Post)) > 0)).order_by('-like_count') but I couldn't get it to work -
Django is not updating my model objects instead they created new
So this is my simple function which is working fine. Basically it's extracting data from this site. def mega(): pageNumber = 1 nextPage = True proList = [] while nextPage: url = "http://www.mega.pk/mobiles/{}/".format(pageNumber) response = get(url) soup = BeautifulSoup(response.text, features="lxml") ul = soup.find('ul', class_='item_grid list-inline clearfix') li = ul.find_all('li', class_='col-xs-6') if not li: break for link in li: if link.find("div", class_="was"): title = link.find(id="lap_name_div").text.replace("\n", "") data = link.find("div", class_="cat_price").text.replace( "\n", "").replace("\t", "").replace(" ", "") lists = data.split("-") if len(lists) > 2: price = lists[1].replace("PKR", "") + "-PKR" else: price = data price = int(price.replace(",", "").replace( '-', "").replace("PKR", "")) productUrl = link.find("a")['href'] image = link.find("img")['data-original'] pro = Product(title=title, price=price, productUrl=productUrl,imageUrl=image, site="mega.pk") proList.append(pro) pageNumber = pageNumber + 1 return proList But following is my view in which when i try to assign item.price = product.price. then instead of updating it's creating new instance. def scraper(request): products = mega() proList = Product.objects.all() for product in products: for item in proList: if product.title == item.title and product.price == item.price: break elif product.title == item.title and product.price != item.price: notify = Notification(user = request.user, changeMessage="Price updated") notify.save() item.price = product.price break return redirect("home") Like this enter image description here -
I couldn't figure out what is happening
User' object has no attribute 'profile' Request Method: POST Request URL: http://127.0.0.1:8000/signup/ Django Version: 3.0 Exception Type: AttributeError Exception Value: 'User' object has no attribute 'profile' Exception Location: E:\accounts\core\tokens.py in _make_hash_value, line 9 Python Executable: C:\Users\Saeed.virtualenvs\accounts-AiaIdtSq\Scripts\python.exe Python Version: 3.8.3 Python Path: ['E:\accounts', 'C:\Users\Saeed\.virtualenvs\accounts-AiaIdtSq\Scripts\python38.zip', 'C:\Python38\DLLs', 'C:\Python38\lib', 'C:\Python38', 'C:\Users\Saeed\.virtualenvs\accounts-AiaIdtSq', 'C:\Users\Saeed\.virtualenvs\accounts-AiaIdtSq\lib\site-packages'] Server time: Tue, 11 Aug 2020 17:32:03 +0000 How do I solve this I am using https://simpleisbetterthancomplex.com/tutorial/2017/02/18/how-to-create-user-sign-up-view.html#sign-up-with-confirmation-mail code. -
How to use Celery 4.4.6 crontab schedules within a Django project
I just upgraded from Celery 3.17 to 4.4.6. Unfortunately, I am experiencing some problems getting the crontab tasks to get picked up by the beat again. I think something has fundamentally changed but not sure what. The docs aren't easy to dissect... I used to put all my recurring tasks in a method and then point in the projects settings.py to this schedule, like so: CELERYBEAT_SCHEDULE = CelerySchedule.celery_schedule The CelerySchedule looks something like: from celery.schedules import crontab """ Check here: https://docs.celeryproject.org/en/stable/reference/celery.schedules.html """ class CelerySchedule(): celery_schedule_match = { ############# ADMIN ############# 'upload-wee': {'task': 'exports.tasks.send_requests', 'schedule': crontab(hour=10, minute=30)}, 'get_wee' :{'task': 'imports.tasks.get_data', 'schedule': crontab(hour=8, minute=30)}, But that does not seem to get read anymore? Why is that and how can I fix it? -
Django app is not loading and giving IsADirectoryError error
I am new to django and python. I used a django theme to build a site. Djanog, NGINX, Gunicorn is working properly. Issue is when I try to load the page using app url, it gives me IsADirectoryError. Below is all the infomation. Base Directory drwxr-xr-x 6 rwb root 4096 Jul 30 15:43 netdash_venv/ drwxr-xr-x 3 rwb root 4096 Aug 5 16:12 projects/core netdash_venv is the python virtual folder and all the projects files are in core folder under projects. :/opt/netdash/projects$ ll core total 76 drwxrwxr-x 7 rwb rwb 4096 Aug 11 11:28 ./ drwxr-xr-x 3 rwb root 4096 Aug 5 16:12 ../ drwxrwxr-x 4 rwb rwb 4096 Aug 10 16:30 app/ drwxrwxr-x 4 rwb rwb 4096 Aug 5 16:31 authentication/ drwxrwxr-x 5 rwb rwb 4096 Aug 5 16:17 core/ srwxrwxrwx 1 rwb www-data 0 Aug 11 11:28 core.sock= -rw-r--r-- 1 rwb rwb 40960 Aug 5 16:39 db.sqlite3 -rwxr-xr-x 1 rwb rwb 624 Aug 5 15:36 manage.py* drwxrwxr-x 4 rwb rwb 4096 Aug 10 16:00 sei/ drwxrwxr-x 4 rwb rwb 4096 Aug 5 15:48 staticfiles/ app and authentication app handles the authentication/login/logout parts. I am having issues launching sei app from the sidebar url. sidebar.html file is in the projects/core/core/templates/ … -
I m getting ctype error when I am converting pdf to text or text to audio file with pyttsx3 module with getproperty (voices)
I am getting the below error, when I am converting pdf to text or text to audio file with pyttsx3 module with getproperty (voices) File "C:\Users\Sanjay\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 88, in return [self._toVoice(attr) for attr in self._tts.GetVoices()] File "C:\Users\Sanjay\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 77, in _toVoice return Voice(attr.Id, attr.GetDescription()) _ctypes.COMError: (-2147200966, None, (None, None, None, 0, None)) Here is my code serializer_class = DictionarySerializers parser_classes = (FileUploadParser, MultiPartParser) def post(self, request, *args, **kwargs): file=fitz.open('dictpdf.pdf') pages=len(file) print(pages) for pic in range(pages): for image in file.getPageImageList(pic): j=0 imageref=image[0] pic_1=fitz.Pixmap(file,imageref) final_pic=fitz.Pixmap(fitz.csRGB,pic_1) # final_pic.writePNG(str(datetime.datetime.now())+".png") final_pic.writePNG(str(pic) +"_" +str(j) + ".png") pic = None final_pic = None j=j + 1 pdf = open('dictpdf.pdf', 'rb') pdf_read_data = PyPDF2.PdfFileReader(pdf) pages = pdf_read_data.numPages print("pages", pages) pagenum = pdf_read_data.getPage(0) print("pagenum", pagenum) text_data = pagenum.extractText() file1 = open("dictionary.txt", "a") file1.writelines(text_data) print("file", file1) file1.close() file = open("dictionary.txt", 'r') text = file.read() print("new_text", text) # return Response("hello") word_list = text.split() table = str.maketrans('', '', string.punctuation) stripped = [w.translate(table) for w in word_list] engine = pyttsx3.init() voices = engine.getProperty('voices') engine.setProperty('voice', voices.id) engine.setProperty('rate', 120) engine.setProperty('volume', 1) message=text_data engine.say("Hello, This is text to audio") engine.save_to_file(message, "+pdftotext ".mp3) engine.runAndWait() engine.stop() return Response(status=status.HTTP_200_OK) -
django.urls.exceptions.NoReverseMatch: Reverse for '/' not found. '/' is not a valid view function or pattern name
I am trying to follow Python TDD O'Reilly. I know the django version they've used is an old one, however, even after making all possible amends, I am getting this error. My urls.py files: superlist.urls.py from django.contrib import admin from django.urls import path, include, re_path from django.conf.urls import url urlpatterns = [ path('admin/', admin.site.urls), path('',include('lists.urls')), ] lists.urls.py urlpatterns = [ path('/', home_page) ] lists.views.py from django.shortcuts import (render, HttpResponse) from rest_framework.decorators import api_view # Create your views here. @api_view() def home_page(request): return HttpResponse('Response') lists.tests.py from django.test import TestCase from .views import home_page # class HomePageTest(TestCase): def test_root_url_resolves_to_home_page_view(self): found = reverse('/') self.assertEqual(found.func, home_page) How could I solve this? I've tried to search about this for long, with no avail. -
How to resolve NoReverseMatch in Django
guys, I am having this error when I try to login to my Django web app NoReverseMatch at /login/ Reverse for 'blog-home' not found. 'blog-home' is not a valid view function or pattern name. Here are the app urls.py codes from django.urls import path from .views import (PostListView, PostCreateView, PostUpdateView, PostDetailView, PostDeleteView, UserPostListView) from . import views app_name = 'posts' urlpatterns = [ path('', PostListView.as_view(), name="blog-home"), path('user/<str:username>/', UserPostListView.as_view(), name="user-posts"), path('post/<int:pk>/', PostDetailView.as_view(), name="post-detail"), path('post/new/', PostCreateView.as_view(), name="post-create"), path('post/<int:pk>/update', PostUpdateView.as_view(), name="post-update"), path('post/<int:pk>/delete', PostDeleteView.as_view(), name="post-delete"), path('about/', views.about, name="blog-about"), ] Here also is the login template code in a separate app called users {% extends "blog/base.html" %} {% load crispy_forms_tags %} {% block content %} <div class="content-section"> <form method="POST"> {% csrf_token %} <fieldset class="form-group"> <legend class="border-bottom mb-4">Log In</legend> {{ form|crispy }} </fieldset> <div class="form-group"> <button class="btn btn-outline-info" type="submit">Login</button> <small class="text-muted ml-2"> <a href="{% url 'password_reset' %}">Forgot Password?</a> </small> </div> </form> <div class="border-top pt-3"> <small class="text-muted"> Need An Account? <a class="ml-2" href="{% url 'register' %}">Sign Up</a> </small> </div> </div> {% endblock %} Below is the project urls.py from django.contrib import admin from django.contrib.auth import views as auth_views from django.urls import path, include from django.conf import settings from django.conf.urls.static import static from users import views as user_view … -
Django template "pluralize" filter causes raw text out put
I'm going through the Django tutorial right now (https://docs.djangoproject.com/en/3.0/intro/tutorial04/) and encountering this little problem with pluralize. With this code: {{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes | pluralize }} The pluralize filter isn’t doing anything, The template returns something like this: Just hacking again -- 2 vote{{ votes | pluralize }} // just the template code itself. as if it was just ignoring the {{ }} indicators. If I take pluralize out, then the choice.votes variable will display (in this case) a 2, as expected, just like it does with {{ choice.votes }}. The addition of | pluralize seems to break the interpolation, just in that area. I don't see any sort of import or the like that I need to add; I even copy and pasted to ensure no spelling errors, nor do I see anything in the console.log. Any insight into what might be (not) happening here? -
Which web-based framework should I learn?
I understand that the most promenient players here are the MERN stack and Django, I am slightly confused as to where I should start with. I am familiar with python and react, so I can take up anyone of them. Could you also please specify a reason for your recommendation. Thank you -
DJANGO BITCOIN ACCOUNT TOP UP
i am creating a django web application where users will be topping up there accounts with credit cards and bitcoin, does anyone know how i can implement a way for users to top up there accounts with bitcoin, i would rather handle some of it myself than give all the power to a 3rd party such as coinbase -
How to implement dynamic multi-level filtering in Django
I am not sure if I'm using a correct term in the title, I read about faceted search but it involves using ElasticSearch and I want it to be as simple as possible. So basically what I want to do is to be able to filter a list of objects that contain 'City' and 'Language'. If I select a specific Language, then I would like to see a list of objects with all Cities with this Language. And then, if I want to, I would like to further filter this list with specific City. Or vice-versa - first City and then Language. So basically a search where you drill down with search criteria. So here is what I have done so far: forms.py class SearchForm(forms.Form): city = forms.ModelChoiceField(queryset=City.objects.all(), to_field_name='slug', required=False, label='City') language = forms.ModelChoiceField(queryset=Language.objects.all(), to_field_name='slug', required=False, label='Language') views.py class HomePageView(FormView, ListView): model = Vacancy template_name = 'home.html' form_class = SearchForm context_object_name = 'vacancies' def get_queryset(self): city = self.request.GET.get('city') language = self.request.GET.get('language') if city or language: _filter = {} if city: _filter['city__slug'] = city if language: _filter['language__slug'] = language context = Vacancy.objects.filter(**_filter) else: context = Vacancy.objects.all() return context home.html {% block content %} <h1>List of vacancies</h1> {% for vacancy in vacancies … -
How can I automate the creation of django model instances from a script?
I'm fairly new to Django and recently created a website to group and display COVID-19 data in my home country. I am recording daily new cases, deaths, and recoveries by city using a CaseDeclaration model: class CaseDeclaration(models.Model): city = models.ForeignKey(City, on_delete=models.CASCADE) date = models.DateField(default=lambda: CaseDeclaration.latest_date()) new_cases = models.IntegerField(default=0) new_deaths = models.IntegerField(default=0) new_recoveries = models.IntegerField(default=0) source = models.URLField(max_length=200, blank=True) It is working properly but I am now writing a script that will automate the process of creating CaseDeclaration objects off of publications made by a local news outlet on Facebook. The script is in a text_extractor.py file next to models.py and views.py. At this point it takes a txt file and extracts the data into a dictionary like so (keys are the city names): >>> print(extract_data()) {'non répertorié': {'new_deaths': 6, 'new_recoveries': 344}, 'Antananarivo': {'new_cases': 388}, 'Ambatondrazaka': {'new_cases': 13}, 'Toliara': {'new_cases': 9}, 'Fianarantsoa': {'new_cases': 7}, 'Mahajanga': {'new_cases': 6}, 'Ambositra': {'new_cases': 3}, 'Miarinarivo': {'new_cases': 2}, 'Toamasina': {'new_cases': 2}, 'Sambava': {'new_cases': 1}} And the date extract_date() returns the format 8-11-2020 as a str. I now need a way to take that data and create model instances for each city, all without me having to use the python shell or admin panel. And finally program … -
Is there a way we can create a custom PasswordResetView in Django?
Been stuck to this problem for quite a long time now. I was wondering how I can create a custom PasswordResetView in Django. I know there is a built inc cbv to reset password but I want to create my own password reset view. If possible someone please help. -
Is it possible to use the django-debug-toolbar with token authentication?
I am developing an application with the Django REST framework. I have implemented an authentication system to manage model permission based on tokens, but that block my access to endpoints on the web. The django-debug-toolbar can only be accessed on the web navigator. Is there any possibility to use it still? -
Django on Mac with server on Win 10 Parallels Desktop configuration
I need to connect my Django app to a DB in a VW whit Parallels Desktop Now, I configured pyodbc and I get a response in terminal: (base) myname@MBP-mypc ~ % tsql -S myserver -U username -P password locale is "it_IT.UTF-8" locale charset is "UTF-8" using default charset "UTF-8" 1> In settings.py I have that configuration: DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'MYDB', 'USER': 'username', 'PASSWORD': 'password', 'HOST': 'xx.xx.xx.xx', 'PORT': '1433', 'OPTIONS': { 'driver': 'SQL Server Native Client 11.0', } } } but I recive that error: django.db.utils.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server Native Client 11.0' : file not found (0) (SQLDriverConnect)") can someone help me plz? TY -
Not able to fetch the object from context correctly in django project
I am working on a basic ecommerce django website. I have a view for my category page which shows all the products and also I have functionality in my template that if the product is already in cart then perform the respective code. This is the HtmL part that I am having problem in: {% if product.id in list_cart %} <div class="btn-group"> <button class="btnabc btnabc-primary">{{list_cart.size}}</button> </div> {% else %} <div class="btn-group"> <select class="selection-2 border" name="size" required id="sizebox"> {% for t in product.size.all %} <option value="{{t}}" id="{{t}}">{{t}}</option> {% endfor %} </select> </div> {% endif %} This is my views.py: def category(request): context = { 'types' : Category.objects.all(), 'prods': Product.objects.filter(), 'cartItems':[], } if request.user.is_authenticated: customer=request.user.customer order, created=Order.objects.get_or_create(customer=customer, complete=False) cartItems=order.get_cart_items, items=order.orderitem_set.all() context['list_cart'] = order.orderitem_set.values_list('product__id', flat=True) return render(request,"category.html",context) When a person selects a size and adds it to cart till there it works fine but after that instead of showing the selectbox for sizes I want to show the size that was selected as tried in my code.The orderitem model has a size field: class OrderItem(models.Model): product=models.ForeignKey(Product,on_delete=models.SET_NULL,null=True) order=models.ForeignKey(Order,on_delete=models.SET_NULL,null=True) quantity=models.IntegerField(default=0,null=True,blank=False) size=models.ForeignKey(Siz,on_delete=models.SET_NULL,null=True) But it doesnt show the size instead shows an empty button.The {% if product.id in list_cart%} works correctly in showing the remove from cart … -
Error code H10 while Deploying Django code to Heroku
I'm having a lot of trouble in deploying my Django app to Heroku. I'm new to both Django and Heroku, and I'm not able to understand what the traceback is telling me. I keep getting the error code "h10" in heroku logs traceback. I believe gunicorn isn't starting properly, but I don't know the solution. I've also searched this issue for hours, and rewriting the Procfile, reinstalling gunicorn, virtualenv, django-heroku, etc hasn't worked for me. I'm not able to see what my error is. When I run heroku logs --tail i see: (--sliced to view gunicorn issue--) 2020-08-11T15:30:05.149176+00:00 app[web.1]: [2020-08-11 15:30:05 +0000] [4] [INFO] Starting gunicorn 20.0.4 2020-08-11T15:30:05.149958+00:00 app[web.1]: [2020-08-11 15:30:05 +0000] [4] [DEBUG] Arbiter booted 2020-08-11T15:30:05.150076+00:00 app[web.1]: [2020-08-11 15:30:05 +0000] [4] [INFO] Listening at: http://0.0.0.0:46142 (4) 2020-08-11T15:30:05.150185+00:00 app[web.1]: [2020-08-11 15:30:05 +0000] [4] [INFO] Using worker: sync 2020-08-11T15:30:05.155860+00:00 app[web.1]: [2020-08-11 15:30:05 +0000] [10] [INFO] Booting worker with pid: 10 2020-08-11T15:30:05.164169+00:00 app[web.1]: [2020-08-11 15:30:05 +0000] [10] [ERROR] Exception in worker process 2020-08-11T15:30:05.164171+00:00 app[web.1]: Traceback (most recent call last): 2020-08-11T15:30:05.164172+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 2020-08-11T15:30:05.164172+00:00 app[web.1]: worker.init_process() 2020-08-11T15:30:05.164173+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 119, in init_process 2020-08-11T15:30:05.164174+00:00 app[web.1]: self.load_wsgi() 2020-08-11T15:30:05.164174+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi 2020-08-11T15:30:05.164174+00:00 app[web.1]: self.wsgi … -
Is this the correct way to add post to favourites using django rest framework?
I have a doubt regarding django rest framework for this function. I have done it the same way I do in a normal django website. can someone please check and tell me whether this is the right way to do it using django rest framework so that, this can be used to connect to a front end later. This is the function. def favourite_post_api(request, slug): post = get_object_or_404(Post, slug=slug) user = request.user serializer = PostSerializer(post) if user in post.favourite.all(): post.favourite.remove(user) return Response("Removed from favourites.", status=status.HTTP_201_CREATED) else: post.favourite.add(user) return Response("Added to favourites.", status=status.HTTP_201_CREATED) Thanks -
django ajax: User matching query does not exist
So I made a django ajax that everytime there is a new message the notification object that I add to my user models will be +1, the problem is that I dont know why is giving me this error: django.contrib.auth.models.User.DoesNotExist: User matching query does not exist. here is my code: views.py: def count_notification(request): user = request.user obj = user.profile.objects.get(pk=1) obj.notifications = obj.notifications +1 obj.save() response_data = {'success':1} return HttpResponse(json.dumps(response_data), content_type="application/json") urls.py: path('messages/notification/', count_notification) html file js // Add the notification val $.get('notification/') models.py: class ProfileImage(models.Model): """ Profile model """ user = models.OneToOneField( verbose_name=_('User'), to=settings.AUTH_USER_MODEL, related_name='profile', on_delete=models.CASCADE ) avatar = models.ImageField(upload_to='profile_image') notifications = models.FloatField(default='0') thank you for the help -
Django website getting down after 4-5 hour interval in namecheap shared hosting
i am struggling with a django application in namecheap shared hosting. After 4-5 hour interval the site is going down and showing the below image. I have contacted with their customer care many times. But, they can't give me any permanent solution. They are killing process manually and site become live. Can anybody help regarding this issue ? -
Daphne. Access to Django defined objects
I am using Django and channels (for WebSockets). Earlier, when I was developing, I created some objects in memory when a user does a request, and then websockets can use these objects. After, I run the production server with ssl, and for testing, I had to run apps separately: python manage.py startsslserver and daphne ... project.asgi:application. And now sockets do not have access to objects, which are initialized in django server. Anybody knows, how I can solve this problem? -
Django - Videos files are not loading in view
I have a video_post model for a blog I'm creating. The video files are saved properly and appear in the designated folder as planned. However, when I load the video_details page in order to view them, the html video tag just loads forever. I checked the console and it does not say that the file cannot be found, it just seems to never load. I'll post my model, view, and display below, I believe more than likely it's a video file type issue or an html issue, but I'm lost at this point: Model: class VideoPost(models.Model): title = models.CharField(max_length=75) author = models.ForeignKey(User, on_delete=models.CASCADE) post_video = models.FileField(upload_to='videos/') description = models.TextField() created_at = models.DateTimeField(auto_now=True) View: def video_detail(request, id): video = VideoPost.objects.get(id=id) context = { 'title': 'LIFT Church - Video Sermen', 'video': video } return render(request, 'sermen-video.html', context) View: <video autoplay controls> <source src="{{ video.post_video.url }}" type="video/mp4"> <source src="{{ video.post_video.url }}" type="video/ogv"> <source src="{{ video.post_video.url }}" type="video/ogg"> Video type invalid or not supported... </video>