Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to resolve graphene django node field with Many-to-Many relationship
I get "Received incompatible instance error" when i try to resolve node field with many-to-many relationship. I need help to resolve this issue. I have listed down the models, graphql types in graphene django for reference. Code Version that i use: graphene django version: 2.2.0 python verions: 3.5.2 django version: (2, 0, 8, 'final', 0) models.py --------- class ModelA: name description Class ModelB: model_code description field3 field4 model_links = models.ManyToManyField(ModelA, through='ModelAModelB') class ModelAModelB: model_a = models.ForeignKey('ModelA', null=True, on_delete=models.CASCADE, db_index=False) model_b = models.ForeignKey('ModelB', null=True, on_delete=models.CASCADE, db_index=False) class Meta: #index is defined here Graphene Django: Type Definition --------------- class ModelANode(DjangoObjectType): class Meta: model = ModelA interfaces = (graphene.relay.Node, ) class ModelBNode(DjangoObjectType): modellinks = graphene.Field(ModelANode) class Meta: model = ModelB interfaces = (graphene.relay.Node, ) def resolve_modellinks(self, info, **args): #how do i resolve this field #I tried the below code modelB = ModelB.objects.get(id=self.id) modelaIDs = modelB.modelamodelb_set.select_related('model_a').values_list('model_a_id', flat=True) modelARecs = ModelA.objects.filter(id__in=modelaIDs) return [graphene.relay.Node.get_node_from_global_id( 'ModelANode', info, to_global_id('ModelANode', rec.id) ) for rec in modelARecs] Graphql Call: ------------ allmodelBs { model_code description field3 field4 modellinks { id } } I get the data for Model B fields but the below error is displayed for modellinks: "errors": [ { "message": "Received incompatible instance \"[None, None]\"." }, { "message": "Received … -
using js to serve a logo depending on domain (django) but cannot use static du to %
my current code is the one below, which as if does detect correctly the domain, BUT the % of the static tags are a problem, if i test in in console if (window.location.hostname == 'drlandivar.com'){ document.getElementById('weblogo').src={% static "/home/img/logoENlast.png" %};} SyntaxError: expected property name, got '%' and <script> if (window.location.hostname == 'www.doutorlandivar.com') { document.getElementById('weblogo').src='{\% static "/opt/virtualenv/landivarpj/home/static/home/img/logoPOlast.png" \%}';} else if (window.location.hostname == 'doutorlandivar.com') { document.getElementById('weblogo').src='{\% static "/opt/virtualenv/landivarpj/home/static/home/img/logoPOlast.png" \%}';} else if (window.location.hostname == 'www.doctorlandivar.com') { document.getElementById('weblogo').src='{\% static "/opt/virtualenv/landivarpj/home/static/home/img/logoESlast.png" \%}';} else if (window.location.hostname == 'doctorlandivar.com') { document.getElementById('weblogo').src='{\% static "/opt/virtualenv/landivarpj/home/static/home/img/logoESlast.png" \%}';} else { document.getElementById('weblogo').src='{\% static "/opt/virtualenv/landivarpj/home/static/home/img/logoENlast.png" \%}';} </script> how can i fix that? -
Django models with mongoengine for refernce dynamic forms to field
What is the way to create a model of db connections with required auth. class PsSQLConnectionForm(EmbeddedDocument): host = fields.StringField(max_length=20, required=True, null=False) port = fields.IntField(required=True, null=False, default=5432) username = fields.StringField(max_length=20, required=True, null=False) password = fields.StringField(max_length=20, required=True, null=False) db_name = fields.StringField(max_length=20, required=True, null=False) class ElasticConnectionForm(EmbeddedDocument): host = fields.StringField(max_length=20, required=True, null=False) index = fields.StringField(max_length=20, required=True, null=False) class DBConnection(Document): name = fields.StringField(max_length=10) # form = -
Cannot interpret feed_dict key as Tensor in Tensorflow model used in Django
I have a website to predict rainfall and floods based on several parameters. The app is written in Django and the pre-trained model is just added to the backend to give output based on inputs. model = load_model('Model.h5') optimizer = tf.train.RMSPropOptimizer(0.002) model.compile(loss='mse', optimizer=optimizer, metrics=['accuracy']) pridection = np.array([minitemp,maxitemp,windgust,wind9,wind3,humid9,humid3,pressure9,pressure3,temp9,temp3]) mean = np.array([12.068963,23.009951,37.19739,13.88135,18.25159,67.70561,49.9628,911.645197,909.72206092,16.76982,21.128429]) std = np.array([6.47953722,7.41225215,16.68598056,9.01179628,9.14530111,20.95509877,22.34781323,310.98021687,309.95752359,6.71328472,7.64915217]) pridection = (pridection - mean) / std if (pridection.ndim == 1): pridection = np.array([pridection]) rainfall = model.predict(pridection) floods = (rainfall - 5) * 5 The error that I'm getting is Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder:0", shape=(11, 32), dtype=float32) is not an element of this graph. I can pinpoint that the error is happening in the model.compile() statement but cannot figure out what exactly is the error. Can someone help me out? -
How to add "forceY" logic to django-nvd3 "Line Plus Bar Chart"?
I've got this example on nvd3.org/livecode/ (Line Plus Bar Chart) working using chart.bars.forceY and chart.lines.forceY. My goal is to center both the line graph and the bar graph, on two different axes, so zero is in the middle of the chart. I want to do this without adding any "fake" data points. nv.addGraph(function() { var chart = nv.models.linePlusBarChart() .margin({top: 30, right: 60, bottom: 50, left: 70}) .x(function(d,i) { return i }) .y(function(d) { return d[1] }) .color(d3.scale.category10().range()) ; chart.xAxis .showMaxMin(false) .tickFormat(function(d) { var dx = data[0].values[d] && data[0].values[d][0] || 0; return d3.time.format('%x')(new Date(dx)) }); chart.y1Axis .tickFormat(d3.format(',f')); chart.y2Axis .tickFormat(function(d) { return '$' + d3.format(',f')(d) }); // Code change here let bar_min = -3899468; let line_min = -600; chart.bars.forceY([bar_min]); chart.lines.forceY([line_min]); d3.select('#chart svg') .datum(data) .transition().duration(500) .call(chart) ; nv.utils.windowResize(chart.update); return chart; }); I want to use the option to "forceY" from django-nvd3 but I have no idea how to use the "forceY" option in django-nvd3. I've stared at the documentation for django-nvd3 for a long time, and looked at this jsfiddle and compared it to the django-nvd3 linePlusBarChart documentation, and I cannot figure out how chart.bars.forceY would get mapped from django-nvd3 to d3.js. I've also checked out the GitHub source code, and it is … -
SQL Server Function to Django Query Set
I have an sql server function dbo.fn_search() that takes in 2 parameters. I would like to utilize this function in a django queryset. I am able to perform a raw-queryset, but that loses the capabilities of the django queryset: mymodel.objects.raw("SELECT * FROM fn_search(%s,%s)", [var1, var2]).using('mydb') Is there a way to pass this function through a django queryset? -
Chronic timeout issue with Google's API via python?
I am working on a little web app to help me manage my gmail. I have set it up through Google's API with the following function using the OAuth token I received through django-allauth. import google.oauth2.credentials from .choices import GMAIL from allauth.socialaccount.models import SocialToken, SocialAccount from apiclient.discovery import build def get_credentials(user): account = SocialAccount.objects.get(user=user.id) token = SocialToken.objects.get(app=GMAIL, account=account).token credentials = google.oauth2.credentials.Credentials(token) service = build('gmail', 'v1', credentials=credentials) return service This seems to work sometimes, but unfortunately, it isn't very reliable. It times out frequently at the build() function, only succeeding about a third of the time. I am wondering what could cause this behavior and if there is a more reliable way to access the API? I found the following AuthorizedSession class from these docs: from google.auth.transport.requests import AuthorizedSession authed_session = AuthorizedSession(credentials) response = authed_session.request( 'GET', 'https://www.googleapis.com/storage/v1/b') But I don't know how to turn it into the kind of object that works with Google's API: def get_labels(user): service = get_credentials(user) results = service.users().labels().list(userId='me').execute() labels = results.get('labels', []) return labels Unfortunately, Google's docs recommend using a deprecated package that I was hoping to avoid. This is my first time really using an OAuth-enforced API. Does anyone have any advice? -
Django filter is not working correctly with boolean field
I have a very simple query to filter but really unable to understand why it is giving me wrong result. This is my code - for s in sqs: print(s.is_draft) sqs = sqs.filter(is_draft=False) print('----------------------') for s in sqs: print(s,s.is_draft) What I am getting is - <SearchResult: products.productcreatemodel (pk='82')> False <SearchResult: products.productcreatemodel (pk='87')> False <SearchResult: products.productcreatemodel (pk='94')> False <SearchResult: products.productcreatemodel (pk='99')> False <SearchResult: products.productcreatemodel (pk='101')> False <SearchResult: products.productcreatemodel (pk='106')> False <SearchResult: products.productcreatemodel (pk='118')> False <SearchResult: products.productcreatemodel (pk='84')> False <SearchResult: products.productcreatemodel (pk='91')> False <SearchResult: products.productcreatemodel (pk='96')> False <SearchResult: products.productcreatemodel (pk='103')> False <SearchResult: products.productcreatemodel (pk='108')> False <SearchResult: products.productcreatemodel (pk='110')> False <SearchResult: products.productcreatemodel (pk='115')> False <SearchResult: products.productcreatemodel (pk='85')> False <SearchResult: products.productcreatemodel (pk='92')> False <SearchResult: products.productcreatemodel (pk='97')> False <SearchResult: products.productcreatemodel (pk='104')> False <SearchResult: products.productcreatemodel (pk='111')> False <SearchResult: products.productcreatemodel (pk='83')> True <SearchResult: products.productcreatemodel (pk='95')> False <SearchResult: products.productcreatemodel (pk='102')> False <SearchResult: products.productcreatemodel (pk='107')> False <SearchResult: products.productcreatemodel (pk='119')> False <SearchResult: products.productcreatemodel (pk='93')> False <SearchResult: products.productcreatemodel (pk='98')> False <SearchResult: products.productcreatemodel (pk='100')> False <SearchResult: products.productcreatemodel (pk='105')> False <SearchResult: products.productcreatemodel (pk='112')> False ---------------------- <SearchResult: products.productcreatemodel (pk='83')> True It should return me the queryset of those which are having is_draft=False but in this you can clearly see it return me the queryset with objects having is_draft=True Now the magic is when I … -
Saving files securely in S3 via Hashicorp Vault
I have a platform which will be used to save files. The files must be stored in a secure way. For this purpose I'm thinking in encrypting the files using the Transit engine of Hashicorp Vault and then uploading the files to S3. Django supports S3 natively, so whenever you upload a file using the standard Model FileField, the file will be automatically stored in S3. My question is: is there any Django app/plugin/alike that I could use to tweak the behaviour of Django and make it send the file to Vault and then save to S3 the encrypted file instead of saving the unencrypted file directly to S3? If there isn't such an app/plugin, what would be a good strategy to patch Django in order to do that? Is there any specific place I should be looking at? -
Django how to import a file from another file under same folder?
This is my Django project structure: project/ app1/ static/ templates/ utils/ __init__.py admin.py forms.py tasks.py urls.py views.py myfile.py Inside myfile.py, I would like to import the test() function inside the task.py: from . import tasks tasks.test() The error from my console: $ python myfile.py Traceback (most recent call last): File "myfile.py", line 1, in <module> from . import tasks ImportError: cannot import name 'tasks' So how to solve this? -
Makemigrations not detecting changes on elastic beanstalk
I am running a Django 1.11 app on Elastic Beanstalk. I have a model Profile as part of an app grams and I added a field email_verified to the model. When I ran makemigrations locally, it picks up the change right away. When I push to elastic beanstalk using eb deploy it runs makemigrations but discovers no changes, then runs migrate and discovers no changes. This server has been running for months and has had multiple successful migrations. Here is the error message after trying to log in after a deployment. Traceback (most recent call last): File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.ProgrammingError: column grams_profile.email_verified does not exist LINE 1: ...ofile"."user_id", "grams_profile"."phone_number", "grams_pro... Here is the deployment script: container_commands: 01_makemigrations: command: "source /opt/python/run/venv/bin/activate && python manage.py makemigrations --noinput" leader_only: true 02_makemigrationsgrams: command: "source /opt/python/run/venv/bin/activate && python manage.py makemigrations grams --noinput" leader_only: true 03_migrate: command: "source /opt/python/run/venv/bin/activate && python manage.py migrate --noinput" leader_only: true 04_createsu: command: "source /opt/python/run/venv/bin/activate && python manage.py createsu" leader_only: true 05_collectstatic: command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput" leader_only: true option_settings: - namespace: aws:elasticbeanstalk:container:python:staticfiles option_name: /static/ value: static/ packages: yum: postgresql95-devel: [] files: "/opt/python/log/django.log" : mode: "000666" owner: ec2-user group: ec2-user content: | … -
Why cannot I access admin section of redirects app in Django?
I have recently installed the redirects app provided by Django (docs:https://docs.djangoproject.com/en/2.1/ref/contrib/redirects/) I went through the proper steps to install it: added to installed apps, added to end of Middleware, and migrated my database. See below: 'django.contrib.redirects', 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', The table successfully was created. However, I cannot seem to view /admin/redirects/redirect. I'm getting the following error Exception Value: invalid literal for int() with base 10: 'redirect' I manually added a record to the django_redirect table and the redirect works. Any ideas why I cannot access the redirects app via the admin? -
How to make a queryset with "or" statement
I have a model Article, in Article i have title and article I have a search function and whatever type in the search must get me all the articles that have the search text in title or article def searh(request): print(request.POST) kw = request.POST['search'] articles = Article.objects.filter(title__contains=kw).filter(article__contains=kw) context = {'News':articles} return render(request, 'menu/search_results.html', context ) by this query is not accurate doesn't return me the if in both how to structure it? articles = Article.objects.filter(title__contains=kw).filter(article__contains=kw) -
How to convert string to call model's name in Django?
view.py from .models import Banana, Mango list = ['Banana', 'Mango'] for x in list: conn = x.objets.all() print(conn.name) when i run this code, it is appear "AttributeError at /search 'str' object has no attribute 'objects'." In thats code, i want to return name value of objects model in my models.py How i can replace string in List to call object models in django? -
Django installed on Heroku with Whitenoice but Google Page Insights saying I need to enable gzip compression
I'm trying to speed up a website running on Heroku. I've installed WhiteNoise by adding in settings.py: MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', ... ] STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', # other finders.. 'compressor.finders.CompressorFinder', ) I've also tried adding to wsgi.py: from whitenoise.django import DjangoWhiteNoise from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") application = get_wsgi_application() application = DjangoWhiteNoise(application) Google insights is saying I can get 81% compression. Is this installed correctly or am I using the wrong tool? -
Creating Custom User Class in Django
I've read and re-read the other questions regarding this issue and I'm still unable to create a custom Django User model. I keep getting the error: Manager isn't available; 'auth.User' has been swapped for 'Users.User'. If not clear by the error, I've created a Users app in which the models.py file defines a custom user class User. Here's are the relevant files from my project, UserTest: Registering the app, specifying the custom user model: UserTest> UserTest> settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'Users' ] AUTH_USER_MODEL = 'Users.User' Extending the default Django User class via my User model and connecting it to a Profile model (not strictly relevant to the issue but a fundamental aspect of the approach.) UserTest > Users > models.py from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): email = models.CharField(max_length=128, blank=False, unique=True, verbose_name='Email', name='email') class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) ... Registering the new User model in my Users App's admin.py (not sure if this is required for testing quick front-end functionality?) UserTest > Users > admin.py from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .models import User admin.site.register(User, UserAdmin) I've created some basic forms and a view to allow … -
html multi button form using in dkango app
i have a html form with multi buttons and html tabs processing for any button every button(for example after to push button n01 i take tab 2 with button n02 after push button n02 i take tab 3 with button n03 where is the final button). my question is hot to take data from button no1(tab 1) and serve to page no2(after push button n01)? if i keep type="button" then in my view i dont take anything if i change to type="submit" then in my view i take results but after push button n01 refresh my page and start to begin again (dont take to tab 2) html form : <form role="form"> .......................... <input type="radio" name="n"> <ul class="list-inline pull-right"> <li><button name='n01' type="button" class="btn btn-primary next-step">Save and continue</button></li> ......................... <input type="radio" name="m"> </ul> <ul class="list-inline pull-right"> <li><button name='n02' type="button" class="btn btn-primary next-step">Save and continue</button></li> </ul> .......................... <input type="radio" name="s"> <ul class="list-inline pull-right"> <li><button name='n03' type="button" class="btn btn-primary next-step">Save and continue</button></li> </ul> </form> django view : if request.method == 'POST' and 'n01' in request.POST: do something if request.method == 'POST' and 'n02' in request.POST: do something else -
Unsupported locale setting only at Heroku
I just have pushed my project to git and suddenly I am getting the following error: /profile/list/48 unsupported locale setting Error during template rendering In template /app/Clientes/templates/Clientes/base.html, error at line 0 The thing is that I am running this project without any problems localy and in Heroku the error appears in a detail view. I do not think that the problem is located in any of my files, but if requested I can post it here. -
Setting detail API View to str instead of pk with Django
I've got my API list view set up to url 'api/', and I want to change the detail (RetrieveAPI) view from url 'api/'pk'/' to 'api/'name'/ where name is a field in my model. I've tried various combinations of lookup_url_kwarg = 'name' and lookup_field = 'name' in both my serializers.py and views.py, but either I get a 404 response, or the url is still api//. Also if the field is a string, will I have to include quotation marks in my urls? Any insight would be great! -
Add form to Django formset dynamically with Javascript
I would like to add forms to my Django formset dynamically with a button but I don't overcome to get a working result. I tried with AJAX to do that but without any result up to now. I defined my formset in my forms.py file : DocumentFormSet = inlineformset_factory(Publication, Document, form=DocumentForm, can_delete=True, extra=0, min_num=1) Then, I defined the view in my views.py file like this : class PublicationCreateView(EdqmCreateView): """ Create publication with document form through formset """ model = Publication template_name = 'publication_form.html' def get_context_data(self, **kwargs): context = super(PublicationCreateView, self).get_context_data(**kwargs) context['document_form'] = DocumentFormSet(self.request.POST or None, self.request.FILES or None) return context def form_valid(self, form): context = self.get_context_data() document = context['document_form'] if document.is_valid(): self.object = form.save() document.instance = self.object document.save() return super(PublicationCreateView, self).form_valid(form) def get_success_url(self): return reverse('publication-list-crud') Now, in my HTML template, I would like to show this formset with the possibility to add new form in this one : {% block main %} <h2>{{ title }}</h2> <div class="row publication-create"> <form method="post" action="" enctype="multipart/form-data" novalidate> {% csrf_token %} <fieldset> <legend class="title"><span class="name">{% trans 'Publication form' %}</span></legend> {{ form|crispy }} </fieldset> <fieldset> <legend class="title"><span class="name">{% trans 'Document form' %}</span></legend> {{ DocumentFormSet.management_form }} <div id="form_set"> {% for form in DocumentFormSet.document_form %} <table class='no_error'> {{ … -
Start docker container and start django project at the same time
I have the following docker-compose.yml file which works with no problem: version: '2' services: nginx: image: nginx:latest container_name: nz01 ports: - "8001:8000" volumes: - ./src:/src - ./config/nginx:/etc/nginx/conf.d depends_on: - web web: build: . container_name: dz01 depends_on: - db volumes: - ./src:/src expose: - "8000" db: image: postgres:latest container_name: pz01 ports: - "5433:5432" volumes: - postgres_database:/var/lib/postgresql/data:Z volumes: postgres_database: external: true The problem is when I run docker-compose up I get this error: python: can't open file 'manage.py': [Errno 2] No such file or directory python: can't open file 'manage.py': [Errno 2] No such file or directory [2018-10-26 12:41:59 +0000] [8] [INFO] Starting gunicorn 19.7.1 [2018-10-26 12:41:59 +0000] [8] [INFO] Listening at: http://0.0.0.0:8000 (8) [2018-10-26 12:41:59 +0000] [8] [INFO] Using worker: sync [2018-10-26 12:41:59 +0000] [12] [INFO] Booting worker with pid: 12 [2018-10-26 12:41:59 +0000] [12] [ERROR] Exception in worker process Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker worker.init_process() File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process self.load_wsgi() File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi self.wsgi = self.app.wsgi() File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load return self.load_wsgiapp() File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app __import__(module) ImportError: … -
Django formset without add new row
I am using django formset to list some data. There won't be new additions to this data. So there won't new row int the db. Only existing rows will be changed. So i don't want to see new addition row at the end of the list. I googled but couldn't find this kind of usage. How can i remove or don't show this last new data add row ? -
Django integration with Bootstrap template
I downloaded Bootstrap theme and integrated it with django, the frontend is perfectly fine but i need help in writing code for its backend integration. index.html as per dwonloaded template: <div class="col-lg-5 col-md-8"> <div class="form"> <div id="sendmessage">Your message has been sent. Thank you!</div> <div id="errormessage"></div> <form action="" method="post" role="form" class="contactForm"> <div class="form-row"> <div class="form-group col-lg-6"> <input type="text" name="name" class="form-control" id="name" placeholder="Your Name" data-rule="minlen:4" data-msg="Please enter at least 4 chars" /> <div class="validation"></div> </div> <div class="form-group col-lg-6"> <input type="email" class="form-control" name="email" id="email" placeholder="Your Email" data-rule="email" data-msg="Please enter a valid email" /> <div class="validation"></div> </div> </div> <div class="form-group"> <input type="text" class="form-control" name="subject" id="subject" placeholder="Subject" data-rule="minlen:4" data-msg="Please enter at least 8 chars of subject" /> <div class="validation"></div> </div> <div class="form-group"> <textarea class="form-control" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Message"></textarea> <div class="validation"></div> </div> <div class="text-center"><button type="submit" title="Send Message">Send Message</button></div> </form> </div> </div> </div> What should be in my models.py file so as to save the received contact data to database. -
Calling Matlab scripts from Django with Python's Popen class
I'm developing a Django app which runs Matlab scripts with Python's Popen class. The python script that calls Matlab scripts lives in the main folder of my Django app (with views.py). When I call the script from command line, it runs like a charm but when I make a request from the client in order to run the corresponding python script, I receive the following warning: "< M A T L A B (R) > Copyright 1984-2018 The MathWorks, Inc. R2018a (9.4.0.813654) 64-bit (glnxa64) February 23, 2018 To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. >> [Warning: Unable to create preferences folder in /var/www/.matlab/R2018a. Preferences folder location must be writable. Using a temporary preferences folder for this MATLAB session. See the preferences documentation for more details.] >> My app uses a Python virtual environment and it is being deployed with Apache web server. Here is my python script that calls Matlab scripts: import os import subprocess as sp import pymat_config def pymat_run(): pwd = pymat_config.pwd_config['pwd'] cmd1 = "-r \"Arg_in = '/path/to/my/main/folder/input.txt'; Arg_out = '/path/to/my/main/folder/file.txt'; matlab_script1\"" baseCmd1 = ['/usr/local/MATLAB/R2018a/bin/matlab', '-nodesktop', '-nosplash', '-nodisplay', 'nojvm', cmd1] os.chdir('/path/to/matlab_script1') sudo_cmd = sp.Popen(['echo', pwd], stdout=sp.PIPE) exec1 = sp.Popen(['sudo', … -
EntityFrameworkQueryableExtensions.Include Method equivalent in Python/Django
Is there any equivalent of EntityFramework Core Include method in Python or Django ORM methods? If not how can I include related entities in the query results?