Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to protect a single database row / Model instance?
We have customers, and Customer objects. One of these, which I was creating with a migration, was Customer( account='INTERNAL' ...) as a placeholder for when we manufacture stuff for internal consumption. Customers come and go, so the objects need to be deletable. But this single row must not be deleted. What is the best way to stop it getting accidentally deleted? I can replace all instances of Customer.objects.get(account='INTERNAL') with get_or_create so it is self-resurrecting, but it feels like storing up trouble for the future if there are ForeignKey references to it and then it gets deleted. (It can't be Models.PROTECT, because other customers can be deleted). Tagged [postgresql], because that's what we use. I suspect there might be a way to use database functionality to do what I want, but I'd appreciate it if the answer showed how to write doing that as a Django migration (if that's possible). I know more about Django than SQL and Postgres extensions. -
Authentication tokens expiring or being deleted after a page refresh
I'm using using Django with Django Rest Framework for my backend API and DJOSER for authentication, along with the **djangorestframework_simplejwt **package for handling JSON Web Tokens (JWT). I have configured the token lifetimes in my settings.py file, but I've encountering issues with authentication tokens expiring or being deleted after a page refresh in my backend. Here is my auth.js file from React: import axios from 'axios'; import { LOGIN_SUCCESS, LOGIN_FAIL, USER_LOADED_SUCCESS, USER_LOADED_FAIL, AUTHENTICATED_SUCCESS, AUTHENTICATED_FAIL, LOGOUT } from './types'; export const checkAuthenticated = () => async (dispatch) => { if (localStorage.getItem('access')) { const config = { headers: { 'Content-type': 'application/json', 'Accept': 'application/json', }, }; const body = JSON.stringify({ token: localStorage.getItem('access') }); try { const res = await axios.post( `${process.env.REACT_APP_API_URL}/auth/jwt/verify/`, body, config ); if (res.data.code !== 'token_not_valid') { dispatch({ type: AUTHENTICATED_SUCCESS, }); } else { dispatch({ type: AUTHENTICATED_FAIL, }); } } catch (err) { dispatch({ type: AUTHENTICATED_FAIL, }); } } else { dispatch({ type: AUTHENTICATED_FAIL, }); } }; export const load_user = () => async (dispatch) => { if (localStorage.getItem('access')) { const config = { headers: { 'Content-type': 'application/json', Authorization: `JWT ${localStorage.getItem('access')}`, Accept: 'application/json', }, }; try { const res = await axios.get( `${process.env.REACT_APP_API_URL}/auth/users/me/`, config ); dispatch({ type: USER_LOADED_SUCCESS, payload: res.data, }); … -
Djano format TextField space every 4 digits (IBAN)
I'm having a TextField and in my form and I'm trying to make a space every 4 digits because I want the IBAN format of 16 digits XXXX-XXXX-XXXX-XXXX. I read about the python package "django-iban" and imported it, but the form formatting didnt work. Is there another way to force the TextField to make a space every 4 digits? -
filter data in table 1 that is not referenced in table 2 through foreign key in python
I have two tables table 1 and table 2, table 2 has a foreign key from table 1 in this case I intend to select all customers from table 1 that are not yet registered in table 2 models.py: class Cliente(models.Model): contador = models.AutoField(primary_key=True) ---------**--------------------- class Factura(models.Model): factura_nr = models.CharField(primary_key=True,max_length=100) contador = models.ForeignKey(Cliente,on_delete=models.CASCADE) estado_factura=models.CharField(max_length=20,default='Aberta',blank=True) views.py facturas_abertas2=Factura.objects.values('contador__contador').filter(data_leitura__month=date.today().month,estado_factura='Aberta') clientes=Cliente.objects.filter(contador=facturas_abertas2).count() -
Reverse for ' signup' not found. ' signup' is not a valid view function or pattern name
I newbie to Django and I do not know how to fix this problem. I have watched many utube videos to fix this issue, but I found not a single solution. Urls.py for project: amazonbackend from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include(('Homepage.urls', 'Homepage'))), path('blog/', include(('blog.urls', 'blog'))), ] urls.py for first app "Homepage" from django.urls import path from Homepage import views urlpatterns = [ path('',views.HomePage,name='Home'), path('signup/',views.SignupPage,name='signup'), path('login/',views.LoginPage,name='login'), path('logout/',views.LogoutPage,name='logout'), ] urls.py for second app "blog" from django.urls import path from blog import views urlpatterns = [ path('',views.BlogHomePage,name='bloghome'), path('createposts/',views.CreatePosts,name='createposts'), path('myposts/',views.MyPosts,name='myposts'), path('comments/', views.PostsComments, name= "comments") ] navbar.html is a template in first app "Homepage" {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Amazon.com Spend less & Smile More</title> <link rel="icon" href="AMZN-e9f942e4.png" /> <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"/> <script src="https://kit.fontawesome.com/5ac1140461.js" crossorigin="anonymous" ></script> </head> <body> <header> <nav class="nav-bar" id="Navigation"> <div class="nav-box1 box"></div> <div class="nav-box2 box"> <div class="box2-left"> <i class="fa-solid fa-location-dot fa-xl" style="color: #ffffff"></i> </div> <div class="box2-right"> <p class="first-box2">Deliver to</p> <p class="second-box2">india</p> </div> </div> <div class="nav-box3"> <select name="" id="" class="nav-select"> <option value="">All</option> </select> <input type="search" placeholder="Search Amazon" class="nav-input"> <div class="box3-icon"> <i class="fa-solid fa-magnifying-glass fa-xl" style="color: #000000;"></i> </div> … -
How can I schedule a periodic task once in every 3 days in django celery crontab?
Need to schedule a task every 3 days celery scheduler in django. I have found the scheduling of different cases such as to schedule a task on minutely, hourly, daily, on-weekdays basis, but I could not find my requirement in the documentation of celery. Does anyone know about this? -
Run server is VScode for python/django ecommerce a "type error" pops up?
So basically I'm trying to relearn python with this course where you make a ecommerce website using Django/Python. After adding in a Views and Urls.py the next step is to run is to hope that are three urls store,cart,checkout pop up, however in the conf.py this error pops up line 65, in _path raise TypeError( TypeError: kwargs argument must be a dict, but got str. This is the line they are talking about if kwargs is not None and not isinstance(kwargs, dict): raise TypeError( f"kwargs argument must be a dict, but got {kwargs.__class__.__name__}." ) i would love to know what is throwing it i tried deleting the line but that didnt work i can provide the urls and view file one of them has to be causing it i think, any help would be greatly apprecited. Im expecting to run the server on port 8000 and be able to check if the three urls are working and will bring me up a html page, however i cant run this server due to this error, i didnt create the conf.py file so im a bit confused. -
Showing invalid python identifier
For my url path it is showing the following error. URL route 'quizzes/<int:quiz_id/question/<int:question_id>' uses parameter name 'quiz_id/question/<int:question_id' which isn't a valid Python identifier. I tried doing this in my urls.py path('quizzes/<int:quiz_id>/question/<int:question_id>',user_views.quizquestions,name='quizquestions') -
What does it mean that serializer validators are good because it makes it easy to switch between Model Serializer and explicit Serializer?
I've been reading the rest_framework document but I'm finding it hard to grasp the meaning of this sentence "It is easy to switch between using shortcut ModelSerializer classes and using explicit Serializer classes. Any validation behavior being used for ModelSerializer is simple to replicate." It's one of the three benefits of using serializer validators but... Why would you switch between ModelSerilzer and Serializer class defined serializers? What does it mean it's easy to replicate? Why would I replicate a validator defined for a ModelSerializer? Here is the link where it's written https://www.django-rest-framework.org/api-guide/validators/ Thank you for checking out this question! I tried looking up for the same question that talks about the replicable advantage of django serializer validators. But All I got was the fact that it's better to create model instance via serializers because serialziers have easy validating logic and that it's better to keep both serialzier validator and model validator. -
Django: dropdown is populated with the id of a ForeignKey, but i would like to populate it with its textual value (and not the id)
In the dropdown I get the campionato id, because I'm selecting a ForeignKey. I would like to populate the dropdown with the textual value of the sampled ForeignKey and not with the id. IMPORTANT: Considering that the two dropdowns are dependent, I had to use campionato of the Full_Record class (and not the one of the Campionato class) I have read several solutions and similar questions, but they didn't help me. Here is my code models.py from django.db import models from smart_selects.db_fields import ChainedForeignKey from django.contrib import admin #### BASIC DATA #### #Campionato class Campionato(models.Model): stagione = models.ForeignKey(Stagione, on_delete=models.CASCADE) name = models.CharField(max_length=40) def __str__(self): return self.name #Teams class Teams(models.Model): stagione = models.ForeignKey(Stagione, on_delete=models.CASCADE) campionato = models.ForeignKey(Campionato, on_delete=models.CASCADE) name = models.CharField(max_length=40) def __str__(self): return self.name #### FULL RECORD #### class Full_Record(models.Model): campionato = models.ForeignKey(Campionato, on_delete=models.CASCADE) team_home = ChainedForeignKey( Teams, related_name='team_home_name', chained_field="campionato", chained_model_field="campionato", show_all=False, auto_choose=True, sort=True) team_away = ChainedForeignKey( Teams, related_name='team_away_name', chained_field="campionato", chained_model_field="campionato", show_all=False, auto_choose=True, sort=True) def partita(self): return f"{self.team_home}-{self.team_away}" def __str__(self): return self.campionato forms.py {% extends 'base.html' %} {% block content %} <!-- First Combobox --> <label for="id_campionato">Country</label> <select name="campionato" id="id_campionato" hx-get="{% url 'trips' %}" hx-swap="outerHTML" hx-target="#id_trip" hx-indicator=".htmx-indicator" hx-trigger="change"> <option value="">Please select</option> {% for campionato in campionati %} <option value="{{ campionato … -
Visual stuido code doesnt run the django site
I started learn django and choose Visual studio code. When i start the site by "python manage.py runserver" it doesnt start, but in Command Prompt it is work. How do improve that?enter image description hereenter image description here I dont know how to improve that -
How to pass a parent id (via foreignkey) if the child form is located on the same template as the parent form?
I am learning Django and I am trying to write a "reply" code for a comment. Currently, when a user clicks the button "reply", the link takes them to a new page, which allows me to pass the parent comment_id to the reply as a foreign key. How can I place the "reply" form on the same page as the comment? I apologize if my question is entirely stupid, I am just learning! Thank you! My current code for the "reply" is: --> how can I pass the comment_id to the reply if the reply form is on the same page as the "comment"? def reply(request, comment_id): comment = get_object_or_404(Comment, id=comment_id) form_reply = ReplyForm(request.POST or None) if request.method == "POST": if form_reply.is_valid(): a_comment = form_reply.save(commit=False) a_comment.comment = comment a_comment.save() return redirect('two_forms') all_replies = Reply.reply_objects.all() return render(request, 'reply.html', {'form_reply': form_reply, 'all_replies': all_replies, }) I tried to place this code on the same template as the "comment" but then the comment_id messes with the url of the comment page and gives an error. -
Trying to update user email using Djoser set_username
I am trying to update my user's username. For some reason when I call /users/set_username it says that: {"current_password":["This field is required."],"new_email":["This field is required."]} So I edited my code to follow that. export const updateUserEmail = (email, password) => dispatch => { const data = { "new_email" : email, "current_password" : password } axios.post("/api/v1/users/set_username/", data) .then(response => { const user = localStorage.getItem('user') let username = JSON.parse(user).username const newUser = { "username": username, "email":email } localStorage.setItem("user", JSON.stringify(newUser)); dispatch({ type: SET_CURRENT_USER, // auth store payload: user }); // dispatch(push("/")); toast.success("Update Successful."); }).catch(error => { // show error toast console.log(error) toastOnError(error); }) } But every time I run this I get a 500 internal server error, but I'm not sure why. I have tried removing the last slash, but that didn't work. I am expecting to update the user's email. -
How to pass an additional parameter to a field on a model that is pointed to by a foreign key in Django?
class File(Model): file = models.FileField('file', validators=[FileExtensionValidator(GET_ALLOWED_EXTENSIONS)]) some_other_fields class User(model): avatar = models.ForeignKey(File, models.PROTECT, '+', allow_extensions=['png', 'jpg']) I want pass allow_extensions through User's avatar field. And file field in File model can get allow_extensions. How do I implement this feature? -
Race condition in Django save()
I have an API that can take a list of files and save it in the DB for a specific user. I want to limit the number of files per user to be some number. The way I enforce this is through overriding the save method: A pseudocode: In the view: For item in list_to_save: item.save() And save method: curr_count= Files.objects.filter(id=user_id).count If curr_count > max_count: Get curr_count-max_count item For del in delete: del.delete() Question is, will this lead to a race condition if the same user tries to send 2 different list of files? Since there might be 2 save operation running at the same time? I am expecting that there is some race condition since the two server will see that DB has entries, and will try to delete them both, leading to some inconsitencies -
django: Recursive function called in views.py method not returning results
I am new to django and web development, I am trying to call a recursive function in views.py on clicking submit button on my form. When I try to call the same function while it returns a simple list, it works fine, but it returns nothing if the core logic is enabled. I am really not sure what's the problem, can anyone tell what's wrong and how to fix it? Following is the implementation of views.py and recursive function: def process_form(request): if request.method == 'POST': print("Request is POST") form = UIForm(request.POST, request.FILES) if form.is_valid(): print("Form is valid") # Create an instance of the model and assign the form data to its fields form_data = FormData() form_data.from_timestamp = form.cleaned_data['from_timestamp'] form_data.to_timestamp = form.cleaned_data['to_timestamp'] form_data.free_text = form.cleaned_data['free_text'] form_data.uploaded_file = form.cleaned_data['file'] # Save the form data to the database form_data.save() file = request.FILES['file'] todayDate = datetime.datetime.now().strftime("%Y-%m-%d") dest_dir = temp_directory + os.sep + todayDate dest_path = dest_dir + os.sep + file.name os.makedirs(dest_dir, exist_ok=True) print("Dest path:", dest_path) # Handle the uploaded file if file: # Save the file to the server's temporary directory with open(f'{dest_path}', 'wb') as destination: for chunk in file.chunks(): destination.write(chunk) # Check the given regular expression against the extracted files pattern = form_data.free_text … -
Make my web page offer download of zipfile
I am building an archive where people can download zip-files (the url is localhost:8000/downloads). I have the zip-files in the games folder (in relation to where manage.py resides). When I pass over with cursor the address shows "localhost:8000/downloads/.../games/GC_007 Goldeneye.zip" which gives "no download" This is what I put in the link: <a href="games/GC_007 Goldeneye.zip" download>007 Goldeneye</a> "localhost:8000/downloads/.../games/GC_007 Goldeneye.zip" is what I get which does not work. -
Like icon and Likes counter does not refresh automatically
I am trying to get a Web page that updates the Likes counter when a user clicks on the Likes icon (similar to Twitter, now X): I am using JavaScript and Django (I am a newbie in both). I am facing this issue: when I click on Like icon ("thumbs up" by default) the Like counter increase but the Like icon does not change to a "thumbs down" icon and indeed if I click on Like icon again then the Like counter increase again. Once I refresh the page manually the Like icon appears as thumb down. I would like that: when I click on Like icon ("thumbs up" by default) the Like counter increase and the Like icon changes to a "thumbs down" icon when I click again on Like icon (it is a "thumb down" icon now) then the Like counter decrease and the Like icon changes to a "thumbs up" icon the above should be gotten without requiring a reload of the entire page (I have to refresh the page manually right now) Please find below my code: index.html {% extends "network/layout.html" %} {% block body %} <!-- Javascript code --> <script> function getCookie(name) { const value … -
Error with static CSS files while deploying django app to Heroku
I'm a new developer here, and I am trying to deploy my first web app (created using Django) and I am using Heroku. I have been getting errors with my static files and while trying to troubleshoot that I've created a few other errors and I am hitting a wall with troubleshooting the errors. Can anyone take a look at the Heroku build log and VSCode and tell me if they see anything? I am trying to deploy my web app using Heroku. My website works fine locally but won't finish deploying. Im getting errors in the static files. I think it might have something to do with the static path. KeyError: 'collectstatic' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/tmp/build_0ef1ffd4/manage.py", line 22, in <module> main() File "/tmp/build_0ef1ffd4/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.heroku/python/lib/python3.11/site-packages/django/core/management/__init__.py", line 262, in fetch_command settings.INSTALLED_APPS File "/app/.heroku/python/lib/python3.11/site-packages/django/conf/__init__.py", line 102, in __getattr__ self._setup(name) File "/app/.heroku/python/lib/python3.11/site-packages/django/conf/__init__.py", line 89, in _setup self._wrapped = Settings(settings_module) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.heroku/python/lib/python3.11/site-packages/django/conf/__init__.py", line 217, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.heroku/python/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) … -
HTTP/1.1" 405 0 Django - Unable to go past Login Page
I created a login page and I have users with 3 roles, Administrator, Student, Supervisor. Each of these users have their separate dashboards. When I login using the username and password, it should check the user's group and based on which should redirect the user to their respective dashboard. When I hit the submit button to login, it gives me an error `. HTTP/1.1" 405 0 Request URL: http://127.0.0.1:8000/ Request Method: POST Status Code: 405 Method Not Allowed Remote Address: 127\.0.0.1:8000 Referrer Policy: strict-origin-when-cross-origin Allow: GET, HEAD, OPTIONS Connection: close Content-Type: text/html; charset=utf-8 Date: Thu, 17 Aug 2023 23:48:51 GMT Server: WSGIServer/0.2 CPython/3.11.3 ` The unfortunate part is that the home page allows only GET requests. Not sure how to change this. I manually forced my app to use post requests by defining them in views.py and forced post request on the form in the home.html file which I use to load my login page. So if you can review the code and help me get past this, it would be of great help. The name of my project is webappsretake2023 and the name of the app is spmsapp spmsapp/views.py from django.contrib.auth import authenticate, login from django.contrib.auth.decorators import login_required from … -
EmailAddress model in Django allauth?
I just started using Django allauth, and I noticed that it created a new accounts_emailaddresses table. I understand this is useful for email confirmation, but if feels like this is a source of denormalization in our database. Our current User model already has an email field. It seems like now I have to maintain the state of both User and allauth.EmailAddress models now. For example, when a user changes emails, I need to change the User model and also mark the new email as primary in EmailAddress This seems really annoying...what is the best practice in this case? Should I remove email field from User? I'm wondering how most people handle this. -
Django 'python manage.py runserver' has stopped working. How can I fix this?
I'm attempting to use Django to create a website builder. I have created a development webserver with "python manage.py runserver" and it worked initially. I created a Products app and added code in the views module and the url module under this app, whilst also mapping it to the parent url module using "path('products/', include('products.urls'))" but when I go back to the link produced by the server, it no longer works. I don't know what the problem is and how to fix it, as I didn't do anything different from the first time I tried this, and it worked briefly, before it stopped. I had to start a new project when this happened but I don't have time to keep starting over. This worked a few days ago but the next day the runserver command wasn't working. I had to delete the project and start again and now I am running into the same problem and I don't know what to do -
Django Related Model Calculations
I am creating a dashboard of sorts, I have two related models. Models: class Batch(models.Model): ... batchid = models.AutoField(primary_key=True, serialize=False, auto_created=True) batchsku = models.CharField(max_length=96) productionarea = models.CharField(max_length=96, choices=prod_area_choices, default=PRESS, verbose_name="Production Area") batchlbs = models.DecimalField(max_digits=15, decimal_places=3, blank=True, null=True, verbose_name="Lbs/Batch") batchcases = models.DecimalField(max_digits=15, decimal_places=4, blank=True, null=True, verbose_name="Cases/Batch") def __str__(self): return self.batchsku class BatchProduced(models.Model): ... batchprodid = models.AutoField(primary_key=True, serialize=False, auto_created=True) sku = models.ForeignKey(Batch, related_name="batch_exists", on_delete=models.PROTECT) location = models.CharField(max_length=96, choices=batch_prod_area_choices, default=PRESS1) created_by = models.ForeignKey(User, on_delete=models.PROTECT) created_time = models.DateTimeField(auto_now_add=True) def __str__(self): return self.sku For the view I would like to see some specific filtered information from the above models. Specifically I would like to have a count, which I get as part of my view through: pr1batchcount = BatchProduced.objects.filter(created_time__date=today, location='pr1').count() In the same view I would like to be able to calculate pr1batchcount * Batch.batchcases but I am struggling to figure out the best approach. I thought about a model calculation under the BatchProduced model like def expcases(self): return sum([Batch.batchcases for Batch in self.item_set.all()]) But this is failing to return anything, and I am not quite sure I am even pointing the right way. I am not confident in my Django knowledge to know if this is the right approach, I've gone through all related … -
How can I set a "safe" running "mode" that determines the collective behavior of django model superclasses I created?
Sorry for the poorly worded title. I just don't know how to phrase it succinctly, but I think I can best ask my question by example. Here is the background: I have a working Django model superclass I wrote called MaintainedModel. It provides a way to auto-update selected fields in a model class using decorated methods that the developer implements in the derived model class. The execution of those methods is controlled automatically via various overrides in my MaintainedModel superclass, such as an override of the Model.save() method. If a model object ever changes, the "maintained fields" in the derived model are auto-updated. It also provides a means to trigger those updates via changes to related model objects such that updates propagate via a relationship chain. One problem I had to overcome is that the autoupdate methods can sometimes be complex and take some time, especially if there are multiple triggers of the same model object due to multiple triggering related model changes. In the wild, that extra time is not noticeable and you don't encounter this repeated trigger case, but during a load of a mass quantity of data, it can double or triple the load time. I worked … -
Error with sending sms in email with celery
class UserRegistrationForm(UserCreationForm): first_name = forms.CharField(widget=forms.TextInput(attrs={ 'class': 'form-control py-2', 'placeholder': 'Enter first_name' })) last_name = forms.CharField(widget=forms.TextInput(attrs={ 'class': 'form-control py-2', 'placeholder': 'Enter last_name' })) username = forms.CharField(widget=forms.TextInput(attrs={ 'class': 'form-control py-2', 'placeholder': 'Enter username' })) email = forms.CharField(widget=forms.EmailInput(attrs={ 'class': 'form-control py-2', 'placeholder': 'Enter gmail' })) password1 = forms.CharField(widget=forms.PasswordInput(attrs={ 'class': 'form-control py-2', 'placeholder': 'Enter password' })) password2 = forms.CharField(widget=forms.PasswordInput(attrs={ 'class': 'form-control py-2', 'placeholder': 'Enter password again' })) captcha = CaptchaField() class Meta: model = User fields = ('first_name', 'last_name', 'username', 'email', 'password1', 'password2') # Email validation def clean_email(self): email = self.cleaned_data.get('email') if User.objects.filter(email=email).exists(): raise forms.ValidationError('This email is invalid') if len(email) >= 350: raise forms.ValidationError('Your email is too long') return email def save(self, commit=True): user = super(UserRegistrationForm, self).save(commit=True) # expiration = now() + timedelta(hours=48) # record = EmailVerification.objects.create(code=uuid.uuid4(), user=user, expiration=expiration) # record.send_verification_email() # return user send_email_verification.delay(user.id) return user import uuid from datetime import timedelta from celery import shared_task from django.utils.timezone import now from user_account.models import EmailVerification, User @shared_task def send_email_verification(user_id): user = User.objects.get(id=user_id) expiration = now() + timedelta(hours=48) record = EmailVerification.objects.create(code=uuid.uuid4(), user=user, expiration=expiration) try: record.send_verification_email() except Exception as e: print(f"Failed to send verification email: {e}") I have a problem connecting celery to sending sms to mail in the console it says that I sent sms …