Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to properly do aggregate functions in django ORM for a case where a reference in a table is more than once
I have a table in django. Everytime a user leaves a tip a entry in that table is created. I am trying to create a query that does the following. gets the user reference to the FK user of a user. but only once. So even if there are more than 1 rows with that user FK (because they left more than one tip) I still only want it once. then the total number of tips a user has left. This is why I only want the user FK object once, regardless of how many times it shows in the table. As the total number of tips is to determine the number of tips a user has left. The total dollar amount of all the tips they have left. so if they left a tip of $5 $15 $ 25 the total amount in this field would be $45 Here is my query set and my serializer and my payload. the shochattotalminutes and totalmoney are unrelated to this question. userlist = ShoChatEntityShoChatTips.objects.annotate( numberofshochats=Count('user')).annotate(totaltips=Sum('tipamount')).filter(shochatentity= shochatentity).order_by('totaltips') serializeduserlist = ContentCreatorTopTippersSerializer(userlist, many=True) payload = { 'userList': serializeduserlist.data, 'shochattotalminutes': shochattotalminutes, 'totalmoney': totalmoney } return Response(payload) however please notice the output in the screen shot below. … -
How to access one to many field on django admin page
I make a table with one to many relationship (One Customer can have many Order). How to make one to many field so we can access it on django admin page? My code: class Customer(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) # How can i make and show this field in admin site? # order = This is field which contains all customer order class Order(models.Model): customer = models.ForeignKey(Customer, on_delete=models.CASCADE) I've been trying to find the answer but mostly the answer is using prefetch_related and show it on template or view. How can i see it on admin site? Thank you. -
Add custom logic in CreateView to not show the add form if a condition is met
How do I add custom logic in a class based view ? urls.py: path('books/add', views.AddBook.as_view(), name='add_book'), models.py class Book(models.Model): title = models.CharField(max_length=255) summary = models.TextField(max_length=2048) created = models.DateTimeField(auto_now_add=True) user = models.ForeignKey(User, on_delete=models.CASCADE) views.py MAX_BOOKS = 5 class AddBook(LoginRequiredMixin, generic.CreateView): model = Book """ if user has reached MAX_BOOKS books = Book.objects.filter(user=request.user) if len(books) == MAX_BOOKS template_name = 'books/restrict_book.html' and send in some data like { 'error_msg': 'You cannot add further books' } """ form_class = BookForm # fields = ['title'] template_name = 'books/add_book.html' success_url = reverse_lazy('dashboard') def form_valid(self, form): form.instance.user = self.request.user super(AddBook, self).form_valid(form) return redirect('dashboard') -
upload contacts from iphone/mac to django app
I am trying to understand if there is a way to upload/sync all my contacts on the contacts app of my mac/iphone with my django app. Any help? -
Forms not working as expected. After submitting, it just refresh a same page of form to me
Im facing a issue where the my input data is not pass on at all in python django code. Im doing a simple testing from the lots of other task I have to put in the code but it is not printing valid on my powershell. My code are: views.py: def device_add(request): if request.method == "POST": device_frm = DeviceForm(request.POST) if device_frm.is_valid(): print("valid") #return render(request, 'interface/device_display.html',{'devices':devices}) #dd_frm = DeviceDetailForm(request.POST) #di_frm = DeviceInterfaceForm(request.POST) #if dd_frm.is_valid() and di_frm.is_valid(): #if dd_frm.is_valid(): #dd_frm.save() #devicedetail = dd_frm.save(commit=False) #devicedetail.save() #dd_frm.save_m2m() #deviceinterface = di_frm.save(commit=False) #deviceinterface.hostname = devicedetail.hostname #deviceinterface.save() else: device_frm = DeviceForm() return render(request, 'interface/device_add.html',{'form':device_frm} ) #dd_frm = DeviceDetailForm() #di_frm = DeviceInterfaceForm() #context = {'dd_frm':dd_frm, 'di_frm':di_frm, 'title':'Device Add'} return render(request, 'interface/device_add.html',{'form':device_frm}) In forms.py class DeviceForm(ModelForm): class Meta: model= Device fields= '__all__' In models.py class Device(models.Model): hostname = models.CharField(max_length=50) ipaddr = models.CharField(max_length=15) date_added = models.DateTimeField(default=timezone.now) #date_updated = models.DateTimeField(auto_new=True) #created_by = models.ForeignKey(User, on_detele=models.CASCADE) #updated_by = models.ForeignKey(User, on_detele=models.CASCADE) def __str__(self): return self.hostname -
Which is a better way to enforce OneToOne Relationship in Django?
Were wondering which would be the effective way to enforce OneToOne relationship in Django. Here is what we have encountered and wanted opinion. class Address(models.Model): phone = models.OneToOneField(Phone, related_name='phoneNumber') class Phone (models.Model): phone = models.PositiveIntegerField(min_length=9) the other was using ForeignKey with unique_together - class Phone(models.Model): address = models.ForeignKey(Address, related_name='phoneAddress',on_delete=models.CASCADE) phone = models.PositiveIntegerField(min_length=9) class Meta: unique_together = ['phone','address',] or by creating a Subclass - class Address(models.Model): .... class Phone (Address): phone = models.PositiveIntegerField(min_length=9) your expertise and insights appreciated. Cheers! -
Django: Even after setting AUTH_USER_MODEL = 'custom_user.User' I get clashes with reverse accessor
I have added a custom_user app to my project and in that I have a model User which extends the AbstractUser model the models.py from django.db import models # Create your models here. from django.contrib.auth.models import AbstractUser class User(AbstractUser): pass I have also AUTH_USER_MODEL = 'custom_user.User' in the settings.py file and also added the app in the INSTALLED_APPS. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'custom_user' ] Still when I run the server I get ERRORS: auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'. HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'. auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'. custom_user.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'. HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'. custom_user.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'. What is the mistake I am doing -
Have django embed url into either image or video tag in the admin list display
I currently have a admin.py file that looks like this from django.contrib import admin from remover.models import FileUrlVal class FileAdmin(admin.ModelAdmin): list_display = ( 'user', 'ip_address', 'value', 'total_credits', 'total_frames', 'preview' ) admin.site.register(FileUrlVal, FileAdmin) With the FileUrlVal model looking like this class FileUrlVal(models.Model): user = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True) ip_address = models.GenericIPAddressField(null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) value = models.CharField(max_length=1000, db_index=True) job_name = models.ForeignKey(Dicty, db_index=True, on_delete=models.CASCADE) total_frames = models.IntegerField(default=0) total_credits = models.IntegerField(default=0) content_type = models.CharField(max_length=240, db_index=True, default='') preview = models.CharField(max_length=240, db_index=True, default='') This all works fine. But what I'm trying to achive is the value item holds a url that is either an image or gif. So I'd like the admin instead of showing me the url, to show me the image or gif. Any help would be apprecicated -
Dockerized Django app not allowing connections
I have a Django project that im trying to dockerize. When I run the the docker image i get no errors and the django app says it waiting for connections. Navigating to localhost, 127.0.0.1, or my VMs ip return no connection and the Django terminal reports no incoming connections. this is how i build and run my docker image docker build -t 0rion447/osas:osas_latest docker run -it -p 80:8000 0rion447/osas:osas_latest here is my dockerfile FROM python:3.8.5 COPY requirements.txt ./ RUN pip3 install --user -r requirements.txt RUN pip3 install psycopg2-binary RUN python3 -m pip install --upgrade Pillow COPY . app COPY run_server.sh ./ RUN chmod +x run_server.sh EXPOSE 8000 ENTRYPOINT ["./run_server.sh"] and my run_server.sh #!/bin/sh python app/manage.py runserver 0.0.0.0:8000 In my settings.py i have ALLOWED_HOSTS['*'] Let me know if you need any other information. -
Fetching data from an api and adding to a database in Django
I'm working on a project where I need to update values based on whether a user adds/deletes them. But, the original data is from an api, and I want to store that in a Django database. How do I do that without repeatedly making calls to the api? In other words, I just want to include the data from the api in my database in the beginning, and then modify it accordingly based on what the user decides to add/delete in the future without having to fetch that api over and over to check if its data exists in the database or not as that is unnecessary. -
How to know customer new payment date is arrived in Django?
Info I am trying to make monthly subscription based like app. Where a customer can buy a property on a monthly basis payment. The customer will continue to pay a certain amount for the property each month until the value of the property is paid. Everthing is working fine now i want to know how can i check which customers new payment date is arrived and how do I filter out customers who haven't made a new payment yet? models.py class Property(models.Model): """Property Model""" area = models.CharField(max_length=255) price = models.DecimalField(max_digits=17, decimal_places=2, default=0.0,) created_on = models.DateTimeField(auto_now_add=True) class Customer(models.Model): """Customer Model""" name = models.CharField(max_length=255) prop_select = models.ForeignKey(Property, on_delete=models.SET_NULL, null=True) created_on = models.DateTimeField(auto_now_add=True) remaning_amount = models.DecimalField(max_digits=17, decimal_places=2, default=0.0) def save(self, *args, **kwargs): property_price = self.prop_select.price payment_done_by_customer = Payment.objects.filter(customer=self).aggregate(Sum('amount'))['amount__sum'] or Decimal('0') # Remaining Amount of each customer self.remaning_amount = property_price - payment_done_by_customer super(Customer, self).save(*args, **kwargs) class Payment(models.Model): """Payment Model""" customer = models.ForeignKey(Customer, null=True, on_delete=models.SET_NULL, related_name='payment') datetime = models.DateTimeField(auto_now_add=True) amount = models.DecimalField(max_digits=17, decimal_places=2, default=0.0) -
How can I fix KeyError: 'ariadne_jwt'?
Sometimes when I attempt to runserver I get the following error and I cant figure out the cause. It used to show up every few times I boot up my Django project but now its occurring every-time and I cant seem to figure out why. I have tried restarting the server, clearing pyCache, updating my packages, uninstalling the ariadne_jwt and reinstalling it but its not working. Terminal output Exception in thread django-main-thread: Traceback (most recent call last): File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run self.check(display_num_errors=True) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/core/management/base.py", line 419, in check all_issues = checks.run_checks( File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/core/checks/registry.py", line 76, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 125, in check_dependencies if not _contains_subclass('django.contrib.messages.middleware.MessageMiddleware', settings.MIDDLEWARE): File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 41, in _contains_subclass candidate_cls = import_string(path) File "/Users/chuksgrinage/Desktop/Projects/Next/pinkle/backend/venv/lib/python3.9/site-packages/django/utils/module_loading.py", line 17, in import_string module = import_module(module_path) File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File … -
Getting text of HTML element and passing it to django view using AJAX
I have the following paragraph: <p>{{donation.pk}}</p>. I want to pass the value of the paragraph into the view bellow as a pk def acceptdonation(request, pk): #the `pk` should be the `pk` of the `p` element deleteitem = Donation.objects.filter(id = pk) deleteitem.delete() return redirect('/dashboard/') I did research, and heard that you need to use AJAX. How exactly can I achieve this. I am not to good with javascript so the easiest and most minimalist way would be helpful. PLEASE NOTE: I already have a button that calls the view, I just want to pass the value of the p element into my function -
Change response to JsonResponse in Class-based view
I'm using curl to submit form data to my website. curl -F some_file=@file.txt -F name=test_01 https://localhost:8000 It's not an API but I have a requirement for a single endpoint that behaves as an API. I'm a little out of my depth here, so I'm hoping someone can help me. I've got the model set up and working and the CreateView, as well: class CreateFile(CreateView): model = SomeFile fields = ['name', 'some_file', . . .] When I send a POST request with curl as above to the specified URL (/file/request), the object is created in the DB and I get a response (set to /thanks now which is a generic templated HTML rendered file). But since a non-browser will be sending this request, I was hoping to respond with some JSON. Maybe with the object's name, status, etc. I've tried a few things with mixed results... For example, if I use View instead of CreateView, I can return JSON but I really like the ease and convenience of the CreateView CBV, so I'm hoping I can do what I want this way. How can I do this? -
Using Django tests on model validation, how to test that a value does not raise a validation error
I know that I can check if a validation error will be raised like so: ` def test_validate_fee_range(self): test = Foo.objects.get(name="T1") test.full_clean() test.fee = 105 # raise Validation error for value less than 0 and greater than 100 self.assertRaises(ValidationError, test.full_clean)` For completeness I want to test that values between 0 and 100 do not raise a ValidationError. How do I do this? -
Django DRF, how to properly register custom URL patterns with DRF actions
Background I have a ModelViewSet that defines several custom actions. I am using the default router in my urls.py to register the URLs. Right now, my views use the default created routes like ^images/$, ^images/{pk}/$. In order for users to use the API using resource names with which they are familiar, I have adapted the viewset to accept multiple parameters from the URL, using the MultipleFieldLookupMixin strategy described in the docs to allow for the pattern images/{registry_host}/{repository_name}/{tag_name}. I've created the get_object method in my viewset like so: class ImageViewSet(viewsets.ModelViewSet): ... def get_object(self): special_lookup_kwargs = ['registry_host', 'repository_name', 'tag_name'] if all(arg in self.kwargs for arg in special_lookup_kwargs): # detected the custom URL pattern; return the specified object return Image.objects.from_special_lookup(**self.kwargs) else: # must have received pk instead; delegate to superclass return super().get_object() I've also added a new URL path pattern for this: urls.py router = routers.DefaultRouter() router.register(r'images', views.ImageViewSet) # register other viewsets ... urlpatterns = [ ..., path('^images/<str:registry_host>/<path:repository_name>/<str:tag_name>', views.ImageViewSet.as_view({'get': 'retrieve',})), path('', include(router.urls)), ] Problem The above all works as intended, however, I also have some extra actions in this model viewset: @action(detail=True, methods=['GET']) def bases(self, request, pk=None): ... @action(detail=True, methods=['GET']) def another_action(...): ... # and so on With the default patterns registered by … -
How do i upload an image into database as base64 in django?
This is my Code. Model Form And View........ class Home(models.Model): title = models.CharField(max_length=250) image = models.FileField() content = models.CharField(max_length=5000000) date_created = models.DateTimeField(auto_now_add=True) is_deleted = models.BooleanField() class Meta: db_table = 'home' #model class HomeForm(forms.ModelForm): class Meta: model = Home fields = '__all__' title = forms.CharField(label="title") image = forms.FileField(label="image") content = forms.CharField(label="content") #form def HomePage(request): home = Home.objects.order_by('-id') form = HomeForm() if request.method == 'POST': # print(request.POST) form = HomeForm(request.POST, request.FILES or None) if form.is_valid(): image = form.cleaned_data['image'] b64_img = base64.b64encode(image.file.read()) form.save() #model Please What am i doing wrong? How do i upload an image into database as base64 in django ?? -
Why is my django project only working properly on Chrome but not Edge nor Safari?
I was working on my landing page for my project and I was doing it all in Chrome but then I wanted open it in Edge and it does not seem like it can find my static files. My page looks all messy in Edge and I get the following in the terminal: On Crome there is no error and that is the weird part for me. Here is the structure of my files: I see it cannot find the files and django has a way of using static files and the way I called each static file is <link href="{%static 'vendor/bootstrap/css/bootstrap.min.css'%}" rel="stylesheet" /> or <script src="{%static 'vendor/bootstrap/js/bootstrap.bundle.min.js'%}"></script>. I have no idea how I got here or if I am doing something wrong so any feedback would be appreciated. -
django collectstatic 'AppConfig' object has no attribute 'ignore_patterns'
I recently upgraded django to 3.2.5, after which admin template was not loading correctly especially in model pages, please see the screenshot, I decided to run, python manage.py collectstatic but then I am receiving following error Traceback (most recent call last): File "/var/www/dev.bluelion.icu/bluelion/manage.py", line 21, in main() File "/var/www/dev.bluelion.icu/bluelion/manage.py", line 17, in main execute_from_command_line(sys.argv) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute_from_command_line utility.execute() File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/core/management/init.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 149, in handle self.set_options(**options) File "/var/www/dev.bluelion.icu/bluelion/bluelionenv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 82, in set_options ignore_patterns += apps.get_app_config('staticfiles').ignore_patterns AttributeError: 'AppConfig' object has no attribute 'ignore_patterns' Any help is appreciated, please let me know if there is any ambiguity in the question! -
form doesnt dave, but adds a weird string into the url
following a Django tutorial, i coded the following html file that takes a form filled by a user and adds it to the database as an object (the form is a bunch of attributes of a class) {% block content %} <form> <form method="POST"> {% csrf_token %} {{ form.as_p }} <input type='submit' value = 'save' /> </form> {% endblock %} instead of saving the form to the database, it adds a weird string to the url (pasted below). this happened to the guy in the tutorial, but it was fixed after he added the <form method="POST"> {% csrf_token %} what is this "error", and how can i deal with it? also, what can i do if it happens in the future? there's no real error, the server goes on fine, so there's no traceback/error message to show. i made sure the form.as_p is a real variable, and that there's no typos in the variables or tags relative to the tutorial. only problem i can think of is the change in versions - the tutorial is in Django 2.0.7 and i am on 3.2.5, but the csrf_token is still valid according to what i saw in the docs. added to the … -
How to set a specific time zone in django?
In django, it only has UTC timezone and other countries, but I live in Texas and there's like a five hour difference. How do I specify central time zone in my settings.py? -
How to direct a python package to a user install library rather than a root library?
I install python packages to my user root directory since I can't install it to the root directory due to security issues. The python package (pyobdc) is looking for /usr/local/lib/libmsodbcsql.13.dylib which doesn't exist there but it exists at /Users/Max/usr/local/lib/libmsodbcsql.13.dylib. I wanted to create a syslink but of course I ran into the same issue which is permissions to root. How can I make the package (Installed in a Django project) point to the user root? -
Exception Value: name 'VideoThumbnailUrl' is not defined
I'm trying to fetch information from videos on youtube using youtube-dl, the problem is when I try to store the information on the DB, When I run my script I'm getting the next error: Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/local/lib/python3.8/dist-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/FullStack/views.py", line 209, in getVideoData Video.objects.create(VideoThumbnailURL=VideoThumbnail) Exception Type: NameError at /getvideodata Exception Value: name 'VideoThumbnailUrl' is not defined My code: views.py from .models import Video def getvideodata(request): if 'url' in request.POST: VideoThumbnail = get_thumbnail(request.POST['url']) # works fine, returns the thumbnail URL Video.objects.create(VideoThumbnailURL=VideoThumbnail) # problem here models.py class Video(models.Model): VideoID = models.UUIDField(default=uuid.uuid4,null=False,primary_key=True,blank=False,editable=False, unique=True) VideoThumbnailURL = models.CharField(max_length=100,null=True,blank=True) The problem I'm seeing is that I'm using VideoThumbnailURL but Python is taking as VideoThumbnailUrl it's lower casing the last part of the variable. Any thoughts on this? Thanks -
Getting a django.contrib.gis.gdal.error - GDAL OGR error
I am getting the following error django.contrib.gis.gdal.error.GDALException: OGR failure. I get this on the following statement. def getDistanceBetweenTwoLocations(source,dest): try: employeeLocation = source.transform(32148, clone=True) <---Error employerLocation = dest.transform(32148, clone=True) distance = Distance(m=employerLocation.distance(employeeLocation)) dis = round(distance.mi, 2) # Convert to miles return dis except (Exception,): print("Unexpected error:", ) Any suggestions on what I might be doing wrong ? -
Django MismatchingStateError CSRF Warning
I am implementing an OAuth Authorization to connect my app to Microsoft Graph API, during callback to my URL http://localhost:8000/callback, the following error happens: MismatchingStateError at /ms/callback (mismatching_state) CSRF Warning! State not equal in request and response. Request Method: GET Request URL: http://localhost:8000/callback?code=0.AS0Al1INNTARS0G_Qyd..... Django Version: 3.2.5 Exception Type: MismatchingStateError Exception Value: (mismatching_state) CSRF Warning! State not equal in request and response. views.py: def get_token_from_code(callback_url, expected_state): aad_auth = OAuth2Session(settings['app_id'], state=expected_state, scope=settings['scopes'], redirect_uri=settings['redirect']) token = aad_auth.fetch_token(token_url, client_secret = settings['app_secret'], authorization_response=callback_url) return token def callback(request): expected_state = request.session.pop('auth_state', '') token = get_token_from_code(request.get_full_path(), expected_state) user = get_user(token) store_token(request, token) store_user(request, user) return HttpResponse("OK") urls.py: urlpatterns = [ path('signin', views.sign_in, name='signin'), path('signout', views.sign_out, name='signout'), path('callback', views.callback, name='callback'), path('callback/', views.callback, name='callback'), ]