Answer by Mojtaba Kamyabi for How to make trailing slash optional in django
You can use re_path instead of path for use regular expression in your url pattern. use ? sign in your url like this:from django.urls import re_pathre_path(r'url/?$', views.appmain, name="main")Note:...
View ArticleLinkerd multicluster: probe-gateway mirrored from cluster but has no endpoints
I am using linkerd and have two clusters (west and east) in GKE, each of them has 3 nodes. I exactly followed the steps in official documents for multicluster. when I try to run check on west I get the...
View ArticleHow to Send AWS Chatbot Notifications Only to Slack Thread Without Posting in...
I am using AWS chatbot and want to group similar messages in a thread. like this:aws sns publish --topic-arn "${AWS_SNS_TOPIC_ARN}" --message '{"version": "1.0","source": "custom","content":...
View ArticleComment by Mojtaba Kamyabi on split huge docker-compose file contains...
there are almost 30 volumes. most of them shared (almost 10) that I need then in all services
View ArticleAnswer by Mojtaba Kamyabi for Django (v4) request.META['REMOTE_ADDR'] not...
Check your intermediate proxies like nginx, apache, etc if you use one in between of your requests and web application. sometimes proxies manipulate request headers before sending it to web...
View ArticleHow can I determine the sector size in windows?
How can I determine the Physical Sector Size (e.g. if i have an Advanced Format drive with 4,096 byte sectors rather than the legacy 512 byte sectors) in Windows 7?I know that by clicking on a file and...
View Articlehow to access pk_set when m2m_changed call with action "pre_clear"?
I want to use m2m_changed signal when a realtion in ManyToMany field removed. I write this code in models.py:class Unit(Model): # ....class Package(Model): # ... Lesson = ManyToManyField(Unit,...
View ArticleNginx error upstream timed out (110: Connection timed out) while SSL...
I have three docker containers in my project: Nginx, tornado-app, and DB. My Tornado app serves WebSocket app (URLs are /clientSocket and /gatewaySocket) and Django app (URLs are everything except...
View ArticleCan I dynamically convert an instance of one class to another?
I have a class that describe chess pieces. I make for all type piece in the Board a class for example Pawn, Queen, keen, etc...I have a trouble in Pawn class I want to convert to Queen or other object...
View ArticleAnswer by Mojtaba Kamyabi for Django Form does not show up until it's submitted
it seems your first if statement in signup function is redundant.if request.method == 'GET': return render(request, 'authentication/register.html')you don't send form variable to the template in these...
View Articlewhy keyError in session when logout?
I set session["logID"] in register and login functions in my view but when I want to save it in the DB when user logs out then I get Loginstatus matching query does not exist. in django. here is my...
View ArticleAnswer by Mojtaba Kamyabi for unique_together and M2M field
you can use through in ManyToManyFieldand connect your many to many relations through custom intermediate table. then add unique_together there:class CodeSynonyms(models.Model): # add through field...
View ArticleAnswer by Mojtaba Kamyabi for Python/pyfpdf: TypeError: list indices must be...
Your data is list object and can't access like data["PowerS"]. you have to use integers or slices as indexing like this:>>> data = [ ['Power:',data["PowerS"],'MVA'],...
View ArticleAnswer by Mojtaba Kamyabi for How to create, update and delete forms in the...
You can use different names for your Edit and New buttons in your form in template like this:<form action="/" method="post"><input type="submit" name="new_customer" value="New" /><input...
View ArticleAnswer by Mojtaba Kamyabi for How to call urls.py fetching a value from a...
You can use Reverse resolution of URLs. just add another url pattern in your urls.py:urlpatterns = [ path('destination/<int:dest>/', views.destination_content, name='destination_content'), #...
View ArticleAnswer by Mojtaba Kamyabi for Name error when trying to print an object of a...
First Problem:Use self inside your class to access to your object not games. change these:games.name, games.platform , games.genre, ...and other stuffs like them to these:self.name, self.platform ,...
View ArticleAnswer by Mojtaba Kamyabi for how to build a sorting key function in python?
You can sort based on second element (its price) of every tuple like this:sorted(a, key=lambda x: float(x[1]))output:[('banana', '2.3'), ('chocolate', '4.4'), ('candy', '5.5')]If you don't want lambda...
View ArticleAnswer by Mojtaba Kamyabi for How can I get Argumants that start with...
views arguments is what you need. You can define variables in you urls.py like...
View ArticleAnswer by Mojtaba Kamyabi for How do I count objects/substrings in a very...
You can use built-in functions of python like literal_eval for evaluate each lines to dictionaries in python:from ast import literal_evalfrom collections import defaultdict, Counterwith...
View Articlehow to read from a GPIO pin when it changes?
I create an app that must detect when the lights(LEDs) changes their status (on->off or off->on) monitor this to a site.I create this app in client side with node.js and use rpi.GPIO package from...
View Article