Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Filter fields queryset in Django ModelChoiceField with external reference keys
The Trim inherited the Car and the TrimType, and the TrimType inherited the Car. When creating Trim on a specific Car detail page, I want to filter the queryset of trimType field by the id of the Car. I referred to How to use the request in a ModelForm in Django. My templates/brand/trim_update.html is: # trim_update.html {% extends 'base.html' %} {% block content %} <div class="container"> <h5 class="my-3 border-bottom pb-2">New Trim</h5> <form method="post" class="post-form my-3" enctype="multipart/form-data"> {% csrf_token %} {{ form.as_p }} <button type="submit" class="btn btn-primary">Save</button> </form> </div> {% endblock %} and brand/models.py is: # models.py class Car(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=200, null=False, blank=False) image = models.ImageField(default=None, null=True, upload_to='car/%Y/%m/%d/') order = models.IntegerField(default=0) def __str__(self): return self.name class TrimType(models.Model): car = models.ForeignKey(Car, on_delete=models.SET_NULL, blank=True, null=True) typeName = models.CharField(max_length=50, blank=False, ull=False) def __str__(self): return self.typeName class Trim(models.Model): id = models.AutoField(primary_key=True) order = models.IntegerField(default=0) trimType = models.ForeignKey(TrimType, on_delete=models.SET_NULL, null=True, blank=True) car = models.ForeignKey('Car', on_delete=models.SET_NULL, null=True) name = models.CharField(max_length=256, default='') price = models.IntegerField(default=0) image = models.ImageField(default=None, blank=True, null=True, upload_to='trim/%Y/%m/%d/') def __str__(self): if self is not None and self.car is not None: return self.car.name +'-'+self.name else: return '' and brand/views/base_views.py is: # base_views.py def trim_create(request, car_id): if request.method == 'POST': car = get_object_or_404(Car, … -
Django project with PostgreSQL bootstrap gets AssertionError: database connection isn't set to UTC
I am following the notes left by the previous engineer to set up the application on a test virtual machine, and it is a Django project using the PostgreSQL database. At the step of bootstrap, I called command python manage.py bootstrap, and the system gets an error saying AssertionError: database connection isn't set to UTC. Any pointers will be highly appreciated, and please let me know if you need more details. Screenshot of the command line: (python) [application@host api]$ python manage.py bootstrap Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/data/application/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/data/application/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/data/application/python/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv self.execute(*args, **cmd_options) File "/data/application/python/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute output = self.handle(*args, **options) File "/data/application/api/applicationbenefitsapp/management/commands/bootstrap.py", line 183, in handle populate_response_statuses() File "/data/application/api/applicationbenefitsapp/management/commands/bootstrap.py", line 51, in populate_response_statuses etransfer_type = Lookup.objects.filter(desc=transfer_type).first() File "/data/application/python/lib/python3.8/site-packages/django/db/models/query.py", line 653, in first for obj in (self if self.ordered else self.order_by('pk'))[:1]: File "/data/application/python/lib/python3.8/site-packages/django/db/models/query.py", line 274, in __iter__ self._fetch_all() File "/data/application/python/lib/python3.8/site-packages/django/db/models/query.py", line 1242, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "/data/application/python/lib/python3.8/site-packages/django/db/models/query.py", line 55, in __iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "/data/application/python/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1133, in execute_sql return list(result) File "/data/application/python/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1512, in cursor_iter for rows in iter((lambda: … -
Adding a form to formset's child elements
I have a Message form, with basic fields: class MessageForm(forms.ModelForm): class Meta: model = Message fields = [ 'message_introduction', 'recipient', 'sender' ] labels = { 'message_introduction': 'message_introduction', 'recipient':'recipient', 'sender':'sender', } Each message can contain multiple question by formset: class Message_questionForm(forms.ModelForm): class Meta: model = Message_question fields = ['message_question', 'recipient', 'sender' ] widgets = { 'message_question': forms.Textarea(attrs={'class': 'formset-field', 'rows': 4}), } So far it all works well, i am able to call the form in the view and save both models with no problem. I am now looking, in the detail view of each message, to display each question related to the message (that is done), but i would like to also add a way for the recipient to answer the question. I have created my model: class Question_answer(models.Model): message_question = models.ForeignKey(Message_question, related_name="question_answers", on_delete=models.CASCADE) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) question_answer = models.TextField() recipient = models.CharField(blank=True, null=True, max_length=255) sender = models.CharField(blank=True, null=True, max_length=255) def __str__(self): return self.question_answer class Meta: db_table = 'question_answers' But from here I am not sure how to proceed in the viewz.py and in the actual template. Would someone know a way to put an answer field in front of each question please ? -
Is there a way to verify google play purchases without oauth2?
I've been building a flutter app that communicates with a Django rest API server. Recently I added a subscription service into the app and I have the ability to perform the purchases on both platforms and able to verify them server-side for the Apple AppStore. However, I am having a bit of trouble trying to do the same with the play store API's. I want to know if there is a way to use this endpoint without Oauth2? I don't have /need sign in with google in the app and I would like to avoid it if possible.I've tried using some of the solutions from this post but I think they may be out dated since they are from 2018. -
How to implement python code in an HTML file in Django
I have written a python file using selenium that scrapes news headlines. Now I would like those headlines to be displayed on a website in Django. Hence I was wondering how to implement this into the corresponding HTML file? Thanks in advance! -
Why would a website want to prevent user to cache?
I found this question in StackOverFlow and I can't understand the reason of not caching. I am very new to web programming so i would be glad if someone can answer me this. -
Django Elasticsearch, icontains and multiple words: smart searching
I wrote something like that. reg = f".*{query}.*" return ProductDocument.search().filter( Q("regexp", title=reg) | Q("regexp", slug=reg) ).to_queryset() 1 problem. It can't search for multiple words: 'macbook pro'. after inserting the space symbol it doesnt return anything 2 problem. How I can improve the searching, now i can write only "icontaints" queries, but I need to search for "redt fox" and get "red foxes" for example. Documents: @registry.register_document class ProductDocument(Document): class Index: name = 'products' settings = {'number_of_shards': 1, 'number_of_replicas': 0} class Django: model = Product fields = ['title', 'slug'] -
Google oAuth 2.0 API Authentication Error: Error 400 - redirect_uri_mismatch (does not comply with policy) DJANGO APP
I am trying to get my google authentication working on a Django app that is requesting Gmail and Calendar data. I have set up the oAuth API in the Google developer console and linked it with my project, and I've triple-checked that my redirect URI perfectly matches that in the code (No errors with HTTP vs. HTTPS nor any inconsistencies with the slashes). I made sure that my key, secret key, ClientID, and Client Secret are all configured and identical in my Django app's admin page. I have followed many youtube tutorials and searched other questions on stack overflow but Authentication is still not working. I am getting an Error 400: redirect_uri_mismatch. Even though I have checked many times to confirm that they are the same. From all the tutorials, I have learned that there are two main origins for this error: Server sided (can be fixed in the cloud hosting developer console) Client sided (can be fixed by altering the code) Both of these errors have their own individualized messages saying what type of mismatch it is. Mine, however, says this: You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy. \n\nIf you're … -
I had "login() missing 1 required positional argument: 'user'" error and its not actually missing
I checked every login func but im still having that error. I'll leave my codes below My views.py codes: def loginUser(request): form = LoginForm(request.POST or None) context = { "form":form } if form.is_valid(): username = form.cleaned_data.get("username") password = form.cleaned_data.get("password") user = authenticate(username=username, password=password) if user is None: messages.warning(request, "Kullanıcı Adı veya Parola Bilgileriniz Hatalı!") return render(request, "login.html", context) login(user) return redirect("index") return render(request, "login.html", context) My urls.py codes: urlpatterns = [ path('register/', register, name= "register"), path('login/', loginUser, name= "loginUser"), path('logout/', logoutUser, name="logoutUser"), ] I can't see a problem about coding all that references are matching. I restarted the server many times and it didn't solve. I can't understand that. -
Django rest framework user registration : Update django user database after the email verification is done
I am trying to register the user by sending an OTP to their mail. Consider the following usual: the user posts a request for registration with an email, password. (email mapped to the username of Django). Django creates the user and the user gets the OTP for verification. If the user verifies, an 'is_verified' field will be set to true. Now, If the user doesn't verify himself with the OTP, I can't get around the following issues. Please suggest a workaround. ---> Any other user can now not use the same email for registration, as email already exists in the database. I want the user to be updated in the database only after the user has successfully verified the otp. -
How to make a Vanilla JS XMLHttpRequest (Wordpress site)
I'm new to wordpress and I'm trying to convert a Django project to wordpress. I have a script.js file that has the XMLHttpRequest function saveInfo() { let request = new XMLHttpRequest(); request.open('POST', '/save/'); let csrf = get_csrf(); request.setRequestHeader('X-CSRFToken', csrf); request.onreadystatechange = () => { if (request.readyState === 4 && request.status == 200) { console.log(JSON.parse(request.responseText)) } } request.send(JSON.stringify(datos)); } Then Django takes the data from that request, saves it to a database and send an email message also with that data: def saveToDB(request): if request.method == "POST": body = request.body.decode('utf-8') body = json.loads(body) client = Client( email=body['email'], edad=body['edad'], ) response = client.save() subject = 'Nueva suscripción a TuKeto' message = 'Email: ' + body['email'] + body['altura'] sendEmail = EmailMessage( subject, message, 'example@gmail.com', ['example@gmail.com'], reply_to=[body['email']], ) status = sendEmail.send() return HttpResponse("SAVED") I have found examples in jquery but they are incomplete and I don't know how to connect the ajax to the wordpress back end. An example of how to make this request with vanilla js and the configuration of the wordpress back end would be very useful. Thanks in advance. -
Using sessions and login() in Django
Session is a piece of info stored in database, can be file-based or cache, and login() stores the data('user id') in session(from Doc). So, Can i retrieve the info saved by login in session,just like doing it with sessions? If yes, then is there any way to override the login to retrieve it? . request.sessions['userid']=request.POST['userid] . user = authenticate(request, username=username, password=password) login(request,user) -
Counting number of object visits per day in django
I have a model like below class Watched(Stamping): user = models.ForeignKey("User", null=True, blank=True, on_delete=models.CASCADE, default=None) count = models.PositiveIntegerField() Each time an object is viewed, the count attribute will increase by 1. My problem is how to find the number of times an object was hit per day. How can I achieve this. The Stamping is another model with created_at and updated_at -
Django how to track each models fields when it was last updated? or is it possible to use autonow in boolean or char fields?
I have a model name CustomerProject and I want to track individually few fields when it was last updated. Right now I am using auto_now= True in datetime fields which can tell me when the whole model was last edited but I want to track individually few boolean fields such as when the work started? when the work delivered etc. here is my models.py class CustomerProject(models.Model): project_title = models.CharField(max_length=2000,blank=True,null=True) project_updated_at = models.DateTimeField(auto_now= True,blank=True,null=True) #I want to track separately those BooleanField project_started = models.BooleanField(default=True) wting_for_sample_work = models.BooleanField(default=False) sample_work_done = models.BooleanField(default=False) working_on_final_project = models.BooleanField(default=False) project_deliverd = models.BooleanField(default=False) project_closed = models.BooleanField(default=False) -
Nested List within Bootstrap 4
I have a table with the following information: Name | Address John | 6432 Newcastle Way Rob | 893 Lake Point St Rob | 1900 Harbor Lane Rob | 124 Marginal St I am trying to create a nested list... That is, to show two total rows (one for John, one for Rob) and within the row, have another list showing each distinct Address (so Rob has 3 lines within his row). This output is not giving me unique values and is not grouping them... any ideas how to tweak this or any walkthroughs I can find? Views.py from django.http import HttpResponse from django.views.generic import TemplateView,ListView from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.urls import reverse_lazy from .models import Book class BookList(ListView): queryset = Book.objects.all().distinct('name') HTML Try 1 <ul class="list-group"> {% for book in object_list %} <li style="margin-bottom: 25px;"> <div class="card" style="width: 18rem;"> <div class="card-body"> <h5 class="card-title">{{ book.name }}</h5> <h6 class="card-subtitle mb-2 text-muted">{{ book.address }}</h6> <a href="{% url 'books_cbv:book_edit' book.id %}">Edit</a> <a href="{% url 'books_cbv:book_delete' book.id %}">Delete</a> </div> </div> </li> {% endfor %} </ul> HTML Try 2 <table> {% for book in object_list %} <li>{{ book.name }} <li> {{ book.address }} </li> </li> {% endfor %} </table> -
AttributeError: module 'student.models' has no attribute 'ManyToManyField'
I'm using the below models: models.py class Student(models.Model): name = models.CharField(max_length = 200) country = models.ManyToManyField(Country, null = True,blank=True) class Country(models.Model): title = models.CharField(max_length = 100, null = True) def __str__(self): return self.title admin.py @admin.register(models.Student) class StudentAdmin(admin.ModelAdmin): formfield_overrides = { models.ManyToManyField: {'widget': CheckboxSelectMultiple}, } I get this error: AttributeError: module 'student.models' has no attribute 'ManyToManyField' -
How to use @font-face with production Django on Digital Ocean?
I can't seem to access my static fonts using @font-face CSS property with the font stored on digital ocean spaces. All my other static items work in the html section. For example, I can do: {% load static %} <div class = "statusImg"><img id = '{{machine.id}}simLight' src="{% static 'images/simLight_off.png' %}"></div> And this will work as expected, bringing in the image from digital ocean. I am not sure how to do this in <style> section though? I tried: <style> @font-face { font-family: PSSroboto; src: url("/static/fonts/roboto/Roboto-Regular.ttf") } </style> and: <style> @font-face { font-family: PSSroboto; src: url({% static '/static/fonts/roboto/Roboto-Regular.ttf' %}) } </style> and: <style> @font-face { font-family: PSSroboto; src: "{% static '/static/fonts/roboto/Roboto-Regular.ttf' %}" } </style> I even hardcoded the URL and made the font public, but this resulted in a CORS policy violation, and in general, probably isn't a great idea anyway. I am hoping it is something small I am missing? Thanks! -
DJango forms: A dynamic integer model choice field always fails form.has_changed()
So I have a list of items, with an integer associated with each values: e.g. CAKE = 1 CHOC = 2 CHIPS = 3 A model with a field foo uses these values as its field, so the model's field is an integer field. This choice selection is not fixed, its dynamic at the point of render. In order to get create a dynamic choice field for an integer field, after much trial and error I eventually got the following solution: class FooForm(forms.ModelForm): def __init__(self, *args, foo_choices, **kwargs): super().__init__(*args, **kwargs) self.fields['foo'].choices = foo_choices def clean_foo(self): foo = int(self.cleaned_data['foo']) return foo class Meta: model = Foo field_classes = { 'foo': forms.ChoiceField, } widgets = { 'property_id': forms.Select(), } All is good, except when i call form.has_changed, the only field which incorrectly reports has changed is 'foo'. The default to_python for a choice field is: def to_python(self, value): """Return a string.""" if value in self.empty_values: return '' return str(value) As you can see the value is always a string. This is fine, because my clean then changes it to an int. However the problem with the has_changed method, is that it checks whether it has changed as follows: if field.has_changed(initial_value, data_value): Where … -
How to implement HATEOS-style links with Django REST framework's ModelViewSets?
I have this product model import uuid from django.db import models class Product(models.Model): """Product in the store.""" title = models.CharField(max_length=120) description = models.TextField(blank=True) price = models.DecimalField(decimal_places=2, max_digits=10) inventory = models.IntegerField(default=0) uuid = models.UUIDField(default=uuid.uuid4, editable=False) def __str__(self): return f'{self.title}' and I defined a serializer for it from rest_framework import serializers from .models import Product class ProductSerializer(serializers.ModelSerializer): class Meta: model = Product fields = ['title', 'description', 'price', 'inventory', 'uuid'] and this is my view from rest_framework import viewsets from .serializers import ProductSerializer from .models import Product class ProductViewSet(viewsets.ReadOnlyModelViewSet): queryset = Product.objects.all() serializer_class = ProductSerializer lookup_field = 'uuid' To start the question, just keep in mind that this view is routed on /store/products/. Now, for example I can do GET http://localhost/store/products/ and it returns [ { "title": "Computer", "description": "", "price": "50.00", "inventory": 10, "uuid": "2d849f18-7dea-42b9-9dac-2ea8a17444c2" } ] but I would like it to return something like [ { "href": "http://localhost/store/products/2d849f18-7dea-42b9-9dac-2ea8a17444c2" } ] and then have http://localhost/store/products/2d849f18-7dea-42b9-9dac-2ea8a17444c2 return { "title": "Computer", "description": "", "price": "50.00", "inventory": 10, "uuid": "2d849f18-7dea-42b9-9dac-2ea8a17444c2" } as it already does. Is this possible using the build-in serialization, or how can I define one that does this? I've played around with the list_serializer_class property but I can't get anything working. -
User modifying field only for themselves in Django
I'm sort of new to Django and am currently struggling with a certain aspect of it. In my project I want all Users to have access to certain Jobs added by the admin and appear on the Front end. However each Job has a field called userStatus that the user should be able to edit. This field however should not change for any other users. Currently I have created a model out of userStatus and created a Foreign Key field to link to a Job. Then userStatus has a User Foreign Key Field. class Job(models.Model): name = models.CharField(max_length=200, help_text='Enter the Spring/Internship') course = models.ForeignKey('Course', on_delete=models.RESTRICT,null=True) company = models.ForeignKey('Company', on_delete=models.RESTRICT,default='N/A') deadline = models.DateField(null=True, blank=True) userStatus = models.ForeignKey('userStatus', on_delete=models.RESTRICT, null=True, blank=True) class userStatus(models.Model): user = models.ForeignKey(User, on_delete=models.RESTRICT) USER_STATUS = ( ('n', 'Not Applied'), ('a', 'Applied'), ('i', 'Got Interview'), ('o', 'Got Offer'), ('r', 'Rejected'), ) stage = models.CharField( primary_key=True, max_length=1, choices=USER_STATUS, blank=False, default='c', help_text='What is the current stage of the process', ) The User should not be able to edit any field except for the userStatus that should only belong to them. The tuple USER_STATUS should be the only options for that model and every Job should have access to these 5 options. … -
Django : how to create a mailbox for each users i have
I have a project with 3 groups of user who are admin, prof, and student. I want all my users to be able to send messages to each other privately. For example if I want a teacher to send a message to a student or admin, how should I proceed? Do I need to create a new model or I just need to add a mailbox field to my models. that's my models models.py from django.db import models from django.contrib.auth.models import User from django.core.validators import RegexValidator from phonenumber_field.modelfields import PhoneNumberField class Prof(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) location = models.CharField(max_length=150) date_of_birth = models.DateField(null=True, blank=True) phone = PhoneNumberField(blank=True) class Student(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) speciality = models.CharField(max_length=150) location = models.CharField(max_length=150) date_of_birth = models.DateField(null=True, blank=True) phone = PhoneNumberField(blank=True) here is how I register my 3 types of users with django signals signals.py from django.db.models.signals import post_save from django.contrib.auth.models import Group from django.dispatch import receiver from .models import Prof, Student from django.contrib.auth.models import User @receiver(post_save, sender=User) def admin_profil(sender, instance, created, **kwargs): if created and instance.is_superuser: group = Group.objects.get(name='admin') instance.groups.add(group) @receiver(post_save, sender=Prof) def prof_profil(sender, instance, created, **kwargs): if created: group = Group.objects.get(name='prof') instance.user.groups.add(group) @receiver(post_save, sender=Student) def student_profil(sender, instance, created, **kwargs): if created: group … -
How to translate form error messages in django?
I want to translate error messages in django's forms and show the translation in my template, but I don't know how to translate error messages when I am using form.errors to get form's error messages. should I use ugettext or ugettext_lazy or something else? How to use them to translate form's messages? -
Django: annotate(sum(case(when())))
In my project, I'm trying to aggregate the data based on the status of a 'field'. The 'view' is expected to return a table like so: SERVICE_CODE SUCCESS TECHNICAL_DECLINES BUSINESS_DECLINES Service-1 S11 S12 S13 Service-2 S21 S22 S23 where S11,S12... are the aggregates taken based on the value of the field 'STATUS' in the model given below: models.py from django.db import models class Wfmain(models.Model): ENTITY_NUM = models.IntegerField() SRV_REF_NUM = models.CharField(max_length=30,primary_key=True) ITER_SL = models.IntegerField() STAGE_ID = models.CharField(max_length=30) ACTION = models.CharField(max_length=30) STATUS = models.CharField(max_length=30) REQUEST_DATE = models.DateField() SERVICE_CODE = models.CharField(max_length=30) SERVICE_TYPE_CODE = models.CharField(max_length=30) FUNCTION_CODE = models.CharField(max_length=30) REQUEST_START_TIME = models.DateField() class Meta: db_table = "WFMAIN" unique_together = (("ENTITY_NUM", "SRV_REF_NUM"),) The aggregates ought to be grouped by the field 'SERVICE_CODE' views.py from django.db.models import When, Case, Sum, IntegerField from django.shortcuts import render,redirect from hr.models import * def financial(request): S=['0','00','000'] NT=['0','00','000','099','100','101','102','103','104','105','107','108','109','110','111','113','114','116','117','118','119','120','121','122', '123','124','180','181','182','183','184','185','186','187','188','189','200','201','205','213','217','218','219','220','221','222','223','224', '230','231','232','233','234','235','236','237','238','239','240','241','248','249','250','256','258','260','262','263','264','265'] B=['S','099','100','101','102','103','104','105','107','108','109','110','111','113','114','116','117','118','119','120','121','122','123','124', '180','181','182','183','184','185','186','187','188','189','200','201','205','213','217','218','219','220','221','222','223','224','230','231', '232','233','234','235','236','237','238','239','240','241','248','249','250','256','258','260','262','263','264','265'] wf=Wfmain.objects.using('MBDB') fin = wf.values('SERVICE_CODE').annotate( Success=Sum(Case(When(STATUS in S, then=1), when(STATUS not in S, then=0), output_field=IntegerField())), Technical_declines=Sum(Case(When(STATUS not in NT, then=1), When(STATUS in NT, then=0), output_field=IntegerField())), Business_declines=Sum(Case(When(STATUS in B, then=1), When(STATUS not in B, then=0), output_field=IntegerField()))).order_by('SERVICE_CODE') I'm stuck with error: "name 'STATUS' is not defined" Output @browser: Please tell me where I went wrong. -
Is there a way to delete an object from database in html document? (django)
view.html <th><button id={{p.id}} onclick="Delete(this.id)" class="btn btn-outline-danger">Delete</button></th> <script> function Delete(row_id){ document.getElementById(row_id).remove(); {{dogss.objects.filter(id=1)}.delete()}} //I wanted this to happen, but it's not working } </script> </tr> view.py def view(response): return render(response, "main/view.html", {"dogs": Dog.objects.filter(user=response.user), "dogss": Dog}) I know that I can make that button interact with .py file and from there it will probably work. But I'm curious why this isn't working? -
calendar-telegram not forwarding more than 1 month
I found th is calendar-telegram https://github.com/unmonoqueteclea/calendar-telegram I'm using python-telegram-bot with the Conversation Handler, but some how when I want to forward in the calendar to a future month it does not work, this is what I have tried so far: bot.py def get_telefono(update: Update, context: CallbackContext) -> None: telefono = update.message.text context.user_data['telefono'] = telefono user_data = context.user_data respuesta = 'Fecha de Vencimiento AAAA-MM-DD' update.message.reply_text(respuesta, reply_markup=telegramcalendar.create_calendar()) return GET_VENCIMIENTO def get_vencimiento(update: Update, context: CallbackContext) -> None: bot = context.bot selected, date = telegramcalendar.process_calendar_selection(bot, update) if selected: respuesta = date.strftime("%d/%m/%Y") update.message.reply_text(respuesta, reply_markup=ReplyKeyboardRemove()) return GET_PAGO class Command(BaseCommand): help = 'test' def handle(self, *args, **options): updater = Updater(settings.TOKEN) dispatcher = updater.dispatcher conv_handler = ConversationHandler( entry_points=[CommandHandler('start', start, Filters.user(username="@cokelopez"))], states={ GET_TELEFONO: [MessageHandler(Filters.regex('^\+?1?\d{9,15}$'), get_telefono)], UP_TELEFONO: [MessageHandler(Filters.regex('^\+?1?\d{9,15}$'), up_telefono)], GET_VENCIMIENTO: [CallbackQueryHandler(get_vencimiento)], GET_PAGO: [MessageHandler(Filters.text, get_pago)], }, fallbacks=[CommandHandler('cancel', cancel)], allow_reentry = True, ) dispatcher.add_handler(conv_handler) dispatcher.add_error_handler(error) updater.start_polling() updater.idle() *it's just part of the code The calendar just hangs and nothing happens, I'm in Auguts and when I click next it goes to September, but ir I try the next mont, October, it just hangs in September