Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django request.user become AnonymousUser after redirect
The problem here is that request.user always turn to AnonymousUser after redirect. I'm writing my own login method and authentication backend because I'm not using password for login. Here's my code. #app/view.py def login(request): template = 'index.html' if request.method == "POST": userId = request.POST.get('userId', '') displayName = request.POST.get('displayName', '') user = auth.authenticate(userId=userId, displayName=displayName) if user.is_authenticated: auth.login(request, user) return redirect('home') ##### if change to "render(request, template, locals())", will see request.user as logged in user ##### else: return render(request, template, locals()) else: return HttpResponse('') def home(request): template = 'index.html' user = request.user return render(request, template, locals()) I'm checking whether the request.user is logged in by javascript. If not, use a post function to /login/ URI. The liff.getProfile() is my third party javascript function to get userId and displayName from profile. #html.javascript DjangoLogin="{{request.user}}"; if (DjangoLogin=="AnonymousUser"){ liff.getProfile().then(function(profile) { userId = profile.userId; displayName = profile.displayName; post('/login/',{ 'userId': userId, 'displayName': displayName, 'csrfmiddlewaretoken': '{{ csrf_token }}'}); }); -
Add celery to existing Django-REST controller
I have an existing Django-REST controller that creates a file and in response it return a url to download the file. Sometimes the file creation takes too much time so now I want to add django-celery to existing Django-REST controller. The response for this API will be task ID representing a backend celery task. class CreateFile(ViewSet): serializer_class = CreateFileSerializer def create(self, request, *args, **kwargs): create_file_serializer = self.serializer_class(data=request.data) if create_file_serializer.is_valid(): # code to write file return Response({url: "/path/to/download/file"}, status=status.HTTP_200_OK) else: return Response({msg: "Invalid Request"}, status=status.HTTP_400_BAD_REQUEST) Suggest any way to implement the requirement. -
Jquery Validation Plugin working in Chrome, but not in Mozilla
I have a form in a Django application whose validation works perfectly on Chrome, but I can't get it to work on Mozilla. I load this version of jquery and jquery validation plugin <script src="//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.19.1/jquery.validate.js"></script> <script src="https://ajax.microsoft.com/ajax/jquery.validate/1.19.1/additional-methods.js"></script> My jquery validation code looks like this: FORM_RULES = { verify_email: { equalTo: '#id_email' }, '{{soldier.date_of_birth.name }}' : {'dateValidator': true, 'dateNotInFutureValidator':true}, '{{soldier.legal_first_name.name}}' : 'allChars', '{{soldier.legal_last_name.name}}' : 'allChars', '{{soldier.naaleh_selah_choice.name}}' : { required: function(element){ return $('#id_naaleh_selah_bool_0').val() == 1 }}, accept_checkbox: {required: true} }; FORM_MESSAGES = { verify_email: {equalTo: 'Please enter the same value as the Email field.'}, accept_checkbox: {required: 'You must accept the terms and conditions to continue.'} }; $('#intake_form').validate({ rules: FORM_RULES, messages: FORM_MESSAGES, errorPlacement: function(error, element) { if ( element.is(":radio")) { error.insertAfter( element.parent().parent().parent() ); } else if (element.attr("id") === "accept_checkbox") { error.insertAfter(element.parent()); } else { // This is the default behavior of the script error.insertAfter( element ); } } }); None of the validation messages are showing up for me on Mozilla Firefox and it lets me submit the form without filling in the required fiels. I do see the following error in the console on Mozilla: SyntaxError: invalid regexp group but I'm not sure that it's related and am not sure … -
Django pass to render context form AND pk parameter
I'm new at Django and I really can't figure out what's wrong in my code. I need to open a page where the user can check what he previously create. In an article he can save as many captions as he wants with a topic labels. The page that will open will show texts and labels and will offer the opportunity to update the objects. I have in my url.py urlpatterns = [ path(r'^home/check/(?P<pk>\d+)/$', TextUpdate, name='check'), ] Where pk is the id of the article. I create a formset that filter for the queryset that refer to our article link. I have in my views.py @login_required def TextUpdate(request, *args, **kwargs): pk = kwargs.pop('pk') link = get_object_or_404(Link, link_id=pk) user_p = UserProfile.objects.filter(user=request.user).first() qs=Text.objects.filter(text_link=link.url,user=user_p) TextFormSet = modelformset_factory(Text, form=UpdateTextForm) if request.method == 'POST': formset = TextFormSet(request.POST,queryset=qs) if formset.is_valid(): formset.save() return redirect('next_view') else: formset=TextFormSet(queryset=qs) context = { "formset": formset, "pk": pk } return render(request, 'news/Text/check.html', context) And I have in my template: <form method="get" > {% for form in formset %} {{ form.as_p }} {% endfor %} <input type="submit" value="save"> </form> But it seems I can't pass to render either my form and the pk. The error is saying: TypeError at /^home/check/(?P177\d+)/$ __init__() missing 1 … -
I updated python to 3.7 from 3.5 and now manage.py cannot be found
(venv) C:\Users\...\PycharmProjects\WebP1>python manage.py runserver C:\Users\...\AppData\Local\Programs\Python\Python37-32\python.exe: can't open file 'manage.py': [Errno 2] No such file or directory This is the error I get post updating to Python. Just before i updated the command was working and I could run my website. Should I revert back to 3.5 or how can I actually get my py file to be found? -
How to customize django cms text plugin?
I want to customize the django cms text plugin.I want to add my custom myclass to the p tag rendered by the placeholder.How can I do it ? template {% placeholder "my_placeholder" or %} <p class="myclass"> some text </p> {% endplaceholder %} -
How to make a interactive video sharing Website and mobile app with same backend
I need to make a website that will contain videos which will have quiestions in the timeline and viewers should be able to select and answer and I should be able to store that data in a mysql database. I want to use django for backend. Later I want to implement everything in mobile app. -
CSS last entries not loading when runserver (Django)?
The problem should be fairly simple. I have 2 HTML files styled by a unique CSS. Basically I have written CSS code for one HTML (the home page) yesterday, and everything works fine. Today I am adding a few 'div' and 'class' elements to the second HTML (checkout) but the code I have added to the CSS today seems to have no effect (code from yesterday works fine though). So, I have inspected the page run on localhost and loaded the link to the CSS. Well, I have found out that the code I have written today is not being loaded. Obviously I have saved the CSS, and also tried to close PyCharm and restart the project, but it does not seem to work. How can I fix this issue? Here is my project directories tree: The CSS body { background-color: green; font-size: 100%; font-family: Sans-serif; } h3 { font-size: 90%; } .menu{ background-color: CadetBlue; text-align: center; display: inline-block; padding-bottom: 20px; padding-left: 20px; padding-right: 20px; margin:auto; } .order { background-color: Brown; float: right; padding-left: 20px; padding-bottom: 20px; padding-right: 20px; } .restaurant_name { color: yellow; font-size: 3em; text-align: center; padding-top:5%; } .order_header { text-align: left; padding-left: 10%; background: grey; color: yellow; … -
'tuple' object has no attribute '_committed'
I am comparatively new to the Django rest API developer. I am currently working on saving the Organisation class and while updating that model. Error: 'tuple' object has no attribute '_committed' Although my POST method is working fine. I am facing issue for PUT only. models.py """Database model for users in the system""" org_id = models.AutoField(unique=True, primary_key=True) org_code = models.CharField(max_length=19, blank=False) org_name = models.CharField(max_length=100, blank=False, unique=True) org_shortname = models.CharField(max_length=25, blank=False) org_ml = models.ForeignKey(Translations, related_name='org_ml', on_delete=django.db.models.deletion.CASCADE, null=True) org_type = models.IntegerField() org_logo = models.ImageField(null=True) org_address = models.CharField(blank=True, max_length=250) contact_name = models.CharField(blank=True, max_length=100) contact_phone = models.CharField(blank=True, max_length=20) country_code = models.CharField(blank=True, max_length=4) contact_email = models.EmailField(blank=True, max_length=100) creation_time = models.DateTimeField(auto_now_add=True, editable=False) creation_by = models.ForeignKey("User", on_delete=django.db.models.deletion.CASCADE, null=True, related_name="organisation_creation_by") modification_time = models.DateTimeField(auto_now=True) modification_by = models.ForeignKey("User", on_delete=django.db.models.deletion.CASCADE, null=True, related_name="organisation_modification_by") status = models.IntegerField(default=0) def __str__(self): return str(self.org_id) + " " + self.org_name class Meta: db_table = "organisation" view.py try: req_data = request.body.decode('utf-8') req_data = json.loads(req_data) req_org_id = req_data['org_id'] req_org_name = req_data['org_name'] req_org_code = req_data['org_code'] req_org_shortname = req_data['org_shortname'] if "org_ml" in req_data: req_org_ml = req_data['org_ml'] else: req_org_ml = None if "org_type" in req_data: req_org_type = req_data['org_type'] else: req_org_type = 0 req_org_logo = req_data['org_logo'] req_org_address = req_data['org_address'] req_contact_name = req_data['contact_name'] req_contact_phone = req_data['contact_phone'] req_country_code = req_data['country_code'] req_contact_email = req_data['contact_email'] if 'status' … -
django create test database error (backend is mysql)
I'm trying to use Django to create unit test cases.(I use PyMySQL==0.9.3) When I run python manage.py test -k I got a database exception: Got an error creating the test database: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE DATABASE IF NOT EXISTS `test_t` ;\n SET sql_no' at line 2") I found Django use this to avoid "database exists" warning: if keepdb: # If the database should be kept, add "IF NOT EXISTS" to avoid # "database exists" error, also temporarily disable "database # exists" warning. cursor.execute(''' SET @_tmp_sql_notes := @@sql_notes, sql_notes = 0; CREATE DATABASE IF NOT EXISTS %(dbname)s %(suffix)s; SET sql_notes = @_tmp_sql_notes; ''' % parameters) I run each single SQL, it works well. So what should I configure to run multiQueries in Django(PyMySQL)? -
Django - Use a property as a foreign key
The database of my app is populated and kept syncd with an external data source. I have an abstract model from which all the models of my app derives, defined as follow: class CommonModel(models.Model): # Auto-generated by Django, but included in this example for clarity. # id = models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID') object_type = models.IntegerField() object_id = models.IntegerField() class A(CommonModel): some_stuff = models.CharField() class B(CommonModel): other_stuff = models.IntegerField() to_a_fk = models.ForeignKey("myapp.A", on_delete=models.CASCADE) class C(CommonModel): more_stuff = models.CharField() b_m2m = models.ManyToManyField("myapp.B") Leaved as-is Django will use its auto-generated primary key id for the foreign key of the model B to A and the many-to-many relation of C to B, which is, the normal and excepted behavior. Problem Whilst keeping the auto-generated primary key in the database, I would like to make my foreign key and many-to-many relations happen on my object_id field instead of the primary key id. Doing this would allow me to create/update a relation with only knowing object_type and object_id and thus saving a database operation for searching the matching object to use. A simple approach to solve this problem would be to use the to_field="object_id" property in my foreign key and roll my own intermediate table for … -
Python scraping site conects to facebook
I'm Working on a crawler project with python django. The problem is when I initiate a browser and send a request to the site (www.mysite.com for example), it connects to facebook (perhaps for using ads).Therefor loading takes too long and some of the tags and features are not shown in my crawler. What should I do with my firefox browser to prevent connecting to faacebook? -
Merge 2 lists and remove duplicates in Python
I have 2 lists, looking like: temp_data: { "id": 1, "name": "test (replaced)", "code": "test", "last_update": "2020-01-01", "online": false, "data": { "temperature": [ { "date": "2019-12-17", "value": 23.652905748126333 }, ... ]} hum data: { "id": 1, "name": "test (replaced)", "code": "test", "last_update": "2020-01-01", "online": false, "data": { "humidity": [ { "date": "2019-12-17", "value": 23.652905748126333 }, ... ]} I need to merge the 2 lists to 1 without duplicating this data: { "id": 1, "name": "test (replaced)", "code": "test", "last_update": "2020-01-01", "online": false, "data": { What is the easiest/efficient way? -
How to generate asgi.py for existent project?
I have an existent django project in 2.2, but now i would like to start using channels, so I have to change to 3.0 and asgi instead of wsgi. How can I generate the asgi.py that I need to run the app? -
Django setting file directory is not registered ModuleNotFoundError: No module named
I am using apache2 + wsgi + django3 when I use $python manage.py mycommand shows error like this, Traceback (most recent call last): File "manage.py", line 24, in <module> main() File "manage.py", line 20, in main execute_from_command_line(sys.argv) File "/home/ubuntu/anaconda3/envs/py37/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/home/ubuntu/anaconda3/envs/py37/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/ubuntu/anaconda3/envs/py37/lib/python3.7/site-packages/django/core/management/__init__.py", line 231, in fetch_command settings.INSTALLED_APPS File "/home/ubuntu/anaconda3/envs/py37/lib/python3.7/site-packages/django/conf/__init__.py", line 76, in __getattr__ self._setup(name) File "/home/ubuntu/anaconda3/envs/py37/lib/python3.7/site-packages/django/conf/__init__.py", line 63, in _setup self._wrapped = Settings(settings_module) File "/home/ubuntu/anaconda3/envs/py37/lib/python3.7/site-packages/django/conf/__init__.py", line 142, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/home/ubuntu/anaconda3/envs/py37/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked ModuleNotFoundError: No module named 'myapp.myconf' this is related with the setting in manage.py def main(): #os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.myconf.local') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.myconf.develop') try: However in my directly I have these, why does it happen?? Also it doesnt show error on django's runserver. manag.py - myapp - myconf - develop.py - local.py -
Django Fromset validation fails with Bootstrap sortable tabel
I have created some sort of nested formset in django (2.2). It all works perfectly. The problem is, that as soon as I try to add Bootstrap to the table the form validation fails. Here is my table that works: <form method="post"> {% csrf_token %} <table> <thead> <tr> <th>Col 1</th> <th>Col 2</th> <th>Col 3</th> <th>Col 4</th> <th>Col 5</th> <th>Col 6</th> </tr> </thead> <tbody> {% for s in s_list %} {{ s.formset.management_form }} <tr> <td>{{ s.form1 }}</td> <td>{{ s.form2 }}</td> <td>{{ s.form3 }}</td> <td>{{ s.form4 }}</td> <td>{{ s.form5 }}</td> </tr> {% endfor %} </tbody> </table> <input type="submit" value="Save"> </form> I then wanted to make the table sort-able via Bootstrap and I found something like this: <form method="post"> {% csrf_token %} <table data-toggle="table"> <!-- Add BS to the table --> <thead> <tr> <th data-sortable="true">Col 1</th> <!-- Make this column sort-able --> <th data-sortable="true">Col 2</th> <!-- Make this column sort-able --> <th data-sortable="true">Col 3</th> <!-- Make this column sort-able --> <th>Col 4</th> <th>Col 5</th> <th>Col 6</th> </tr> </thead> <tbody> {% for s in s_list %} {{ s.formset.management_form }} <tr> <td>{{ s.form1 }}</td> <td>{{ s.form2 }}</td> <td>{{ s.form3 }}</td> <td>{{ s.form4 }}</td> <td>{{ s.form5 }}</td> </tr> {% endfor %} </tbody> </table> <input type="submit" value="Save"> … -
React And Django Deployment on heroku
I am badly stuck in deployement, I am trying to deploy the react django together on heroku,the problem is react app is not loading when i hit url it shows blank page and I can't get what the problem is it might be of build directory,where I think the path is not correct when made initial build "npm run build".Here's my below try: Settings.py TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'build')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'build/static'), ] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') urlpatterns = [ path('admin/', admin.site.urls), path('automation/', include('performaApp.urls')), re_path('.*',TemplateView.as_view(template_name='index.html')) #url(r'^', FrontendAppView.as_view()) ] build/index.html <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/static/manifest.json"><link rel="shortcut icon" href="/static/favicon.ico"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css"><title>Cameria - Facial Recognition</title><link href="/static/css/main.1ec2ccf3.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="/static/js/main.40de23a7.js"></script></body></html> Package.json { "name": "react-redux-starter-template", "version": "0.1.0", "private": true, "homepage": "https://adidas008.herokuapp.com", "dependencies": { "@material-ui/core": "^4.9.0", "@material-ui/icons": "^4.5.1", "axios": "^0.19.2", "material-ui": "^0.20.0", "react": "^16.2.0", "react-bootstrap": "^0.32.0", "react-dom": "^16.2.0", "react-flexbox-grid": "^2.0.0", "react-loader-spinner": "^3.1.5", "react-redux": "^5.0.6", "react-router-dom": "^4.2.2", "react-scripts": "1.0.17", "react-webcam": "^0.2.0", "redux": "^3.7.2", "redux-logger": "^3.0.6", "redux-promise": "^0.5.3" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts … -
superuser not creating TypeError: create_superuser() missing 1 required positional argument: 'name'
when i run createsuperuser command ..it ask's me to enter email and then password .After entering password it doesn't create super user instead it gives me TypeError: create_superuser() missing 1 required positional argument: 'name'. Here is my models.py from django.db import models from django.contrib.auth.models import AbstractBaseUser,PermissionsMixin, BaseUserManager class UserProfileManager(BaseUserManager): def create_user(self, email, name, password=None): if not email: raise ValueError('User must have an email address') email = self.normalize_email(email) user = self.model(email=email, name=name) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, name, password): user = self.create_user(email, name, password) user.is_superuser = True user.is_staff = True user.save(using=self._db) return user class UserModel(AbstractBaseUser, PermissionsMixin): email = models.EmailField(max_length=300, unique=True) name = models.CharField(max_length=255) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) objects = UserProfileManager() USERNAME_FIELD= 'email' REQUIRED_FIELD = 'name' def get_full_name(self): return self.name def get_short_name(self): return self.name def __str__(self): return self.email -
not all arguments converted during string formatting when passing a list to SQL query
Hi am using the code below: def GetData(request): try: year='' month=[] results=[] conn = connections["connection1"] cursor = conn.cursor() year = request.GET.get('year') print(year) month = request.GET.getlist('month[]') for i in month: print("Months::"+i) class = request.GET.get('class') response_list = [] cursor.execute(" select Year,month,student_name,admission_date,class from admission_table\ where MONTH(admission_date) in (%s) AND YEAR(admission_date) in ('"+year+"') AND class in ('"+class+"')"% ",".join(map(str,month))) rows = cursor.fetchall() print(rows) if rows: for row in rows: response_list.append({'year':row[0],'month':row[1],'student_name':row[2],'admission_date':str(row[3]),'class':row[4]}) except Exception as e: print(str(e)) return HttpResponse(json.dumps(response_list)) Am getting an error 'not all arguments converted during string formatting' How can I solve this? Thanks for your help in advance -
Video File in Django Site how to watch films
Hi everyone is trying to add to my project the ability to watch movies in the "FIlmy" application. And I don't know what I'm doing wrong but it only shows me a black window without loading. My models: class Video(models.Model): name = models.ForeignKey(Movie, on_delete=models.CASCADE) file = models.FileField(upload_to='films_image/', null=True, verbose_name="") My views: @login_required def showvideo(request): firstvideo = Video.objects.last() videofile = firstvideo.videofile return render(request, "MyPage/MovieDetail.html", {'videofile': videofile}) My template: <h3><b>Clip</b></h3> <br> <video width='400' controls> <source src='{{ videofile }}' type='video/mp4'> Your browser does not support the video tag. </video> I probably have a source error and I don't know what I'm doing wrong I've added to my URLS ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) And my settings: MEDIA_URL = os.path.join(BASE_DIR, 'media/') MEDIA_ROOT = '/media/' I added a file to my Movie foreign key and now I want the movie title to be viewed in my tempplate -
Django, How to get object instance(id) before creating it in form_valid function of generics view?
When i creating Post model object i need to get it ID instantly and create a second model User_permission , how in this case can i pass to post variable the ID data of newly created post class CreatePostView(LoginRequiredMixin, CreateView): model = Post form_class = PostForm def form_valid(self, form): obj = User_permission.objects.create(post=post) obj.save() return super().form_valid(form) -
Access form element attributes in Django template
How can I access an input element attribute, say aria-describedby, in Django template syntax? As shown below, in the template I can access the label as {{form.email.label}}, but how do I get the attribute aria-describedby? <!-- Django 2.2.9 --> <form method="POST"> {% csrf_token %} <label for="{{ form.email.id_for_label }}">{{form.email.label}}</label> {{ form.email }} <button type="submit" class="btn btn-primary">Submit</button> </form> The file form.py is listed below. # Django 2.2.9 from django import forms class ExampleForm(forms.Form): email = forms.EmailField( label="Email address", widget=forms.EmailInput( attrs = { "class":"form-control", "placeholder":"Enter email", "aria-describedby":"EmailHelp" } ) ) Using {{ form.email }} in the template, the code listed in forms.py will render an input element as shown below. <input type="email" name="email" class="form-control" placeholder="Enter email" aria-describedby="EmailHelp" required id="id_email"> It would be convenient if it was possible to access the aria-describedby attribute using use some code like {{form.email.aria_describedby}}. Notes There are other similar question on SO suggesting to use syntax like {{form.email.widget.attrs.placeholder}}, however, in Django 2.2.9 this does not work. I would prefer not to use any addional packages, like Crispy forms. Additional code lisings views.py # Djano 2.2.9 from django.shortcuts import render,redirect from . forms import ExampleForm def contact(request): if request.method == "POST": return redirect('example-index') form = ExampleForm() context = {'form':form} return … -
Get first values from JSON file in Django/Python
I have following JSON file in my python django project: { "id": 1, "name": "test (replaced)", "code": "test", "last_update": "2020-01-01", "online": false, "data": { "temperature": [ { "date": "2019-12-17", "value": 23.652905748126333 }, ... ], "humidity": [ { "date": "2019-12-17", "value": 23.652905748126333 }, ... I need al the data except the values in "data". So I need: { "id": 1, "name": "test (replaced)", "code": "test", "last_update": "2020-01-01", "online": false, } How can I do this the most efficient? -
SMTPAuthentication error when sending confirmation email in Django
Getting the error message SMTPAuthenticationError at /accounts/signup/teacher/ (530, b'Must issue a STARTTLS command first') when trying to test the signup process in my django app. What should happen is that a user who signs in should receive a confirmation email after signing up. Here are my settings EMAIL_BACKED = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'mail.privateemail.com' EMAIL_PORT = 587 EMAIL_USER_TLS = True EMAIL_HOST_USER = '***@***.com' EMAIL_HOST_PASSWORD = '***' I am using privateemail from namecheap to send the confirmation emails -
Difference of deploying django using nginx and nginx with gunicorn
I have a django project which I want to deploy on digitalocean and I am confused about how I can do it. I found tons of articles where people advice to use nginx itself and others nginx with gunicorn. Because of it I have several related questions. Is it possible to deploy django using nginx without gunicorn? If answer is yes what pros and cons of deploying using nginx itself and nginx + gunicorn