Category : django

I have a piece of code using os.listdir() to show the files inside the folder. But I have the error because canĀ“t find the path. I’ve already verify but is ok. How can I obtain the list with os.listdir() or other method? My piece of code: context[‘files’] = os.listdir("/static/assets/external_files/"+info_curso.code) Source: Python..

Read more

I am using qsstats to show plots in my website, but when I try to create time series I get only zeroes. Code of API’s method: data = request.query_params orders = Transaction.objects.all() qsstats = QuerySetStats(orders, date_field=’date_time’, aggregate=models.Sum(‘cost’)) date_dt1 = datetime.strptime(data[‘start_date’], ‘%m/%d/%y’) date_dt2 = datetime.strptime(data[‘end_date’], ‘%m/%d/%y’) values = qsstats.time_series(date_dt1, date_dt2, interval=data[‘interval’]) if len(values) > 100: return ..

Read more

When I am using django-admin startproject api then it is opening file named django-admin.py and the code looks like this : #!C:UsersAdministratorDesktopapivenvScriptspython.exe When the django-admin.py deprecation ends, remove this script. import warnings from django.core import management try: from django.utils.deprecation import RemovedInDjango40Warning except ImportError: raise ImportError( ‘django-admin.py was deprecated in Django 3.1 and removed in Django ..

Read more

Hello guys I am new in Django REST API. I want your help. I am trying to join my two models : User and blogs to get specific api output like this: { "blog_id": 1, "title": "first blog", "description": "hola", "image": "/images/phone.jpg", "create_at": "2021-04-08T14:24:51.122272Z", "update_at": "2021-04-08T14:37:00.287746Z", "user": 1, "user_name": "superuser", "first_name": "Dannis", "email": "[email protected]" } ..

Read more

I’m running into this issue: django.db.utils.ProgrammingError: (’42S02′, "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name ‘MYSCHEMA.MyUnmanagedModel’. It’s an unmanaged model, so I understand that I have to create the table manually ahead of time. Here is the model: class MyUnmanagedModel(models.Model): id = models.IntegerField(db_column="ID", primary_key=True) end_year = models.IntegerField(db_column="endyear") grade = models.CharField(db_column="grade", max_length=2) enrollments = ..

Read more

model = load_model(‘./saved_model.h5’) "OSError: SavedModel file does not exist at: ./saved_model.h5{saved_model.pbtxt|saved_model.pb}" The model is well called in python, not in django, but not in django. The model is in the same folder as the code. What is the problem? (For your information, I already installed h5py..!) Source: Python..

Read more