Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
"<VariationPrice>" needs to have a value for field "id" before this many-to-many relationship can be used
I have this model in my django code. I want to check whether VariationPrice for a product with the variations exist. If it exists, make changes to the already existing VariationPrice else save the new VariationPrice. The error I'm getting with the existing code is "<VariationPrice: >" needs to have a value for field "id" before this many-to-many relationship can be used. class Product(models.Model): .... product_name = models.CharField(max_length=200, unique=True) class Variation(models.Model): .... variation_value = models.CharField(max_length=100) class VariationPrice(models.Model): price = models.IntegerField() product = models.ForeignKey(Product, on_delete=models.CASCADE) variations = models.ManyToManyField(Variation, blank=True) def __str__(self): if self.pk is not None: return ", ".join(str(var) for var in self.variations.all()) else: return '' def save(self, *args, **kwargs): if self.pk is None: var_list = [i['variation_value'] for i in self.variations.values()] vprice = VariationPrice.objects.filter(product=product,variations__variation_value__in=var_list).annotate(num_attr=Count('variations__variation_value')).filter(num_attr=len(var_list)) if vprice.exists(): self.pk = vprice.first().pk super(VariationPrice, self).save(*args, **kwargs) -
How to print elements of list of an unknown number of zipped lists in Djanto templates
a = [1,2,3,4,5] b = [[3,4],[4,5],[6,7]] out = [[x if x in l else 'X' for x in a] for l in map(set, b)] z = zip(a,*out) In above code the list a will have fix number of elements but list b will be varying, hence elements in z will vary as well. Now in Django template I would Like to print the elements of z. What I tried for above scenario is {% for d,s1,s2,s3 in z %} <tr> <td> {{d}} </td> <td> {{s1}} </td> <td> {{s2}} </td> <td> {{s3}} </td> </tr> {% endfor %} Which works fine if I know the number of elements present in the z; but unfortunately it's varying. Sometimes it could have 10 lists , sometimes nothing. Sometimes the scenario will be like below: {% for d,s1 in z %} <tr> <td> {{d}} </td> <td> {{s1}} </td> </tr> {% endfor %} So How can I correct above template code to print variable number of list elements in the table? Thanks. -
Django tutorial throws ImportError if importing the model from commandline python
Given the exact code from the tutorial part Creating models polls/models.py from django.db import models class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0) Why can't I from .models import Question? [polls]$ python Python 3.8.12 (default, Dec 4 2021, 10:54:00) [GCC 11.1.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from .models import Question Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: attempted relative import with no known parent package Otherweise the tutorial works fine so yes _init_.py exists in the polls directory (created by the django tutorial). None of the many related questions have helped me, thus please don't close as duplicate. -
Django: Object of type Profile is not JSON serializable
I have a model called Order, Profile and Users. In my Order model, i want to access the Profile of the buyer and seller, so i wrote a function in the Order model to get the profile of the buyer and the seller. class Orders(models.Model): service = models.ForeignKey(Service, on_delete=models.SET_NULL, null=True, related_name="service_orders") seller = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name="seller") buyer = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, related_name="buyer") ... def seller_profile(self): seller_profile = Profile.objects.get(user=self.seller) return seller_profile def buyer_profile(self): buyer_profile = Profile.objects.get(user=self.buyer) return buyer_profile Now when i add the seller_profile and buyer_profile in my OrderSerializer in serializer.py, and try accessing the api endpoint in the browser, it shows the error Object of type Profile is not JSON serializable, Do i need to serialize my Profile Model or something like that? class OrderSerializer(serializers.ModelSerializer): class Meta: model = Orders fields = ['id','seller', 'buyer', 'buyer_profile', 'seller_profile', ...] def __init__(self, *args, **kwargs): super(OrderSerializer, self).__init__(*args, **kwargs) request = self.context.get('request') if request and request.method=='POST': self.Meta.depth = 0 else: self.Meta.depth = 2 I dont have any ProfileSeriallizer, do i need it? -
Django DSL custom analyzer
i made my own custom analyzer, I am using elasticsearch:7.5.2 when i run python manage.py search_index --rebuild the error is raise RedeclaredFieldError( django_elasticsearch_dsl.exceptions.RedeclaredFieldError: You cannot redeclare the field named 'name' on CarDocument class CarDocument(Document): name = fields.TextField(analyzer=ngram_analyzer) class Index: name = 'cars' settings = { 'number_of_shards': 1, 'number_of_replicas': 0, } class Django: model = Car fields = [ 'name' ]``` -
How can two HTML template elements be updated using (HTMX)?
I have a form in which there are three fields, basically these fields contain drop-down lists - selections. These select lists are based on a data model that has fields associated with ForeynKey . After completing this form. I update information, code and do calculations in code. Further after the calculations. I am updating two elements on the template - a table and a graph. I have these two elements in separate parts of the template. Like two different pieces of HTML . With (HTMX) I can only update one element on the table - this element is a chunk of the HTML template - which is updated by rendering that chunk of that template. How can I update another piece of the template? How can two HTML template elements be updated using (HTMX) ? I would be very grateful for any help. -- <div class="row"> <div class="col-6"> <form method="POST" class="post-form"> {% csrf_token %} {{form_1.as_p}} <button type="submit" class="save btn btn-light">Form</button> </form> </div> </div> <div class="row"> <div class="col"> {{ div_1|safe }} {{ script_1|safe }} </div> </div> <div class="row"> <div class="col"> {{ div_2|safe }} {{ script_2|safe }} </div> </div> -- class Form_1(forms.ModelForm): class Meta: model = Model_1 fields = "__all__" -- class … -
Add CSS File to Django Project - Nothing seems to work
I feel kinda tired of this problem right now, and am desperately looking for help. I try to add a main.css file to my django project so I can do the CSS myself. Watched like 8 full tutorials already and 6 of them crashed my project while the other 2 did not work. So please is there anyone who really knows how to do this? This must be a really simple thing i guess? Im stuck on my project for 3 days now, so frustrating. I hope to find a decent explanation of someone who really knows how this works. -
Using stripe.js with dj-stripe
I'm using django and I want to integrate stripe using the abstraction layer dj-stripe. From what I understand from the documentation, ElementJs with Payment Intent is the preferred way to allow users to enter their payment details. see https://dj-stripe.dev/stripe_elements_js/ However, there is no documentation on how to connect dj-stripe with stripe.js. The first step of the usage documentation in dj-stripe already assumes payment methods have been connected (https://dj-stripe.dev/usage/subscribing_customers/). I looked through the code of dj-stripe and it seems to have Payment Intent classes, but I can't figure out how to use them. How can I generate a client secret for customers created in dj-stripe that can then be used in stripe.js? (Or if I'm not on the right path, what should I do instead to allow adding payment details to be used in dj-stripe) -
Possibility to return json or xml In one django function
There is a task in which you need to implement the ability, depending on the url, to transfer data to the user in json or xml format. format is passed to str:typeof path('<str:typeof>/site/<str:domain_name>', ApiInterfaceViewSet.as_view({"post":"site_info"})), The main logic is implemented in the ViewSet class class ApiInterfaceViewSet(ViewSet): read_only = True renderer_classes = (XMLRenderer, JSONRenderer) def site_info(self, request: HttpRequest, typeof: str, domain_name: str, *args, **kwargs): responce = None records = Site.objects.raw("""select * from urlopen_app_site uas where uas.domain_name = %s""", [domain_name]) serializer = SiteSerializer(records[0]) if typeof == 'json': responce = Response(serializer.data, content_type='application/json; charset=utf-8') return responce elif typeof == 'xml': xml_data = XmlRendererSite(records) xml_data = xml_data.formation_xml_site() responce = Response(xml_data.getvalue().decode(encoding="utf-8"), content_type='application/xml; charset=utf-8') return responce an xml transformation factory implemented in the XmlRendererSite class. Manually It would be possible to separate the logic into different classes. in one class return xml, and in another json but it needs to be implemented in one function The problem I am facing is how to implement this idea. Explicitly specifying the content type does not help. The XML is returned as a string. response.media_type = "application/xml" doesn't help. I broke my head. I miss something important or get confused in simple things separating logic into different classes works correctly, but … -
How to solve SMTP Recipient Refused error
I had set app password in EMAIL_PASSWORD but i am getting this error smtp RecipientsRefused.The entered gmail ids are correct. I have followed all mentioned procedures in app password generation i don't know what is the cause of the error -
I can't use try-except in django
I have problem in try-except The file is views.py function 'noun_check' return nouns of the sentence that I received from contenct.para(=input) If there is no noun in the sentence than function 'noun_check' return error If the error occur, go to except and return(request, 'main/desktop.html'), and receive another sentence. And If I got nouns, I return render(request, 'main/introduction.html', context). This is the way I thought. But error occured in function 'noun_check', logic doesnt' go to except, and return render(request, 'main/introduction.html', context) Could you explain why try-except doesn't work? def submit(request): if request.method == 'POST' and request.POST['input'] != '': try: content = Diary_content() content.para = request.POST['diary_input'] tokenized_nouns = noun_check(content.para) context = {'para' : content.para, 'emotions':tokenized_nouns} return render(request, 'main/introduction.html', context) except: return render(request, 'main/desktop.html') I seperate the function, and made function if error occur return False And use temp = function(sentence) \n if temp == 0: ... Althogh 'temp == 0' is True, logic doesn't go under 'if function' -
Django admin prefetch_related
I have django models organized like this: class Filmwork(UUIDMixin, TimeStampedMixin): ... class Genre(UUIDMixin, TimeStampedMixin): ... class GenreFilmwork(UUIDMixin): film_work = models.ForeignKey(Filmwork, on_delete=models.CASCADE) genre = models.ForeignKey(Genre, on_delete=models.CASCADE) How can i get prefetch all genres of filmwork in django admin using prefetch_related? I'm trying like this: @admin.register(Filmwork) class FilmworkAdmin(admin.ModelAdmin): list_display = ('title', 'type', 'get_genres', 'creation_date', 'rating', 'created', 'modified') list_prefetch_related = ( ??????? ) def get_queryset(self, request): queryset = ( super() .get_queryset(request) .prefetch_related(*self.list_prefetch_related) ) return queryset def get_genres(self, obj): return ','.join([genre.name for genre in obj.genres.all()]) -
why docxtpl jinja annotate doesnt work with postgrsql?
i ve created a view to generate a doc with docxtpl, for this i use this view bellow but the annotate with FLoatfield doesnt work, can you help me please ? def postACD(request, id): Raison_sociale = Client.objects.filter(id=id).values_list('Raison_sociale',flat=True).annotate(Raison_sociale_as_float=Cast('Raison_sociale', output_field=FloatField())).get() byte_io = BytesIO() tpl = DocxTemplate(os.path.join(settings.MEDIA_ROOT, 'ACD.docx')) context = {} context['Raison_sociale'] = Raison_sociale tpl.render(context) tpl.save(byte_io) byte_io.seek(0) return FileResponse(byte_io, as_attachment=True, filename=f'ACD{id}.docx') you can see the message error : enter image description here i try many solutions but nothing -
PostgreSQL port ignored when starting Django runserver
I can’t understand, i start the server locally with the POSTGRES_PORT=5432 value, but when i runs the django runserver command it still starts locally on port 8000. What is the problem? -
Objects.filter(id__in=[ids]) "Field 'id' expected a number but got 1,2" JavaScript and Django
Im tring to set categories for my post without a form, with javascript template: <form enctype="multipart/form-data" method="POST" action="" accept=".mp4" style="text-align: center;"> {% csrf_token %} <p style="color: gray; padding-top: 20px;">or</p> <select name="" id="ms" multiple="multiple"> {% for category in categories%} <!-- <option type="checkbox" value="{{category}}">{{category}}</option> --> <input id="category" class="category" catid="{{category.id}}" type="checkbox" value="{{category.id}}">{{category}}</input> {% endfor %} </select> <input type="text" name="title" id="title" placeholder="Title"> <input type="text" name="tags" id="tags" placeholder="Tags: Please separate by comma ','"> <textarea name="description" id="description" cols="30" rows="10" placeholder="Please describe your video..."></textarea> <div class="form-group"> <label>Select file to upload.</label> <input type="file" name="file" accept=".mp4" class="form-control" id="fileupload" placeholder="Select file"> </div> <input type="submit" value="Upload" id="submit" class="btn btn-success"> </form> js: var id_categories = []; var category = document.querySelectorAll("input[type=checkbox]:checked") for (var i = 0; i < category.length; i++) { id_categories.push(category[i].value) } var formData = new FormData(); formData.append('categories', id_categories) in my views: categories_1 = Category.objects.all() if request.method == 'POST': categories = request.POST['categories'] FileFolder.save() tag_list = taggit.utils._parse_tags(tags) FileFolder.tags.add(*tag_list) categories_post = Category.objects.filter(id__in=[categories]) if categories_post: for category in categories_post: FileFolder.categories.add(category) return render(request, 'main/create_post.html', {'categories': categories_1}) It returns : ValueError: Field 'id' expected a number but got '3,4'. but when i type manually [3,4], it works, any ideas? -
Is there a way to make a django account section where we can send otp and put it in the same page to register user?
I need a code which can send an otp then a column to put otp will apear and then we can put the otp in the field to create an account. Like i need to send, and apply otp to create account in the same page without changeing link or html? or atleast just dont change the link??? I want view, html, and url if it is needed. I tried many ways i cant get to an answer All i can get was a way where i can use multiple urls, view and link to get it but i dont want to make multiple views, link and urls -
Is it possible to have unique together but in an order
I would like to know if it's possible to have unique together for two fields but in order so the following would raise an error if it already exists seller = user1 buyer = user2 but this will go through because the order is different seller = user2 buyer = user1 Is there a way in Django to make this happen that the order of the fields determine uniqueness -
Django star rating stars not changing color
I'm trying to make a star rating in django, but none of the hover settings are working because of how the html code is arranged. The problem is that there's no selector for if the input field is checked, make the label change colors since the input field is IN the label. does anyone know how to make this work? HTML <div id="star"> <div> <label for="star_0"> <input type="radio" name="rating" value="1" id="star_0"> </label> </div> <div> <label for="star_1"> <input type="radio" name="rating" value="2" id="star_1"> </label> </div> <div> <label for="star_2"> <input type="radio" name="rating" value="3" id="star_2"> </label> </div> <div> <label for="star_3"> <input type="radio" name="rating" value="4" id="star_3"> </label> </div> <div> <label for="star_4"> <input type="radio" name="rating" value="5" id="star_4"> </label> </div> </div> CSS #star div { display: inline-block; } #star input { display: inline-block; box-shadow: none; width: 20px; margin: 5px; } #star label { display: block; width: 45px; } #star label::before { content: '★ '; font-size: 50px; } #star > input:checked ~ label { background: radial-gradient( 30% 200% at 50% top, #ff9a48, #b15408 ); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } #star div:not(:checked) > label:hover { background: radial-gradient( 30% 200% at 50% top, #ff9a48, #b15408 ); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } #star > input:checked ~ label:hover, #star > input:checked + … -
Reverse for 'PostDetail' not found. 'PostDetail' is not a valid view function or pattern name
I have two different views: one to render post and another one to render comments in those post. When I tried to redirect the post view from the comment view I am getting a error NoReverseMatch at /3/create Reverse for 'PostDetail' not found. 'PostDetail' is not a valid view function or pattern name. Request Method: POST Request URL: http://localhost:8000/3/create Django Version: 4.1.2 Exception Type: NoReverseMatch Exception Value: Reverse for 'PostDetail' not found. 'PostDetail' is not a valid view function or pattern name. Exception Location: /workspace/.pip-modules/lib/python3.8/site-packages/django/urls/resolvers.py, line 828, in _reverse_with_prefix Raised during: website.views.createComment Python Executable: /home/gitpod/.pyenv/versions/3.8.11/bin/python3 Python Version: 3.8.11 Python Path: ['/workspace/RaizalDuo', '/home/gitpod/.pyenv/versions/3.8.11/lib/python38.zip', '/home/gitpod/.pyenv/versions/3.8.11/lib/python3.8', '/home/gitpod/.pyenv/versions/3.8.11/lib/python3.8/lib-dynload', '/workspace/.pip-modules/lib/python3.8/site-packages', '/home/gitpod/.pyenv/versions/3.8.11/lib/python3.8/site-packages'] Server time: Sun, 12 Feb 2023 07:55:21 +0000 Traceback Switch to copy-and-paste view /workspace/.pip-modules/lib/python3.8/site-packages/django/core/handlers/exception.py, line 55, in inner response = get_response(request) … Local vars /workspace/.pip-modules/lib/python3.8/site-packages/django/core/handlers/base.py, line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) … Local vars /workspace/.pip-modules/lib/python3.8/site-packages/django/contrib/auth/decorators.py, line 23, in _wrapped_view return view_func(request, *args, **kwargs) … Local vars /workspace/RaizalDuo/website/views.py, line 51, in createComment return redirect('PostDetail', newComment.post.id I am trying to see the comment made in the post_details. html -
Filter returns many more objects
I have two models: class PhotoAlbum(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, auto_created=True) name = models.CharField(max_length=50, verbose_name='Pet name') class AlbumImage(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, auto_created=True) album = models.ForeignKey(PhotoAlbum, on_delete=models.CASCADE, related_name='photos') image = models.ImageField(upload_to='images/', height_field=None, width_field=None, max_length=100, blank=True) When i send GET request without query parameters i see a normal response like (one random entry): [ { "id": 1, "name": "Album name", "photos": [ { "id": 2, "url": "http://localhost:8000/media/random_image_one.png" }, { "id": 3, "url": "http://localhost:8000/media/random_image_two.png" } ] } ] And there is a problem! When i overrided the method get_query_set like: isnull_filter = {'true': False, 'false': True} has_photos = self.request.query_params.get('has_photos') return PhotoAlbum.objects.filter(photos__isnull=isnull_filter[has_photos]) I see the response like: [ { "id": 1, "name": "Album name", "photos": [ { "id": 2, "url": "http://localhost:8000/media/random_image_one.png" }, { "id": 3, "url": "http://localhost:8000/media/random_image_two.png" } ] }, { "id": 1, "name": "Album name", "photos": [ { "id": 2, "url": "http://localhost:8000/media/random_image_one.png" }, { "id": 3, "url": "http://localhost:8000/media/random_image_two.png" } ] } ] It returns one entry for each photo object in photos. So if, the photo album has 10 associated AlbumImage objects in photos it returns 10 similar entries instead of 1. What i did wrong? -
How to wait for loading data in function Quart
I have Quart App with Telegram Telethon, I have a function that returns some data, but the function takes 10-300 seconds. Is there any way to return the page and then wait for the function's data? QuartApp code: @app.route("/exporter", methods=["GET", "POST"]) async def exporter(): all_data = [] for i in data: doingsomething here then append the data return await render_template('mypage.html', user_data=all_data) And here is the HTML code: <tbody> {% for data in user_data %} <tr> <td>{{ data[0] }}</td> <td>{{ data[1] }}</td> <td>{{ data[2] }}</td> <td>{{ data[3] }}</td> <td> <div class="form-check d-flex justify-content-center"> <input class="form-check-input" type="radio" name="flexRadioDefault" value="flexRadioDefault-{{data[2]}}"></div> </td> </tr> {% endfor %} </tbody> I'm expecting to load the page while function the doing something in the background -
Django Cookie Cutter - postgres not found
I'm following the book, "A Wedge of Django," and it uses the Cookiecutter template framework. It says to check if postgres is running by entering pg_isready into the command line. But pg_isready gives an error and postgres -V also gives an error, so it seems that postgres isn't installed or configured properly as it should be. I've walked through each step in the book (chapter 19.3.3) and can't find that I'm missing any instructions. I seem to be in the proper directory. I can't move forward if I can't get postgres running. Any help is appreciated. (everycheese) joshp@joshs-mbp-2 everycheese % pg_isready zsh: command not found: pg_isready (everycheese) joshp@joshs-mbp-2 everycheese % postgres -V zsh: command not found: postgres (everycheese) joshp@joshs-mbp-2 everycheese % ls CONTRIBUTORS.md env.sample.windows requirements COPYING everycheese requirements.txt README.md locale setup.cfg config manage.py env.sample.mac_or_linux pytest.ini -
ModuleNotFoundError - from .local_settings import *; Django
Rather than using environmental variables to hide sensitive information, such as, SECRET_KEY, I'm using a module called local_settings.py since the file is ignored by gitignore. Private settings in Django and Deployment Within settings.py, I imported the module as from .local_settings import * I'm using PythonAnywhere as the means of deploying my website yet when python manage.py collectstatic is executed in its console the following error is raised: from .local_settings import * ModuleNotFoundError: No module named 'stackoverflow_clone.local_settings' Is this error occuring because local_settings.py is being treated as if it doesn't exist at all? How can the error be resolved so that configuration such as SECRET_KEY can be imported? This directory structure reflects what's on my local machine. -
django reverse foreign key pefetch related, queryset condition not working
Consider the following condition: class Book(models.Model): name = models.CharField(max_length=300) price = models.IntegerField(default=0) def __str__(self): return self.name class Store(models.Model): name = models.CharField(max_length=300) default = models.BooleanField(default=False) books = models.ForeignKey(Book, on_delete=models.CASCADE) So, for this query: Book.objects.prefetch_related(Prefetch('store_set', queryset=Store.objects.filter(default=False))) .values("store__name", "name", "store__default") The SQL query is not considering queryset default=True condition SELECT "core_store"."name", "core_book"."name", "core_store"."default" FROM "core_book" LEFT OUTER JOIN "core_store" ON ("core_book"."id" = "core_store"."books_id") Result: <QuerySet [{'store__name': 'Subway Store', 'name': 'Hello', 'store__default': False}, {'store__name': 'Times Square', 'name': 'Hello', 'store__default': False}, {'store__name': 'Subway Store', 'name': 'GoodBye', 'store__default': True}, {'store__name': 'Times Square', 'name': 'GoodBye', 'store__default': False}, {'store__name': 'Subway Store', 'name': 'Greetings', 'store__default': True}, {'store__name': 'Subway Store', 'name': 'HateWords', 'store__default': False}]> I want to have a query set condition while prefetching the query. I am not able to find any way to do it in one query or a minimum number of queries. I was thinking it should make a where condition with the OUTER JOIN with core_store table. Here LEFT OUTER JOIN "core_store" ON ("core_book"."id" = "core_store"."books_id") -
Django - Pulp Optimisation AttributeError: 'str' object has no attribute 'hash'
I am writing a script for pulp Optimisation to engage with my Django database. The problem contains a few thousand variables to be optimised and several hundred constraints which vary depending upon the values of a,b,c. var_names[] var_values{} for _foo_ in list_1: for _bar_ in list_2: for _var_ in list_3: for _eet_ list_4: var_name = str(_foo_)+str(_bar_)+str(_var_)+str(_eet_) var_names.append(var_name) exec(str(_foo_)+str(_bar_)+str(_var_)+str(_eet_) + "= LpVariable("str(_foo_)+str(_bar_)+str(_var_)+str(_eet_)+", lowBound=0, cat='Integer')") var_value = DataBase.objects.get(column_A = str(_foo_)+str(_var_)).value var_values.append(var_value) obj_func = LpAffineExpression([var_names[i],var_values[i] for in in range(len(var_names))]) problem = LpProblem(name="name", sense=LpMinimise) #Example of constraints exec("problem += (" + str(function(a1,b1,c1)_) +str(function(a1,b1,c2)) +" >= Database_2.objects.get(column_A = z1).value") problem += obj_func problem.sovle() The code works in jupyter notebook when I load the database info as a dataframe. However, I keep receiving this following error code when using in Djagno: File "/path/to/files/prob.py", line 1610, in <module> problem.solve() File "/path/to/files/lib/python3.9/site-packages/pulp/pulp.py", line 1913, in solve status = solver.actualSolve(self, **kwargs) File "/path/to/files/lib/python3.9/site-packages/pulp/apis/coin_api.py", line 137, in actualSolve return self.solve_CBC(lp, **kwargs) File "/path/to/files/lib/python3.9/site-packages/pulp/apis/coin_api.py", line 153, in solve_CBC vs, variablesNames, constraintsNames, objectiveName = lp.writeMPS( File "/path/to/files/lib/python3.9/site-packages/pulp/pulp.py", line 1782, in writeMPS return mpslp.writeMPS(self, filename, mpsSense=mpsSense, rename=rename, mip=mip) File "/path/to/files/lib/python3.9/site-packages/pulp/mps_lp.py", line 204, in writeMPS constrNames, varNames, cobj.name = LpProblem.normalisedNames() File "/path/to/files/lib/python3.9/site-packages/pulp/pulp.py", line 1546, in normalisedNames _variables = self.variables() File "/path/to/files/lib/python3.9/site-packages/pulp/pulp.py", line 1624, in …