Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django calender tools missing (not shown) when loaded via ajax call
I need to have a model change_form that will call a 'child form' when a change is detected in it's select field. This is from admin.py class SuratAdmin(admin.ModelAdmin): change_form_template = 'surat_form_htmx.html' admin.site.register(Surat, SuratAdmin) and this is template 'surat_form_htmx.html' {% extends "admin/change_form.html" %} {% block after_field_sets %} <!--- add htmx --> {% load static %} <script src="https://unpkg.com/htmx.org@1.6.0"></script> <script src="{% url 'js-catlog' %}"></script> <!--script src="{% static '/admin/js/core.js' %}"></script--> <!--link rel="stylesheet" href="{% static 'admin/css/base.css' %}"--> <link rel="stylesheet" href="{% static 'admin/css/widgets.css' %}"> <script src="{% static '/admin/js/calendar.js' %}"></script> <script src="{% static '/admin/js/admin/DateTimeShortcuts.js' %}"></script> <style> /* DivTable.com */ .divTable{ display: table; width: 100%; } .divTableRow { display: table-row; } .divTableCell, .divTableHead { border: 1px solid #999999; display: table-cell; padding: 3px 10px; } .divTableHeading { display: table-header-group; font-weight: bold; } .divTableFoot { background-color: #EEE; display: table-footer-group; font-weight: bold; } .divTableBody { display: table-row-group; } </style> <!-- dummy hidden input needed for js --> <input id="loaded_object" type="hidden" size="20" readonly {% if not add %} value="{{ original.pk }}" {% endif %}> <p> <!-- eof ndummy hidden input needed for js --> <div id="htmx_get_result"> </div> <!-- evt listener id_template change--> <script> const selectElement = document.querySelector("#id_template"); const url_base = "/mst/htmx/child_form"; selectElement.addEventListener('change', (event) => { var template_id = document.getElementById("id_template").value ; var surat_id … -
How to use two different ports for frontend and backend with the same domain name
I am very new to django and nginx and trying to host my application using nginx as server. I am able to setup the frontend with domain name and 80 as the port but i am unable to setup backend with the domain name serving on port 8000. But when i use the IP address it seems to work fine but not with the domain name. I have been trying since two days and nothing seems to work . Any help would be much appreciated. Frontend Config server{ listen 80; listen [::]:80; listen 443 ssl; include snippets/snakeoil.conf; server_name example.com; location = /favicon.ico { access_log off; log_not_found off; } location / { # reverse proxy for next server proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_headers_hash_max_size 512; proxy_headers_hash_bucket_size 128; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } Config For Backend server { listen 8000; server_name example.com; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /root/backend/lithexBackEnd; } location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; } } -
DJango admin is serving static files from /media instead of /static
When I run my django app in production mode (ie without DEBUG), my admin site tries to serve static files from "/media" instead of "/static", which causes 404s This is what it's trying to serve. GET https://<domain>/media/admin/css/base.css But if I manually type in https://<domain>/static/admin/css/base.css It serves the static file correctly. So my "collectstatic" is working fine, but somehow the admin site is trying to serve from /media. I don't understand what settings would cause this. Everything I search for related to this is from before django 1.4 where there was a specific setting for admin media url. Other than that I don't see anyone else having this issue. I'm loosely following https://github.com/cookiecutter/cookiecutter-django and I'm on the latest version of django right now. I'm not sure what else to look for -
Is it possible to filter form field according to another field?
I want to choose only a car_model related to the selected vehicle_brand. Is it possible to do in django? Or need to use JS? Code example below: vehicle_brand = forms.ModelChoiceField(label='Brand', queryset=VehicleBrand.objects.all(), widget=forms.Select(attrs={'class': 'select form-select'})) car_model = forms.ModelChoiceField(label='Model', queryset=CarModel.objects.all(), widget=forms.Select(attrs={'class': 'select form-select'})) -
ModuleNotFoundError: No module named 'caching.base'
I am Adam Jon. Now, I am learning Django Framework. Yesterday I got a sample project from my boss. So Today I installed Django framework and ruined. But in installation, I discover mistake like ModuleNotFoundError: No module named 'caching.base'. But I couldn't find solve the way. So, I wish that you help me... Please Thank you I I researched Python tutorial and W3.school. -
cannot connect to the backend server running port 8000 using nginx, django and docker
I've spent two days trying to figure this out. I'm running docker containers that host a django+react website from a docker compose file. I can access the website on port 80 (IP: http://52.90.163.11:80), but I can't seem to access the django admin panel on port 8000 (IP should be http://52.90.163.11:8000 but it doesn't work). I'm using AWS to host my website. I simply want the backend container accessible via port 8000. I have two docker compose files. One I build on my local machine. After building on local machine, I push the images to dockerhub. The second dockerfile resides on the AWS server, and uses images from the first build. Here is my docker-compose file on my local machine to create the images. version: '3' services: backend: build: context: ./backend/src command: gunicorn djreact.wsgi --bind 0.0.0.0:8000 ports: - 8000:8000 depends_on: - pgdb pgdb: image: postgres environment: POSTGRES_HOST_AUTH_METHOD: trust volumes: - pgdata:/var/lib/postgresql/data frontend: build: context: ./frontend/gui volumes: - react_build:/frontend/build nginx: image: nginx:latest ports: - 80:8080 volumes: - ./nginx/nginx_setup.conf:/etc/nginx/conf.d/default.conf:ro - react_build:/var/www/react depends_on: - backend - frontend volumes: react_build: pgdata: Here is my dockerfile on my AWS server. It uses the images created on my local machine. version: '3' services: backend: image: ansariuminhaj/mynacode:mynacode-backend command: … -
OSError: [Errno 99] Address not available - sending e-mail from django app with gmail smtp
I am trying to send the email using smtp with django application. It is working on my local environment, but not working on production environment. File "/usr/local/lib/python3.9/site-packages/django/core/mail/message.py", line 298, in send return self.get_connection(fail_silently).send_messages([self]) File "/usr/local/lib/python3.9/site-packages/django/core/mail/backends/smtp.py", line 124, in send_messages new_conn_created = self.open() File "/usr/local/lib/python3.9/site-packages/django/core/mail/backends/smtp.py", line 80, in open self.connection = self.connection_class( File "/usr/local/lib/python3.9/smtplib.py", line 255, in __init__ (code, msg) = self.connect(host, port) File "/usr/local/lib/python3.9/smtplib.py", line 341, in connect self.sock = self._get_socket(host, port, self.timeout) File "/usr/local/lib/python3.9/smtplib.py", line 312, in _get_socket return socket.create_connection((host, port), timeout, File "/usr/local/lib/python3.9/socket.py", line 844, in create_connection raise err File "/usr/local/lib/python3.9/socket.py", line 832, in create_connection sock.connect(sa) OSError: [Errno 99] Address not available My settings files has credentials as below: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_USE_TLS = True EMAIL_PORT = 587 DEFAULT_FROM_EMAIL = '********' EMAIL_HOST_USER = '*******' EMAIL_HOST_PASSWORD = '******' Tried with different credentials, but getting the same error. I tried to print the email credentials from django setting and it is correct. -
We can swap the order of the answers every time a quiz game is started
ich möchte, dass die antworten ({{q.op1}},{{q.op2}},{{q.op3}},{{q.op4}}) nich immer an der selben stelle sind sondern gemischt werden. Zum Beispiel einmal : ({{q.op4}},{{q.op3}},{{q.op1}},{{q.op2}}) und der nächsten Frage wieder anders. Wie kann ich das machen? I want the answers ({{q.op1}},{{q.op2}},{{q.op3}},{{q.op4}}) are not always in the same place but are mixed. For example once : ({{q.op4}},{{q.op3}},{{q.op1}},{{q.op2}}) and the next question again different. How can I do that? html {% for q in questions %} {% if q.kategorie == category and q.flaag == True %} {% if questions.has_next %} <br/> <div class="flex-container"> <div class="container1"> <div class="game_options_top"> <div class="option"> <p><button class="option_btn" name="next" value="{{q.op1}}" formaction="{% url 'quiz' %}?page={{ questions.next_page_number }} " type="submit">A: <span id="option_span">{{q.op1}}</span></button></p> </div> <div class="option"> <p><button class="option_btn" name="next" value="{{q.op2}}" formaction="{% url 'quiz' %}?page={{ questions.next_page_number }} " type="submit">B: <span id="option_span">{{q.op2}}</span></button></p> </div> </div> <div class="game_question"> <h1 class="display_question">{{q.question}}</h1> </div> <div class="game_options_bottom"> <div class="option"> <p><button class="option_btn" name="next" value="{{q.op3}}" formaction="{% url 'quiz' %}?page={{ questions.next_page_number }} " type="submit">C: <span id="option_span">{{q.op3}}</span></button></p> </div> <div class="option"> <p><button class="option_btn" name="next" value="{{q.op4}}" formaction="{% url 'quiz' %}?page={{ questions.next_page_number }} " type="submit">D: <span id="option_span">{{q.op4}}</span></button></p> </div> </div> </div> models.py question = models.CharField(max_length=200, null=True,) op1 = models.CharField(max_length=200, null=True) op2 = models.CharField(max_length=200, null=True) op3 = models.CharField(max_length=200, null=True) op4 = models.CharField(max_length=200, null=True) ans = models.CharField(max_length=200, null=True) flaag = models.BooleanField('Aprroved', default=False) views.py if … -
Django ORM not releasing memory even when garbage collector is called explicitly
It seems like ORM objects are not releasing memory - please refer code below. I tried various approaches like, but nothing helped: Manually call gc.collect() Manually disable and enable gc Use queryset Use iterators Use lists In actual case, I query about 60K articles, and would like the memory to be released as soon as I am out of the function. The memory is not released even after days. So, I guess its not an issue with garbage collector. Please suggest. import gc import os import django import psutil from api.models import Article os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') django.setup() def fetch_articles(): # gc.disable() # no help articles = Article.objects.order_by('-id')[:10].iterator() # articles = Article.objects.order_by('-id')[:10] # similar memory consumption # articles = list(Article.objects.order_by('-id')[:10]) # similar memory consumption for article in articles: pass del article del articles # gc.enable() # no help gc.collect() # gc.collect() # no help process = psutil.Process(os.getpid()) print(process.memory_info().rss / (1024 * 1024), "MB") # 41.203125 MB fetch_articles() # gc.collect() # no help print(process.memory_info().rss / (1024 * 1024), "MB") # 44.21875 MB -
Looks like your app is listening on 127.0.0.1. You may need to listen on 0.0.0.0 instead. Railway Deployment Django Sqlite3 db
Can anyone help me with this? How to change port from localhost to 0.0.0.0. -
How to add "Edit Function" in django
I need to add an edit button to my django app but it only redirects me to the homepage and no edit is saved. this is my views.py code, i think that's where the issue is coming from def editPhoto (request, pk): photo = Photo.objects.get(id=pk) categories = Category.objects.all() if request.method == 'POST': description = request.FILES.get('description') photo.save() return redirect ('/') context = {'categories': categories, 'photo': photo} return render(request, 'photos/edit.html', context)` models.py class Category(models.Model): name = models.CharField(max_length=100, null=False, blank=False) def __str__(self): return self.name class Photo(models.Model): category = models.ForeignKey( Category, on_delete=models.SET_NULL, null=True, blank=True) image = models.ImageField(null=False, blank=False) description = models.TextField() def __str__(self): return self.description` edit.html <div class="container"> <div class="row justify-content-center"> <div class="col"> <a href="{% url 'gallery' %}" class="btn btn-dark my-3">Go Back</a> <form method='POST' action="" enctype="multipart/form-data"> {% csrf_token %} <div style="height: 90vh;"> <img style="max-width: 100%; max-height: 100%;" src="{{photo.image.url}}" class="center" > </div> <div> <input required name="description" class="input" value="{{photo.description}}" type="text" size="60"></input> </div> <div class="center"> <button type="submit" class="btn btn-primary m-3; center">Update</button> </div> </div> </div> </div>` -
Why isn't the filename property getting set on my FileField instance?
This code is creating and updating objects with empty filename attributes: def _database_path(project, filename): return f'{project.id}/{filename}' database = models.FileField(upload_to=_database_path, storage=FileSystemStorage(location=/tmp/project_bucket)) The files are saved and retrieved without a problem, but the filename property is blank for this field. Why isn't this working (and what can I do to fix it)? -
django channels: notifications of message not working properly
I am writing a django module that handles real time message paired with notification. So far: a conversation can only take place between no more than 2 users. a notification should be sent after each message. I am currently working on getting the notifications to show up and the issue is that the notification gets rendered in the sender profile page and not in the recipient profile. I cant see where my error is Here is what I have done: consumers.py import json from channels.generic.websocket import AsyncWebsocketConsumer from channels.db import database_sync_to_async from .models import Chat, ChatRoom from accounts.models import User from asgiref.sync import sync_to_async from django.contrib.auth import get_user_model from django.shortcuts import get_object_or_404 from asgiref.sync import async_to_sync class ChatConsumer(AsyncWebsocketConsumer): async def connect(self): self.room_id = self.scope['url_route']['kwargs']['room_id'] self.room_group_name = 'chat_%s' % self.room_id await self.channel_layer.group_add( self.room_group_name, self.channel_name ) await self.accept() async def disconnect(self, close_code): await self.channel_layer.group_discard( self.room_group_name, self.channel_name ) async def receive(self, text_data): text_data_json = json.loads(text_data) message = text_data_json['message'] recipient = text_data_json['recipient'] self.user_id = self.scope['user'].id # Find room object room = await database_sync_to_async(ChatRoom.objects.get)(pk=self.room_id) print('ok1') # Create new chat object chat = Chat( content=message, sender=self.scope['user'], room=room, ) print('ok2') await database_sync_to_async(chat.save)() print("ok3") # get the recipient user recipient_user = await database_sync_to_async(User.objects.get)(id=recipient) print("ok4") await sync_to_async(chat.recipient.add)(recipient_user.id) print("ok5") await … -
django.db.utils.ProgrammingError: relation "pdf_conversion" does not exist
I am trying to add in a conversion model that is referenced in the fileurl model that calls my customuser model. But for some reason, I get the following error when loading the admin panel. Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Internal Server Error: /admin/pdf/conversion/ Traceback (most recent call last): File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedTable: relation "pdf_conversion" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "pdf_conversion" ^ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/contrib/admin/options.py", line 616, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/contrib/admin/sites.py", line 232, in inner return view(request, *args, **kwargs) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper return bound_method(*args, **kwargs) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view response = view_func(request, *args, **kwargs) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1697, in changelist_view cl = self.get_changelist_instance(request) File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/contrib/admin/options.py", line 736, in get_changelist_instance return ChangeList( File "/home/john/PycharmProjects/pdf/venv/lib/python3.8/site-packages/django/contrib/admin/views/main.py", line 100, in __init__ self.get_results(request) File … -
Django: Call a view function into another view function
my todo list has two different functions add_task & view_task I don't want to create one single function I want that view task will call add task # Add Task Page def add_task(request): submitted = False if request.method == "POST": form = TodoForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/add_task?submitted=True') else: form = TodoForm if 'submitted' in request.GET: submitted = True return render(request, "core/add_task.html", {'form':form, 'submitted': submitted}) # Task List Page def view_task(request): task_list = Todo.objects.all() #This is the part of view_task function where I have been trying to call add_task function # If you see a few lines below, I am calling already form, return render(request, "core/view_task.html", { 'task_list': task_list, #'form':form, }) -
Define multiple templates for a block
I am moving a site over to wagtail and decided to use the codered extensions. The library comes with a image-gallery content-block. I want to use this but define a few templates that you can choose from in the admin ui. Normally you define a template in the meta section but I noticed there is a dropdown in the admin ui for template. How do I add a template to that dropdown? Link to the content block I want to change I am interested in adding a html template and not inheriting from the content-block to change behaviour. (Unless inheriting is the only way to add a template to the dropdown) -
django NoReverseMatch not a valid view function or pattern name
I am having problems with an old project that was running on a deprecated django version. I updated django to 4.1.5 and made a few edits to the urls.py files that they were using python from django.conf.urls. I changed this to use re_path but now am running into an issue I have not been able to resolve. The server starts up okay however when I try to access any of the pages, I get the following Error: Error: NoReverseMatch at /control/ Reverse for 'control.views.set_notes' not found. 'control.views.set_notes' is not a valid view function or pattern name. Looking at the Trace here is where it looks like the error is happening from url line below: $.ajax({ url: "{% url 'control.views.set_notes' %}", type: "POST", data: { 'csrfmiddlewaretoken': '{{ csrf_token }}', 'notes' : notes }, error: function (error) { alert("error setting notes to " + notes); }, success: function (response) { } I have my root urls.py setup as follows: from django.urls import include, re_path urlpatterns = ( re_path(r'^control/', include('control.urls')), re_path(r'^profiles/', include('profiles.urls')), re_path(r'^roasts/', include('roasts.urls')), ) My other control.urls.py setup is as follows: from django.urls import re_path import control.views urlpatterns = ( re_path(r'^$', control.views.index), re_path(r'^get_state/$', control.views.get_state), re_path(r'^cancel_profile/$',control.views.cancel_profile), re_path(r'^get_profile/$', control.views.get_profile), re_path(r'^set_temp/$', control.views.set_temp), re_path(r'^set_notes/$', control.views.set_notes), re_path(r'^add_marker/$', … -
The Payment could not be created because the data didn't validate
I get the following error: The Payment could not be created because the data didn't validate. #view def home(request): customer = Customer.objects.all().filter(user=request.user) payments = Payment.objects.all().filter(user=request.user) if request.method == "POST": form = PaymentForm(request.POST) if form.is_valid: fs = form.save(commit=False) fs.user = request.user fs.save() messages.add_message(request, messages.INFO, 'ثبت با موفقیت انجام شد') else: messages.add_message(request, messages.WARNING, 'خطا در ثبت') else: form = PaymentForm() context = { 'payments': payments, 'customer': customer, 'form': form, } return render(request, 'payment/index.html', context) #model class Payment(models.Model): number = models.IntegerField(verbose_name='شماره چک', unique=True) price = models.IntegerField(verbose_name='مبلغ چک') date = jDateField() pardakht = models.ForeignKey(Customer, on_delete=models.CASCADE, verbose_name='دریافت از') bank = models.IntegerField(choices=bank, verbose_name='بانک') description = models.TextField(verbose_name='توضیحات', null=True) status = models.BooleanField(default='0') user = models.ForeignKey(User, on_delete=models.CASCADE, null=True) created_at = models.DateTimeField(auto_now_add=True, null=True) def __str__(self): return f'{self.number}' #forms from jalali_date.fields import JalaliDateField, SplitJalaliDateTimeField from jalali_date.widgets import AdminJalaliDateWidget, AdminSplitJalaliDateTime from .models import Payment class PaymentForm(forms.ModelForm): class Meta: model = Payment fields = ['number', 'price', 'date', 'pardakht', 'bank', 'description'] number = forms.IntegerField(widget=forms.TextInput(attrs={'class': 'form-control'}), label='شماره چک') price = forms.IntegerField(widget=forms.TextInput(attrs={'class': 'form-control'}), label='مبلغ چک') pardakht = forms.ChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), label='مشتری') bank = forms.ChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), choices=bank, label='بانک') description = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}), label='توضیحات') def __init__(self, *args, **kwargs): super(PaymentForm, self).__init__(*args, **kwargs) self.fields['date'] = JalaliDateField(label=('تاریخ چک'), widget=AdminJalaliDateWidget) index.html <h4 class="text-center alert alert-info"> ثبت چک جدید </h4> <form method="post" action="#"> {% … -
Python Openpyxl library cannot deal with automatic row height
I'm currently using Openpyxl in a Django project to create an excel report. I'm starting from a blank excel model in which column C has text wrap enabled. Infact when I open the model and populate manually a cell I correctly get this But when I run this trial code wb = openpyxl.load_workbook(fileExcel) sh = wb["Rapportini"] sh["C3"]="very very very very very very very very very very long row" wb.save(fileExcel) this is the result I know openpyxl (strangely) cannot set row autoheight. I also tried to set wrap_text = True in the cell, but no way... any ideas ? -
Django error: Cannot assign "''": "" must be a "" instance
I am getting this error when adding a pair. Cannot assign "'1'": "Pair.exchange" must be a "Exchange" instance. models.py: class Exchange(models.Model): name = models.CharField(max_length=25) def __str__(self) -> str: return f'{self.name}' class Pair(models.Model): symbol = models.CharField(max_length=20) ask = models.FloatField() bid = models.FloatField() exchange = models.ForeignKey(Exchange, on_delete=models.PROTECT) created = models.DateTimeField() def __str__(self) -> str: return f'ID: {self.id} Symbol: {self.symbol} Ask: {self.ask} Bid: {self.bid} Exchange: {self.exchange}' views.py: def show_pair(request): pairs = Pair.objects.all() br = [str(pair) + '<br>' for pair in pairs] return HttpResponse(br) def add_pair(request, symbol, ask, bid, exchange): pair = Pair.objects.create(symbol=symbol, ask=ask, bid=bid, exchange=exchange) return HttpResponsePermanentRedirect('/pair/') urls.py: path('pair/add/<symbol>/<ask>/<bid>/<exchange>/', views.add_pair) I'm trying to add pairs via a link, but I get this error, what could be the problem? -
How to limit the number of fetched children in django-treenode
I have a comment Model, where a comment can be a root item or under another comment. I'm using REST API to get the full tree. Is it possible to limit its depth, so for example It will stop after 3 nodes from each root comment. I want to add a "more" feature instead of show the whole tree at once. ` class CommentSerializer(serializers.ModelSerializer): leaf_nodes = serializers.SerializerMethodField() class Meta: model = Comment fields = [ 'id', 'body', "leaf_nodes" ] def get_leaf_nodes(self, obj): return CommentSerializer(obj.get_children(), many=True).data ` I tried looking at the documentation on GitHub but didn't find a solution. -
I have problem using google OAuth2 with django: GSI_LOGGER]: The given origin is not allowed for the given client ID
I have an issue with @react-oauth/google npm package. When I using react app on port 3000 and backend django on port 8000 every thing work's, but after I build react app and using port 8000, I try to log in via google, I get that Erros: Failed to load resource: the server responded with a status of 400 m=credential_button_library:45 [GSI_LOGGER]: The given origin is not allowed for the given client ID. I did double check on 'Authorised JavaScript origins' and 'Authorised redirect URIs' (image attached) but the giving origin are allowed, so whats can be the problem? I read about similar problems here on the site and also tried CHAT GPT but nothing helped. This is my configurations: CORS_ALLOWED_ORIGINS = [ "http://localhost:8000", "http://localhost:3000", "http://127.0.0.1:3000", "http://127.0.0.1:8000" ] class GoogleLogin(SocialLoginView): adapter_class = GoogleOAuth2Adapter callback_url = ['http://localhost:8000', 'http://localhost:3000', 'http://127.0.0.1:8000', 'http://localhost:8000/accounts/google/login/callback/'] # ! client_class = OAuth2Client -
Installed Django using pipenv on Mac (Zsh). Command not found: django..?
Installed django inside a file in Desktop using pipenv., it created pipfile and pipfile.lock without any issues later when trying to start project using 'djang0 -admin startproject' it outputs Zsh: command not found: django. Tried python3 -m django startproject forum and it worked fine., untill later i tried creating superuser using the same method and it outputs the same result. why it didn't work in the first and worked fine with the second command.? Is there any resource you can point where i can understand the shells and paths better..? What's the solution for this..? Sorry, i am new to Coding and these issues taking up a lot of my productive time..Trying to understand the issue better and prevent this from happening in future rather than fixing it temporarily. Thanks in advance I have tried installing the latest version of python3 Uninstalling and installing pipenv, django using pip3 pipenv graph shows django 4.10 was installed I couldn't locate the bin folder or define path as stated on some blogs -
Rollup.js Typescript React Npm Package Error: Cannot find module './tslib.es6-eaa548e7.js'
I have created a npm package using typescript react and rollup.js. I have link it to the project using yalc (similar to npm link) and getting the following error: Server Error Error: Cannot find module './tslib.es6-eaa548e7.js' Require stack: - /Users/paul/Projects/test-project/.next/server/pages/index.js Package structure: - dist/ - ContactForm7.d.ts - ContactForm7.js - index.d.ts - tslib.es6-eaa548e7.js - Wordpress.d.ts - Wordpress.js - src/ - package.json - rollups.config.js - tsconfig.json pages/index.tsx is importing the package with: import { getPage } from 'package-wordpress/dist/Wordpress'; This is the starting contents of dist/Wordpress.js which looks to be initiating the error: 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib_es6 = require('./tslib.es6-eaa548e7.js'); // this is where error occurs var axios = require('axios'); var cacheData = require('memory-cache'); rollup.config.js: import typescript from '@rollup/plugin-typescript'; import replace from 'rollup-plugin-replace'; import commonjs from '@rollup/plugin-commonjs'; export default { input: { Wordpress: 'src/Wordpress.tsx', ContactForm7: 'src/ContactForm7.tsx' }, output: { dir: 'dist', format: 'cjs', exports: 'named', }, plugins: [ typescript({ tsconfig: 'tsconfig.json' }), replace({ 'process.env.MY_VARIABLE': JSON.stringify(process.env.MY_VARIABLE) }), commonjs() ], external: ['react'], }; tsconfig.json: { "compilerOptions": { "target": "es5", "jsx": "react", "module": "esnext", "lib": ["esnext"], "strict": true, "esModuleInterop": true, "declaration": true, "outDir": "dist", "importHelpers": true }, "include": [ "src", "src/index.tsx" ] } -
How to integrate Cardpointe payment gateway in django
How to integrate Cardpointe payment gateway in Django. I got stuck with it. I dont know how to do it and I am not getting any example on google.