Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Extract data from a related field in django rest framework
I am trying to extract data from a Foreign Key related field in django rest framework using PrimaryKey. Views.py class DispatchervsLrAPIView(CreateAPIView): def get(self, request): date_to = request.data['date_to'] date_from = request.data['date_from'] company_id = request.data['c_name'] company_emp = Teacher.objects.filter(company_id=company_id).values_list('user_id', flat=True) d = LR.objects.filter(Q(created_on__range=[date_to, date_from]) | Q(lr_quiz_id__owner_id__in=list(company_emp))) print(" d is ", d) serializer = DispvsLRSerializer(d, many=True) return Response(serializer.data, status=status.HTTP_201_CREATED) Serializers.py class DispvsLRSerializer(serializers.ModelSerializer): lr_quiz = serializers.PrimaryKeyRelatedField class Meta: model = LR fields = "__all__" But the output I am given in postman is this: [ { "id": 1, "lr_no": 0, "lr_date": "2019-11-10T12:45:33.478763", "lr_billingparty": "0", "invoice_no": 0, "lr_declared": 0, "ewaybill_no": 0, "lr_quantity": 0, "lr_weight": 0, "lr_invoice_date": "2019-11-10T12:45:33.478763", "lr_item_name": "0", "lr_consignor_name": "0", "lr_consignor_address": "0", "lr_consignor_contact_name": "0", "lr_consignor_contact_phone": "0", "lr_consignee_name": "0", "lr_consignee_address": "0", "lr_consignee_contact_name": "0", "lr_consignee_contact_phone": "0", "vehicle_no": "0", "lr_vehicle_type": 0, "driver_name": "0", "driver_no": "0", "created_on": "2019-11-10T00:00:00", "lr_quiz": 1, "lr_owner": 2 } ] How can I expand the "lr_quiz" ? where lr_quiz is a foreign Key related field -
overwrite query set inside steriliser class
I have three model like game: id,home_team_id, away_team_id, season_type team: id,name team_standing: id, team_id, season_type, win, loss I have used eager loading inside drf serializers @classmethod def setup_eager_loading(cls, queryset): """ Perform necessary eager loading of data. """ # select_related for "to-one" relationships queryset = queryset.select_related('home_team', 'away_team').prefetch_related('home_team__team_standings', 'away_team__team_standings') return queryset I need list of game with team details including team_standings like: [ { id:1, home_team_id:1, away_team_id:2, season_type:1, home_team:{ id: 1 (it will be id of team model), name: GS, team_standing:{ id:team standing model id, season_type: season_type value but it must be same as of game season_type, team_id: team id, win:3 } }, away_team:{ id: 1 (it will be id of team model), name: INA, team_standing:{ id:team standing model id, season_type: season_type value but it must be same as of game season_type, team_id: team id, win:2 } } } ] But I am getting all team standing records with different season type. Is there any way to make filter game season_type with team_standing season_type, although I know there is no direct relation between these column. -
I want to make a Social Media Platform
As per the current scenario which technology should perform best and easy to make a social media platform. -
Django: Filtering via SQL, not Python
I created the following context variables context["genders"] and context["ages"]. Currently, there is a lot of work done by Python under #Filtering, while I think it would be better done in #Query. However, that's where I currently struggle. Do you have an idea on how to achieve the pre-filtering? Please not the int(answer_obj.answer) as answer is a TextField. # Query responses = Response.objects.filter( survey__event=12, survey__template=settings.SURVEY_POST_EVENT ).order_by("-created") # Filtering filtered_responses = [] for response in responses: for answer_obj in response.answers.all(): if ( answer_obj.question.focus == QuestionFocus.RECOMMENDATION_TO_FRIENDS and int(answer_obj.answer) >= 8 ): filtered_responses.append(response) # Context gender_list = [] age_list = [] for response in filtered_responses: for answer_obj in response.answers.all(): # Here a list of all the genders that gave that answer: if answer_obj.question.focus == QuestionFocus.GENDER: gender_list.append(answer_obj.answer) # Here a list of all the ages that gave that answer: if answer_obj.question.focus == QuestionFocus.AGE: age_list.append(answer_obj.answer) context["genders"] = gender_list context["ages"] = age_list models.py class Answer(TimeStampedModel): question = models.ForeignKey( "surveys.Question", on_delete=models.CASCADE, related_name="answers" ) response = models.ForeignKey( "Response", on_delete=models.CASCADE, related_name="answers" ) answer = models.TextField(verbose_name=_("Answer")) choices = models.ManyToManyField( "surveys.AnswerOption", related_name="answers", blank=True ) class Response(TimeStampedModel): class Language(Choices): CHOICES = settings.LANGUAGES survey = models.ForeignKey( "surveys.Survey", on_delete=models.CASCADE, related_name="responses" ) order = models.ForeignKey( "orders.Order", on_delete=models.SET_NULL, null=True, blank=True, related_name="response", ) attendee = models.ForeignKey( "attendees.Attendee", on_delete=models.SET_NULL, … -
How to send the value present in a table row when i click on a button in javascript
So i have a table which looks something like this: clicking on the trash icon deletes the row but I also want to send the primary key which is Flight Number back for further processing when that button is clicked so that I can receive it in a statement like this: val = request.POST.get("flightnum", None) table html block: <table class="table table-bordered"id="flight"> <thead> <tr> <th class="text-center" scope="col">Flight Number</th> <th class="text-center" scope="col">Parking Bay</th> <th class="text-center" scope="col">Destination</th> <th class="text-center" scope="col">Departure Time</th> <th class="text-center" scope="col">Inbound</th> <th class="text-center" scope="col">Airline</th> <th class="text-center" scope="col">Arrival Time</th> <th class="text-center" scope="col">Update / Delete</th> </tr> </thead> <tbody> {% for brake in brakes %} <tr> <td class="text-center">{{brake.fl_no}}</td> <td class="text-center">{{brake.park_bay}}</td> <td class="text-center">{{brake.dest}}</td> <td class="text-center">{{brake.dep_time}}</td> <td class="text-center">{{brake.inbound}}</td> <td class="text-center">{{brake.airline}}</td> <td class="text-center">{{brake.arr_time}}</td> <td class="text-center"> <a href="{% url 'flight_update' brake.pk%}"><button type="button" class="update-status btn btn-sm btn-primary"> <span class="fa fa-pencil"></span> </button> <form action="{% url 'flight_delete' brake.pk %}" method='POST' style="display: inline;"> {% csrf_token %} <input type='hidden' name='flight-no' value="{{brake.fl_no}}"/> <button type="submit" class="delete-status btn btn-sm btn-danger"> <span class="fa fa-trash"></span> </button> </form> </tr> {%endfor%} </tbody> </table> -
Django forms with multiple access
After creating a multi-stage form. How do I restrict the access to the particular part of the form to a particular user. Suppose I have 3part of the form... User1 can access part1 of the form after that user2 can access the part2 of the form and so on... Admin can View and access all part of the multi stage form -
Django-Python Instance of 'Object' has not 'value' member even if I instantiate
With the following definition: class Ticket(models.Model): ... title = models.CharField( _('Title'), max_length=200, ) queue = models.ForeignKey( Queue, verbose_name=_('Queue'), ) created = models.DateTimeField( _('Created'), blank=True, help_text=_('Date this ticket was first created'), ) modified = models.DateTimeField( _('Modified'), blank=True, help_text=_('Date this ticket was most recently changed.'), ) submitter_email = models.EmailField( _('Submitter E-Mail'), blank=True, null=True, help_text=_('The submitter will receive an email for all public ' 'follow-ups left for this task.'), ) assigned_to = models.ForeignKey( MongoUser, related_name='assigned_to', blank=True, null=True, verbose_name=_('Assigned to'), ) ... And this Instantiation: ticket = Ticket( title="aaaaa", submitter_email=request.POST['submitter_email'], assigned_to= contableHelpdesk, status=1, queue=queue, description=request.POST['body'], priority=request.POST['priority'], ) print(ticket.title) print(ticket.submitter_email) print(ticket.queue) ticket.save() Ticket is not getting the correct values, I checked that types match. When 'prints', ticket.title says Instance of 'Ticket' has not 'title' member and so on with submitter_email and queue. -
How to fix automatic login in Django?
How to fix automatic login in Django? When Someone goes to someone profile by typing URL like http://127.0.0.1:8000/profile/1 so when the page loaded it will automatic login to person profile, for example, the admin had 1 profile with pk=1 so if some type URL like this http://127.0.0.1:8000/profile/1 he will log in to admin without password username I Want Like This No Body Can log in To Profile with a link and He Can Only View Someone Profile Not Login To Someone Profile Here is my Views.py def profile_detail(request,pk): user = get_object_or_404(User, pk=pk) model = user_register_model() return render(request,'profile_detail_view.html',{'user':user,'model':model,}) Here is my Base.html {% if user.is_authenticated %} <li class="nav-item"> <a class="nav-link navaour" href="{% url 'profile' pk=user.pk %}"><i class="fa fa-user"></i>&nbsp; Profile</a> </li> <li class="nav-item"> <a class="nav-link navaour" href="{% url 'logout' %}"><i class="fa fa-power-off"></i>&nbsp; Logout</a> </li> {% else %} <li class="nav-item"> <a class="nav-link navaour" href="{% url 'register' %}"><i class="fa fa-check-square-o"></i>&nbsp; Sign up Free</a> </li> <li class="nav-item"> <a class="nav-link navaour" href="{% url 'login' %}"><i class="fa fa-user"></i>&nbsp; Login</a> </li> {% endif %} Here is my Profile_Detail_View.html <div class="row"> <div class="col-sm-3 col-md-2 col-5"> <label style="font-weight:bold;">Full Name</label> </div> <div class="col-md-8 col-6"> {{user.username}} </div> </div> <hr /> <div class="row"> <div class="col-sm-3 col-md-2 col-5"> <label style="font-weight:bold;">Join Date</label> </div> <div class="col-md-8 … -
Limit custom migration to one model
I have decided to implement registration option for my website, I used this tutorial (signup with confirmation part). Following this material I have created Profile module to hold some info. Everything (seems to be) working now, but the problem is that old profiles throws relatedObjectDoesNotExist error. According to these two questions (first, second) I need to make a migration to create profiles for old user accounts. I tried to follow this doc as suggested in one of the answers, but then I try to run a migration I get following error: KeyError: ('stv', 'bazinekaina') stv is the name of my app and bazinekaina is the name of the next model after the one I need to create profiles. How to limit migration to only the first model? My relevant models.py code: class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) email_confirmed = models.BooleanField(default=False) first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) email = models.EmailField(max_length=254) @receiver(post_save, sender=User) def update_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.get(user=instance) instance.profile.save() #next model, this one throws an error, despite the fact it should not be touched at all class BazineKaina(models.Model): #bazines kainos modelis bazka = models.DecimalField(max_digits=5, decimal_places=2) data = models.DateField(auto_now=False, auto_now_add=True) def __str__(self): return str(self.bazka) class Meta: verbose_name_plural = "Bazinė kaina" … -
Empty GET response after clicking button on web page
I stucked with next (search.html): <form action="{% url 'search' %}" method="GET"> {% csrf_token %} <div class="row"> <input placeholder="Word" style="width:50%;height:15px;border:1px solid #de272b" type="text" value="" name="textbox1" size="1"/> </div> <div class="row"> <input placeholder="Phone" style="width:50%;height:15px;border:1px solid #de272b" type="text" value="" name="textbox2" size="1"/> </div> <input style="margin-top:10px; margin-bottom:15px;width:300px;height:30px;" type="submit" class="btn btn-primary" value="Search" name="button"> </form> This is search form in my template. views.py: def search_engine(request): db = MySQLdb.connect(host="localhost", user="user", passwd="123456", db="test", charset="utf8") cur = db.cursor() q = request.GET.get("button", None) if q: cur.callproc('search', {'Id': 2}) data = cur.fetchall() request.GET.get('textbox1') request.GET.get('textbox2') return render(request,'search.html', {'result': data}) return render(request, 'search.html') Mysql procedure works fine, problem is in django. urls.py: url(r'^search', search_engine, name="search") After clicking button I recieves nothing. Adding any data in "if" statement and sending to render - no effect. -
Django custom command not working with args
I am trying to call the command using args in Django 2.0. When I pass the args it give this error message: "TypeError: Unknown option(s) for dummy command: args. Valid options are: help, no_color, pythonpath, settings, skip_checks, stderr, stdout, traceback, url, verbosity, version." The command works fine with options. It only cause this error when called using args. My command code: from django.core.management.base import BaseCommand class Command(BaseCommand): help = 'A description of your command' def add_arguments(self, parser): parser.add_argument( '--url', required=False, type=str, help='the url to process', ) def handle(self, *args, **options): for url in args: self.stdout.write(url) Here I call the command from django.core.management import call_command from django.test import TestCase class DummyTest(TestCase): def test_dummy_test_case(self): call_command("dummy", args=['google.com']) -
Cannot open include file: 'mysql.h': No such file or directory
I am trying to install requirements.txt of a django project and it is giving me the following error: MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory I have tried the following commands but they don't seem to work for me Commands that I tried: pip install mysqlclient==1.3.4 pip install --only-binary :all: mysqlclient error: Installing collected packages: mysqlclient, wheel, gunicorn, psycopg2, python-dateutil, numpy, pandas, django-pandas, kuchbhi, pyparsing, pulp, sqlalchemy, xlwt, django-bootstrap-modal-forms, MarkupSafe, jinja2, branca, certifi, urllib3, chardet, idna, requests, folium, django-widget-tweaks, googlemaps, decorator, ipython-genutils, traitlets, pywin32, jupyter-core, pyrsistent, attrs, more-itertools, zipp, importlib-metadata, jsonschema, nbformat, pyzmq, tornado, jupyter-client, pickleshare, backcall, parso, jedi, wcwidth, prompt-toolkit, colorama, pygments, ipython, ipykernel, testpath, defusedxml, pandocfilters, webencodings, bleach, mistune, entrypoints, nbconvert, pywinpty, terminado, Send2Trash, prometheus-client, notebook, widgetsnbextension, ipywidgets, geojson, gmaps, django-fullcalendar, geographiclib, geopy, pillow, brotli, django-brotli, zopfli, django-static-compress, django-clear-cache, pyjwt, djangorestframework, djangorestframework-simplejwt, djangorestframework-jwt, django-cors-headers Found existing installation: mysqlclient 1.3.12 Uninstalling mysqlclient-1.3.12: Successfully uninstalled mysqlclient-1.3.12 Running setup.py install for mysqlclient ... error Complete output from command c:\users\rahul\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Rahul\\AppData\\Local\\Temp\\pip-build-pul5j4z0\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Rahul\AppData\Local\Temp\pip-mn6g7opp-record\install-record.txt --single-version-externally-managed --compile: c:\users\rahul\appdata\local\programs\python\python36-32\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running install running build running build_py creating build creating build\lib.win32-3.6 creating build\lib.win32-3.6\MySQLdb copying … -
Error occured during project deployement in pythonanywhere
I have done it many times in windows operating system but now i am using Ubantu as my primery system. So when i tried makemigrations command inside my project directory(server) to pythonanywhere bash throw below error. (myproject) 07:29 ~/Product-Management-System (master)$ python manage.py makemigrations django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") Please someone help me!! -
Allow an authenticated User to Book Multiple Users Django
I am making a django website with a booking feature. Now I have created a working website where there is a feature to book a single user (who is logged in). What I want is to allow a logged in user to book multiple of his friends that might not be in the database. I am confused about the model. I know django has a formset for creating multiple similar forms but I want the information of that form to be associated to a single user(who booked them). So what I am thinking regarding model is: class GroupBooking(models.Model): booker = models.ForeignKey(User,on_delete=models.CASCADE) number_of_people = models.PositiveIntegerField() class UnregisteredUsers(models.Model): group = models.ForeignKey('GroupBooking',on_delete=models.CASCADE) name = models.CharField(max_length=50) mobile = models.CharField() # Other Information . . . . . . . . . Number_of_people could be number of forms created or it could be changed dynamically by adding a button that creates a new form and increments. I want suggestions regarding my approach and how should I proceed forward. Also I would appreciate some reading material or tutorial covering the features involved in such a process. -
How to rename parent's fieldname
class PermissionsMixin(models.Model): ... groups = models.ManyToManyField( Group, verbose_name=_('groups'), blank=True, help_text=_( 'The groups this user belongs to. A user will get all permissions ' 'granted to each of their groups.' ), related_name="user_set", related_query_name="user", ) ... class AbstractUser(AbstractBaseUser, PermissionsMixin): ... ... class MyUser(AbstractUser): //i want groups rename to roles class Meta: db_table = 'user' i see the migrations has RenameField , how to use? the code is very clear, why the system always prompts for more details, idiot system. -
changing form to search box
Here is my code for form where a user insert stock symbol and the result of the input is shown in the new page. What I did so far: in models.py from django.db import models from django.contrib import auth class Child(models.Model): name = models.CharField(max_length=150, blank=True) in forms.py from django import forms from .models import Child class ChildlForm(forms.ModelForm): class Meta: model = Child fields = ('name',) In views.py from django.shortcuts import render from .forms import ChildForm from pandas_datareader import data as wb from yahoofinancials import YahooFinancials # Create your views here. def home(request): form = ChildForm() if request.method == "POST": form = ChildForm(request.POST) if form.is_valid(): data = form.save(commit=True) name = data.name symbols = [name] yahoo_financials = YahooFinancials(symbols) new_data = pd.DataFrame() for s in symbols : new_data[s] = wb.DataReader(s, data_source ='yahoo', start = '2014-1-1')['Adj Close'] a = new_data[s] b = a[-1] context={ 'name':name, 'b':b,} else: form = ChildForm() return render(request,'main/index.html',{'form':form}) return render(request,'main/index2.html',context) return render(request,'main/index.html',{'form':form}) the index.html file <form method="POST"> {{ form }} {% csrf_token %} <input class="form-control mr-sm-2" type="text"> <button type="submit">OK</button> </form> I realised that the form method has limitation and puts name in front of input box which looks ugly. I tried to build serach box in index.html file with search … -
How append a python dictionary to the end of a django queryset?
I have a Django Queryset object that looks like this (it is a derived queryset, not a queryset for a Model): <QuerySet [{'A': 2, 'B':3, 'C':0 }, {'A': 1, 'B':2, 'C':1 }]> I also have a dictionary with a similar structure to the queryset that looks like this: {'A': 1, 'B':4, 'C':7 } How can I append this dictionary to the end of the queryset? That is, I will have: <QuerySet [{'A':2, 'B':3, 'C':0 }, {'A':1, 'B':2, 'C':1 }, {'A':1, 'B':4, 'C':7 }]> -
How build API to to match Django app users
I'm creating a Django app that allows users to register as either a "mentor" or "mentee". Each user has some information stored in the User that is common across all accounts, while mentors have a second table (one-to-one) MentorProfile with areas of expertise. Similarly MenteeProfile is a table populated with mentees' areas of interest. The goal is to create a mechanism by which a mentor is assigned to a mentee after running a matching algorithm (such as stable relationship). I have working registration/edit features, however am stuck on how to begin implementing the match. Is there a way to introduce a button into the Django admin panel that, when clicked: Pulls the necessary information from the Django app Makes the Mentor/Mentee matches and assignments Updates the MentorProfile and MenteeProfile tables with these matches For what it's worth, we have a working python script that pulls the necessary information from a properly formatted csv that can make the mentor/mentee relationship assignment. We are simply unsure on how to implement this logic into our app. -
How To Add Last Seen in Django?
Hi Everyone How To Add Last Seen In Django? Can You Please Help Me i Want To Create A App That can also show last seen so how can i add last seen? If You Need Any Files Please Comment Me :) Any Help Will Be Appreciated Thanks! -
unknown Invalid HTTP_HOST header in Django logs: api-keyboard.cmcm.com
I have been testing a new Django application on aws beanstalk. While looking through the httpd error logs I see thousands of lines like this: ... Invalid HTTP_HOST header: 'api-keyboard.cmcm.com'. You may need to add 'api-keyboard.cmcm.com' to ALLOWED_HOSTS.* Normally this is because I didn't add my own hostname to ALLOWED_HOSTS but this domain is completely foreign to me and I can't find references to it online. So I'm wondering what this means, how do random host like this end up in the header, and if anyone recognized this one. Thanks! -
Django: Problem with Using Slug in Templates
I am a beginner in Django. I am building a Django app, named PhoneReview. It will store reviews related to the latest mobile phone. It will also display phone brands, along with the associated phone models. I have already created models, views and the template files. Now, I am facing a problem. I can't use slug in URLs. Right now, it looks like this: Here are my codes of models.py located inside PhoneReview folder: from django.db import models from django.template.defaultfilters import slugify # Create your models here. class Brand(models.Model): brand_name = models.CharField(max_length=100) origin = models.CharField(max_length=100) manufacturing_since = models.CharField(max_length=100, null=True, blank=True) slug = models.SlugField(max_length=150, null=True, blank=True) def __str__(self): return self.brand_name def save(self, *args, **kwargs): self.slug = slugify(self.brand_name) super().save(*args, **kwargs) class PhoneModel(models.Model): brand = models.ForeignKey(Brand, on_delete=models.CASCADE) model_name = models.CharField(max_length=100) launch_date = models.CharField(max_length=100) platform = models.CharField(max_length=100) slug = models.SlugField(max_length=150, null=True, blank=True) def __str__(self): return self.model_name def save(self, *args, **kwargs): self.slug = slugify(self.model_name) super().save(*args, **kwargs) class Review(models.Model): phone_model = models.ManyToManyField(PhoneModel, related_name='reviews') review_article = models.TextField() date_published = models.DateField(auto_now=True) # slug = models.SlugField(max_length=150, null=True, blank=True) link = models.TextField(max_length=150, null=True, blank=True) def __str__(self): return self.review_article Here are my codes of urls.py located inside PhoneReview folder: from . import views from django.urls import path urlpatterns = [ path('index', … -
Not null constraint failed. Even when I've removed fields that caused issue with not null constraint. Django postgres
I'm having difficulty updating these three models which are linked with Foreign keys Reason they are linked with foreign keys is Events can have multiple Markets and Markets can have multiple Runners. I'm at my wits end with this not null error. Even If I have a field that causes the issue and I remove the field from my model. Make migrations, migrate and remove the save from my task I still get the exact same error. What is the purpose of this not null argument? Even If I have null=True or null=False on brand new models I still get the error. Not null constraint failed I've no idea why this is failing. Do I need to make sure all fields have a null argument? According to django documentation default is false. For each object my task runs all fields have data. So default of false should be fine. Could this be due to the manner I'm updating the models with my task? full stacktrace here https://gist.github.com/Cally99/08fed46ba8039fa65d00f53e8a31b37a class Event(models.Model): sport_name = models.CharField(max_length=15) event_id = models.BigIntegerField(unique=True) event_name = models.CharField(max_length=200) start_time = models.DateTimeField() status = models.CharField(max_length=13) class Market(models.Model): event = models.ForeignKey(Event, on_delete=models.CASCADE) market_id = models.BigIntegerField(unique=True) market_name = models.CharField(max_length=35) status = models.CharField(max_length=10) volume … -
How to include other app's urls.py in get_absolute_url: reverse() django?
In app models.py, I am using get_absolute_url to reverse to a particular path using "name" that is in different app urls.py. But of course I am getting error because the I have not created urls.py for that app as the urlpattern is already present in some other urls.py. So is there any include(app.urls) type functionality that I can use in reverse? #app: A - urls.py urlpatterns = [ path('post/<int:pk>/', PostDetailView.as_view(), name = 'post-detail'), ... ] #app: B - models.py def get_absolute_url(self): return reverse('post-detail',kwargs = {'post_id.id':self.post_id.id}) -
Display modal instead of options in select input with selection
i'm using React and django to test some projects and i'm newbie. i Want to display a modal box instead of dropdown options ( options are my api data ) of a selection in form, and let user select that options ( fruits ) in a modal box and add multiple selected fruits to Fruitbox . this is what i tried : https://codesandbox.io/s/objective-blackwell-nh6n5?fontsize=14 anyone knows how this codes will look like? -
Is there a dynamic scheduling system for better implementation of a subscription based payment system?
I was making a subscription payment system from scratch in python in Django. I am using celery-beat for a scheduled task with RabbitMQ as a queue broker. django_celery_beat uses DatabaseScheduler which is causing problems. Takes a long time to dispatch simple-task to the broker. I was using it to expire users. For some expiration tasks, it took around 60 secs - 150secs. But normally it used to take 100ms to 500ms. Another problem is that, while I re-schedule some task, while it is being written into the database it blocks the scheduler for some bizarre reason and multiple tasks are missed because of that. I have been looking into Apache Airflow because it is marketed as an industry-standard scheduling solution. But I don't think, it is applicable and feasible for my small project. If you have worked and played with a subscription payment system, can you advise me how to go forward with this?