Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Adding 'only' before prefetch related slows down query
In pseudocode, I have a db model like this: Model T name tags = models.ManyToManyField(Tag, related_name="Ts") symbol = models.ForeignKey(Symbol) Model Symbol name category = models.ForeignKey(Category) Model Tag name And this is the code I use to export it: query = T.objects.annotate(category=F('symbol__category')).prefetch_related('tags') for t in query: _dict = model_to_dict(t) _dict["category"] = t.category _tags = [] for tag in _dict["tags"] _tags.append(tag.id) _dict["tags"] = _tags In this code, _dict gives me the wanted result. However, T has many other fields I don't need, so I changed query to: T.objects.only("name", "symbol", "tags").annotate(category=F('symbol__category')).prefetch_related('tags') For some reason, this slows down the execution. Original query takes 6 seconds while the last one takes 8 seconds. Why? How can I prefetch everything correctly so that I don't have to loop over tags and append their ids in a dictionary? How can I do this while also using .only()? -
Django rest-auth registration error after creating new user. account_confirm_email not found
I am creating a registration system with Django rest-auth and allauth. Looking at the documentation endpoints, I just used: urls.py app_name = "apis" urlpatterns = [ path('users/', include('users.urls')), path('rest-auth/', include('rest_auth.urls')), path('rest-auth/customlogin', CustomLoginView.as_view(), name='rest_login'), path('rest-auth/customlogout', CustomLogoutView.as_view(), name='rest_logout'), path('rest-auth/registration/', include('rest_auth.registration.urls')), ] when I run, a browseable API appears like below: After entering the details and post it, the below error occurs: django.urls.exceptions.NoReverseMatch: Reverse for 'account_confirm_email' not found. 'account_confirm_email' is not a valid view function or pattern name. is there another URL i need to implement (with the name of account_confirm_email) ? I have read the documentations and rest-auth demos on this and it seems I need to include the following urls: url(r'^verify-email/$', VerifyEmailView.as_view(), name='rest_verify_email'), url(r'^account-confirm-email/(?P<key>[-:\w]+)/$', TemplateView.as_view(), name='account_confirm_email'), but this still did not fix the error why is that? -
AttributeError: module 'tagulous' has no attribute 'models' in Django
So I have been building a web app, and for the tags system, I decided to go with django-tagulous. However, when I import it in my models, I am getting this error: AttributeError: module 'tagulous' has no attribute 'models' in Django I have put it in my python INSTALLED_APP list in settings.py, and imported it in models.py, but still get the error. Here is some code. models.py import tagulous class Post(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=75) text = models.TextField() created_date = models.DateTimeField(default=timezone.now) image = models.ImageField(upload_to='post_images',blank=True,null=True) published_date = models.DateTimeField(blank=True,null=True,auto_now_add=True) NSFW = models.BooleanField(default=False) spoiler = models.BooleanField(default=False) interests = tagulous.models.TagField() tags = TaggableManager() def __str__(self): return self.title def save(self, *args, **kwargs): super().save(*args, **kwargs) In that Post class, I am using this on the interests one. Here is my forms.py PostForm class PostForm(forms.ModelForm): class Meta(): model = Post fields = ['title','text','image','interests','spoiler','NSFW'] widgets = { 'title':forms.TextInput(attrs={'class':'textinputclass'}), 'text':forms.Textarea(attrs={'class':'textareaclass editable'}), } def __init__(self, *args, **kwargs): super(PostForm, self).__init__(*args, **kwargs) self.fields['image'].required = False So far I have found nothing online about this error. I was expecting it to work, but it didn't Thanks :) -
How to customize the submit and verification method of Django forms?
I've been making my blog project with Django and I was tryting to implement Toast UI Text Editor README, a kind of open source text editor which be be loaded on client web pages. What I'm considering was to locate the text editor inside my form, however, If I do that, I have to remove the CharField named content(which is to be replace with the content of text editor) from forms.py and have to customize sumbit method. But the problem is I don't know how to customize the form submit method or verification method. What I want to do is use the default verification method on client side and if it tells the input is valid, then submit the form data added the content text editor. this is my code. class ArticleCreationForm(forms.Form): do_you_wanna_get_emails = forms.ChoiceField( choices = ( ('option_one', "YES. I wanna get an email once someone reply to you"), ('option_two', "NO. I don't need to get an email.") ), widget = forms.RadioSelect(), initial = 'option_two', ) title = forms.CharField() name = forms.CharField() password = forms.CharField( widget=forms.PasswordInput(), help_text = "Here's more help text" ) email = forms.CharField() ### I removed this field to replace this with the content of Toast … -
DJANGO - upload image stored locally to model ImageField attribute
I have my images downloaded inside the subroot images in my media folder and I'm trying to generate new models which will contain the photo inside the images folder. This is what my model and my view look like: class Post(models.Model): ... image = models.ImageField(upload_to="images", blank=True, null=True) def generate_posts(request): for i in range(20): title_ = f'title{i}' body_ = f'text for post number : {i}' author_ = f'author{i}' network_ = randomize_social() post = Post(title=title_, body=body_, author=author_, social_network=network_) if randomize_picture(): post.image.save("logo.png", File("images/svante.jpg"), save=True) else: post.image = None post.save() areGenerated = True return render(request, "posts/generate_posts.html", {'areGenerated':areGenerated}) The logo.png file is created inside the images folder, but it's blank, 0kb size and when I follow the /generateposts url, I receive this error message: AttributeError at /generateposts 'str' object has no attribute 'read' What can I do to solve this problem? -
how can achieve to Intended query set by this models in django
I have Post model: class Post(models.Model): description = models.CharField( max_length=1500, blank=True, ) school = models.ForeignKey( 'school.School', on_delete=models.CASCADE, null=True ) sibling_uuid = models.CharField(max_length=36, null=True) create_date = models.DateTimeField(default=timezone.now) if Post objects belong to school the sibling_uuid will be random uuid.uuid4 and i will create a post for every class of this school a Post instance with same sibling_uuid . by this way i will know which post should be remove if school's manager removing a school's post.but if i want return a school post to school's manager i need just return one of post per sibling post.(means that from Posts with same sibling_uuid just one of them should be in query set).i'm doing by this way now: school_posts = Post.objects.filter(school__isnull=False).distinct('sibling_uuid') # from every sibling post just on will exist in school_posts classroom_posts = Post.objects.filter(school__isnull=True) all_posts_queryset = sorted(chain(classroom_posts, school_posts), key=attrgetter('create_date'), reverse=True) i want doing above code in a single line to my code be cleaner and i learn ORM better. thank you. -
How to get model from plugin?
My model: class Post(models.Model): title = models.CharField(max_length=100) short_description = models.CharField(max_length=100) image = models.ImageField(upload_to="uploads/images/") content = HTMLField(blank=True) slug = AutoSlugField(always_update=True,populate_from='title', unique=True) date_created = models.DateField(default=datetime.date.today()) CMS Plugin: class PostPlugin(CMSPlugin): post = models.ForeignKey(Post, on_delete=models.CASCADE) Register plugin: @plugin_pool.register_plugin class CMSPostPlugin(CMSPluginBase): model = PostPlugin name = _("Post") render_template = "post/post.html" allow_children = True admin_preview = True module = "subpage" def render(self, context, instance, placeholder): context.update({ 'post':instance.post, 'instance':instance, 'placeholder':placeholder }) return context So, after that, I add this to my table, the intermediate table was created. Here a screenshot. table screenshot So that how I get the plugins: CMSPlugin.objects.filter(plugin_type='CMSPostPlugin', placeholder_id=placehoder.id) after that, I want to get the Post model from this intermediate table, but I don't know how to do that. -
How to return values from database/model after post request in Django Rest framework
I recently started working on django. I am trying to send a location name via post method and then display the list of values from the model on the url or api end point. I am unable to do it. When I send a post request I am not able to view the results on the url/api end point. It displays GET menthod not allowed. This is my views.py class location_details(APIView): def post(self, request, *args, **kwargs): event_id = json.loads(request.body).get('location_name') queryset = customer.objects.filter(eid= event_id) serializer_class = customer_details data = serializers.serialize('json', queryset) return HttpResponse(data, content_type='application/json') How can I display the values based on a post request? I am stuck with this issue for a long time. -
Django admin anotate not work with change list view queryset
I need to create a summary view for a list of records grouped by year, month and category. When I use the model manager and do annotating it works fine, and summary is correctly created. However, if I use the changelist_view request objetcts' queryset it duplicate ungrouped records as well. See the two code listings below. Correct Values: Bill.objects.values_list('category__name', 'year', 'month').annotate(Sum('amount'), due=Sum(F('amount') - F('paid_amount'), output_field=models.FloatField())) <QuerySet [('Insurance', '2019', 'FEB', Decimal('35200.2300000000'), 25200.230000000003), ('Telephone', '2019', 'AUG', Decimal('3353.54000000000'), -23.0), ('Telephone', '2019', 'JUL', Decimal('200'), 200.0)]> Incorrect when used with changelist_view queryset: qs = response.context_data['cl'].queryset extra_context['summary'] = qs.values_list('category__name', 'year', 'month').annotate( Sum('amount'), due=Sum(F('amount') - F('paid_amount'), output_field=models.FloatField())) print(extra_context['summary']) <QuerySet [('Telephone', '2019', 'AUG', Decimal('1677'), -23.0), ('Telephone', '2019', 'JUL', Decimal('500'), 500.0), ('Telephone', '2019', 'AUG', Decimal('1676.54000000000'), 0.0), ('Telephone', '2019', 'JUL', Decimal('-300'), -300.0), ('Insurance', '2019', 'FEB', Decimal('35200.2300000000'), 25200.230000000003)]> Above see that AUG 2019 not grouped correctly. -
What is {% url %} in django?
I have django template: <form id="contactForm" method="get" action="{% url 'contact-form' %}"> ... </form> What is {% url 'contact-form' %} ? -
How to receive a form input in a python script in django?
what i nee is: On a html form when user click the submit button the value of that button to be received as a python variable so that i can use it in my script. My button value is a path to the csv file "CSV/sample_submission.csv" uploaded by user in my app and stored in a folder in my django app. What i want to do is plot some plotly plots by using the file uploaded by the user. I've tried to send the data through the post request and receive it in my view function and render it on html page but what i want is that data to be saved as a global or any type of variable that can be used in any python script in my app. URL.py path("event/",views.event,name="event"), Views.py: def event(request): context={} file= request.POST.get('file',None) context['file']=file return render(request,'main/event.html',context) Following is my code of plot.py from plotly.offline import plot import plotly.graph_objs as go import pandas as pd def get_simple_candlestick(): df = pd.read_csv("FILE PATH RECEIVED FROM FORM") df.head() data = [ go.Bar( x=df['x'], # assign x as the dataframe column 'x' y=df['y'] ) ] layout = go.Layout( title='Plot Title', xaxis=dict( autorange=True ), yaxis=dict( autorange=True ) ) plot_data = … -
The current path, product/, didn't match any of these
I am having trouble with connecting to url code. Everything is showing fine but after I tried to create, this error message pops up. Also, I would like to know if path function works on the django 1.x. '''error message''' Page not found (404) Request Method: POST Request URL: http://127.0.0.1:8000/product/ Using the URLconf defined in seany.urls, Django tried these URL patterns, in this order: ^admin/ ^$ ^register/$ ^login/$ ^product/create/ The current path, product/, didn't match any of these. '''url.py''' from django.conf.urls import url from django.contrib import admin from seany_user.views import index, registerview, loginview from seany_product.views import productlist, productcreate urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', index), url(r'^register/$', registerview.as_view()), url(r'^login/$', loginview.as_view()), url(r'^product/create/', productcreate.as_view()) ] '''form.py''' from django import forms from seany_product.models import seanyproduct class registerform(forms.Form): name = forms.CharField( error_messages={ 'required': 'enter your goddamn product' }, max_length=64, label='product' ) price = forms.IntegerField( error_messages={ 'required': 'enter your goddamn price' }, label='price' ) description = forms.CharField( error_messages={ 'required': 'enter your goddamn description' }, label='description' ) stock = forms.IntegerField( error_messages={ 'required': 'enter your goddamn stock' }, label='stock' ) def clean(self): cleaned_data = super().clean() name = cleaned_data.get('name') price = cleaned_data.get('price') description = cleaned_data.get('description') stock = cleaned_data.get('stock') if name and price and description and stock: seany_product = product( … -
csrf and cors errors in localhost development of webpacked vuejs/reactjs/angularjs website with django backend
How can I run my vuejs application on localhost and have it send its API calls to my deployed django rest framework backend without getting cors and csrf issues? So far I have these issues: I can't read the cookie from browser because it's domain is not set to localhost. I need that to set the X-CSRFTOKEN header for django. I get CORS errors since localhost is not the same origin as my domain(example.com) I get error that referer does not match. -
How to crop images in django if I already have the cropping data (x,y,etc) coordinates?
I have an app where users would upload images and may crop a part of it so I added cropper.js to capture the coordinates and used a pillow code to crop it , I found it in this blogpost but nothing changes in the images I checked the data type of the coordinates and checked everything and nothing happened. from PIL import Image def crop(corrd, file ,path): image = Image.open(file) cropped_image = image.crop(corrd) resized_image = cropped_image.resize((384, 384), Image.ANTIALIAS) resized_image.save(path) return file if form.is_valid(): image = form.save(commit=False) x = float(request.POST.get('x')) y = float(request.POST.get('y')) w = float(request.POST.get('width')) h = float(request.POST.get('height')) print(x) print(y) print(w) print(h) crop((x,y,w+x,y+h),image.pre_analysed,image.pre_analysed.path) image.patient = patient messages.success(request,"Image added successfully!") image.save() class ImageForm(ModelForm): x = forms.FloatField(widget=forms.HiddenInput()) y = forms.FloatField(widget=forms.HiddenInput()) width = forms.FloatField(widget=forms.HiddenInput()) height = forms.FloatField(widget=forms.HiddenInput()) class Meta: model = UploadedImages fields = ('pre_analysed', 'x', 'y', 'width', 'height', ) so what I'm doing wrong here? I tried using opencv but i ran into issues/errors I couldn't fix. -
OSError at /en/ Django Saleor webpack error
I am trying Django Saleor to experience ECommerce framework. But I get this error. And I even tried finding the project root, I couldn't find webapck-bundle.json. This is the error of my django debug page OSError at /en/ Error reading /workspace/saleor/saleor/webpack-bundle.json. Are you sure webpack has generated the file and the path is correct? -
Django ReactJS bundle file not getting building with docker
I am learning docker and dockerizing my Django-react app! It is working now great except an issue and that is the bundle.js file are not getting Django when i run the project through dockcer But bundle.js files are found if run the project without docker! I guess, docker bundle the javascript in a different directory, that is why it is not getting if run with docker! this is my settings.py file STATICFILES_DIRS = [ os.path.join(os.path.join(BASE_DIR, os.pardir), 'dist'), ] and my Dockerfile is given below: FROM node:8 # Name work directory, it can be whatever you want WORKDIR /app COPY . ./ RUN yarn RUN npm run build # Pull base image FROM python:3 # Set environment varibles ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Set work directory, we can name it whatever we want WORKDIR /djangobackend # Install dependencies # Copy requirement file from the docker workdir we defined named djangodocker COPY requirements.txt /djangobackend/ RUN pip install -r requirements.txt # Copy project COPY . /djangobackend/ and this is my dockcer-compose.yml file version: '3.2' services: db: image: postgres:10.1-alpine volumes: - postgres_data:/var/lib/postgresql/data/ web: build: . command: python backend/manage.py runserver 0.0.0.0:8000 ports: - 8000:8000 depends_on: - db volumes: postgres_data: Please know the problem … -
I'd like to know if the ManyToMany Field for each post contains a user ID in django
I'm trying to make a blog web. I want to change the color of the 'like it button' like Instagram depending on whether users like it or not. But I don't know how to build this. views.py def list(self, request, *args, **kwargs): user = request.user if not user.is_authenticated: return redirect('blog:signup') else: response = Blog.objects.filter(owner=user.id) return Response({'posts': response, 'user': user}, template_name='blog/blog_list.html') models.py class Blog(models.Model): title = models.CharField(max_length=255) body = models.TextField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) likes = models.ManyToManyField(User, related_name='likes', blank=True, default='') owner = models.ForeignKey(User, on_delete=models.CASCADE) templates {% for post in posts %} <button type="button" class="like" name="{{ post.pk }}" > {% if post.likes.exist %} <img class="float-left card-icon mx-1 like-img" src="{% static 'blog/like.png' %}" alt=""> {% else %} <img class="float-left card-icon mx-1 like-img" src="{% static 'blog/favorite.png' %}" alt=""> {% endif %} </button> I'm trying to filter in the template. but post.likes.exists is not what I want. This code below is what I exactly want. x = user.likes.through.objects.filter(blog=obj.id, user__id=user.id).exists() Can I implement this code as a template code? Or is there another solution to this? Thank you! -
Django Rest Framework: URL for associated elements
I have the following API endpoints already created and working fine: urls.py: router = DefaultRouter() router.register(r'countries', views.CountriesViewSet, base_name='datapoints') router.register(r'languages', views.LanguageViewSet, base_name='records') Now, I need to create a new endpoint, where I can retrieve the countries associated with one language (let's suppose that one country has just one associated language). For that purpose, I would create a new endpoint with the following URL pattern: /myApp/languages/<language_id>/countries/ How could I express that pattern with the DefaultRouter that I'm already using? -
Implementing PostgreSQL HStore in Django
I found some couple of packages to implement PostgreSQL HStore in Django from djangopackages.org. The most stared and most forked package was last updated in March 2, 2017. I think it is not maintained regularly. But as it at the top of the list I am confused about that should I use it in my project or there is a better option for me. Which is the best and handy way to implement PostgreSQL HStore in Django? -
Django rest-auth custom login form - not recognising inputted email: "Must include \"email\" and \"password\"."
I wrote a very simple custom login form over the rest-auth LoginView like below: view class CustomLoginView(LoginView): def get(self, request): form = CustomUserLoginForm() print(form.get_user()) return render(request, "api/test_template.html", context={"form": form}) form class CustomUserLoginForm(AuthenticationForm): class Meta: model = CustomUser fields = ('email', 'password') template {% block content %} <div class="container"> <form method="POST"> {% csrf_token %} <div> <label for="{{ form.email.id_for_label }}">Email: </label> <input type="email" {{ form.email }}> </div> <div> <label for="{{ form.password.id_for_label }}">password: </label> <input type="password" {{ form.password }}> </div> <button style="background-color:#F4EB16; color:blue" class="btn btn-outline-info" type="submit">Login</button> </form> Don't have an account? <a href="/register" target="blank"><strong>register here</strong></a>! </div> {% endblock %} In my settings.py i am making sure that the email is required and username is not: ACCOUNT_AUTHENTICATION_METHOD = 'email' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_USERNAME_REQUIRED = False AUTHENTICATION_BACKENDS = ( # Needed to login by username in Django admin, regardless of `allauth` "django.contrib.auth.backends.ModelBackend", # `allauth` specific authentication methods, such as login by e-mail "allauth.account.auth_backends.AuthenticationBackend", ) When I go to enter my email and password and then submit the form, Django rest-auth framework gives the below error: As a test, I then input the same email address in the provided field in the browserable API and I manage to log-in successfully. Why does rest-auth not recognize the … -
Using multiple models for django ecommerce cart
I'm making a cart for an ecommerce project that I am working on, at the moment the cart does work. However it only works for one model and I'm not sure how to make it work with more than one. This is my contexts.py file in my cart folder: from django.shortcuts import get_object_or_404 from courses.models import Course from food_order.models import Food_order def cart_contents(request): """ Ensures that the cart contents are available when rendering every page """ cart = request.session.get('cart', {}) cart_items = [] total = 0 course_count = 0 for id, quantity in cart.items(): course = get_object_or_404(Course, pk=id) total += quantity * course.price course_count += quantity cart_items.append({'id': id, 'quantity': quantity, 'course': course}) return {'cart_items': cart_items, 'total': total, 'course_count': course_count} Here is my views.py from django.shortcuts import render, redirect, reverse # Create your views here. def view_cart(request): """A View that renders the cart contents page""" return render(request, "cart.html") def add_to_cart(request, id): """Add a quantity of the specified product to the cart""" quantity = int(request.POST.get('quantity')) cart = request.session.get('cart', {}) if id in cart: cart[id] = int(cart[id]) + quantity else: cart[id] = cart.get(id, quantity) request.session['cart'] = cart return redirect(reverse('index')) def adjust_cart(request, id): """ Adjust the quantity of the specified product to the specified … -
django default Authenticaiton form shows username rather than email
I implemented my own user login form with django like below from django.contrib.auth.forms import AuthenticationForm class CustomUserLoginForm(AuthenticationForm): class Meta: model = CustomUser fields = ('email', 'password') then as a view this is what I have: from rest_auth.views import LoginView from users.forms import CustomUserLoginForm class CustomLoginView(LoginView): def get(self, request): form = CustomUserLoginForm() return render(request, "api/test_template.html", context={"form": form}) in my template then, I am calling {{form.as_p}} in <form> tag to show the form input details. However, by default, this shows the username and password forms. How can I replace the username with the email? in the rest-auth, browserable api, both the username and the email are present so I know that I can do this since I am using the rest-auth LoginView as backend. Can I manually unpack {{form}} since later I would still like to style this form. How can I do this? -
Django drf_yasg POST with input parameters produces error - cannot add form parameters when the request has a request body
I'm trying to use Django drf_yasg to create a POST api with input parameters like below: x_param = openapi.Parameter('x', in_=openapi.IN_FORM, description='string', type=openapi.TYPE_STRING) @swagger_auto_schema(method='post', manual_parameters=[x_param]) @api_view(['POST']) def another_view(request): x_param = request.POST['x'] logging.debug("x_param = %s", x_param) return Response("I'm OK", status=status.HTTP_200_OK) pass however it produces this error in $ python manage.py runserver raise SwaggerGenerationError("cannot add form parameters when the request has a request body; " drf_yasg.errors.SwaggerGenerationError: cannot add form parameters when the request has a request body; did you forget to set an appropriate parser class on the view? How can I solved this ? -
how to specify in django form that we want certain value to be inserted in database via dropdown list
I am trying to save the name of the students in the database. Right now, it is saving the ID of the student instead of the name. I am using django form and i am not sure hw to tell the django form that i want to insert the student name in the database. Below is my forms.py code: class studentAttendanceForm(forms.ModelForm): class Meta: model = MarkAtt fields = ['studName'] def __init__(self,*args, **kwargs): class_group = kwargs.pop('class_group') super(studentAttendanceForm, self).__init__(*args,**kwargs) self.fields['studName'].label = "Select your name:" self.fields['studName'].queryset = Namelist.objects.filter(classGrp=class_group) Template: <h6 style=" display: inline;"> Lab Group: {{group.classGrp}} </h6> <h6 style="padding-left:70px; display: inline;">Day: {{group.day}} </h6> <h6 style="padding-left: 70px;display: inline;">Time: {{group.time}} </h6> <h6 style="padding-left: 70px;display: inline;"> Today's date: {{date.today}}</h6> <br> <br> {{ form.as_p }} <button type ="submit" class="btn btn-outline-success" >Mark Attendance</button> right now is saving as: id att studName classId week date 42 1 1 1 0 2019-09-15 i want to save as 42 1 testName 1 0 2019-09-15 -
PYTHON - DJANGO - 'ImageFieldFile' object has no attribute 'replace'
The error message is: AttributeError at /projects/ 'ImageFieldFile' object has no attribute 'replace' Request Method: GET Request URL: http://localhost:8000/projects/ Django Version: 2.2.5 Exception Type: AttributeError Exception Value: 'ImageFieldFile' object has no attribute 'replace' Exception Location: .../js-portfolio/venv/lib/python3.6/site-packages/django/utils/encoding.py in filepath_to_uri, line 252 Python Executable: .../js-portfolio/venv/bin/python Python Version: 3.6.8 Python Path: ['.../js-portfolio', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '.../js-portfolio/venv/lib/python3.6/site-packages'] I have a Project MODEL, that takes an image. I added the model to my admin page, and I created an object from admin and can add an image no problem. The problem happens when I try to display my views. I am not even making a reference to the image in base.html. I have been stuck on this for hours, so I figured it's time to get some help. Any hints would be greatly appreciated. Thanks! My Project model(models.py): from django.db import models class Project(models.Model): title = models.CharField(max_length=100) description = models.TextField() technology = models.CharField(max_length=20) image = models.ImageField(default='default.jpg', upload_to='img') def __str__(self): return self.title My settings.py: STATIC_URL = '/static/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' base.html: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <div class="container"> <a class="navbar-brand" href="{% url 'project_index' %}">JS Portfolio</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> …