Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django cannot delete cookie and session after logout, cahing on nginx level, auth system not work?
nginx cahing everything, if I login to the system, then I can no longer exit it until the caching expires, since I'm Logout from the account, i need to know how to delete cookies and session, DJANGO !? -
ModuleNotFoundError: No module named 'rest_framework' I already installed djangorestframework
I got an error,ModuleNotFoundError: No module named 'rest_framework' when I run command python manage.py runserver . Traceback says Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x108193ae8> Traceback (most recent call last): File "/Users/xxx/anaconda/envs/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/Users/xxx/anaconda/envs/env/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run autoreload.raise_last_exception() File "/Users/xxx/anaconda/envs/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception six.reraise(*_exception) File "/Users/xxx/anaconda/envs/env/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/Users/xxx/anaconda/envs/env/lib/python3.6/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/Users/xxx/anaconda/envs/env/lib/python3.6/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/xxx/anaconda/envs/env/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/Users/xxx/anaconda/envs/env/lib/python3.6/site-packages/django/apps/config.py", line 116, in create mod = import_module(mod_path) File "/Users/xxx/anaconda/envs/env/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked ModuleNotFoundError: No module named 'rest_framework' I already run command pip3 install djangorestframework,when I run this command again, Requirement already satisfied: djangorestframework in /usr/local/lib/python3.6/site-packages shows in terminal.Python version is 3.6.2.What is wrong in my code?How should I fix this?I use Anaconda virtual environment. -
Django allauth custom template not hashing passwords
I am using my own custom view and inheriting from SignupView in (from allauth.account.views import SignupView) I also am using my own forms.py to pass on to my custom view. It is signing up the user just fine, but one thing it's not doing is hashing the passwords. It's saving the passwords for the user the way it is. How can I make it so that the passwords are stored in the table as a hash? forms.py from .models import User from django import forms class RegisterForm(forms.ModelForm): class Meta: model = User fields = ['username', 'email', 'password'] username = forms.CharField(label='Username', widget=forms.TextInput(attrs={'placeholder': 'Username:'})) email = forms.EmailField(label='Email', widget=forms.EmailInput(attrs={'placeholder': 'Email:'})) password = forms.CharField(label='Password', widget=forms.PasswordInput(attrs={'placeholder': 'Password:'})) views.py from allauth.account.views import SignupView from .forms import RegisterForm class RegisterView(SignupView): form_class = RegisterForm template_name = 'oauth/auth_form.html' project urls.py urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^accounts/', include('oauth.urls')), //app name I created where my custom sign up view is url(r'^profiles/', include('profiles.urls')), url(r'^accounts/', include('allauth.urls')), ] -
How to make it an integer?
in view.py: return redirect('/website/detail/{0}/'.format(pk)) in urls.py: url(r'^detail/(?P<pk>\d+)/$',views.productDetailView,name='productDetailView'), pk is integer type but when I am passing it through '/website/detail/{0}/'.format(pk) this is becoming string. So I am getting this error: TypeError at /website/detail/1/ must be real number, not str I can solve it changing the url pattern. But I don't want that. So how can I pass pk as integer? -
cannot Login with credentials, that was used in signup form in django.
I have created a simple signup and login form for a web application. I was able to perform the sign up, but when I tried to login the user, using the credentials that I used during signup, it is not logging in. Only the users which are created using django- admin create superuser will be logged in, and not the users which were created using the sign up form. Here's my sample code. Views.py def signup(request): if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): user=form.save() userNAME = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=userNAME, password=raw_password) login(request, user) return redirect('/UserPage') else: form = UserForm() return render(request, 'signup.html', {'form': form}) Urls.py urlpatterns=[ url(r'^$',views.HomePageView.as_view()), url(r'^about/$',views.AboutPageView.as_view()), url(r'^time/$', current_datetime), No need , displaying in home page url(r'^input/$',views.EmployeeView.as_view()), url(r'^signup/$',signup, name="signup"), url(r'^UserPage/$',views.UserPageView.as_view()), url(r'^login/$',auth_views.login, {'template_name':'login.html'},name='login'), ] models.py class UserCredentials(models.Model): user_name=models.CharField(max_length=20) user_email=models.CharField(max_length=20) user_password=models.CharField(max_length=20) class Meta: db_table="userdetails" def __str__(self): return (self.user_name) class UserForm(ModelForm): class Meta: model=UserCredentials fields=['user_name', 'user_email', 'user_password'] And, by the way, I'm using django's default login and authenticate methods from django.contrib.auth. Also, It would be great, if someone can explain how does django stores the data posted from the form, and where does (may be in db tables) it looks for validation, when user credentials are supplied … -
Django NoReverseMatch exception with no arguments not found
Basic structure of my app is that of a blog which has comments. urls.py # methods to access details of a post url(r'^detail/(?P<pk>\d+)/$', staff_view.DetailPostView.as_view(), name = 'details'), # methods to add objects for posts(communication) and comments url(r'^new_comm/$', staff_view.form_view, name ='add_communication'), url(r'^detail/(?P<pk>\d+)/comment/new$', staff_view.comment_view, name='add_comment'), ] detail.html <div class='container'> <h2>{{ post.title }}</h2> <h3><span class="label label-info">{{post.date}}</span></h3> <br> <div class ='well'><h5>{{ post.descr }}</h5></div> <a href="{% url 'add_comment' pk=post.id %}">Add A Comment</a> views.py def comment_view(request,pk): comm_form = comment_form() print(request.POST.get('pk')) if request.method == 'POST': form = comment_form(request.POST) if form.is_valid(): usn = request.user.get_username() print(usn) new_com = comment() new_com.content = form.cleaned_data.get('content') print(new_com.content) new_com.link_to_comm = Comm_Item.objects.get(pk = request.POST.get('pk')) new_com.username = User.objects.get(username = usn) new_com.save(commit=True) return redirect('details',pk = self.kwargs ['pk']) return render(request, 'staffcom/comment.html', {'form': comm_form}) So what I want to do is add a comment to post(Comm_Item) through the details page of the post. The details page works correctly, however when I click on the link to add a comment, the comment form doesn't get rendered. It seems the get request doesn't get fulfilled. Reverse for 'add_comment' with no arguments not found. 1 pattern(s) tried: ['staffcom/detail/(?P<pk>\\d+)/comment/new$'] Would it help if I had an exception made for the request.method == "GET instead of leaving it to the remaining part of the … -
Django Social Auth Session not working
In my current project, I'm using two different Django web apps. One of this two web apps handles the authentication with email + password and python social auth. So both using django.contrib.sessions.backends.signed_cookies as SESSION_ENGINE with the same SECRET_KEY. When the user login with email + password on app1 he can access app2 and is authenticated but when he connects to e.g. Google or Facebook and then login he can't access app2 and is not authenticated. But why? Here my settings.py SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies" SESSION_COOKIE_NAME = 'curr_user_session' SESSION_COOKIE_SECURE = True SESSION_COOKIE_DOMAIN = ".example.com" SECRET_KEY = "just4testing" INSTALLED_APPS = [ # Add your apps here to enable them 'django.contrib.admin', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', "oidc_provider", "core", 'django.contrib.auth', "social_django", ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ '...', 'social_django.context_processors.backends', 'social_django.context_processors.login_redirect', ], }, }, ] SOCIAL_AUTH_PIPELINE = ( 'social_core.pipeline.social_auth.social_details', 'social_core.pipeline.social_auth.social_uid', 'social_core.pipeline.social_auth.auth_allowed', 'social_core.pipeline.social_auth.social_user', 'social_core.pipeline.social_auth.associate_user', 'social_core.pipeline.social_auth.load_extra_data', 'social_core.pipeline.user.user_details', ) -
Django rest framework get data based on current userId/token
In my model, i have a family table where user are able to enter their family details and store their information. But how do i get/query all the family member based on current userId ? For eg: userId=1 added 2 family member, mother and father. How do i get these 2 family member based on the query of the current user's userId ? here is my code : models class MyUser(AbstractUser): userId = models.AutoField(primary_key=True) gender = models.CharField(max_length=6, blank=True, null=True) nric = models.CharField(max_length=40, blank=True, null=True) birthday = models.DateField(blank=True, null=True) birthTime = models.TimeField(blank=True, null=True) class Family(models.Model): userId = models.ForeignKey(MyUser) relationship = models.CharField(max_length=100) first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) gender = models.CharField(max_length=6, blank=True, null=True) serializers class MyUserSerializer(serializers.ModelSerializer): valid_time_formats = ['%H:%M', '%I:%M%p', '%I:%M %p'] birthTime = serializers.TimeField(format='%I:%M %p', input_formats=valid_time_formats, allow_null=True, required=False) class Meta: model = MyUser fields = ['userId', 'username', 'email', 'first_name', 'last_name', 'gender', 'nric', 'birthday', 'birthTime'] read_only_fields = ('userId',) extra_kwargs = {"password": {"write_only": True}} def update(self, instance, validated_data): for attr, value in validated_data.items(): if attr == 'password': instance.set_password(value) else: setattr(instance, attr, value) instance.save() return instance class FamilySerializer(serializers.ModelSerializer): class Meta: model = Family fields = ('id', 'userId', 'first_name', 'last_name', 'gender', 'relationship') views class MyUserViewSet(viewsets.ModelViewSet): permission_classes = [AllowAny] queryset = MyUser.objects.all() serializer_class = MyUserSerializer filter_backends … -
How to get information from save in django
I need to see what value I saved in the save model of Django. I am not able to save the model after performing changes. class CategoryInlineAdmin(admin.TabularInline): model = Category fields = ('title', 'specifications') Category = forms.ModelChoiceField(queryset=Category.objects.all()) Product = forms.ModelChoiceField(queryset=Product.objects.all()) print("Ensi") # This gets printed def save(self, obj, *kwargs): x = self.cleaned_data['Category'].specifications y = self.cleaned_data['Product'].specifications print(x,y) # Any way to print this? y.update(x) # This is not working Product.save() # Unable to save after updating specifications -
slice a query result string field in annotation using Substr and negative values
I am trying to slice the last two characters of a field and annotate it to query result, using the method given in this post. Something like: Person.objects.all()\ .annotate( code = Substr('Number', 1, -2), ) The above code returns an empty string as soon as I use negative values as the third argument. How can I achieve this? -
how to insert polish characters into database in django
I am trying to insert text containing polish characters: ( ąęó ) into my database. But, django doesn't allow to do this ,I see the error: (1366, "Incorrect string value: '\xC4\x99cej' for column 'comments' at row 1") I have already added # -- coding: utf-8 -- at the beginning of the view file. Was also trying to use decode('utf8')/encode('utf8') functions but it didn't work. I'll be very thankful for help, Thanks in advance -
How to update the specific field in django
I am a beginner in django. My doubt is there is some field which needs to be updated. Change from false to true. Since this is the requirement. So far I've written this. shortlisted_venues = Shortlist.objects.filter(event_planning__in=event_objects, object_type_id=19) shortlist_filter = shortlisted_venues[0] shortlist_filter.from_see_price = True shortlist_filter.save() shortlist_filter.refresh_from_db() so when I run same commands in django shell I see the change in value. But when running by url it doesn't. What am I missing over here, so that my object gets updated. -
Remove spaces from words and generate exact words
I am using python and I am looking a way where I can arrange the words in a meaning full seance and can improve the readability. Sample words are H o w d o sm a l l h o l d e r f a r m e r s f i t i n t o t h e b i g p i c t u r e o f w o r l d f o o d p r o d u c t i o n Output How do small holder farmers fit into the big picture of world food production This one way to remover one time white spaces, where the line has two spaces it will keep the one. Can anyone suggest more ways . I am using python django framework Thanks in advance. -
Django clean method based on condition (one form used in two views)
I have one form which is used in two views. One to save and one edit/update. There is a clean function I use to check unique condition. (form has three fields. A combination of three can come only once.) Now as I am using the same form, it checks this condition for both views - Save and Edit. This results in form throwing an error in edit view stating that the value already exists. How could I use this clean method in such a way that it will check for this validation for save view but will not check for edit view. Edit View: @login_required def permissionEditView(request, pk): data = models.PermissionModel.objects.get(pk=pk) p_form = forms.PermissionForm(instance=data) if request.method == 'POST': p_form = forms.PermissionForm(request.POST, instance=data) if p_form.is_valid(): p_form.save() messages.success(request, 'Permission updated successfully.') return redirect(companyProfileView) return render(request, 'company_profile.html', {'p_form': p_form}) Save view: def permissionFormView(request): p_form = forms.PermissionForm() if request.method == 'POST': p_form = forms.PermissionForm(request.POST) if p_form.is_valid(): p_form.save() messages.success(request, 'Permission added successfully.') return redirect(companyProfileView) return render(request, 'company_profile.html', {'p_form': p_form}) Form with clean method: class PermissionForm(forms.ModelForm): class Meta: model = models.PermissionModel fields = '__all__' def clean(self): role = self.cleaned_data.get('role_name') feature = self.cleaned_data.get('feature') if models.PermissionModel.objects.filter(role_name=role, feature=feature).exists(): raise forms.ValidationError('Permission exists.') def __init__(self, *args, **kwargs): super(PermissionForm, self).__init__(*args, **kwargs) for … -
Django settings.cpython-36.pyc not ignored by gitignore
The file "settings.cpython-36.pyc" is not being ignored even duo I have added it to the .gitignore file. My current gitignore file Gitkraken view, you can see it still picks it up This line "LearnDjango/pycache/" in the gitignore file ignores the other ".cpython-36.pyc" files but not "settings.cpython-36.pyc" View of pycache folder, the 1st and 3rd files are ignored but not the 2nd Please help. P.S I am new to Django and git. -
Database and Models present still programming error is coming in DJango
I am trying to get the models data on the browser using the urls.py and views.py for last 3 days and failing miserably, although I am able to get the database in a json file but not on browser. This is the error log [http://dpaste.com/2DQZX1Z][1] and the code is here models.py from __future__ import unicode_literals from django.db import models class Authors(models.Model): aid = models.AutoField(primary_key=True) aname = models.CharField(max_length=200, blank=True, null=True) adescription = models.CharField(max_length=8000, blank=True, null=True) class Books(models.Model): bid = models.IntegerField(primary_key=True) bname = models.CharField(max_length=200, blank=True, null=True) bdescription = models.CharField(max_length=8000, blank=True, null=True) class Bookauth(models.Model): bid = models.ForeignKey(Books, models.DO_NOTHING, db_column='bid', blank=True, null=True) aid = models.ForeignKey(Authors, models.DO_NOTHING, db_column='aid', blank=True, null=True) views.py from __future__ import unicode_literals from django.shortcuts import render import requests from django.http import HttpResponse from django.db import models from .models import Books import json from django.core import serializers def index(request): return HttpResponse("Hello, world. You're at the polls index.") def getObject(request): all_books = Books.objects.all() html = serializers.serialize('json', all_books) return HttpResponse(html) #data = serializers.serialize("json", Books.objects.all()) #return HttpResponse(data, mimetype='application/json') urls.py from django.conf.urls import url from . import views urlpatterns = [ url(r'^non', views.index, name = 'index'), url(r'^auth', views.author_search, name = 'AuthSearch'), url(r'^book', views.getObject, name = 'Books') ] -
How to make Django authenticate User and Employee?
I have following models: Company, Employee, Bid When a User registers he can create number of companies. Under these created companies, he can add number of employees. These employees must be able to authenticate and create bids under a company in which they are created. User also must be able to create bids under any company. For now, Django authenticates only my User. But I want to add functionality to authenticate Employee as well. How to implement it? I did google it, however, found mostly examples which refer to official documentation. Not really sure which way to go. -
Reverse to the same page with pk as slug field after submit. Error:Reverse with no arguments not found
following scenario: I do have a edit profile page which pulls the data from db so the user can change them. After submitting everything gets stored in the db but the reverse doesn't seem to work. Basically I don't know how to give the pk along to be able to call the same site with reverse. views.py class EditUserProfileView(UpdateView): model = UserProfileInfo form_class = UserProfileForm template_name = "accounts/user_profile.html" def get_object(self, *args, **kwargs): user = get_object_or_404(User, pk=self.kwargs['pk']) return user.userprofileinfo def get_success_url(self, *args, **kwargs): if 'pk' in self.kwargs: pk = self.kwargs['pk'] else: slug = 'main' return reverse("accounts:edit") urls.py app_name = 'accounts' urlpatterns=[ url(r'^edit/(?P<pk>\d+)/$', views.EditUserProfileView.as_view(), name="edit-user-profile"),] html from where I call the edit-user-profile <li class="nav-item nav-link">Hello <a href="{% url 'accounts:edit-user-profile' pk=user.pk %}">{{user.first_name}}</a></li> Cheers -
Run Python GUI application as a web app in Python
i have a desktop Python GUI application.Can any one please suggest how to make it run able as a web app? -
How to re-increment each id attribute in Formset after deleting a Form in Django?
I currently have a formset rendered to a template, where I do a for loop over it to display each form. I have a button which adds extra forms and I also have a delete button which removes any of the forms. My problem is when I delete one of the middle forms, the incrementing from the formset management (ie. id="form-0-choice") gets thrown off. If I add 3 new forms, I now have form 1, 2, 3. If I delete form 2 and then add another form, I now have form 1, 3, 4. Not all the forms will be saved correctly. How would I go about re-incrementing these id's? Is there a better way to manage creating/deleting in a formset manager on the template side? Or, would I need to just use JS to split apart the id's and re-number them based on the TOTAL_NUM_FORMS or however it is spelled. -
django prefetch_related's Prefetch, order_by?
I figured the following query: context['user_artists'] = Artist.objects.filter(users=current_user).all() Coupled with the following usage in templates: {% if user_artists %} ... {% for artist in user_artists %} .... <p class="small">last release: {{ artist.release_groups.last.title }}</p> <p class="small">date: {{ artist.release_groups.last.release_date }}</p> Was hitting the database 3 times for every artist in the query. I know this can be brought down to 2 by simple saving .last in the template, but that still isn't fast enough. I know I can use prefetch_related like so: Artist.objects.filter(users=current_user).prefetch_realted(`release_groups`).all() And I also need eliminate he usage of .last since it implies another query. I can probably use the template engine's slice method to get the last element. But then I have to order the related relationship: meaning, I need release_group ordered by its own release_date before I access them in the template. This must not affect the order of the artist objects. How can this be done? -
Django Form post method returning error
I'm making a single page chat app which will list all the message I post. The thing is in order to make the list and the form appear in single page, I have to define a single view(from what I understand. I'm pretty new to Django.) that point to a url. My django files are like this: chat/urls.py from django.urls import path from chat import views urlpatterns = [ path('chat/', views.ChatListView.as_view(), name='chat'), ] chat/forms.py from django import forms from chat.models import Chat class NewMessageForm(forms.ModelForm): message = forms.CharField(widget=forms.Textarea( attrs={'rows': 3, 'placeholder': 'Type here'}), max_length=1000) class Meta: model = Chat fields = ['message'] chat.html ...#some styling codes <form method="post" novalidate> {% csrf_token %} {{ form }} <button type="submit" class="btn btn-success">Post</button> </form> chat/views.py from django.shortcuts import render from django.views.generic import ListView from chat.models import Chat from chat.forms import NewMessageForm class ChatListView(ListView): model = Chat template_name = 'chat.html' paginate_by = 20 ##I had a hard time rendering the form in html and this code solves the problem (from a stackoverflow answer) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['form'] = NewMessageForm() return context ##I'm not sure of this code. Am I doing it right? def new_message(request): if request.method == 'POST': form = NewMessageForm(request.POST) if form.is_valid(): … -
Update View not updating table when Rendering fields manually
When I am using simply this <form action="" method="post" enctype="multipart/form-data"> {% block content %} {% csrf_token %} {{ form }} <input type="submit" value="Update" /> {% endblock content %} </form> It is updating my JobFinal Table I can see POST /JobSchd/jobform_final/3/update/ HTTP/1.1" 302 0 But when changing {{ form }} to {{ form.job_name }} It doesn't update the table and doesn't redirect to the reverse url.And I can see POST /JobSchd/jobform_final/3/update/ HTTP/1.1" 200 4492 Here is my snippet of related View.py class JobFinalUpdate(UpdateView): model = JobFinal form_class = JobFormFinal template_name_suffix = '_update_form' def get_success_url(self): return reverse('JobSchd:user_details',kwargs={'pk': self.request.user.id}) Here is my form.py class JobFormFinal(forms.ModelForm): class Meta: model=JobFinal exclude=['user'] -
how to send null object (image) using axios to django
I have a django backend that will save / remove image when receiving request from API. I have succesfully delete the saved image if i using swagger / postman to call the API (sending the parameter null object). But i can't get it work via Axios. The CURL from Swagger : curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6IlNZU0FETUlOQFRSRUVTLkhBUlBBLkNPTSIsImV4cCI6MTUxNTAzNTU1MiwidXNlcl9uYW1lIjoiU1lTQURNSU5AVFJFRVMuSEFSUEEuQ09NIiwib3JpZ19pYXQiOjE1MTQ5NDkxMDR9.oz3_2fGKlOCesmU_RmSRJZOifZeFFQO1nwAWzyD6BYc' -d '{ \ "menu_type": 255, \ "icon": null, \ "login_id": 1 \ }' My axios sample code : formData.append('menu_type', 255) formData.append('login_id', 1) formData.append('icon', null) const config = { headers: { 'content-type': 'application/json' } } return new Promise(resolve => { axios.put(url + form.menu_uuid + "/", formData, config) .then(function (response) { resolve(response); }) .catch(function (error) { resolve(error.response); }); }); My request payload screenshot : Is there something that i missing that makes this axios request won't work ? -
Creating Django model instance on form submission
I have am trying to create a "stats" app in my project that keeps track of all the leads my site generates. When a user submit the "request info" form a message is automatically sent to the business associated with that product. Simultaneously I would like a model instance to be created in one of the models in the Stats app (different app then we are working in). The Stats works in the background simply collecting info view model instance for certain things. Here is the code breakdown: The view: def ListingView(request,name_initials,l_slug): listing = get_object_or_404(Listing,l_slug=l_slug) images = ListingImage.objects.filter(property=listing) form = ContactPropertyForm(request.POST or None) context = { 'listing':listing, 'images':images, 'form':form, } if form.is_valid(): name = form.cleaned_data.get('name') phone = form.cleaned_data.get('phone') email = form.cleaned_data.get('email') party_size = form.cleaned_data.get('party_size') form_message = form.cleaned_data.get('message') listing_address = listing.address message = name + " " + phone + " " + email + " " + party_size + " " + listing_address to_email = ['email here'] html_message = "<b>Name: </b>" + name + "<br>" + "<b>Phone: </b>" + phone + "<br>" + "<b>Email: </b>" + email + "<br>" + "<b>Group Size: </b>" + party_size + "<br>" + "<b>Property: </b>" + listing_address send_mail('New Lead', message, 'from email', ['To email'], fail_silently=False, …