Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Reverse for 'profile-update' with no arguments not found. 1 pattern(s) tried: ['profile\\/update/(?P<pk>[\\-\\w]+)/']
sir i'm getting this error, Reverse for 'profile-update' with no arguments not found. 1 pattern(s) tried: ['profile\/update/(?P[\-\w]+)/'] after the form validation getting that error. I am unable to redirect it. how do i redirect to profile-update how to solve this problem please help me views.py @login_required def profile_update_view(request, pk): user = User.objects.get(pk=pk) form = UserProfileForm(instance=user) if request.user.is_authenticated and request.user.id == user.id: if request.method == "POST": form = UserProfileForm(request.POST, request.FILES, instance=user) if form.is_valid(): created_prof = form.save(commit=False) created_prof.user = request.user created_prof.save() return redirect('profiles:profile-update') return render(request, "profiles/profile_form.html", { "pk": pk, "form": form, }) else: raise PermissionDenied class ProfileDetailView(LoginRequiredMixin,DetailView): template_name = 'profiles/profile_detail.html' def get_object(self): username = self.kwargs.get("username") if username is None: raise Http404 return get_object_or_404(User, username__iexact=username, is_active=True) models.py def get_sentinel_user(): return User.objects.get_or_create(username='deleted')[0] class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.SET(get_sentinel_user)) profile_image = models.ImageField(blank=True, upload_to='imgfolder/profile_image/') magz_cover_name = models.CharField(max_length=20, blank=True, default='') website = models.URLField(default='', blank=True) bio = models.TextField(default='', blank=True) phone = models.CharField(max_length=20, blank=True, default='') class Meta: verbose_name = _("UserProfile") verbose_name_plural = _("UserProfiles") def __str__(self): return '%s' % (self.user.username) def create_profile(sender, **kwargs): user = kwargs["instance"] if kwargs["created"]: user_profile = UserProfile(user=user) user_profile.save() post_save.connect(create_profile, sender=User) urls.py urlpatterns = [ re_path('update/(?P<pk>[\-\w]+)/', views.profile_update_view, name='profile-update'), re_path('(?P<username>[\w-]+)/', ProfileDetailView.as_view(), name='profile-detail'), ] template <form action="." method="post" enctype="multipart/form-data" > {% csrf_token %} {{form.as_p}} </form> -
How can I change django runserver url?
I'm trying to change django project url, so that users, who wants to connect to website in local area network will see url instead of localhost:8000 or 127.0.0.1. I need to change localhost:8000/users/board to be http://example.eu. I've tried to python manage.py runserver http://example.euand then thought about changing url's but it doesn't work. Also tried to change hosts file(Windows OS), but as far as I understand I need real ip address not url. Is it possible to do this thing and how? -
FileNotFoundError: No such file or directory: '/media/images/test2_EDBjGU4.jpg'
view.py from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse from males.models import Male from .forms import MaleForm from django.http import HttpResponseRedirect import io import os from google.cloud import vision from google.cloud.vision import types def detect_text(path): client = vision.ImageAnnotatorClient() with io.open(path, 'rb') as image_file: content = image_file.read() image = types.Image(content=content) response = client.text_detection(image=image) texts = response.text_annotations for text in texts: print(text.description.encode('utf-8')) def response(request): queryset = Male.objects.all() for each in queryset: path = each.image.url detect_text(path) context = { "object_list" : queryset, } return render(request, 'result.html', context) and my result.html <!DOCTYPE html> <head> <title>Success</title> </head> <body> <center> <p>Response text...</p> {% for each in object_list %} {% if each.image %} <img src='{{ each.image.url }}' height="200px" width="200px"> <br /> <p>{{ each.image.url }}</p> {% endif %} {% endfor %} <h3>click <a href='/'>here </a>for HOME</h3> </center> </body> </html> here...in img tag when i use "each.image.url" as source of image it renders an image but when i pass this(each.image.url) argument to detect_text() function that is my client application for google cloud vision api that contains /media/iamge/bill.jpg it shows me error how can i resolve this django version 2.0 python 3.6.4 -
how can we query foreign key and get results of objects which are connected to foreign key
hello guys i want to know what is the way i can use managers to query my foreign key and then retrieve objects that are connected to foreign key so here is my models.py from django.db import models # Create your models here. class BookManager(models.Manager): def title_count(self,keyword): return self.filter(title__icontains=keyword).count() class CategoryManager(models.Manager): def category_count(self): return self.filter(category__icontains=python).count() class Category(models.Model): title=models.CharField(max_length=20) def __str__(self): return self.title class Enquiry(models.Model): title=models.CharField(max_length=200) category=models.ForeignKey(Category ,default=False,blank=False) detail=models.TextField() objects = BookManager() objects=CategoryManager() # tags=models.ChoiceField() def __str__(self): return self.title i tried to use category manager but it gave me a strange error i just want to know how exactly we can get the objects that are connected with category foriegnkey and show them as list to the users -
How to iterate over a list value of a dictionary in django template
I have a dictionary where value are in list { 'Fees': ['88000', '88000'], 'ROll Number': ['I0', 'I1'], 'Mark': [10, 10] } So I am trying to insert this data in table, SO my django template are <table> <thead> <tr> {% for k, v in loan_bank_info.items %} <th>{{ k }}</th> {% endfor %} </tr> </thead> <tbody> <tr> {% for k, value in loan_bank_info.items %} {% for v in value %} <td>{{ v }}</td> {% endfor %} {% endfor %} </tr> </tbody> </table> but in table value are printing as follow, Fees ROll Number Mark 88000 88000 I0 I1 10 10 But what I want is - Fees ROll Number Mark 88000 I0 10 88000 I1 10 how to iterate over list value in django template -
Django and trac integrations
Is there any ways to run the django apps in trac as plugins and host both in the same virtual host in apache? I am using trac to develop plugin but now moving towards django so I like to use it along with trac?? -
How to implement a search algorithm on help topics
We're adding a help guide section to our site and it contains articles on how to use our site. We want to implement search feature - similar to how most support sites work. How do I implement such a feature? For instance, if a user searches for "I want to add a user", how should I search our help topics? My current idea is to add keywords manually for each topic and then match the search query against my keywords. Or should I look to third party tools such as Haystack? Similarly, if a user creates a support ticket, how can we display a list of suggested help topics - similar to how SO suggests answers while I'm typing the question. Or would this follow a different approach? Our site has been built using Django. -
Getting TemplateSyntaxError when trying to use Jinja's replace filter
Below is the snip of code I am using. <ul class="article_list"> {%for article in articles %} <li><a href="{{article.title|replace(' ','-')}}">{{article.title}}</a></li> {%endfor%} </ul> This is the exception I get. Invalid filter: 'replace' Request Method: GET Request URL: http://127.0.0.1:8000/Mathematics/ Django Version: 1.10.5 Exception Type: TemplateSyntaxError Exception Value: Invalid filter: 'replace' My intention is to redirect user to http://127.0.0.1:8000/mathematics/how-to-use-replace-in-jinga when they click on the article: How to use replace in jinga Please help. -
What is Room, Channels and Groups in Django
I'm new to Django and making a feed system using Django where users can receive feed notification from their subscribed channels. But I'm getting confused on these terms (Room, Channels, Groups). Can anybody clarify these terms and let me walk through the process to achieve the feed notification system. Any help would be appreciated. Thanks -
Django -Duplicate Key Errors while using Update_or_Create to save multiple selection form
I'm trying to save data using the model object manager. Everything works for creating a new entry, but I'm unable to update it. Models.py class Choice(models.Manager): def rates (self, Assignment_id, rating2, years,rating_id): assignment = Assignment.objects.get(id=Assignment_id) rating = rating2 rating_id = rating_id for i in range(len(rating2)): yo =NewYear.objects.get(new_year=years[i]) rated = Prog_capability.objects.update_or_create( defaults={ 'task' : task, 'rating' : rating, 'fy' :yo, 'rating_id': rating_id, }, task = task, rating = rating[i], fy = yo, rating_id = rating_id[i] ) class Choice(models.Model): rating_id = models.CharField(primary_key=True,max_length=255) rating = models.CharField(max_length=255, blank=True, null=True) fy = models.ForeignKey(NewYear, related_name="fcap", blank=True, null=True) assignment = models.ForeignKey(Assignment, related_name="tcap") objects = ChoiceManager() Views.py def task_rating(request, Assignment_id): ratings= request.POST.getlist('rating2',[]) years= request.POST.getlist('yo',[]) rating_id = request.POST.getlist('rating_id',[]) rates = Choice.objects.rates(Assignment_id, ratings, years, rating_id) I keep getting this error: duplicate key value violates unique constraint. DETAIL: Key (rating_id)=([u'17-1'....]) already exists. My question is: once I create the entries, how can I structure the model manager to update the entries? I want it to use the rating_id(primary key) to search for the entries and update them and if the rating_id does not exist create a new entry. Thank you in advance for your assistance. -
ImportError: No module named 'wagtail.core'
I am using python3 in a virtual environment and have wagtail installed via pip. When I am trying to extend home model for home page. I get the error:- ImportError: No module named 'wagtail.core' Here is the code of models.py:- from django.db import models from wagtail.core.models import Page from wagtail.core.fields import RichTextField from wagtail.admin.edit_handlers import FieldPanel class HomePage(Page): body = RichTextField(blank=True) content_panels = Page.content_panels + [ FieldPanel('body', classname="full"), ] I am following the basic tutorial for wagtail. Here is the link http://docs.wagtail.io/en/latest/getting_started/tutorial.html Version of wagtail==1.13.1 and Django==1.11.10. Kindly point to right direction. Thanks in advance. -
How to use Joined table in django queryset
i was join two table and i want to get field in joined model class school_name_list = Students.objects.select_related('School').values('school_name') but this code raise django.core.exceptions.FieldError: Cannot resolve keyword 'school_name' into field`` how can i solve it? -
how to implement timer in django application to track time spent on a multiple project at the same time by a perticular user?
I am sending the value of time_spent like this to client side: return render(request, 'index.html',{'time_spent':100}) here is my javascript code which I got from heresettimeout Here is my customize javascript code for timer: //Assignment Timer javascript var c = 0; var t; var timer_is_on = 0; function setTime(time){ this.c=time; } function timedCount() { document.getElementById("assignment_timer").value = c; c = c + 1; t = setTimeout(function(){ timedCount() }, 1000); } function startCount() { if (!timer_is_on) { timer_is_on = 1; timedCount(); } } function stopCount() { clearTimeout(t); timer_is_on = 0; } Here is how I call it: <script src="{% static 'assets/js/dls_preload.js' %}"></script> <input type="text" id="assignment_timer"> <script type="text/javascript"> var t="{{time_spent}}"; this.setTime(parseInt(t)); this.startCount(); </script> This is ok for one assignment. but how do I implement when more than one project? -
Send data from django service views to java script(chrome extension)
I am sending email and password from chrome extension to django service to check whether email and password is present in database or not. Next I have to send response from django service to java script(chrome extension). javascript in chrome extension: document.addEventListener('DOMContentLoaded', loginEvents, false); function myAction(femail,fpassword) { //alert("femail=" + femail.value + "fpassword=" +fpassword.value); var strLogin = "email=" + femail.value + "&password=" + fpassword.value; if (femail.value == ""){ alert("Username must be filled out"); return false; } if (fpassword.value == ""){ alert("Password must be filled out"); return false; } var newxmlhttp = new XMLHttpRequest(); var theUrl = "http://127.0.0.1:8000/polls/login/?"; newxmlhttp.open("POST", theUrl, true); newxmlhttp.onreadystatechange = function() { if (newxmlhttp.readyState == 4){ alert("entered"); } else{ alert("not entered"); } }; newxmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"); newxmlhttp.send(strLogin); } function loginEvents() { console.log("entered console"); var loginSubmitButton = document.getElementById('loginSubmit') loginSubmitButton.addEventListener('click', function(event) { var userEmail = document.getElementById('email'); var userPassword = document.getElementById('password'); myAction(userEmail,userPassword); }); } views.py: from django.http import HttpResponse from django.http import HttpResponseRedirect, HttpResponse from django.core.exceptions import ObjectDoesNotExist from django.shortcuts import render from .models import UserProfile from django.views.decorators.csrf import csrf_exempt @csrf_exempt def login(request): print(request.method) useremail = request.POST.get('email') userpassword = request.POST.get('password') print('email %s %s' % (useremail,userpassword)) try: /* to check the data is present in database or not */ entry = UserProfile.objects.get(email=useremail,password=userpassword) print('matched== %s %s' … -
Django customise response for success and fail
I want to create customise response for both success and fail for 1 of my serializer. Right now i only have the create function for success only I want the output to display like the default output + my 2 other message. promptmsg and status. eg output of json data: if success: promptmsg = "You have successfully create xxx" status = '200' if fail promptmsg = "You have fail to create xxx" status = '400' Here is the code for my views class ScheduleViewSet(viewsets.ModelViewSet): permission_classes = [AllowAny] queryset = Schedule.objects.all() serializer_class = ScheduleSerializer def create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) if not serializer.is_valid(raise_exception=False): return Response({"promptmsg": "You have failed to register an account", "status": "400"}, status=HTTP_400_BAD_REQUEST) response = super(ScheduleViewSet, self).create(request, *args, **kwargs) response.data['promptmsg'] = 'You have successfully create a book' response.data['statuscode'] = '200' return response def update(self, request, *args, **kwargs): partial = kwargs.pop('partial', False) instance = self.get_object() serializer = self.get_serializer(instance, data=request.data, partial=partial) if not serializer.is_valid(raise_exception=False): return Response({"promptmsg": "You have failed to register an account", "statuscode": "400"}, status=HTTP_400_BAD_REQUEST) # serializer.is_valid(raise_exception=True) # self.perform_update(serializer) response = super(ScheduleViewSet, self).update(request, *args, **kwargs) response.data['promptmsg'] = 'You have successfully create a book' response.data['statuscode'] = '200' return response As you can see, if fail, it will just return … -
Django User to User Messaging ModelForm Setup
I'm trying to build my own custom user to user messaging app for my site. I know about Postman and the other ones, but I'm doing my own for two reasons: 1. Get more familiar with Django, 2. Include the possibility for further customization down the road. As such, I'm trying to create a simple model and ModelForm to use but I'm getting an error. The following is my code. models.py from django.db import models from home.models import Profile class Message(models.Model): recipient = models.ManyToManyField(Profile, related_name = 'recipient') sender = models.ForeignKey(Profile, on_delete = models.CASCADE, related_name = 'sender') subject = models.CharField(max_length = 1000, blank = True) message = models.TextField() sent = models.DateTimeField(auto_now_add = True) unread = models.BooleanField(default = True) def __str__(self): return 'Message from ' + str(self.sender) + '. Subject:' + str(self.subject) For completeness the home.models Profile class is below, though this is not the problem. home.models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete = models.CASCADE, null = True) bio = models.TextField(max_length=500, blank=True) location = models.CharField(max_length=30, blank=True) birth_date = models.DateField(null=True, blank=True) def __str__(self): return self.user.username forms.py from django.forms import ModelForm from django.contrib.auth.models import User from messenger.models import Message class MessageForm(ModelForm): class Meta: model = Message fields = ('recipient','sender','subject','message','unread') I'm simply trying to figure … -
Extending User fields in UserCreationForm
I am trying to add some custom fields to a user, and extend the UserCreationForm so that I can add these fields when the user is created. I am following the docs but when I try to load the page to create a user I get an error: Unknown field(s) (username) specified for Customer. The docs that I am following: Custom User and Auth Forms models.py class User(AbstractUser): is_restaurant = models.BooleanField(default=False) is_customer = models.BooleanField(default=False) class Customer(models.Model): user = models.OneToOneField(User, primary_key=True, on_delete=models.CASCADE) address = models.CharField(max_length=200) def __str__(self): return self.user.get_full_name() forms.py class CustomerSignUpForm(UserCreationForm): class Meta(UserCreationForm.Meta): model = Customer fields = UserCreationForm.Meta.fields + ('address',) I understand that username is not part of the Customer class, but the docs appear to be doing the same thing... -
opencv function to save image to a memory object buffer instead of file (imwrite)
Currently, I have an image in opencv that is processed. Using imwrite(), I am able to save it to a file. cropped_resize = cv2.resize(cropped_image, (0,0), fx=float(s)/cropped_image.shape[0], fy=float(s)/cropped_image.shape[0]) cv2.imwrite("test.png",cropped_resize) <--- this is where i want to store in an image object I am writing a Django web app, and I dont want it to save to a file everytime for performance issue. I am actually going to upload the image to AWS S3. Through REST API, I upload the image this way https://github.com/ageitgey/face_recognition/issues/324 FYI, Im using imdecode() for converting raw image to cv2. im_cv = cv2.imdecode(np.fromstring(im_obj.read(), np.uint8), cv2.IMREAD_UNCHANGED) How can I do it viceversa? I would prefer to store it in a memory object and then upload it to S3 therefore this object is to assign to Django ImageField. What is the opencv function to do this (meaning store in an image object) instead of imwrite() ? My initial thoughts for the solution is probably using imencode() ? -
why "django.forms.widgets has no attribute RadioFileRender" excetpion occured?
I am a newbie to django and djangocms , when i try to install djangocms's addon aldyrn_bootstrap3 ,my command is python manage.py migrate aldryn_bootstrap3 the following error shows es\aldryn_bootstrap3\models.py", line 26, in <module> from . import model_fields, constants File "C:\Users\shikw\AppData\Local\Programs\Python\Python36-32\lib\site- packages\aldryn_bootstrap3\model_fields.py", line 26, in <module> from . import fields, constants File "C:\Users\shikw\AppData\Local\Programs\Python\Python36-32\lib\site- packages\aldryn_bootstrap3\fields.py", line 8, in <module> from . import widgets, constants File "C:\Users\shikw\AppData\Local\Programs\Python\Python36-32\lib\site- packages\aldryn_bootstrap3\widgets.py", line 10, in <module> class ContextRenderer(django.forms.widgets.RadioFieldRenderer): AttributeError: module 'django.forms.widgets' has no attribute 'RadioFieldRender er' Django (1.11.10) django-cms (3.5.0) i seems that 'RadioFieldRender' has been removed. can somebody help me -
Django URL conf gives a HTTP 405 Error
So i have two very similar endpoint URLs: url(r'^users/(?P<username>.+)/$', user_detail, name='user_detail'), url(r'^users/(?P<username>.+)/followers/$', follow_view, name='follow'), In that order, i get a HTTP 405 (Method Not Allowed), but when the order is changed (/followers on top) i dont get the error, but i get it now in the second endpoint. The respective api_views have the respective allowed method list, for example: @api_view(['POST', 'GET', 'DELETE']) @authentication_classes((BasicAuthentication,)) @permission_classes((IsAuthenticated,)) def follow_view(request, username, format=None): What can i do to make this URL Conf work? Thanks! -
Django: Key (slug)=(*) already exists
I'm pretty new to Django and python and I'd like to learn more about how to populating my Postgres database. Here is my current model:models.py from django.template.defaultfilters import slugify class Skill(models.Model): name = models.TextField() slug = models.TextField(unique = True) def __unicode__(self): return "%s" % self.name` and my views:views.py `r = r.json() try: Skills = r['data']['skills'] except: pass for skill in Skills: skill = Skill.objects.create(name=skill['name'],slug=slugify(skill['name'])) I'm getting the error: Exception Type: IntegrityError DETAIL: Key (slug)=(systems-engineering) already exists. I've been reading a similar post although still haven't been able to solve my problem. objects.create() will shows an error when the object already exists in the database, but I was getting error with the code above. Could "unique = True" be causing the error? and how do you fix this? -
How to test a Django custom filter?
This question is similar to Testing a custom Django template filter, but unlike in that example, the filter is actually defined in a module in the templatetags directory as described in https://docs.djangoproject.com/en/2.0/howto/custom-template-tags/#writing-custom-template-filters. Here is the filter code in templatetags/label_with_classes.py: from django import template register = template.Library() @register.filter(is_safe=True) def label_with_classes(bound_field): classes = f"{'active' if bound_field.value() else ''} {'invalid' if bound_field.errors else ''}" return bound_field.label_tag(attrs={'class': classes}) Here is my first stab at a test for it: from ..templatetags.label_with_classes import label_with_classes from django.test import SimpleTestCase from django.template import Context, Template from ..forms.sessions import SessionForm class CustomFilterTest(SimpleTestCase): def test_1(self): form = SessionForm(data={}) self.assertFalse(form.is_valid()) self.assertEqual( form.errors, {'session_number': ['This field is required.'], 'family': ['This field is required.'], 'session_type': ['This field is required.']}) template = Template('{{ form.session_number|label_with_classes }}') context = Context({'form': form}) output = template.render(context) The problem is that I get an error that the filter was not found: django.template.exceptions.TemplateSyntaxError: Invalid filter: 'label_with_classes' This is because the test case doesn't mimic the behavior of registering the filter and loading it in the template. It seems like in the Django source code, for example https://github.com/django/django/blob/master/tests/template_tests/filter_tests/test_join.py, there is an elaborate setup decorator which provides the test class with a self.engine whose render_to_string method has the required filters already installed. … -
i am trying to create a website with python and django and i am not able to run my server and i tired everything
PS C:\Users\jared\Desktop\django.website> cd mysite PS C:\Users\jared\Desktop\django.website\mysite> python manage.py runserver Performing system checks... Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000028B7237D7B8> Traceback (most recent call last): File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run self.check(display_num_errors=True) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 364, in check include_deployment_checks=include_deployment_checks, File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 351, in _run_checks return checks.run_checks(**kwargs) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\checks\registry.py", line 73, in run_checks new_errors = check(app_configs=app_configs) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique all_namespaces = _load_all_namespaces(resolver) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces url_patterns = getattr(resolver, 'url_patterns', []) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\functional.py", line 36, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\resolvers.py", line 536, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\functional.py", line 36, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\resolvers.py", line 529, in urlconf_module return import_module(self.urlconf_name) File "C:\Users\jared\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 719, in exec_module File "<frozen importlib._bootstrap_external>", line 855, in get_code File "<frozen importlib._bootstrap_external>", line 786, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed **File "C:\Users\jared\Desktop\django.website\mysite\mysite\urls.py", line 22 ] ^ SyntaxError: … -
Django template onclick inline html javascript alternative
I read that using onclick is deprecated and bad practice. I have this do_something function that will proccess the data inside of onclick. How I can convert this to javascript: {% for user in all_user %} <tr> <td>{{ user.code }}</td> <td> <button type="button" onclick="do_something('{{ user.name }}', '{{ user.age }}', 1, '{{ user.desc }}');">small</h6></button> </td> </tr> {% endfor %} -
gaierror while using send_mail django
I'm running into a gaierror [errno 8] when using send_mail for a contact form on my website hosted on my linode server. This is what I have in the setting.py file: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'example@domainhostedongsuite.com' EMAIL_HOST_PASSWORD = 'password' EMAIL_PORT = 587 EMAIL_USE_TLS = True The server is running apache 2, not sure if that has anything to do with it. Can someone help me out?