Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Is it possible to do complex SQL queries using Django?
I have the following Script to get a list of calculated index for each day after specific date: with test_reqs as ( select id_test, date_request, sum(n_requests) as n_req from cdr_test_stats where id_test in (2,4) and -- List of Ids included in index calc date_request >= 20170823 -- Start date (end date -> Last in DB -> Today) group by id_test, date_request ), date_reqs as ( select date_request, sum(n_req) as n_req from test_reqs group by date_request ), test_reqs_ratio as ( select H.id_test, H.date_request, case when D.n_req = 0 then null else H.n_req/D.n_req end as ratio_req from test_reqs H inner join date_reqs D on H.date_request = D.date_request ), test_reqs_index as ( select HR.*, least(nullif(HA.n_dates_hbalert, 0), 10) as index_hb from test_reqs_ratio HR left join cdr_test_alerts_stats HA on HR.id_test = HA.id_test and HR.date_request = HA.date_request ) select date_request, 10-sum(ratio_req*index_hb) as index_hb from test_reqs_index group by date_request Result: --------------------------- | date_request | index_hb | --------------------------- | 20170904 | 7.5508 | | 20170905 | 7.6870 | | 20170825 | 7.4335 | | 20170901 | 7.7116 | | 20170824 | 1.6568 | | 20170823 | 0.0000 | | 20170903 | 5.1850 | | 20170830 | 0.0000 | | 20170828 | 0.0000 | --------------------------- The problem is that … -
Securing Folder on EC2 Amazon Marketplace AMI
I'm planning to start a small business and submit an Linux AMI to Amazon's AWS Marketplace. As I'm reading the seller's guide, I see this: AMIs MUST allow OS-level administration capabilities to allow for compliance requirements, vulnerability updates and log file access. For Linux-based AMIs this is through SSH." (6.2.2) How can I protect my source code if anyone who uses my product can SSH to the machine and poke around? Can I lock down certain folders yet still allow "os-level administration"? Here is a bit of context if needed: I'm using Ubuntu Server 16.04 LTS (HVM), SSD Volume Type (ami-cd0f5cb6) as my base AMI I'm provisioning a slightly modified MySQL database that I want my customers to be able to access. This is their primary way of interacting with my service. I'm building a django web service that will come packaged on the AMI. This is what I'd like to lock down and prevent access to. -
How to search a model using multiple fields and to set a priority for them?
I'm using Haystack for searching users in database. I want to check the name of the user, city and state (+abbr of state). I've done autocomplete using ElasticSearchEdgeNgramField. # search_indexes.py class SwimmerIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) name = indexes.CharField(model_attr='get_display_name') name_auto = ElasticSearchEdgeNgramField(use_template=True, template_name='search/indexes/sdif/swimmer_text.txt', index_analyzer="edgengram_analyzer", search_analyzer="standard_analyzer") # swimmer_text.txt {{ object.get_full_nickname }} {{ object.state }} {{ object.get_state_display }} {{ object.city }} And the search. sqs = sqs.autocomplete(name_auto=request.GET.get('q', '')) I have 2 users in database: Jack Hunt, Oklahoma, OK Jack Smith, Huntsville, AL When I search for "Jack Hunt" I'm getting: Jack Smith, Huntsville, AL Jack Hunt, Oklahoma, OK The reason is the city. So I'm searching for the way to boost user if name matches. I've found one solution. nickname = indexes.CharField(model_attr='get_full_nickname', boost=1.125) state = indexes.CharField(model_attr='state', boost=1.0) state_display_name = indexes.CharField(model_attr='get_state_display', boost=1.0) city = indexes.CharField(model_attr='city', boost=1.0) Following the example from https://django-haystack.readthedocs.io/en/master/boost.html sqs = sqs.filter(SQ(name=AutoQuery(q)) | SQ(state=AutoQuery(q)) | SQ(state_display_name=AutoQuery(q)) | SQ(city=AutoQuery(q))) But after searching for "Jack Hunt" I haven't got Jack Smith from Huntsville. Since his name is not like "Jack Hunt" and his city is not like "Jack Hunt". I know I can search for each word. But it's not very "elastic". What can I do to make autocomplete on 4 fields … -
import module form package using string configuration
in my python application i import some configuration related the moudule that i want to import so how to do that using string conf like shown in below example for exmpple i use pakage package="pak.pak1" module="moduleA" and i want to do folwing from package import module but i have the error that ModuleNotFoundError: No module named moudleA //////////////////////////////////////////// in my python application i import some configuration related the moudule that i want to import so how to do that using string conf like shown in below example for exmpple i use pakage package="pak.pak1" module="moduleA" and i want to do folwing from package import module but i have the error that ModuleNotFoundError: No module named moudleA -
One Form for 2 Models with ForeignKey
I use one html form to insert data into two models. Model Table_2 has ForeignKey pointing to the model Table_1, therefore I must insert row in the Table_1 beforehand Table_2. At present I've solved my problem the following way: ## First write to Table_1 tbl_1 = form_1.save() tbl_2 = form_2.save(commit=False) ## Then use Table_1 as foreign key in Table_2 tbl_2.fk = tbl_1 tbl_2.save() models.py class Table_1(models.Model): name = models.CharField(max_length=255, blank=False, null=False) postcode = models.CharField(max_length=10, blank=False, null=True) class Table_2(models.Model): name = models.CharField(max_length=255, blank=False, null=False) email = models.EmailField(max_length=255, blank=False, null=False) fk = models.ForeignKey(Table_1, models.DO_NOTHING, blank=True, null=True) forms.py class ModelForm_1(ModelForm): class Meta: model = models.Table_1 fields = ['name', 'postcode'] class ModelForm_2(ModelForm): class Meta: model = models.Table_2 fields = ['name', 'email'] views.py class HomeView(generic.base.TemplateView): template_name = 'portal/home.html' context_object_name = 'ctx' success_url = reverse_lazy('portal:portal') form_1 = forms.ModelForm_1(prefix='f1', auto_id=True) form_2 = forms.ModelForm_2(prefix='f2', auto_id=True) def get(self, request, *a, **kw): ctx = super(HomeView, self).get_context_data(**kw) ctx.update({'form_1': self.form_1, 'form_2': self.form_2}) return render(request, self.template_name, ctx) def post(self, request, *a, **kw): ctx = super(HomeView, self).get_context_data(**kw) ## Init forms with user data form_1 = forms.ModelForm_1(request.POST, prefix='f1', auto_id=True) form_2 = forms.ModelForm_2(request.POST, prefix='f2', auto_id=True) ## Verify form data if not all([f.is_valid() for f in (form_1, form_2)]): ctx.update({'form_1': form_1, 'form_2': form_2}) return render(request, self.template_name, ctx) ## … -
How do I use CreateView with ModelForm and Id of a parent Model in URL?
I am trying to make a CreateView that also accepts a variable from url. My models: class BuddyConnection(models.Model): owner = models.ForeignKey(User, on_delete=models.CASCADE) class BuddyConnectionAction(models.Model): connection = models.ForeignKey(BuddyConnection, on_delete=models.CASCADE) ... my url is as follows: url('^actions/(?P<connection_id>[0-9]+)/$', views.BuddyConnectionActionView.as_view(), name='buddy_connection_actions'), My view is as follows: class BuddyConnectionActionView(CreateView): form_class = BuddyConnectionActionForm success_url = reverse_lazy('buddy_connection_actions') template_name = 'buddy/connection_actions.html' basically, I am trying the get the variable from the url, into the form, so when I save the object, I can set it up as the foreign key. -
How to prevent unneccessary queries in Django properties?
I have a property on a Django model that needs to access a related object through its foreign key relationship. In some functions, I loop through a large set of objects, calling this property. select_related doesn't appear to be working anymore once inside the property method. The code I have is similar to the following: def usefulFunction(): aObjs = ClassA.objects.all().select_related('bObj', 'bObj__cObj') for aObj in aObjs: usefulResult = aObj.bObj.property class ClassA: bObj = models.ForeignKey(ClassA) class ClassB: cObj = models.ForeignKey(ClassC, null=True) aField = models.FloatField() @cached_property def property(self): if self.cObj: return self.cObj.aValue else: return 2*aField I access property in many places throughout my project, including serializing it with Django Rest Framework. From profiling, I can see that a new query is executed on the if self.cObj line, even though usefulFunction does a select_related('bObj__cObj'). Is there any way to get similar functionality, but preventing all these queries? -
Django Sphinx Error while importing
I am getting below error while running make html AppRegistryNotReady: Apps aren't loaded yet. My conf file contains the below conf for importing import os import sys sys.path.insert(0, os.path.abspath('..')) from django.conf import settings settings.configure() docs is contained in my project folder. I have multiple apps. -
Started a django server from inside Pycharm, but now I cannot turn it off
I'm new to Pycharm IDE. Previously have been using Atom editor and a shell. Tonight I created a small Django project in Pycharm. I used the "Tools: Run manage.py task" menu option. Then I ran runserver from the terminal it opened. This launched my server at http://127.0.0.1:8000, as expected. But later I accidentally closed the manage.py window pane in pycharm ide. The server continues to run. Even after I closed Pycharm, the server remains running. How do I stop it?!?! Embarassing. -
Django Autocomplete Light Empty Select Box
Why does implementation of django-autocomplete-light result in an empty dropdown box? I have seen similar questions in GitHub issues, but the solutions there didn't affect my situation, and the solutions were generally just compromises with the type of field used. I have followed the dal tutorial and resulted in the following files. These files are all within my actions app, including the urls.py: models.py class Entity(models.Model): entity = models.CharField(primary_key=True, max_length=12) entityDescription = models.CharField(max_length=200) def __str__(self): return self.entityDescription class Action(models.Model): entity = models.ForeignKey(Entity, on_delete=models.CASCADE, db_column='entity') action = models.CharField(max_length=50) def __str__(self): return '%s' % self.entity forms.py: class ActionForm(ModelForm): class Meta: model = Action fields = '__all__' widgets = { 'entityDescription': autocomplete.ModelSelect2(url='eda') } ActionFormSet = modelformset_factory(Action, extra=1, exclude=(), form=ActionForm) views.py: class EntityAutocomplete(autocomplete.Select2QuerySetView): def get_queryset(self): qs = Entity.objects.all() if self.q: qs = qs.filter(entityDescription__istartswith=self.q) return qs urls.py: urlpatterns = [ url(r'actions', views.actions, name='actions'), url( r'^eda/$', views.EntityDescriptionAutocomplete.as_view(), name='eda', ), ] This is in my template: {% block footer %} <script type="text/javascript" src="/static/collected/admin/js/vendor/jquery/jquery.js"></script> {{ form.media }} {% endblock %} Going to http://127.0.0.1:8000/eda results in seemingly proper JSON: {"results": [{"id": "123", "text": "123 - Michael Scott"}, {"id": "234", "text": "234 - Jim Halpert"}, {"id": "345", "text": "345 - Pam Beasley"}], "pagination": {"more": false}} Reversing the url... >>>from django.urls … -
Django overide parts of iinherited template
I have the following templates set up base.hmtl {% extends 'base/main_base.html' %} {% block main-content %} <1>Header stuff<h1> ... {% block article-content %} {% endblock %} {% endblock %} article.html {% extends 'base.html' %} {% block article-content %} <h2>Content</h2> <p>More content</p> ... {% endblock %} Now, I a view connected to the article.html, and I want use the dynamic view data to overwrite the 'header stuff' in the 'base.html' template. Problem is, the view is connected to the article.html, which inherits from the base. Is there a way to override parts of the base template from the child template? -
Django Channel first steps error
I'm following the Getting Started tutorial from Channels docs, but when I launch the runserver and try to load any page it gives me this error: 16:17:46 [django.request] ERROR Internal Server Error: / Traceback (most recent call last): File "C:\web\wr-kpi-dashboard\.venv\lib\site-packages\django\core\handlers\base.py", line 235, in get_response response = middleware_method(request, response) File "C:\web\wr-kpi-dashboard\.venv\lib\site-packages\wr_security\middleware\log_access.py", line 39, in process_response 'protocol': request.META['SERVER_PROTOCOL'], KeyError: 'SERVER_PROTOCOL' [2017/09/06 16:17:47] HTTP GET / 500 [0.63, 127.0.0.1:60297] settings.py CHANNEL_LAYERS = { "default": { "BACKEND": "asgiref.inmemory.ChannelLayer", "ROUTING": "dashboard.channels.routing.channel_routing", }, } routing.py from channels.routing import route from consumers import ws_message channel_routing = [ route("websocket.receive", ws_message), ] consumers.py def ws_message(message): # ASGI WebSocket packet-received and send-packet message types # both have a "text" key for their textual data. message.reply_channel.send({ "text": message.content['text'], }) -
Django, AJAX and Queryset with Foreignkey issue
I try stored some data using AJAX, but I have problem with ForeignKey attribute. How should be look a valid queryset? Ajax.js: $.ajax({ type: 'POST', url: '/board/table/card/create/', data: { board: $('#title').val(), title_card: $('#title_card').val(), description_card: $('#description_card').val(), csrfmiddlewaretoken: $("[name='csrfmiddlewaretoken']").val() }, statusCode: { 200: function(response) { alert('Card has been created and stored.'); }, 400: function(response) { alert('Oups, it worked yesterday!'); }, 409: function(response) { alert('Please, fill out card form.'); }, 406: function(response) { alert('Title should be unique.'); } }, }); urls.py : url(r'^table/card/create/$', views.create_card, name='create_card'), views.py: def create_card(request): if request.method == 'POST': board = request.POST['board'] title_card = request.POST['title_card'] description_card = request.POST['description_card'] unique = Board.objects.get(title=board) if (len(title_card) != 0 and len(description_card) != 0) and \ (len(title_card) <= 15 and len(description_card) <= 15): #PROBLEM HERE obj, created = Card.objects.get_or_create(Board, board=unique, title_card=title_card, description_card=description_card) if created: return HttpResponse(status=200) else: return HttpResponse(status=406) else: return HttpResponse(status=409) else: return HttpResponse(status=400) models.py class Board(models.Model): title = models.CharField(max_length=15, unique=True) description = models.CharField(max_length=25) category = models.CharField(max_length=20) def __str__(self): return self.title class Card(models.Model): board = models.ForeignKey(Board) title_card = models.CharField(max_length=15, unique=True) description_card = models.CharField(max_length=15) Ajax.js and urls are valid. They work good. It's issue with views.py and ORM QuerySet. Django show me: Internal Server Error: /board/table/card/create/ Traceback (most recent call last): File "C:\Program Files\Python36\lib\site-packages\django\core\handlers\excepti on.py", … -
django check if word is in model field
i searched a lot before posting this question but i didn't find the answer i was looking for. i recently added the seach function to my Django powered site this is the code: my Html input name is 'q' and the form action is:{% url searcher %} my url: url(r'^sercher$', views.searcher, name='searcher'), the view: def searcher(request): Userinput = request.GET.get("q") return render(request, 'music/FP.html', {'FP': Project.objects.filter(Userinput)}) and it's working, for example if i have a project_title called "my project" and the user searched for "my" the search function wont work the user have to type "my project" how to fix this? -
Sphinx not picking up automodules
I am using Sphinx for django documentation. Followed all steps as mentioned on http://www.marinamele.com/2014/03/document-your-django-projects.html Things are working fine, except that the generated html doesn't contain models definitions. The link to models just shows what I have included. ..automodule:: kyc_connect.kyc_rest_services.kyc_connect_accounts.models members: -
Get data from 2 models with Django
I am new to Django and I need data from two models and would like to do it with one query. Here is what I have in sql that gives me exactly what I need. Can someone please show me how to do it in Django. select api_userprofile.last_name, api_userprofile.first_name, api_userdevice.is_admin, api_userdevice.is_alerts_enabled,api_userdevice.is_owner from api_userprofile join api_userdevice on api_userdevice.user_id=api_userprofile.user_id where api_userdevice.user_id=10 and api_userdevice.device_id=29 These are my 2 models: class UserDevice(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=False) device = models.ForeignKey(Device, on_delete=models.PROTECT, null=False) activation_date = models.DateTimeField(default=timezone.now, null=False) friendly_name = models.CharField(max_length=20, null=True, blank=True) is_owner = models.BooleanField(null=False, default=False) is_admin = models.BooleanField(null=False, default=True) is_alerts_enabled = models.BooleanField(null=False, default=True) class UserProfile(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=False) token = models.TextField(null=False, blank=True) first_name = models.TextField(null=True, blank=True) last_name = models.TextField(null=True, blank=True) Any help would be greatly appreciated. -
Django template - number between?
I am trying to do an if statement in a Django template for if a number is greater than 75 but less than 90, I'm not sure how this is done in a template, below is my code thus far, which errors:- Error: Could not parse the remainder: '<=90' from '<=90' Code: <td> <span class=" {% if i.speed_down >= 90 %} red {% elif i.speed_down >= 75 <=90 %} amber {% endif %} "> Speed Down: {{ i.speed_down }} </span> </td> -
Build a simple online video editor - node.js, django, J2EE?
I'm studying the technical aspects of a personal project, and I've questions about the feasibility and the techno to use ! Basically, I need to be able to create a (verry simple) online video editor, with the following functionnalities : - Upload one or many videos - Crop the videos - Put together the videos to make a single longest videos - Make (simple) transitions between the videos - Change the luminosity and contrast - Adjust the sound - Add a background music - Integrate the videos in a kind of "video theme" (You know, kind of like iMovie video themes, with pre-defined colors and animations, but very simple) So I wonder about the technologies to use : Better to use javascript with node.js ? Better to user Django, with python in backend to calcul my render ? Better to use J2EE for the same reason ? Then, do you know if I could use an existing framework or project to do it easily ? e.g. :I noticed that many in javascript (node) exists on github Finaly, do you know about the calculation power / CPU needed by the server ? Basically, it would be a web app that could … -
Django login to channel
I'm new in django and python also, I need to change login logic to similar to Slack, the user should give the channel name and user email also, that means the email is not unique anymore and the same email can be more then by one user. The channel should hava an administrator and the administrator can invoite new people to this channel. Maybe someone nows close open source projects to this logic ? Or can help with desing of the models ? -
Create a many to many relationship in Django Models replicating pivot tables, issues with ModelSerializer in Django Rest Framework
I have a Django Model called Hackathon and another called User. Multiple Users may be associated with multiple Hackathons and may have different roles which is basically an enum defined by me. Now my concern is, would creating a 2 way association as so be the most appropriate? What are the best practices? """ Hackathon Model """ class Hackathon(models.Model): id = models.PositiveIntegerField(primary_key=True) data = models.TextField() is_published = models.BooleanField(default=False) """ User Model """ # Enum for roles of a user USER_ROLES = ( ('O', 'Organiser'), ('P', 'Participant'), ('V', 'Volunteer'), ('M', 'Mentor'), ) class User(models.Model): id = models.PositiveIntegerField(primary_key=True) hackathons = models.ManyToManyField(Hackathon) role = models.CharField(max_length=1, choices=USER_ROLES) Ideally, we would have a seperate Hackathon table, a separate User table and then a pivot table that stores (user_id, hackathon_id, user_role) in that. Does my relationships achieve that? Now when I use this Model as a ModelSerializer, I want to insert a user without specifying the roles. I believe I can override it but is this the right way to go? class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('id', 'hackathons') I am very confused. What about extensive validation and making sure that the input data is correct? How to implement the validation logic in … -
Perform additional operations for each call to an external API
I have an external API that I cannot modify. For each call to this API, I need to be able to perform an operation before and after. This API is used like this: def get_api(): """ Return an initiated ClassAPI object """ token = Token.objects.last() api = ClassAPI( settings.CLASS_API_ID, settings.CLASS_API_SECRET, last_token) return api I am using python 2.7. get_api() is called everywhere in the code and the result is then used to perform request (like: api.book_store.get(id=book_id)). My goal is to return a virtual object that will perform the same operations than the ClassAPI adding print "Before" and print "After". The ClassAPI looks like this: class ClassAPI class BookStore def get(...) def list(...) class PenStore def get(...) def list(...) I tried to create a class inheriting from (ClassApi, object) [as ClassAPI doesn't inherit from object] and add to this class a metaclass that decorates all the methods, but I cannot impact the methods from BookStore (get and list) Any idea about how to perform this modifying only get_api() and adding additional classes ? I try to avoid copying the whole structure of the API to add my operations. Regards -
Django include urls not found (404)
i'm trying to make a simple login page with the python framework Django but the regex doesn't match... The predefine url 'admin' seems to works. Main's urls code: from django.conf.urls import url, include from django.contrib import admin from login import views from home import views urlpatterns = [ url(r'^login/', include('login.urls')), url(r'^home/', include('home.urls')), url(r'^admin/', admin.site.urls), ] The login's page url: from django.conf.urls import url from django.contrib import admin from . import views urlpatterns = [ url(r'^login/$', views.login) ] And the login's page view: # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render # Create your views here. def login(request): return render(request, 'login/login.html', {'date': datetime.now()}) I've had 'login' to settings.py at 'INSTALLED_APP'. Any help would be appreciated, thanks :) -
No default service defined with ZEEP
So I'm trying to get a response with ZEEP but get 'There is no default service defined'. I've done this the hardcoded way before, and are trying to start using ZEEP. So bare with me. This is my new view: def status(request): IP = "n.n.n.n" URL = "http://" + IP + "/service" session = Session() session.auth = HTTPBasicAuth('username', 'password') client = Client(URL, transport=Transport(session=session), strict=False) response = client.service.Method1(request={'getList'}) return response As I said; I've done this the hard way before, with hardcoded requests. This is how it looked like which also is working. And this I am trying to convert using ZEEP instead. def GetSession(IP): request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' request = request + ' <soapenv:Body>' request = request + '<login>' request = request + '<userName>username</userName>' request = request + '<pw>password</pw>' request = request + '</login>' request = request + '</soapenv:Body>' request = request + '</soapenv:Envelope>' request = u"""""" + request + """""".format() encoded_request = request.encode('utf-8') headers = {"Host": ""+ IP +"", "Content-Type": "text/xml; charset=UTF-8", "Content-Length": str(len(encoded_request)), "SOAPAction": ""} response = requests.post(url="http://"+ IP +"/service", headers=headers, data=encoded_request, verify=False) return response.content def GetArray(session, IP): request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">' request = request + '<soapenv:Header>' request = request + '<session>' + session + '</session>' request = … -
Django ORM and multiple annotations
How to get correctly result with multiple annotations? when I type: MyModel.objects.values('fk1__fk2__fk3__name').annotate(x=Count('fk1__items')) I get <QuerySet [ {'fk1__fk2__fk3__name': u'Name1', 'x': 1}, {'fk1__fk2__fk3__name': u'Name2', 'x': 2778} ]> When I type: MyModel.objects.values('fk1__fk2__fk3__name').annotate(x=Count('fk1__fk2__fk3__name')) I get <QuerySet [ {'fk1__fk2__fk3__name': u'Name1', 'x': 1}, {'fk1__fk2__fk3__name': u'Name2', 'x': 33} ]> But when I'm trying to connect this two annotations I get different results: MyModel.objects.values('fk1__fk2__fk3__name').annotate(x=Count('fk1__fk2__fk3__name'), y=Count('fk1__items')) Out[43]: <QuerySet [ {'y': 1, 'fk1__fk2__fk3__name': u'Name1', 'x': 1}, {'y': 2778, 'fk1__fk2__fk3__name': u'Name2', 'x': 2778} ]> How can I fix this? -
Django form not rendering properly
I am following the documentation of the Django Forms but I do not know why my form does not want to show up ! I am creating a form that will get an email en create invitation for user to sign in using this app :https://github.com/bee-keeper/django-invitations My forms.py: class InviteForm(forms.Form): Email1 = forms.EmailField(label='Email 1') My Views.py: from django.shortcuts import render from django.views.generic import TemplateView from .forms import InviteForm def CreateInvite(request): if request.method == 'POST': form = InviteForm(request.POST) if form.is_valid: email = form.cleaned_data['email1'] invite = Invitation.create('form.email1') invite.send_invitation(request) print("The mail was went") else: print("Your form is not valid") else: form = InviteForm() return render(request, 'HRindex.html', {'form': form}) My HTML: {% extends 'base.html' %} {% block body %} <div class="jumbotron"> <h1>Welcome to SoftScores.com</h1> <h2>Team analytics platfom</h2> <h3>Welcome to {{User.username}}, it is your Page</h3> </div> <div class="container"> <p> <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample"> Create a new team </a> </p> <div class="collapse" id="collapseExample"> <div class="card card-body"> In order to create a new team please invite new members. A link will be sent to them in order to give the access to the application </div> <form method="post"> {% csrf_token %} {{ form.as_p }} <input type="submit" value="Submit" /> </form> </div> </div> When it render the …