Django community: Django Q&A RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Searching Cards using Javascript by exclusion
I am trying to implement seach using Javascript by search cards using card-title and if it is not found in a card to be deleted from the html result. I had it working before in another but now when I was trying to implement it again it is not working for some reason. Here is the card html <main> <div class="container"> <div class="row"> <div class="col-md-12"> <form action="/store/s/" role="search"> <input name="q" id="search_here" class="mt-2 mb-2 form-control" placeholder="Type to search..."> </form> <section class="text-center mb-3"> <div id="box" class="row wow fadeIn"> {% for item in object_list %} <div class="col-lg-4 col-md-6 mb-3 outers"> <div class="card h-100"> <div class="view overlay"> <a href="{{item.get_absolute_url}}"> <img src="{{ item.image.url }}" class="card-img-top" alt=""> <div class="mask rgba-white-slight"></div> </a> </div> <div class="card-body text-center mirror-face"> <a href="{{item.get_absolute_url}}" class="grey-text"> <h4 class="card-title proj-title">{{ item.title|capfirst }}</h4> </a> </div> </div> </div> {% endfor %} </div> </section> </div> </div> </div> </main> Here is the script <script> const input = document.getElementById('search_here') input.addEventListener('keyup', (e) => { var inputs = e.target.value.toLowerCase(); //do lowercase //loop through outer div and hide it document.querySelectorAll('.outers').forEach(function(el) { el.style.display = 'none'; }); //loop through outer ->card-title document.querySelectorAll('.outers .card-title').forEach(function(el) { //compare if (el.textContent.toLowerCase().indexOf(inputs) > -1) { el.closest('.outers').style.display = "block"; //if match show that div } }) }) </script> My question: … -
gunicorn fails to start: ModuleNotFoundError: No module named 'django'
I am using Django 3.1 with gunicorn (latest version). I have installed everything correctly as per the instructions here However when I run the command gunicorn --bind 0.0.0.0 foo.bar.wsgi, I get the following error stack trace: me@YOURBOX:/opt/websites/demo_project$ gunicorn --bind 0.0.0.0 foo.bar.wsgi [2021-01-16 22:11:09 +0000] [2737] [INFO] Starting gunicorn 20.0.4 [2021-01-16 22:11:09 +0000] [2737] [INFO] Listening at: http://0.0.0.0:8000 (2737) [2021-01-16 22:11:09 +0000] [2737] [INFO] Using worker: sync [2021-01-16 22:11:09 +0000] [2740] [INFO] Booting worker with pid: 2740 [2021-01-16 22:11:09 +0000] [2740] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 144, in load_wsgi File "/usr/lib/python3/dist-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/lib/python3/dist-packages/gunicorn/util.py", line 383, in import_app mod = importlib.import_module(module) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/opt/websites/demo_project/foo/bar/wsgi.py", line 12, … -
reverse foreignkey modelform
models.py: class Team(models.Model): name = models.CharField(max_length=100, unique = True) class Member(models.Model): name = models.CharField(max_length=100, unique = True) team = models.ForeignKey(Team, on_delete = models.RESTRICTED, null = True) (One Member can be only part of one Team, but Team can have 0, one or any number of members) class MemberForm(forms.ModelForm): class Meta: model = Member Works as expected, but I want to make TeamForm: class TeamForm(forms.ModelForm): class Meta: model = Team fields = ['name', ' member__team'] but it doesn't work (there's no member__team field) I imagine form with multiplechoiceField - you can select from members which are connected with no team... I made own forms.Form: class TeamForm(forms.Form): name = forms.CharField(label = "Name", max_length=100, widget=forms.TextInput(), required = True) team_members = forms.MultipleChoiceField(choices=Member.objects.filter(team__isnull=True).values_list('id','name')) But has problem with updating: views.py: if form.is_valid(): team = Team.objects.create(name = form.cleaned_data['name']) #and now update all members in form.cleaned_data['team_members'] with team= team # but how? -
Pandas TypeError: cannot subtract DatetimeArray from ndarray
I ran into a really annoying error and I've been stuck for a while. I have two Pandas time series which look like this: 338 2019-09-06 339 2019-08-13 340 2019-07-26 341 2019-07-25 342 2019-07-10 Name: Target announced, Length: 343, dtype: datetime64[ns] and : 338 2018-08-16 339 2018-11-16 340 2017-06-02 341 2017-07-27 342 2019-03-28 Name: IPO date, Length: 343, dtype: datetime64[ns] All I'm trying to do is to subtract the second one from the first one. When I do this in Jupyter Notebook it works fine, but when I transfer the code to PyCharm I get the following error: TypeError: cannot subtract DatetimeArray from ndarray I tried to install the same pandas and numpy versions in my virtual environment as the ones I use in Jupyter Notebook. Nothing helps. Everything I do has to do with TimeSeries and not being able to manipulate those in PyCharm is killing my project. I'd appreciate your help! -
`op_name` parameter for `graphene_django`
The django graphene documentation shows a test example like this: class MyFancyTestCase(GraphQLTestCase): def test_some_query(self): response = self.query( ''' query { myModel { id name } } ''', op_name='myModel' ) content = json.loads(response.content) # This validates the status code and if you get errors self.assertResponseNoErrors(response) # Add some more asserts if you like ... They don't have any API documentation for what op_name is, and what we should set it as. I tried to set it to my query name, but get the error: [{'message': 'Unknown operation named "myQuery".'}] -
Force_authenticate superuser django rest unit testing
I have structured my api so that only the superuser can delete accounts. I am trying to force authenticate a superuser in my unit test but I am running into issues. Unit test: class PrivateUserApiTests(TestCase): """Test the users API (private)""" def setUp(self): self.user = create_user( email='tes111t@test.com', password='test123', name='name', ) self.user.is_superuser = True self.client = APIClient() self.client.force_authenticate(user=self.user) def test_user_successful_delete(self): """Test that user was succesfully deleted""" payload = {'email': 'test@test123.com', 'password': 'test123'} user = create_user(**payload) res = self.client.delete(reverse('user:delete_user', kwargs={'pk': user.id})) self.assertEqual(res.status_code, status.HTTP_204_NO_CONTENT) ERROR: Traceback (most recent call last): File "/app/user/tests/test_user_api.py", line 152, in test_user_successful_delete self.assertEqual(res.status_code, status.HTTP_204_NO_CONTENT) AssertionError: 403 != 204 Am I using the force_authenticate() method wrong? How can I create a user that is a superuser -
How to create service for django app with nssm on windows
nssm service to run django application. I have created nssm service to run my django app on windows machine but it doesn't work. Please suggest an alternative package or the right config to get the service running. Here is the command I used. Adding nssm to environment variable some_shell>setx PATH "%PATH%;C:\Users\app\nssm" /M Creating nssm service some_shell>nssm install myappservice Here I gave C:\Users\django_app\manage.py as path and; C:\Users\django_app as Startup directory I get "windows could not start the myappservice on local computer..." error whenever I try to start the service. -
Creating messaging (chatting) functions in Django
I created models for messaging between users of my project. My messaging models: class Chat(models.Model): id = models.CharField(_('id'), primary_key=True, default=hex_uuid, editable=False, max_length=32) chat_participants = models.ManyToManyField(User, blank=True) class Meta: db_table = 'chat' verbose_name_plural = 'chats' class Message(models.Model): id = models.CharField(_('id'), primary_key=True, default=hex_uuid, editable=False, max_length=32) chat = models.ForeignKey(Chat, on_delete=models.CASCADE) author = models.ForeignKey(User, on_delete=models.CASCADE) text = models.TextField(_('text'), max_length=1500, null=True, blank=True) send_datetime = models.DateTimeField(auto_now_add=True, blank=True) class Meta: db_table = 'message' verbose_name_plural = 'messages' class MessageRecipient(models.Model): id = models.CharField(_('id'), primary_key=True, default=hex_uuid, editable=False, max_length=32) message = models.ForeignKey(Message, on_delete=models.CASCADE) recipient = models.ForeignKey(User, on_delete=models.CASCADE) is_seen = models.BooleanField(_('is_seen'), default=False) class Meta: db_table = 'message_recipient' verbose_name_plural = 'message recipients' unique_together = ('message', 'recipient') How can I automatically align 'author' field in Message class (model) to the ID of user who writes a message? Now I need by myself choose the 'author' from the (not real) users that are in my database, but it is wrong, it has to be automatically selected depending on who writes the message. Or, let's, say who's account this message is being written from. In MessageRecipient class (model) I have to choose recipient myself, and I can choose not only from the participants of the particular chat group where the message has to be arrived, but … -
Creating Delete User Unit Test Django rest_framework
I'm struggling to figure how to get the id of the user I created using the create_user() function in my unit test. Unit test below: from django.test import TestCase from django.contrib.auth import get_user_model from django.urls import reverse from rest_framework.test import APIClient from rest_framework import status DELETE_URL = reverse('user:delete_user') class PrivateUserApiTests(TestCase): """Test the users API (private)""" def setUp(self): self.user = create_user( email='tes111t@test.com', password='test123', name='name' ) self.client = APIClient() self.client.force_authenticate(user=self.user) def test_user_successful_delete(self): """Test that user was succesfully deleted""" payload = {'email': 'test@test123.com', 'password': 'test123'} create_user(**payload) # Here is where I create the user I want to delete user = get_user_model().objects.get() res = self.client.delete(DELETE_URL) # I'm not sure how to pass the id of the user I just created. The way my url works is: (the id passed in is the user that is deleted) 0.0.0.0:8000/api/user/delete-user/id urls.py urlpatterns = [ path('create/', views.CreateUserView.as_view(), name='create'), path('token/', views.CreateTokenView.as_view(), name='token'), path('me/', views.ManageUserView.as_view(), name='me'), path('all_users/', views.RetrieveUsersView.as_view(), name='all_users'), path('delete-user/<int:pk>', views.DeleteUserAPI.as_view(), name='delete_user') ] When using the self.client.delete() How do i pass in the id? -
Is it a good idea to run django management command as windows service?
Following this answer you can register a python script as a windows service with NSSM. But are there any obvious downsides on registering a django management command as windows service this way? nssm.exe install ProjectService nssm.exe set ProjectService Application "c:\path\to\env\Sricpts\python.exe" nssm.exe set ProjectService AppParameters "c:\path\to\django_project\manage.py command" The command would parse the contents of some files as they are being created. -
How to stop page refresh on each task addition in my Django To-do app?
I am quite new to the web development world and have just built a Todo app using Django and hosted the app on Heroku. I have used Django ModelForm for adding tasks to my TaskModel. Now my problem is that each time I add a task, the whole page refreshes as the added task goes to the postgres database used by Heroku. It is not a very good user experience, as it is refreshing the page on each task addition and also it is taking time for reloading the page. What should I do to stop page refresh but still add the task to the database? Note: I have used authentication in my todo app so that the tasks can be accessed from any device, so I don't think storing my task merely in the browser cache will work. But I am open to any suggestions. -
python django variables from views.py to html show the code intead of the value
I'm trying to print my products from sqlite the problem is that the result in the browser is the code itself and not the value. views.py: from django.shortcuts import render from django.http import HttpResponse from .models import Product def index(request): products = Product.objects.all() return render(request, 'index.html', {'dict': products}) index.html: <ul> {% for prod in dict %} <li>{{ prod.name }}</li> {% endfor %} </ul> The result in the browser is: {% for prod in dict %} {{ prod.name }} {% endfor %} -
SOCKETS IN DJANGO
I've build an app in Django that sends socket messages to a external Desktop app. It works perfectly in local sending messages to a custom Ip and port address using the python library Websockets. Here's my code: import asyncio import websockets async def getstatus(ip,port): uri = f"ws://{ip}:{port}/" async with websockets.connect(uri) as websocket: await websocket.send(str(json.dumps({"Action":"status"}))) return await websocket.recv() Now i deployed it into a HEROKU server and sockets doesn't work. I also use django Channels wirh Redis and Daphne Anyone knows the best way to do this??? Thanks a lot :) -
Converting a function decorator to a Class Mixin django
I tried to convert a cutoms decorator from a function to a Class Mixin because I use CVB and I wanted to inherit from this Mixin to check for users status for some pages. I have this decorator which check whether the user is authenticated or not, if the user is authenticated and tries to access a page that has this decorator it will be redirected to the dashboard if is not then il will have the access to acces the page. I wrote this class as a class version of the decorator and if the user is logged in then it works ok but if it it's not and tries to acces that page it give me this error: ImproperlyConfigured at /auth/login/ UserLoginView is missing the permission_required attribute. Define UserLoginView.permission_required, or override UserLoginView.get_permission_required(). this is the decorator: def is_authenticated(view_func): def wrapper_func(request, *args, **kwargs): if request.user.is_authenticated: return redirect('dashboard') else: return view_func(request, *args, **kwargs) return wrapper_func class version: class IsAuthenticatedMixin(PermissionRequiredMixin): def dispatch(self, request, *args, **kwargs): if request.user.is_authenticated: return redirect('dashboard') return super().dispatch(request, *args, **kwargs) the views which inherits this mixin class IndexFormView(IsAuthenticatedMixin, CreateView): permission_required = 'view' template_name = 'home/index.html' form_class = NewsletterForm def post(self, request, *args, **kwargs): email = request.POST['email'] if Newsletter.objects.filter(email=email).exists(): … -
The included URLconf 'appName.urls' does not appear to have any patterns in it
Checking the documentation doesn't show any potential cause for the error. I have a django project with a number of apps (dir layout: ) settings.py (cryptoboard): ... # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] AUTH_USER_MODEL = "cryptousers.CryptoUser" # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'leads', 'rest_framework', 'frontend', 'knox', 'cryptousers', 'cryptocurrency', ] ... ROOT_URLCONF = 'cryptoboard.urls' urls.py (cryptoboard): from django.contrib import admin from django.urls import path, include urlpatterns = [ path('', include('frontend.urls')), path('', include('leads.urls')), path('', include('cryptousers.urls')), path('', include('cryptocurrency.urls')) # <== WORKS IF COMMENTED OUT ] urls.py (cryptocurrency): import sys from django.conf.urls import url from django.urls import path from . import views urlpatterns = [ path('get_currency_latest/', views.get_latest_currency, name='get_currency_latest'), # this used to work # url(r'^get_currency_on_date/(?P<date_day>\d{4}-\d{2}-\d{2})/$', # views.get_currency_on_date, name='get_currency_on_date'), # # Sample: # # http://127.0.0.1:8000/get_currency_between_dates/2020-11-24/2020-11-25 # url(r'^get_currency_between_dates/(?P<date_start_day>\d{4}-\d{2}-\d{2})/(?P<date_end_day>\d{4}-\d{2}-\d{2})$', # views.get_currency_between_dates, name='get_currency_between_dates') re_path(r'^get_currency_on_date/(?P<date_day>\d{4}-\d{2}-\d{2})/$', views.get_currency_on_date, name='get_currency_on_date'), re_path(r'^get_currency_between_dates/(?P<date_start_day>\d{4}-\d{2}-\d{2})/(?P<date_end_day>\d{4}-\d{2}-\d{2})$', views.get_currency_between_dates, name='get_currency_between_dates') ] The same error is thrown regardless whether the urls.py above is as it is or empty. views.py (cryptocurrency) from django.shortcuts import render import json from django.shortcuts import render from django.http import HttpResponseRedirect, HttpResponse, JsonResponse from django.shortcuts import get_object_or_404, render from django.urls import reverse from django.utils import timezone from django.utils.datetime_safe import datetime … -
Django form field using jQuery
I want to pass the screen size of the client to the django view.py. Right now I am trying to pass it through a form from jQuery, but I keep getting 'None'. What am I doing wrong? Or is there any other way I could get the screen size? My js: <script type="text/javascript"> document.getElementById('{{ form.width.id_for_label }}').value = screen.width; document.getElementById('{{ form.height.id_for_label }}').value = screen.height; </script> HTML: <form id="myform" method="POST"> {% csrf_token %} {{ form.myfield }} <div class='width'> {{ form.width }} </div> <div class='height'> {{ form.height }} </div> <input id="submit" type="submit" style="display: none"/> </form> form.py class MymodelForm(forms.ModelForm): class Meta: model = Mymodel fields = ['myfield', 'width', 'height',] widgets = { 'width': forms.HiddenInput, 'height': forms.HiddenInput } -
How to make my webapp only accessible only on a private network/place
I'm building a webapp, actually it's ready to deploy but I need it to be restricted. like I want that I'm the only one and my client have access to that web application. That my client can't access it on other networks or IP address. only in his home/office. I already set CORS on my webapp but I don't know what IP to set. Is there a specific IP address to set on my CORS? because afaik, ISP IP addresses changes from time to time. How can I do it? thanks! -
How To Add $2 To a User Account Balance Immediately A Post is Viewed on a Django Blog
I want Users on my website to be able to Earn from my website immediately they View a post on my blog website but am finding it difficult to add that feauture to my apps. I want an amount to be added to my website immediately a post is been viewed on clicked on and i have an IP function because i want the action to be once(the amount should be added once). Please take a good look at my models.py for the post class Post(models.Model): title = models.CharField(max_length=160, help_text='Maximum 160 Title characters.') summary = models.TextField(max_length=400, help_text='Maximum text of 400 characters can be inserteed here alone' ) subtitle = models.CharField(max_length=250, blank=True) introduction = models.TextField(max_length=500, blank=True,) content = RichTextUploadingField(blank=True, null=True) This is balance.py class Balance(models.Model): user = models.ForeignKey(User) date = models.DateTimeField(default=timezone.now) balance = models.IntegerField(default = 0) In my models.py i also have a code for my view #this is used in ordering view count in django views class PostView(models.Model): post = models.ForeignKey('Post', on_delete=models.CASCADE) date = models.DateTimeField(auto_now=False, auto_now_add=True) ip = models.GenericIPAddressField(null=False, blank=False) class Meta: ordering = ['-date'] This is the property that counts my views @property def view_count(self): return PostView.objects.filter(post=self).count() Question Summary I Now want $2 to be added to this default … -
Why is this not JSON?
"{"ops": [{"insert": "Ajax story content."}]}" I am trying to send json from a django view to my template and play with it with JS. Why can I not parse this? When I run JSON.parse() I am given an error that says VM817:1 Uncaught SyntaxError: Unexpected token in JSON at position 40 at JSON.parse () at :1:6 I've run it through JSONLint and it gives me an error Error: Parse error on line 1: "{"ops ": [{"insert ": Expecting 'EOF', '}', ':', ',', ']', got 'undefined' To me, it looks like valid JSON. What's up? -
Why my model's __str__ method return a Queryset only when testing?
I have a simple model that have a __str__ method that returns a string as expected, but when testing the __str__ method it returns a Queryset and the test fails. Why this happens? I am already calling the method using str() instead of __str__() as this other post suggested class Author(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) profile_picture = models.ImageField() def __str__(self): return self.user.username In the shell it returns the username from the corresponding User object as a string, as expected: author = Author.objects.get(pk=1) str(author) 'edumats' But when testing the __str__ method of the model, the test fails, as the method returns a Queryset: The test: def test_author_methods(self): author1 = Author.objects.filter(user__username='Test User') self.assertEqual(str(author1), 'Test User') The error from the test: FAIL: test_author_methods (posts.test_models.PostTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/edumats/Projects/blog/blog/posts/test_models.py", line 37, in test_author_methods self.assertEqual(str(author1), 'Test User') AssertionError: '<QuerySet [<Author: Test User>]>' != 'Test User' - <QuerySet [<Author: Test User>]> + Test User -
Django ORM - Can I create a new object with a foreign key using a different column other than ID?
I checked around a fair bit and could not find any examples of what I am looking for so i am not sure if it is possible at all. I have a model with a foreign key. I want to create a new object in that model but i don't have the ID but I do have the field "username" value. I should also add that this is a foreign key relationship to another foreign key WeekdayAssignment Model example: class WeekdayAssignment(models.Model): start_date = models.DateField(auto_now=False, auto_now_add=False) end_date = models.DateField(auto_now=False, auto_now_add=False) triage = models.ForeignKey(TeamMember, on_delete=models.PROTECT, related_name="triagers") ... TeamMember Model Example: class TeamMember(models.Model): member = models.ForeignKey(User, on_delete=models.PROTECT, verbose_name='Member Name') ... User Model Example: class User(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) username = models.CharField(max_length=50) What I would like to do is create a new object using the members username from the Foreign key's not the ID like this: WeekdayAssignment.objects.create(start_date='2021-01-13', end_date='2021-01-20', triage__member__username='jac') However, if i do this i get the error WeekdayAssignment() got an unexpected keyword argument 'triage__member__username' and same thing if i drop __username If drop the __member__username from the field like this: WeekdayAssignment.objects.create(start_date='2021-01-13', end_date='2021-01-20', triage='jac') i get ValueError: Cannot assign "'jac'": "WeekdayAssignment.triage" must be a "TeamMember" instance. which is totally expected as … -
hello you can explain to me how to make a one to one communication
hello you can explain to me how to make a one to one communication system example of facebook with chat in friend or linkedin -
calling a function on button click in Django
I have multiple buttons on an HTML page. When a user clicks them, I want to call respective functions and manipulate the database. I don't know if Django-forms are the right thing to use here. If yes, should I use different forms for different buttons? -
How to get the value (not the key) of a TypedChoiceField in django form?
I have a django form with some TypedChoiceFields like this one : Q1 = forms.TypedChoiceField(coerce=choice_parser, choices = Q1_CHOICES, label=Q1_TITLE, initial='', widget=forms.Select(), required=True) Here is my Q1_CHOICES : Q1_CHOICES = ( ("W", "Woman"), ("M", "Man") ) My problem is in my view when I call this form when I want to get the answer of the user I only succeeded to get the keys (W or M) but never the values "Man" or "Woman". I used form.cleaned_data["Q1"] to get the answers. I know I could differiantiate them with "W" and "M" but for the other questions it is a big deal Thanks for your help -
RuntimeError: There is no current event loop in thread 'ThreadPoolExecutor-0_0'
Trying to call app.add_chat_members from Pyrogram in a Django view but can't seem to instantiate the client. Steps to Reproduce views.py ... from pyrogram import Client def add_users_to_chat(chat_id, user_ids, forward_limit = 0): user_bot = Client("session_name", api_key=API_KEY, api_hash=API_HASH) with user_bot: return user_bot.add_chat_members(chat_id, user_ids, forward_limit) def add_user_to_chat_view(request): ... add_users_to_chat(request.kwargs.get('chat_id'),request.user.telegram_id) I am running django in asgi with uvicorn uvicorn config.asgi:application --host 127.0.0.1 --reload. I have tried using async: async def add_users_to_chat(chat_id, user_ids, forward_limit = 0): user_bot = Client("session_name") async with user_bot: return await user_bot.add_chat_members(chat_id, user_ids, forward_limit) I have also tried async_to_sync from asgiref.sync import async_to_sync @async_to_sync async def add_users_to_chat(chat_id, user_ids, forward_limit = 0): user_bot = Client("session_name") async with user_bot: return await user_bot.add_chat_members(chat_id, user_ids, forward_limit) Traceback File "/utils/telegram.py", line 6, in <module> from pyrogram import Client File "/.local/lib/python3.8/site-packages/pyrogram/__init__.py", line 41, in <module> from .client import Client File "/.local/lib/python3.8/site-packages/pyrogram/client.py", line 44, in <module> from pyrogram.methods import Methods File "/.local/lib/python3.8/site-packages/pyrogram/methods/__init__.py", line 25, in <module> from .messages import Messages File "/.local/lib/python3.8/site-packages/pyrogram/methods/messages/__init__.py", line 23, in <module> from .edit_inline_media import EditInlineMedia File "/.local/lib/python3.8/site-packages/pyrogram/methods/messages/edit_inline_media.py", line 25, in <module> from .inline_session import get_session File "/.local/lib/python3.8/site-packages/pyrogram/methods/messages/inline_session.py", line 27, in <module> lock = Lock() File "/usr/lib/python3.8/asyncio/locks.py", line 164, in __init__ self._loop = events.get_event_loop() File "/usr/lib/python3.8/asyncio/events.py", line 639, in get_event_loop raise RuntimeError('There is no …