Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to add help text for many to many field in Django?
I created this simple model, but need your help to add a help_text: class FormModel(models.Model): fullname = models.CharField(max_length=150) slug = models.SlugField(max_length=255) ... interests = models.ManyToManyField(Interests) I tried several ways, there is a similar question in SO. It didn't work either. Thanks -
NoReverseMatch at /accounts/login/ Reverse for '' not found. '' is not a valid view function or pattern name
Environment: Request Method: POST Request URL: http://127.0.0.1:8000/accounts/login/ Django Version: 3.0.5 Python Version: 3.7.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'articles', 'accounts'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "C:\Users\Joga\testenv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\Joga\testenv\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\Joga\testenv\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Joga\Desktop\project\djangonautic\accounts\views.py", line 24, in login_view return redirect(request.POST.get('next')) File "C:\Users\Joga\testenv\lib\site-packages\django\shortcuts.py", line 41, in redirect return redirect_class(resolve_url(to, *args, **kwargs)) File "C:\Users\Joga\testenv\lib\site-packages\django\shortcuts.py", line 131, in resolve_url return reverse(to, args=args, kwargs=kwargs) File "C:\Users\Joga\testenv\lib\site-packages\django\urls\base.py", line 87, in reverse return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)) File "C:\Users\Joga\testenv\lib\site-packages\django\urls\resolvers.py", line 677, in _reverse_with_prefix raise NoReverseMatch(msg) Exception Type: NoReverseMatch at /accounts/login/ Exception Value: Reverse for '' not found. '' is not a valid view function or pattern name. after reading the traceback im pretty sure the errors at : return redirect(request.POST.get('next')) but i cant figure out whats wrong -
ERROR: Could not find a version that satisfies the requirement django==1.7b1 (from tictactoe) (from versions: 1.1.3 (...) 3.0.5 )
I'm trying to install the "tictactoe" module from pygame (I've already intall pygame), but when I run: pip3 install tictactoe I get an ERROR message (the one from the Title): ERROR: Could not find a version that satisfies the requirement django==1.7b1 (from tictactoe) (from versions: 1.1.3 (...) 3.0.5 ) And also: ERROR: No matching distribution found for django==1.7b1 (from tictactoe) Any idea on what might be the problem? I'm new in programming so it's probably something silly... -
Django sum total price from table items and table transaction
I have two tables, items and transaction, how do i calculate the total price, and displaying the total price in templates class Items(models.Model): items_name = models.CharField(max_length=50) price = models.PositiveIntegerField() def __str__(self): return self.items_name class Transaction (models.Model): items = models.ForeignKey(Items, on_delete=models.CASCADE) qty = models.PositiveIntegerField() def total_price(self): total = self.qty * self.items.price return total total_price = models.PositiveIntegerField(total_price) Here is the View def transaction(request): transactions=Transaction.objects.all() context={'transactions':transactionss} return render(request,'app/transaction.html',context) here is my template {% for transaction in transactions %} <tr> <td>{{transaction.item}}</td> <td>{{transaction.qty}}</td> <td><a class='btn btn-sm btn-info' href="#"> Update</a></td> <td><a class='btn btn-sm btn-danger' href="# ">Delete</a></td> </tr> {% endfor %} <tr><td> {{total_price}} </td></tr> I want to display the full total_price of all transactions, for example item 1 with price 100 * quantity 2 and item 2 with price 200 * quantity 3 . then the total price would be 200 + 600 = 800. I want to display the 800 in the template. -
Django-select2 HeavySelect2MultipleWidget -> Dynamic Choices
What is the correct way to use HeavySelect2MultipleWidget with Dynamic choices ?? I am using Django-select2 HeavySelect2MultipleWidget to fetch and select data by using ajax search from table... I referred Django-select2 documentation and testapp in their github repo, their documentation is not much helpful but in their testapp, they have very basic example. they are feeding choices from custom static list, which is not from database and also not dynamic. it loads everything to choices. if I use combination of ModelMultipleChoiceField and HeavySelect2MultipleWidget and if I pass queryset of respective model then it loads entire table in choices... which I dont want... my existing code looks like this: class CustReqForm(forms.Form): customer = forms.ModelMultipleChoiceField(widget=HeavySelect2MultipleWidget(data_view='customer_search',), queryset=Customer.objects.filter(channel='34342').all() ) I have a huge data in my table. though I filtered in my query, still it loads 100K unique records... Please advice the right method to implement this... -
Django overriden model save method returning old data
I may be tired and I'm not seeing something, but I've tried too much. class Pizza(models.Model): portion_size = models.ForeignKey('PortionSize', on_delete=models.PROTECT) pizza_type = models.ForeignKey('PizzaType', on_delete=models.PROTECT) toppings = models.ManyToManyField('Topping', blank=True) special = models.BooleanField() price = models.DecimalField( max_digits=4, decimal_places=2, editable=False, default=0 ) def calculate_price(self, topping_amount): print(self.toppings.count()) topping_amount = self.toppings.count() base_pizza = PizzaBase.objects.get( portion_size=self.portion_size, pizza_type=self.pizza_type, special=self.special, topping_amount=topping_amount ) self.price = base_pizza.price def save(self, *args, **kwargs): super().save(*args, **kwargs) self.calculate_price() This is model I've defined for Django and I'm trying to set the the price of the pizza that is being created when the user saves form, but every time the code is run, the toppings.count value is always behind. For instance, if I pick three toppings, and before saving the form in the admin panel there were only two toppings selected, I'd get the calculated price for two toppings. I've tried changing the order of the save method but it didn't change anything. I've also used the shell to check if there was a problem, but while in Django shell everything was fine with the toppings count. I've also check the admin interface, refreshed it multiple times, cleared cache and everything seemed fine there too. I've started Signals to solve this. Creating a receiver for … -
Django how to print out a list in html page
I have a list of data that looks like this [['mvpd', 'asdf, wefef', 'Optimum'], ['app_name', 'd', 'austin.com']] In my template I have a table that I want to put everything in. <table class="table table-hover"> <thead> <tr> <th scope="col">Property</th> <th scope="col">Expected Value</th> <th scope="col">Actual Value</th> </tr> </thead> <tbody> <tr> <th scope="row">1</th> <td>Mark</td> <td>Otto</td> </tr> <tr> <th scope="row">2</th> <td>Jacob</td> <td>Thornton</td> </tr> <tr> <th scope="row">3</th> <td colspan="2">Larry the Bird</td> </tr> </tbody> </table> However I am not sure how to grab the first list in the list and print them out in each row. Or will I need to send a different data structure to my template? -
cant get image to display Angular, GET 404 (Not Found)
Angular8. I am trying to display images that I previously saved using Angular/Django. I upload the images to the src/assets/images/images_are_here folder. I get the error GET http://127.0.0.1:8000/media/images/photo1_7x0DKZh.png 404 (Not Found). I have tried several different variations: <img [src]="recipe.photo"> and i tried creating a variable path that I then inserted <img [src]="path", tried brackets, no brackets around src. If I directly put in the path however this works <img src="assets/images/ryanphoto1_7x0DKZh.png"> When I save the image it uploads it to the correct place in the asset folder which is src/assets/images/ but when it displays the image filepath (in the browser) it shows http://127.0.0.1:8000/media/images/ which is correct because thats how my Django is set up: settings.py MEDIA_ROOT = '/Users///frontend2/src/assets' MEDIA_URL = '/media/' I think it has something to do with angular running on http://localhost:4200/ and django running on http://127.0.0.1:8000?? -
How can a post have an author on django?
I have been trying to make a post have the username of the creator on it but when I run the code, whenever I change profile, the username that is on the post changes. It seems That something on the models.py file is not correct. Views.py def home(request): created_posts = Create.objects.all().order_by("-added_date") return render(request, 'base.html', {"created_posts": created_posts}) def create(request): if request.method == 'POST': created_date = timezone.now() header1 = request.POST['header'] content1 = request.POST['content'] created_obj = Create.objects.create(added_date=created_date, title=header1, content=content1) created_obj.save() print('create created') return redirect('home') else: print('create not created') return render(request, 'create.html') Models.py class Create(models.Model): added_date = models.DateTimeField() title = models.CharField(max_length=200) content = models.CharField(max_length=200) create.html (creates the post) {% extends 'home.html' %} {% block body %} <div style="margin-top: 200px; margin-left:200px;"> <form action="create" method="POST"> {% csrf_token %} <input type="text" name="header" placeholder="Add here..."> <input type="text" name="content" placeholder="Add here..."> <button type="submit"name="action" class="btn btn-primary mb-2">submit</button> </form> </div> {% endblock %} base.html (shows the created posts in lists) {% extends 'home.html' %} {% block body %} <ul action="{% url 'create' %}" class="container-sm list-group" style="margin-top: 200px;"> {% for created_post in created_posts %} <li class="list-group-item">{{ created_post.title }} <p>{{ user.username }}</p> <p>{{ created_post.content }}</p> <div class="float-right"> <form action="delete_create/{{ created_post.id }}/" action="post"> <button type="submit" class="btn btn-outline-danger btn-sm">Delete</button> </form> </div> <div class="float-right"> <a href="{% … -
Assign Change Function To Django Formset Fields
I have the following function: <script> $("#id_form-0-ProductCode").change(function() { var pId = $("#id_form-0-ProductCode").val(); console.log(pId) $.ajax({ url: "/ajax/product", data : {'product': pId}, success: function(data) { $("#id_form-0-DescriptionOfGoods").val(data.DescriptionOfGoods) $("#id_form-0-Type").val(data.UnitType) $("#id_form-0-Price").val(data.Price) } }); }); </script> This is working perfectly fine - but the problem is that I'm offering the user the ability to add additional forms to the formset dynamically. So when they click the 'Add' button they get a new form. In that case, I would need the same function to apply to that form as well, but all of the ids would change so that the function would effectively look like: <script> $("#id_form-1-ProductCode").change(function() { var pId = $("#id_form-1-ProductCode").val(); console.log(pId) $.ajax({ url: "/ajax/product", data : {'product': pId}, success: function(data) { $("#id_form-1-DescriptionOfGoods").val(data.DescriptionOfGoods) $("#id_form-1-Type").val(data.UnitType) $("#id_form-1-Price").val(data.Price) } }); }); </script> Could anyone recommend the smartest way to implement this kind of thing? I don't want to write the function out many times A) because that's cumbersome and B) because that would create an upper limit to how many forms within the formset this would work for. -
Django Queryset Occurences Counts
I have the following django model... class Entry(models.Model): entry_UUID = models.UUIDField() entry_description = models.TextField() numeric_value = models.FloatField(null=True, blank=True) entry_category = models.CharField() I am trying to query the database - I expect groups of entry_UUIDs and for each group some statistics for numeric_value (Min/Max/Avg) and counts for entry_category. I won't know the specific values for entry_category ahead, but I expect them to form a set (ex. {low, med, high}). I have tried the following query: Entry.objects.filter( entry_UUID__in = entry_UUIDs).values( 'entry_UUID').annotate( Avg('numeric_value'), Min('numeric_value'), Max('numeric_value'), Count('entry_category')) Which returns... <QuerySet [{'entry_UUID': UUID('9fcfea6d-9480-595f-1e1f-81130ddc0c99'), 'numeric_value__avg': 51.5089, 'numeric_value__min': 23.174, 'numeric_value__max': 76.421, 'entry_category__count': 4}, {'entry_UUID': UUID('9fcfea6d-9490-595f-1e1f-81130ddc0c99'), 'numeric_value__avg': 5.2882, 'numeric_value__min': 1.282, 'numeric_value__max': 9.7553, 'entry_category__count': 6}]> For entry_category I am looking to get counts of occurences for each value rather that a total count. Not sure how to got about this. Thanks. -
How do I configure my Apache VirtualHost to only pass certain paths to my Django application?
I'm using Apache 2 on Linux 18.04 with Python 3.6. I have the following virtual host set up ... <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName lab.chicommons.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html/web # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. LogLevel info ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined #Alias /static /srv/rdmo/rdmo-app/static_root/ #<Directory /srv/rdmo/rdmo-app/static_root/> # Require all granted #</Directory> # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI … -
Having trouble using js_link to add dropdown selector in Bokeh
I'm trying to implement widgets into my Bokeh diagrams. The first I would like is a drop down menu allowing the selection of other option strategies. I can't seem to figure out the js_link function in order to have the selection make a change on the graph. I fear I may have set up the diagram wrong. Any help is greatly appreciated. from bokeh.plotting import figure, output_file, show from bokeh.models import ColumnDataSource, Div, Select, Slider, TextInput,CustomJSTransform from bokeh.io import curdoc from bokeh.transform import transform from bokeh.layouts import gridplot, column import matplotlib import matplotlib.pyplot as plt import numpy as np strike1 = 20 #Long Call strike2 = 33 #Short Call strike3 = 30 #Long Put strike4 = 60 #Short Put premium1 = 0.5 premium2 = 1.6 premium3 = 2.1 premium4 = 1.5 price = np.arange(15,25,0.01) contracts = 1 symbol = 'TSLA' option = ['Long Call', 'Long Put', 'Short Call', 'Short Put', 'Bull Call Spread', 'Bear Put Spread', 'Straddle', 'Butterfly Spread', 'Box Spread', 'Iron Condor'] def long_call(price, strike1, premium1, contracts): P = [] for i in price: P.append((max(i - strike1, 0) - premium1) * (contracts * 100)) return np.array(P) def long_put(price, strike1, premium1, contracts): P = [] for i in price: P.append((max(strike1 … -
Django's FILE_UPLOAD_PERMISSIONS not working for directories
I'm trying to use Django's FILE_UPLOAD_PERMISSIONS to set permissions when a user uploads a file. The file itself is created with the correct permissions (775), but any directories created seem to be stuck with the default (755). Example: If a file (foo.jpg) is uploaded for a user (id = 123), it should save to media/123/foo.jpg, creating the 123 directory if it does not already exist. foo.jpg has 775 but 123 has 755. How can I get directories saving with the correct permissions? I am using Apache with mod_wsgi in a httpd Docker container if it is relevant. -
API gives 200 Success but object does not change Python
I'm calling this api to cancel an order in my app. After I call the api, I get a success message, but, nothing changes. Here is the code I'm using: API @csrf_exempt def customer_reset_order(request): customer = get_user(request) if not customer: return JsonResponse({'invalid token'}) order = Order.objects.filter( id=request.POST["order_id"], status=Order.READY ) order.status = Order.CANCELED order.save() return JsonResponse({"status": "reset"}) Why can I call the api but, see no change? -
Getting the id of a model from a button in Django
I currently have a template set up so that it loops through all of my menu items with a button that correspond to a post request in my views.py <td> {% for menu_items in menu %} {{ menu_items.Menu_name }} {% endfor %} </td> <td> {% for menu_desc in menu %} {{ menu_desc.Menu_Desc }} {% endfor %} </td> <form method="post"> {% csrf_token %} <th><input class="btn btn-success" type="submit" value="Add To Cart" name="add">. </th> </form> In my views file I have a if statement that tries to get the id of the model that was clicked. However, i'm only able to get the Query Set and not the specific ID of the model. def ordering(request): latest_order = Order.objects.all() menu = Menu.objects.all() if 'add' in request.POST: user_order = Order.objects.get(name='') print(menu.id) return render(request, 'users/ordering.html', {'title':'Ordering', 'latest_order': latest_order, 'menu':menu}) -
Django: CSRF verification fail despite token being provided
I get 403 error due to csrf_token verification failure in spite of token explicit declaration in an ajax call. I for my data dictionary in the same manner in other functions and it works just great. Here is JS: $(document).on("click", ".update-cleaning", function(event){ event.preventDefault(); var input_field_name = $(this).attr('name') var obj_id = $(this).attr('value') var model_name = $(this).attr('data-model') var field_name = $(this).attr('data-field') var value = $("#" + input_field_name + obj_id).val(); if (!value) { alert('Fill the field!') } else { $.ajax({ url: "{% url 'ajax_update_cleaning' %}", type: "POST", data: {'object_id': obj_id, 'model_name': model_name, 'field_name': field_name, 'value': value, 'csrfmiddlewaretoken': '{{ csrf_token }}'}, dataType: 'json', }) .done(function(response){ console.log(response); }) } }); My html form is in a popover which is toggled by a click on <td> and looks like this: <td class="text-md-center with-popover" name="frequency" value="{{cleaning.id}}"> {{ cleaning.frequency }} <div id="frequency{{cleaning.id}}" style="display: none"> <form method="POST"> <label for="cleaning_frequency">Frequency: </label> <input id="cleaning_frequency{{cleaning.id}}" type="number" name="cleaning" value="{{cleaning.frequency}}"> <button type="submit" class="btn btn-success btn-sm update-cleaning" name="cleaning_frequency" data-model="Cleaning" data-field="frequency" value="{{cleaning.id}}"> Change </button> </form> </div> </td> Could you give me some ideas? Thank you. -
Filtering Blogs Posts in Django based on Admin Approved Posts
I have made a blog as a project and I have set users to submit posts for the blog directly but I want to direct this post to the admin first for approval before showing on the website. I have added a field to Post model, 'admin_approved = models.BooleanField(default=False)'. I also filtered by Post.objects.filter(admin_approved=True), but still nothing happens and posts are published class PostListView(ListView): model = Post template_name = "score.html" ordering = ['-date_posted'] context_object_name = 'posts' def score(request): context = { 'posts': Post.objects.filter(admin_approved=True) } return render(request, "score.html", context) class PostDetailView(DetailView): model = Post template_name = "post_detail.html" class PostCreateView(LoginRequiredMixin, CreateView): model = Post fields = ['caption', 'design'] template_name = "post_form.html" success_url = '/score' def form_valid(self, form): form.instance.author = self.request.user return super().form_valid(form) Here is the model: class Post(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE) design = models.ImageField( blank=False, null=True, upload_to='new designs') caption = models.TextField(max_length=100) date_posted = models.DateTimeField(default=timezone.now) admin_approved = models.BooleanField(default=False) def __str__(self): return self.caption def get_absolute_url(self): return reverse("core:post-detail", kwargs={"pk": self.pk}) Am I missing a step or is there something I should do? -
Show the authenticated user who is "online" (logged in) in Django
this is my first question here in stackoverflow, i apologize for any mistakes or bad explanation about my problem. (English is not my native language) I recently started studying web development using Django as framework, and i'm kinda lost in some topics, i'm working on a website, that have some options: Register a new user, and log in. When the user is successfully authenticated, he can acess the "profile" page, that is allowed only for authenticated users. In this page, i'm trying to implement a "webchat", like a group of WhatsApp, so the users can send messages, and the other users can see it and reply, and etc... But right know, i'm trying right to implement a list of "who is online" in this profile page to start this whole thing. The idea is simple, whatever person is logged in, it need to be shown in some list in the HTML, i'll send the code to demonstrate the idea. My views.py def sign_in(request): context = {} user = request.user if user.is_authenticated: return redirect("/profile") if request.POST: form = AccountAuthenticationForm(request.POST) if form.is_valid(): email = request.POST['email'] raw_password = request.POST['password'] user = authenticate(email=email, password=raw_password) if user: login(request, user) return redirect("/profile") else: form = AccountAuthenticationForm() … -
Djnago annotate if id is in subquery
I have employers = Employers.objects.all() employers_hired = employers.filter(person__in=get_valid_people()).distinct('id') employers_never_hired_anyone = Employers.objects.exclude(id__in=employers) employers.annotate(never_hired=Exists(employers_never_hired_anyone)) however my never_hired flag does not work as I intended. What am I missing? -
expected an element of ColumnData(String, Seq(Any))
im trying to print a data visualization using bokeh and django, the data that i want to print is int and string, but i got this error, i tried changing the data to string but i still cant get it to work, the data is being outputed from sqlite using filtering in django, here is what i already do views.py def datvis(request, id): usrn = request.user.username fruits = t_nilai.objects.filter(nama=usrn).values('nama_mapel')[0]; counts = t_nilai.objects.filter(nama=usrn).values('nilai')[0]; source = ColumnDataSource(data=dict(fruits=fruits, counts=counts)) p = figure(x_range=fruits, plot_height=350, toolbar_location=None, title="Fruit Counts") p.vbar(x='fruits', top='counts', width=0.9, source=source, legend_field="fruits", line_color='white', fill_color=factor_cmap('fruits', palette=Spectral6, factors=fruits)) p.xgrid.grid_line_color = None p.y_range.start = 0 p.y_range.end = 9 p.legend.orientation = "horizontal" p.legend.location = "top_center" script, div = components(p) return render(None, 'grader/dataVisualisasi.html', {'script' : script, 'div' : div} ) urls.py url(r'^dataVisualisasi(?P<id>\d+)$', datvis, name='datavis') the html file <html> <head> <link href="http://cdn.pydata.org/bokeh/release/bokeh-2.0.2.min.css" rel=”stylesheet” type=”text/css"> <link href="http://cdn.pydata.org/bokeh/release/bokeh-widgets-2.0.2.min.css" rel=”stylesheet” type=”text/css”> <script src="http://cdn.pydata.org/bokeh/release/bokeh-2.0.2.min.js"></script> <script src="http://cdn.pydata.org/bokeh/release/bokeh-widgets-2.0.2.min.js"></script> {{ script | safe }} <title>Data visualisasi</title> </head> <body> {{ div | safe}} </body> </html> -
Django code changes not reflected without restart
I used python manage.py runserver to start the django server locally. I noticed the change of HTML code is not reflected if I don't re-start the server. Is it normal? Is it possible to see the change without restarting the server? -
Object word is assign to models automatically in Django
How object word is added automatically? It makes difficulty in choosing. How to set different words to it? -
How to get the first child from a recursive relationship
I've been using def get_all_children(self, include_self=True): r = [] if include_self: r.append(self) for c in Cateogory.objects.filter(parent=self): _r = c.get_all_children(include_self=True) if 0 < len(_r): r.extend(_r) return r to get all the children of an object, however it returns all the children of its children as well. How can I can only the first, direct children? -
Django not rendering a template with a raw query
I'm trying to render a custom template with a custom SQL statement with the following code: def get_pms(): with connection.cursor() as cursor: cursor.execute('SELECT p.Id, f.Id, p.description as ProjectName, f.xPMNumber as xNumber from ' 'project_project p LEFT OUTER JOIN xpm_xpm f ON f.ProjectID = p.Id') result = cursor.fetchall() return result and I also tried with this one, which basically does the same thing, except this one is not raw: result = list(Project.objects.values(ProjectName=F('description'), xNumber=F('p_set__xPMNumber'))) Views.py class ListProjectsView(LoginRequiredMixin, ListView): #xpms = Project.objects.values(ProjectName=F('description'), xNumber=F('p_set__xPMNumber')) xpms = get_pms() template_name = 'project/feed.html' model = Project context_object_name = 'xpms' I commented out one variable here to test out if it worked This is the template where I'm trying to render {% extends "base.html" %} {% load bootstrap4 %} {% block head_content %} <title>Projects</title> {% endblock %} {% block container %} <div class="container"> <div class = "list-group"> {% for i in xpms %} <a href=""class="list-group-item list-group-item-action"> <p>{{ i.description }} </p> <p>{{ i.xPMNumber }}</p> </a> {% endfor %} </div> <div class="float-right mt-4"> <a class="btn btn-primary" href="{% url "project:create" %}" role="button">Create a new project</a> </div> </div> {% endblock %} It renders the project name with i.description but it doesn't render the xPMNumber I don't know if I'm accessing wrong into …