Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ModelForm is not rendering on browser
I am creating a form for users to be able to create listings for an auction page however when I click the link from my index page to take me to the create page, i get redirected to the create page but on the browser, the form does not show. INDEX.HTML <p>You can create your first auction here <a href={% url 'create_listing' %}>Add new</a></p> URLS.PY path("create/", views.create_listing, name="create_listing") MODELS.PY from django.contrib.auth.models import AbstractUser from django.db import models class User(AbstractUser): pass class Auction(models.Model): title = models.CharField(max_length=25) description = models.TextField() current_bid = models.IntegerField(null=False, blank=False) users_bid = models.IntegerField(null=False, blank=False) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title VIEWS.PY from django.shortcuts import render, redirect from django.template import context from .forms import AuctionForm from .models import User def create_listing(request): form = AuctionForm() if request.method == 'POST': form = AuctionForm(request.POST) if form.is_valid: form.save() return redirect('index') context = {'form': form} return render(request, 'auctions/create-listing.html', context) FORMS.PY from .models import Auction from django.forms import ModelForm class AuctionForm(ModelForm): class Meta: model = Auction fields = ['title', 'description', 'current_bid'] CREATE-LISTING.HTML {% extends "auctions/layout.html" %} {% block content %} <form action="" method="post" class="ui form"> {% csrf_token %} {{form.as_p}} <input type="submit" class="ui button primary teal" value="Submit"> </form> {% endblock %} -
Trying to create an object in Django's database with React using User as foreign key (rest-framework)
I'm trying to register Club with owner (ForeignKey) and name fields via form in React. Everything works untill I submit the form. This gives me 401 Unauthorized error: const onSubmit = (event) => { event.preventDefault(); if (checkExistingClubNames(clubName, clubs)) { const owner = isAuthenticated().user; const name = clubName; createClub({owner, name}) .then((data) => { if (data.name === clubName) { setClubName(''); setNameTaken(false); navigate('/'); } }) .catch((error) => console.log(error)); } else { setNameTaken(true); } } clubName is a text variable from an input form (useState, ofc), checkExistingClubNames(clubName, clubs) just checks if a club with the same name exists, isAuthenticated().user returns currently logged user, nameTaken is just for displaying some text it does not matter in this case. The problem lies within createClub function, at least I think so: export const createClub = (club) => { return fetch('http://127.0.0.1:8000/api/clubs/', { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", }, body: JSON.stringify(club), }) .then((response) => { return response.json(); }) .catch((error) => console.log(error)); }; On the backend part it's just serializer: class ClubSerializer(serializers.ModelSerializer): class Meta: model = Club fields = 'id', 'owner', 'name' And viewset: class ClubViewSet(viewsets.ModelViewSet): queryset = Club.objects.all() serializer_class = ClubSerializer So as I said it gives me 401 Unauthorized error, I use basically the same … -
there is short api of loan calculator python code executed but the value of MonPayment is not showing on front end plzzz check the code below
this is the html file {% csrf_token %} Enter Years Enterest rate Enter Amount <button type='submit' class="btn btn-primary">calculate</button> <input type='text' value="{{MonPayment}}" class="form-control"> </form> my views.py is below def calculator(request): try: if request.method=='POST': year=eval(request.POST.get('year')) print(year) rate=eval(request.POST.get('rate')) print(rate) principal=eval(request.POST.get('Principal')) print(principal) year=year*12 rate=(rate/100)/12 MonPayment=(rate*principal*((1+rate)**year)-1) print(MonPayment) context={''} context={'rates' :'rate', 'years': 'year', 'Principal': 'principal'} except: MonPayment='invalid operation...' return render(request, 'calculator.html',context) -
Custom lookup in Django (filter parameter different type than field type)
I have a simple model in Django. class Books(models.Model): title = models.CharField(max_length=255) page_size = models.IntegerField(null=True) An example instance of this model may look like this: ("Alice's Adventures in Wonderland", 70). I would like to create a lookup which would allow users to filter the books by page sizes in the following form if the user types (inside the filter box) >n Django filter would return only books which have more pages than n, if the user types <n Django filter would return only books with less pages than n. To sum up I would need a lookup __cmp which would be capable of joining the queryset before executing it. So I would like to have an if-else block implemented somewhere inside. filter_param, value = filter_param, filter_value = list(user_filter) if filter_param == ">": qr = Books.objects.filter(page_size__gt=n) else: qr = Books.objects.filter(page_size__lt=n) Is it possible to create a custom lookup which would implement such logic? -
datetimefield only show time in html template
I have a datetime field but in the html code I would like to show only the time, how can I do? I tried {{ data|time }}, {{ value|time:"H:i" }} but nothing views from django.shortcuts import render from .models import Count import datetime # Create your views here. def contatore(request): settaggio = Count.objects.get(attivo = True) data = settaggio.data.strftime("%m %d, %Y %H:%M:%S") context = {'data':data} return render(request, 'count.html', context) models class Count(models.Model): data = models.DateTimeField() html <h5 style="color: #fff">{{ data }}</h5> -
How to dockerize Django project already created in anaconda?
I have a Django application that is already created and running in anaconda, now I want it to be dockerized, can you please help me so that I can dockerize my Django project. -
Custom TruncFunc in Django ORM
I have a Django model with the following structure: class BBPerformance(models.Model): marketcap_change = models.FloatField(verbose_name="marketcap change", null=True, blank=True) bb_change = models.FloatField(verbose_name="bestbuy change", null=True, blank=True) created_at = models.DateTimeField(verbose_name="created at", auto_now_add=True) updated_at = models.DateTimeField(verbose_name="updated at", auto_now=True) I would like to have an Avg aggregate function on objects for every 3 days. for example I write a queryset that do this aggregation for each day or with sth like TruncDay function. queryset = BBPerformance.objects.annotate(day=TruncDay('created_at')).values('day').annotate(marketcap_avg=Avg('marketcap_change'),bb_avg=Avg('bb_change') How can I have a queryset of the aggregated value objects for each 3-days interval with the index of the second day of that interval? -
Want to upload an image using a custom upload image function python djano
This is my custom image upload function def upload_image(file, dir_name, filename): try: target_path = '/static/images/' + dir_name + '/' + filename path = storage.save(target_path, file) return storage.url(path) except Exception as e: print(e) and this is my model class MenuOptions(models.Model): name = models.CharField(max_length=500, null=False) description = models.CharField(max_length=500, null=True) image_url = models.ImageField(upload_to=upload_image()) def __str__(self): return f'{self.name}' I want to upload the image using my upload_image function, and as you can see it is taking 3 parameters file,dir_name, and the file_name. how can I pass these parameters in my model.ImageField() Also, I want to store the image_url to my database as returned by the upload_image function will it store the file in DB or the URL? -
Heroku Django request.POST giving wrong values
I have deployed an app in heroku build using django.In my django views.py iam getting some value using request.POST and storing in a global variable so that i can access that value in another function which is then rendered into the template. Eveything worked fine on devolopment server but when i deployed it on heruko,request.POST is not retriving the correct value. views.py: serv='--' def home(request): global serv if request.method=='POST': dayCheck.clear() serv=request.POST['service'] return HttpResponseRedirect('func') def func(request): global serv #Doing something,does not involve serv return render(request,'index.html',{'service':serv}) When i try to log serv in home() it gives correct value but different value in func and the same is rendered,mostly it will be value which i previously clicked or sometimes it would be just -- as declared. Please help me! Thanks in Advance -
mysql 8 gives error on creating table ( running migrate command in django )
Django3.2 mysql 5.7 I have a model name BlackboardLearnerAssessmentDataTransmissionAudit and its length is 48 characters and it has 1 not null field. On mysql5.7 it is working fine. But when try to upgrade with mysql8+ migrations throws error Identifier name is too long. This model generates following name in mysql8.5 blackboard_blackboardlearnerassessmentdatatransmissionaudit_chk_1 it has 65 characters. mysql8 limit info I have a question what are the possible solutions to fix this issue on mysql8 ? -
dot line graph in django with mysql
Thanks in Advance...! Query: I want to display my graph in a card. The graph must look like enter image description here but i am unable to design this... as this graph must be dynamic with Django and mysql. my models.py file is: class JaAiPredictions(models.Model): project_management_id = models.IntegerField(blank=True, null=True) date = models.DateField(blank=True, null=True) ecommerce_users = models.FloatField(blank=True, null=True) total_revenue = models.FloatField(blank=True, null=True) conversion_rate = models.FloatField(blank=True, null=True) total_transactions = models.IntegerField(blank=True, null=True) avg_order_value = models.FloatField(blank=True, null=True) total_ads_clicks = models.IntegerField(blank=True, null=True) total_ads_cost = models.FloatField(blank=True, null=True) ads_cpc_value = models.FloatField(blank=True, null=True) mcf_conversion = models.FloatField(blank=True, null=True) mcf_conversion_value = models.FloatField(blank=True, null=True) mcf_assisted_conversion = models.FloatField(blank=True, null=True) mcf_assisted_value = models.FloatField(blank=True, null=True) social_facebook_clicks = models.IntegerField(blank=True, null=True) social_twitter_clicks = models.IntegerField(blank=True, null=True) social_pinterest_clicks = models.IntegerField(blank=True, null=True) social_instagram_clicks = models.IntegerField(blank=True, null=True) new_visitors = models.IntegerField(blank=True, null=True) returning_visitors = models.IntegerField(blank=True, null=True) total_users = models.IntegerField(blank=True, null=True) total_pageviews = models.IntegerField(blank=True, null=True) bounce_rate = models.FloatField(blank=True, null=True) total_sessions = models.IntegerField(blank=True, null=True) session_duration = models.IntegerField(blank=True, null=True) session_by_desktop = models.FloatField(blank=True, null=True) session_by_tablet = models.FloatField(blank=True, null=True) session_by_mobile = models.FloatField(blank=True, null=True) total_mobile_users = models.IntegerField(blank=True, null=True) total_desktop_users = models.IntegerField(blank=True, null=True) total_tablet_users = models.IntegerField(blank=True, null=True) total_paid_pageviews = models.IntegerField(blank=True, null=True) total_paid_users = models.IntegerField(blank=True, null=True) total_referral_pageviews = models.IntegerField(blank=True, null=True) total_referral_users = models.IntegerField(blank=True, null=True) total_organic_pageviews = models.IntegerField(blank=True, null=True) total_organic_users = models.IntegerField(blank=True, null=True) total_direct_pageviews = models.IntegerField(blank=True, null=True) total_direct_users = models.IntegerField(blank=True, … -
How to assign value? [closed]
In my project I have A class of choices: class ServiceChoices(models.IntegerChoices): WASHING_OUTSIDE_WINDOWS = 1 HEATING = 2 I want to add the following choices: MAINTENANCE_HEAtING_INSTALLATION/AUTOMATIC_DOOR(24_HOUR_SERVICE) = 4 I am getting an error when I am using () and the / is there any way to do it. Thanks in advance! -
Celery/django - chunk tasks
I have a lot of tasks that are being generated that I would like to group in to chunks, but I think in the opposite way as Celery does. From my understanding, I can use the chunks feature to split up a list of items when I create the task. I would like to do the opposite. The data I have is being produced one at a time from different endpoints. But I would like to process them in chunks so that I can insert them in to a database in single transactions. So essentially I'd like to add items to a queue 1 at a time, and dequeue them 100 at a time (either at some specified time interval or once the queue reaches a certain level) and use a transaction to insert all of them in to a database. This would save me from Is this possible with celery? Would it be easier to drop down to redis and create a custom queue there? -
python - Django Operational Error, No such table
I am learning django and I really can't solve this error, I tried modifying every file but I can't find where the issue is. Error: OperationalError at /topics/ no such table: pizzas_topic I have to mention that this exercise is from Python Crash Course 2nd Edition Thanks Here is the code from my project: base.html: <p> <a href="{% url 'pizzas:index' %}">Pizzeria</a> - <a href="{% url 'pizzas:topics' %}">Pizzas</a> </p> {% block content %}{% endblock content %} index.html {% extends "pizzas/base.html"%} {% block content %} <p>Pizzeria</p> <p>Hi</p> {% endblock content%} topic.html {% extends 'pizzas/base.html' %} {% block content %} <p>Topic: {{topic}}</p> <p>Entries:</p> <ul> {% for entry in entries %} <li> <p>{{entry.date_added|date:'M d, Y H:i'}}</p> <p>{{entry.text|linebreaks}}</p> </li> {% empty %} <li>There are no entries for this topic yet.</li> {% endfor %} </ul> {% endblock content %} topics.html {% extends "pizzas/base.html" %} {% block content %} <p> Topics</p> <ul> {% for topic in topics %} <li> <a href="{% url 'pizzas:topic' topic.id %}">{{ topic }}</a> </li> {% empty %} <li>No topics have been addet yet.</li> {% endfor %} </ul> {% endblock content %} urls.py """Defines URL patterns for pizzeria.""" from django.urls import path from . import views app_name = 'pizzas' urlpatterns = [ # Home … -
How to pass Serizalizer Fields to front-end Framework from RESTful API - DRF (Django)?
I want to use Svelte in the front-end and DRF (Django) in the back-end. This is what I have right now: #models.py class Student(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) # serializers.py class StudentSerializer(serializers.ModelSerializer): class Meta: model = Student fields = "__all__" But when I know want to create a form in the front-end (Svelte) I have to manually do that? Is there a way of requesting a json with all the required fields and the to build a form around it. Like first I request api.com/students/form wich returns a json: { "fields":[ "first_name", "last_name" ] } And then I could just iterate over the fields in "fields" and create <input> tags for the form acordingly. -
Django: How to get parameters used in filter() from a QuerySet?
For the following QuerySet, qs = MyModel.objects.filter(attribute_one='value 1', attribute_two='value 2') How can I retrieve the parameters used in the filter (i.e. attribute_one and attribute_two) and the corresponding values (i.e. value 1 and value 2) from qs? Thank you! -
API call interation store each response
I have a list of items that I pass into an API call for each item and return a response for each one. For each response, I extract the values I want. The list of items will grow over time. How do I collect the response of each call and reference that in the template? for item in tokens: data = cg.get_coin_by_id(item.token_slug) price = (data['market_data']['current_price']['usd']) symbol = (data['symbol']) day_change_percentage = (data['market_data']['price_change_percentage_24h']) logo = (data['image']['small']) I have been adding each value to the database so that I can reference the values using query set using tokens = profile.tokens.all() and then using {% for token in tokens%} ... , but I don't really need to be storing this long-term. Thanks -
Python: SystemError: null argument to internal routine
After installation of python packages I am running into below error. It doesn't give any idea what is doing wrong. garg10may@DESKTOP-TVRLQTQ MINGW64 /e/coding/github/product-factory-composer/backend ((bf13ffe...)) $ python manage.py migrate Traceback (most recent call last): File "E:\coding\github\product-factory-composer\backend\manage.py", line 22, in <module> main() File "E:\coding\github\product-factory-composer\backend\manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Python310\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\Python310\lib\site-packages\django\core\management\__init__.py", line 377, in execute django.setup() File "C:\Python310\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Python310\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\Python310\lib\site-packages\django\apps\config.py", line 90, in create module = import_module(entry) File "C:\Python310\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "<e:\coding\github\product-factory-composer\backend\src\core-utils\src\core_utils\__init__.py>", line 3, in <module> File "<frozen core_utils>", line 6, in <module> SystemError: null argument to internal routine -
how to display multiple videos in django
Here code is working fine but I want to display multiple videos. Here only displaying one video. when Uploading second video, second video file is storing but it is not displaying. Please help me out to solve this. Please. views.py: def showvideo(request): lastvideo= Video.objects.all() form= VideoForm(request.POST or None, request.FILES or None) if form.is_valid(): form.save() context= {'lastvideo': lastvideo, 'form': form } return render(request, 'master/video.html', context) forms.py: class VideoForm(forms.ModelForm): class Meta: model= Video fields= ["name", "videofile"] models.py: class Video(models.Model): name= models.CharField(max_length=500) videofile= models.FileField(upload_to='videos/', null=True, verbose_name="") def __str__(self): return self.name + ": " + str(self.videofile) video.html: <html> <head> <meta charset="UTF-8"> <title>Upload Videos</title> </head> <body> <h1>Video Uploader</h1> <form enctype="multipart/form-data" method="post" action=""> {% csrf_token %} {{ form.as_p }} <input type="submit" value="Upload"/> </form> <br><br> <video width='400' controls> <source src='{{videofile.url}}' type='video/mp4'> Your browser does not support the video tag. </video> <br><br> </p> </body> <script>'undefined'=== typeof _trfq || (window._trfq = []);'undefined'=== typeof _trfd && (window._trfd=[]),_trfd.push({'tccl.baseHost':'secureserver.net'}),_trfd.push({'ap':'cpbh-mt'},{'server':'p3plmcpnl487010'},{'id':'8437534'}) // Monitoring performance to make your website faster. If you want to opt-out, please contact web hosting support.</script> <script src='https://img1.wsimg.com/tcc/tcc_l.combined.1.0.6.min.js'></script> </html> urls.py: path('videos/',views.showvideo,name='showvideo'), -
Could not parse the remainder: '(audio_only=True)'
in my templates/videos.html, <div class="grid grid-cols-3 gap-2"> {% for vid in videos.streams.filter(audio_only=True) %} <a href="{{vid.url}}">{{vid.resolution}}</a> {% endfor %} </div> Error is, Could not parse the remainder: '(audio_only=True)' from 'videos.streams.filter(audio_only=True)' I can solve this when i pass all_videos = videos.streams.filter(audio_only=True) from my views.py as context, and in templates/videos.html i replace videos.streams.filter(audio_only=True) with all_videos, but I want to know that is there any other method to solve this -
Sentry is working on local but not working in server
I'm troubled with the sentry, I configured sentry in my Django application it's working fine and an error arrives in sentry UI from localhost, but in the same case, I run from the server it's not working, and no error arrives into sentry UI. DEBUG=False ALLOWED_HOSTS = ["*"] sentry_sdk.init( dsn="https://sentry-url", integrations=[DjangoIntegration(), CeleryIntegration(), RedisIntegration()], # Set traces_sample_rate to 1.0 to capture 100% # of transactions for performance monitoring. # We recommend adjusting this value in production. traces_sample_rate=1.0, # If you wish to associate users to errors (assuming you are using # django.contrib.auth) you may enable sending PII data. send_default_pii=True, ) -
Not correct scope for accessing events
HttpError at /calendar <HttpError 403 when requesting https://www.googleapis.com/calendar/v3/calendars/primary/events?singleEvents=true&orderBy=startTime&alt=json returned "Request had insufficient authentication scopes.". Details: "[{'message': 'Insufficient Permission', 'domain': 'global', 'reason': 'insufficientPermissions'}]"> Request Method: GET Request URL: http://localhost:8000/calendar Django Version: 3.2.9 Exception Type: HttpError Exception Value: Then does this after a while RefreshError at /calendar The credentials do not contain the necessary fields need to refresh the access token. You must specify refresh_token, token_uri, client_id, and client_secret. It seems I don't possess the right scope when accessing the calendar and it seems currently the access_token does appear. from google.oauth2.credentials import Credentials def get_user_events(request): credentials = Credentials(get_access_token(request), scopes=SCOPES) service = googleapiclient.discovery.build('calendar', 'v3', credentials=credentials) google_calendar_events = service.events().list(calendarId='primary', singleEvents=True, orderBy='startTime').execute() google_calendar_events = google_calendar_events.get('items', []) return google_calendar_events def get_access_token(request): social = request.user.social_auth.get(provider='google-oauth2') return social.extra_data['access_token'] -
attach domain name with lightsail instense and django
I have created static ip in lightsail and attached it to the django instanse. I bought domain name from godaddy. I then created domain zone in lightsail and created 2 DNS records type "A" with the following: @.drmahahabib.com www.drmahahabib.com Then i copied the name servers from the same page for my lightsail then took that to godaddy site and changed the name servers there. Now i get the page that confirms that the lightsail is working but not the site instense of django. do i need to do some modification? below is the screenshot or just visit the webpage. my site -
how go through and see the library source code
hello friends i code django and python in pycharm for a company .i have 2 project in one of them i can see the source code of django and django rest framework with "command + mose over" and in another one it doesnt work with django and other libraries except my code and python source code. i mean i can see the source of os in "import os " but i cant see and go through the for example "from rest_framework import authentication".... the senior tell me maybe the place of the env file ....I do not know what to do? can anyone help me ? this is the location of my "venv" and "bime" is the name of the project place of env and project -
django admin The outermost 'atomic' block cannot use savepoint = False when autocommit is off
When I try to delete an item from a table generated by django admin, it throws this error Environment: Request Method: POST Request URL: http://127.0.0.1:8000/admin/sybase_app/packageweight/?q=493 Django Version: 1.8 Python Version: 3.6.9 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog', 'sybase_app') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware') Traceback: File "/home/pd/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in get_response 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/pd/.local/lib/python3.6/site-packages/django/contrib/admin/options.py" in wrapper 616. return self.admin_site.admin_view(view)(*args, **kwargs) File "/home/pd/.local/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view 110. response = view_func(request, *args, **kwargs) File "/home/pd/.local/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs) File "/home/pd/.local/lib/python3.6/site-packages/django/contrib/admin/sites.py" in inner 233. return view(request, *args, **kwargs) File "/home/pd/.local/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper 34. return bound_func(*args, **kwargs) File "/home/pd/.local/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view 110. response = view_func(request, *args, **kwargs) File "/home/pd/.local/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func 30. return func.__get__(self, type(self))(*args2, **kwargs2) File "/home/pd/.local/lib/python3.6/site-packages/django/contrib/admin/options.py" in changelist_view 1590. response = self.response_action(request, queryset=cl.get_queryset(request)) File "/home/pd/.local/lib/python3.6/site-packages/django/contrib/admin/options.py" in response_action 1333. response = func(self, request, queryset) File "/home/pd/.local/lib/python3.6/site-packages/django/contrib/admin/actions.py" in delete_selected 49. queryset.delete() File "/home/pd/.local/lib/python3.6/site-packages/django/db/models/query.py" in delete 537. collector.delete() File "/home/pd/.local/lib/python3.6/site-packages/django/db/models/deletion.py" in delete 282. with transaction.atomic(using=self.using, savepoint=False): File "/home/pd/.local/lib/python3.6/site-packages/django/db/transaction.py" in __enter__ 164. "The outermost 'atomic' block cannot use " Exception Type: TransactionManagementError at /admin/sybase_app/packageweight/ Exception Value: The outermost 'atomic' block cannot use savepoint = False when autocommit is off. How can I …