Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django TextField default value
In one of my tables I have a field game_fen_when_leave = models.TextField(). But it gives me an error "You are trying to add a non-nullable field 'game_fen_when_leave' to game without a default; we can't do that (the database needs something to populate existing rows)". Is it necessary for this field to have a default value? I saw an example without having a default. -
Django Oauth Toolkit customize validator
I swapped AccessToken model with my one, so it has relation to some Project model: class AccessToken(oauth2_models.AbstractAccessToken): """ Extend the AccessToken model with relation to projects. """ class Meta(oauth2_models.AbstractAccessToken.Meta): swappable = 'OAUTH2_PROVIDER_ACCESS_TOKEN_MODEL' project = models.ManyToManyField( Project, null=True, blank=True, related_name='project' ) Lets assume I get some incoming request which is executing some actions on some any objects related to this Project model: DELETE { "market": {"project_id": 2, "name": "EN"} } Authorization Bearer XXXX Now I`d like to check if the token of this incoming request has permissions to "deal" with this Project with id 2. I assume I need some custom validator MyValidator (some which are used in annotation @protected_resource(validator_cls=MyValidator)), but I cannot find any examples for that. And even not sure if it`s a valid/good approach at all maybe I should dig in another direction. -
how to compare two fields of different models in Django query-set?
Want to compare(if they are same or not) 'map_id' of 'map' model with 'uni_id' of 'Uni' model, return if they are same. Note: models map and Uni are also in different databases. Below are the two models: class map(models.Model): job_id = models.AutoField(db_column='job_id', primary_key=True) company = models.CharField(max_length=255, blank=True, null=True) map_id = models.CharField(db_column='Map_ID', max_length=255, blank=True, null=True) class Meta: managed = True db_table = 'Map' class Uni(models.Model): uni_id = models.BigAutoField(db_column='Uni_ID', primary_key=True) comp_name = models.TextField(blank=True, null=True) name = models.TextField(blank=True, null=True) class Meta: managed = True db_table = 'Uni' below is the code which i tried: obj_map = map.objects.using("Map").filter(map_id=pk).filter(map_id__in=F('uni_id')) -
I have an issue in django framework using mongodb database as backend the djongo models the code is as follows in models.py
This is the code which is in models.py file class ManageTribe(models.Model): _id=models.ObjectIdField() tribe_name=models.CharField(max_length=255) Date_created = models.DateTimeField(auto_now_add=True) Date_updated = models.DateTimeField(auto_now_add=True) objects = models.DjongoManager() def _str_(self): return self.tribe_name class User(models.Model): NORMALUSER = 'NOR' TRIBE_LEADER = 'TRL' SOCRAI_LEADER = 'SCL' SOCRAI_Admin = 'SCA' UserRoles = [ (NORMALUSER, 'NormalUser'), (TRIBE_LEADER, 'Tribe leader'), (SOCRAI_LEADER, 'Socrai leader'), (SOCRAI_Admin, 'Socrai admin'), ] _id=models.ObjectIdField() firstname=models.CharField(max_length=255) UserRoles = models.CharField(max_length=45,choices=UserRoles,default=NORMALUSER) lastname = models.CharField(max_length=255) password=models.CharField(max_length=255) username = models.CharField(max_length=255) current_level=models.CharField(max_length=255) current_level_point=models.IntegerField() leader_id=models.IntegerField() Date_created = models.DateTimeField(auto_now_add=True) Date_updated = models.DateTimeField(auto_now_add=True) tribename=models.EmbeddedField(model_container=ManageTribe,rel='tribe_name') objects = models.DjongoManager() def __str__(self): return self.firstname error is Value: ManageTribe object (None) must be an instance of <class 'dict'> The relationship is not created between to models -
Accessing data from a json array in python JSONDecodeError at /get/
My response looks like: [ {"_id":"5f6060d0d279373c0017447d","name":"Faizan","email":"faizan@test.com"} ] I want to get the name in python. I am tryting: response = requests.get(url) data = response.json() The error I am getting is: JSONDecodeError at /get/ -
Having an attribute error saying doesn't not have a attribute 'write'
[here is a photo of my cmd showing an attributeerror at base.py of my Django project. So I was able to track it there but can't see the cause of the error][ the other image is regarding my code at base.py file where the error is at. Please what's the cause of this error from the images I sent. Thanks in advance] -
removing cache of browser after clearing memcached from admin django
hello guys i want use memcached for one of my class like this: @method_decorator(cache_page(60 * 15), name='list') @method_decorator(csrf_exempt, name='list') class MostDiscountedCourses(generics.ListAPIView): and i use ajax for handling my request but i have a problem after clearing cache .my browser doesnt update if i dont use ctrl + shift + r. how can i handle it: the request of my header is this: {'Content-Length': '', 'Content-Type': 'text/plain', 'Host': '127.0.0.1:8000', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'no-cache', 'Accept': 'application/json, text/javascript, /; q=0.01', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36', 'X-Requested-With': 'XMLHttpRequest', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Dest': 'empty', 'Referer': 'http://127.0.0.1:8000/home/', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'fa-IR,fa;q=0.9,en-US;q=0.8,en;q=0.7', 'Cookie': 'pga4_session=cebb4feb-a0e0-477a-a580-651f8253b53f!tOhsFlL10HtTWOK6V0xwiTAjTcU=; csrftoken=MSqcZhyhrQjACjP5Qk18mDa27lL2XGYWQWAHBtd1UJa4D5gcklFt2G6z018nMt0o; sessionid=b3umdoks9u40n231olvmz99j3c81if22'} i thanks alot if anybody know it help me. -
Variable not reassigned in Django template
I am trying to reassign a variable in a for-loop. Depending on the value, I will proceed to do other things, before resetting it to another default. However, the value is not being replaced properly within the loop. These are my template tags: @register.filter def addition(val1, val2): return val1 + val2 @register.simple_tag def assignVar(arg1): return arg1 Here is a portion of my full template {% assignVar 50 as testVar %} <table> <tbody> {% for data in LIST %} <tr> A: {{testVar}} {% assignVar testVar|addition:20 as testVar %} B: {{testVar}} {% if testVar > 150 %} {{data}} {% assignVar 0 as testVar %} {% endif %} </tr> {% endfor %} </tbody> </table> My output is as such: A: 50 B: 70 A: 50 B: 70 A: 50 B: 70 ... Why does my testVar value not increase? Each time it loops, the testVar variable keeps going back to the initial value instead of being replaced with the new one. This was what I expected: A: 50 B: 70 A: 70 B: 90 A: 90 B: 110 ... -
Django 3.1 admin with tornado integration
There are multiple talks of integrating django with tornado. But they're all at least 3 years old and no longer up to date since django is (partly) async now, and tornado as well supports native async coroutines. Therefore it should be easier to integrate django with tornado, right? I only need admin interface from django. Therefore the question - how to do it? Does anyone already has an experience doing that? Some specifics: I still use tornado 5.1, haven't migrated yet. Python 3.8.5 Postgres 13 with asyncpg as an interface. Would hear any helpful thoughts on a subject. -
issue in redirecting user to home page django
When I try to login, it does not reedirect me to home page. instead, it shows me an error the url should be http://127.0.0.1:8000/ it shows http://127.0.0.1:8000/login I tried to user both function and path names urls.py app_name = "accounts" urlpatterns = [ path('', views.home,name="home"), path('register/',views.register, name='register'), path('login/',views.loginPage, name='login')] views.py def loginPage(request): if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') user = authenticate(request,username=username, password=password) if user is not None: login(request,user) return redirect('home') return render(request,'accounts/login.html') Error NoReverseMatch at /login/ Reverse for 'home' not found. 'home' is not a valid view function or pattern name. Request Method: POST Request URL: http://127.0.0.1:8000/login/ Django Version: 3.0.4 Exception Type: NoReverseMatch Exception Value: Reverse for 'home' not found. 'home' is not a valid view function or pattern name. Exception Location: C:\Users\Mahmoud Ishag\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 677 -
why topic object is showing instead of topic name
instead of topic name why it is showing topic object import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'third_project.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == '__main__': main() -
including model to my Django app, no access: ImproperlyConfigured
I'm creating Django app, which should receive user questions, transfer them to the database, display some ML model answers and allow users to evaluate these answers. So, I've created model.py with class Dialog(models.Model) with text field, but there is some problem with including. models.py Dialog(models.Model): user_message = models.TextField(max_length=500, default="Hello world!") messages = models.Manager() def __str__(self): return f'User message: {self.messages.all()}' then I've changed settings.py: INSTALLED_APPS = [ 'django.contrib.staticfiles', # 'dialog.models.Dialog', # all variants that I tred # 'dialog.apps.DialogConfig', 'dialog', ] And add app.py: from django.apps import AppConfig class DialogConfig(AppConfig): name = 'dialog' but when I try to connect to my server, I get Atribute Error "Manager isn't accessible via Dialog instances". Then I've tried to run my models.py aim check the problem and I get: django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. So, I tried several variations in settings.py and I have os.environ['DJANGO_SETTINGS_MODULE'] = 'chatbot.settings' either in settings.py and wsgi.py There is a structure of my project: bot_infr - chatbot - chatbot -__init__.py - asgi.py - settings.py - urls.py - wsgi.py - dialog - migrations - __init__.py - admin.py - apps.py - forms.py - models.py … -
check if Django is running background tasks
I am developing a django website. There is a function which is to read a large PDF and may use several minutes to complete the task. But I found out when running the function, user can actually refresh the page or leave the page. As you can see from the above screenshot, I actually jump to the admin page and it can still continue to read the PDF. But the server will fail if I upload another new PDF and run the same function again. What I want to achieve is a function like this: def readPDF(pdf_file): if There is there is another readPDF() is running: ignore else: read the PDF (Start the task) So I want to ask if there is any method to check whether the job is running, or any other method or idea to achieve my purpose?? -
How to restrict int field in fucntion queryset
How can I restrict rating field to exactly to +1. Now it goes up to +2, +3, +4. My model field: rating = models.SmallIntegerField(default=0, validators=[MinValueValidator(-1), MaxValueValidator(1)]) My function: def add_like(obj, user): obj_type = ContentType.objects.get_for_model(obj) like = Like.objects.update_or_create(content_type=obj_type, object_id=obj.id, user=user) Like.objects.filter(content_type=obj_type, object_id=obj.id, user=user).update(rating=F('rating') + 1) return like -
making link short in django pagination
I have multiple params in GET request which i'm passing through-out pagination.(i mean pass params in pagination's link). Following code in my pagination link. <a class="waves-effect page-link" href="?page={{ page_obj.previous_page_number }}{% if search == none %}{%else%}&search={{search}}{%endif%}{% if filter_property == none%}{% else %}&filter_property={{filter_property}}{% endif %}{% if overseas %}&overseas={{overseas}}{% endif %}{% if rtc %}&rtc={{rtc}}{% endif %}{% if rbc %}&rbc={{rbc}}{% endif %}" aria-label="Next"> Next</a> is there any solution where i can make it short and batter through pythonic way? Thanks in advance. -
How to create a XML-RPC api with Django
I need to create a XML-RPC API with Django, I check xmlrpc docs but I didin't found a way to integrate the server with Django and also I can't find any resource that may can help me with this. Any suggestion or resource to acomplish this would be great. -
Summing up multiple class Def function to get total amount in Django models
I've gone through questions relating to my question, but none is pointing to what I've in mind. I've different class model, with def functions. I can achieve the total amount for each model, but what I want to achieve is, after getting the total amount for each model, how can I sum to models together, to get my total amount for all the models. Below are my code class HomeOrderItem(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) home_ordered = models.BooleanField(default=False) item = models.ForeignKey(HomeItem, on_delete=models.CASCADE) quantity = models.IntegerField(default=1) def get_total_item_price(self): return self.quantity * self.item.home_price def get_total_discount_price(self): return self.quantity * self.item.home_discount_price def get_final_price(self): if self.item.home_discount_price: return self.get_total_discount_price() return self.get_total_item_price() class HomeOrder(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) home_items = models.ManyToManyField(HomeOrderItem) date_created = models.DateTimeField(auto_now_add=True) ordered_created = models.DateTimeField() home_ordered = models.BooleanField(default=False) def __str__(self): return self.user.username def get_total_everything(self): total = 0 for order_item in self.home_items.all(): total += order_item.get_final_price() return total class MenOrderItem(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) men_ordered = models.BooleanField(default=False) item = models.ForeignKey(MenItem, on_delete=models.CASCADE) quantity = models.IntegerField(default=1) def get_total_item_price(self): return self.quantity * self.item.men_price def get_total_discount_price(self): return self.quantity * self.item.men_discount_price def get_final_price(self): if self.item.men_discount_price: return self.get_total_discount_price() return self.get_total_item_price() class MenOrder(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) men_items = models.ManyToManyField(MenOrderItem) date_created = models.DateTimeField(auto_now_add=True) ordered_created = models.DateTimeField() men_ordered = models.BooleanField(default=False) def __str__(self): return self.user.username def get_total_men_everything(self): … -
Using fetch() to dynamically update objects rendered on HTML page?
I am developing a dictionary app using Django. I have a bookmarks page that lists bookmarked definitions. Every bookmarked definition has a button to remove the bookmark. My problem is that when I remove the bookmark from a bookmarked definition it does not go away from the bookmarks page until I refresh the page. In bookmark.js, am trying to call fetch() after I remove the bookmark from the definition to "reload" or "update" the content of the page dynamically: function bookmark(event) { // Get definition id. let id = event.target.id.split("-")[1]; // Add/remove bookmark to definition. $.get("/bookmarks/bookmark/" + id, function (data) { if (data.added) { alert('Definition added to your bookmarks.') event.target.innerHTML = 'Remove definition from your Bookmark'; } else if (data.removed) { alert('Definition removed from your bookmarks.') event.target.innerHTML = 'Add definition to your Bookmarks'; } }); // Get updated list of bookmarks. fetch('/bookmarks/') // <---------------- PROBLEM } $(window).on("load", () => { $(".bookmark-btn").each(function (index) { $(this).on("click", bookmark); }); }); This is my views.py: # URL: /bookmarks/ class BookmarksView(generic.ListView): """Lists bookmarked definitions.""" model = Definition template_name = "bookmarks/bookmarks.html" def get_context_data(self, **kwargs): language = get_language() bookmarks = self.model.objects.filter(language=language, is_bookmarked=True) context = super().get_context_data(**kwargs) context["bookmarks"] = bookmarks.order_by("-publication_date") return context # URL: /bookmarks/bookmark/definition_id def bookmark(request, definition_id): """Toggles … -
Running custom Django command from Apache
Objective I'm trying to deploy my application in Django to Apache on a raspberryPi to be able to access my website from another PC connected to the same wifi. Setup Apache As for now I have the following Apache default config file /etc/apache2/sites-available/000-default.conf <VirtualHost *:443> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName www.example.com ServerAdmin webmaster@localhost #DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. LogLevel info debug ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line … -
Where I have to write bulk_create function If I want to insert the data into database in Django app? In which file
I have to check the infinite scroll of post news. And I need to bulk_create a lot of empty news. But I don't know where I have to write the code in order to insert the data into database I think with for loop. Thank you! -
Django display a png created with a view
I am currently working on a project on which I want to build a website where you can enter any URL. With clicking on a button you should get a screenshot of this requested website. Furthermore, there is another button that modulates this png into an RGB-image. For a few days, I have a problem, that the screenshot is generated but not displayed anymore on my website, while there is still an old image displayed. This is my HTML-template. <h1> CovertCast </h1> <form action="" method="post"> {% csrf_token %} <label>url: <input type="url" name="deine-url" value="https://"> </label> <button type="submit">Get Screenshot</button> </form> {% load static %} <img src="/media/screenshot_image.png" class="bild"/> <form action="/modulated.html" method="post"> {% csrf_token %} <button type="submit">Modulate</button> </form> <img src="/media/modulated_image.png" alt="abc"/> My function view looks like this: def screenshot(request): DRIVER = 'chromedriver.exe' if request.method == 'POST' and 'deine-url' in request.POST: url = request.POST.get('deine-url', '') if url is not None and url != '': options = webdriver.ChromeOptions() options.add_argument('--ignore-certificate-errors') options.add_argument('--ignore-ssl-errors') driver = webdriver.Chrome(ChromeDriverManager().install()) driver.get(url) img_dir = settings.MEDIA_ROOT img_name = ''.join(['screenshot', '_image.png']) path = os.path.join(img_dir, img_name) if not os.path.exists(img_dir): os.makedirs(img_dir) driver.save_screenshot(path) screenshott = img_name driver.quit() return render(request, 'main.html') else: return render(request, 'main.html') def modulate(request): with open('screenshot_image.png', 'rb') as image: f = image.read() a = bytearray(f) w = … -
why tests are not using test-database in testing django-rest-framework API? in this API there is another api call
tests.py from rest_framework import status from django.urls import reverse from rest_framework.test import APITestCase lass LoginTestCase(APITestCase): def test_sent_forgot_pass_code_and_checkmail(self): response = self.client.put( reverse('create_token'), # /login/ data={ 'username': self.gmail_user } ) self.assertEqual(response.status_code, status.HTTP_200_OK) you see I am using APITestCase in tests. views.py from rest_framework.reverse import reverse from rest_framework import status, generics from rest_framework.response import Response import requests from common.utils import get_abs_url class CognitoViews(generics.GenericAPIView): def put(self, request, *args, **kwargs): print(request.data) username = request.data.get('username') username = username.replace(" ", "") reset_pwd_payload = { "email": username } reset_pwd_request = requests.post( get_abs_url(request, reverse('reset-password-request')), #/password/ data=reset_pwd_payload, allow_redirects=False) if reset_pwd_request.status_code == 200: response_data = {'message': 'Code Sent.'} status_code = status.HTTP_200_OK else: response_data = {'message': 'Error sending the code.'} status_code = status.HTTP_401_UNAUTHORIZED return Response(response_data, status=status_code) here in this view there is another api call which is using python requests package which I think causing the problem. common/utils def get_abs_url(request, url): host = request.get_host() if not settings.DEBUG: return '{0}{1}{2}'.format('https://', host, url) else: return '{0}{1}{2}'.format('http://', host, url) when I run this test I get this error: File "/home/bilal/codebase/django-backend/.venv/lib/python3.7/site-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='testserver', port=443): Max retries exceeded with url: /password/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa3c9aa5990>: Failed to establish a new connection: [Errno -2] Name or service not known')) … -
Django Localhost Redirecting too many times
Hi there I created a decorator to protect a certain view from unauthorized persons though I am using django allauth to handle my authentications so I've used its login url. On testing whether the authorization works instead of redirecting me to the login page Localhost gets stuck in a redirect loop here is a look at my code decorators.py from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.decorators import user_passes_test def seller_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url='account_login'): ''' Decorator for views that checks that the logged in user is a seller, redirects to the log-in page if necessary. ''' actual_decorator = user_passes_test( lambda u: u.is_active and u.is_seller, login_url=login_url, redirect_field_name=redirect_field_name ) if function: return actual_decorator(function) return actual_decorator views.py from django.views.generic import CreateView,DetailView, ListView from django.utils.decorators import method_decorator from django.contrib.auth.decorators import login_required from .decorators import seller_required @method_decorator( seller_required , name='dispatch') class SellerDashBoardView(ListView): model = Seller template_name = 'seller_dashboard.html' App level urls from django.urls import path from .views import SellerSignUpView, SellerDashBoardView urlpatterns = [ path('seller_reg/', SellerSignUpView.as_view(), name='seller_reg'), path('seller/', SellerDashBoardView.as_view(), name='seller_dash') ] project level urls from django.contrib import admin from django.urls import path, include from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('users/', include('user.urls')), #path('users/', include('django.contrib.auth.urls')), path('accounts/', include('allauth.urls')), path('', include('pages.urls')), path('store/', include('store.urls')), #path("djangorave/", include("djangorave.urls", namespace="djangorave")), … -
Django-filters how to create dynamically filterset_fields
I wrote a viewset, which depends on the endpoint: ALLOWED_ENTITIES = { 'persons': [Person, PersonSerializer, '__all__'], 'locations': [Location, LocationSerializer, ('country', 'city', 'street')], 'institutes': [Institute, InstituteSerializer, ('number', 'name_short', 'mail_domain')], } class EntityViewSet(viewsets.ModelViewSet): filter_backends = [DjangoFilterBackend] filterset_fields = '__all__' #should be ALLOWED_ENTITIES[self.kwargs['entity_name']][2] def get_queryset(self): model = ALLOWED_ENTITIES[self.kwargs['entity_name']][0] return model.objects.all() def get_serializer_class(self): serializer = ALLOWED_ENTITIES[self.kwargs['entity_name']][1] return serializer urls.py: urlpatterns = [ path('', RedirectView.as_view(url=reverse_lazy('aim:api-root'))), url(r'^api/(?P<entity_name>\w+)', EntityListView.as_view({'get': 'list'})), url(r'^/admin/', admin.site.urls), ] and it works as expected, when i go to /api/persons it shows me viewset with Person Model and PersonSerializer. But the problem, that i dont know how to define filterset_fields = ALLOWED_ENTITIES[self.kwargs['entity_name']][2] and i can not use filterset_fields = '__all__' because i get the following error: Unsupported lookup 'icontains' for field 'aim.Department.parent'. where 'aim.Department.parent' is ForeignKey. Perhaps someone knows how to dynamically define filterset_fields. Thank you in advance. -
DJANGO POST GET not working after i18n translation
I have multiple POST requests from my template for example: $.ajax({ url: '/apply_payment', type: 'POST', data: { basket: JSON.stringify(basket), key: $('#key_input').val(), csrfmiddlewaretoken: CSRF_TOKEN }, dataType: 'json', success: function (data) { $("#key_input").val(""); }, ... I read in the basket data in a view.py like this: basket = request.POST.get('basket', '') In the urls.py I have these urls in the form of: path('apply_payment', entrance_api.apply_payment, name='apply_payment'), Now lately I added i18n_patterns into the URLs, and translated all of my pages, however the AJAX calls stopped working. I guess it is becase the URLs are dynamically changing between selected languages, but I might be wrong. For example the shows basket variable is always None in the view now. How can I fix this?