I have this Django app running on my computer, as a local server and I deployed it to an azure server. It works fine locally however when it runs on the azure server gives me this error.
Request Method: POST
Request URL: http://runnify.azurewebsites.net/route/
Django Version: 3.0.5
Exception Type: OperationalError
Exception Value:
no such table: pages_routerequest
Exception Location: /antenv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 396
Python Executable: /opt/python/3.7.7/bin/python3.7
Python Version: 3.7.7
Python Path:
['/opt/python/3.7.7/bin',
'/home/site/wwwroot',
'/antenv/lib/python3.7/site-packages',
'/opt/python/3.7.7/lib/python37.zip',
'/opt/python/3.7.7/lib/python3.7',
'/opt/python/3.7.7/lib/python3.7/lib-dynload',
'/opt/python/3.7.7/lib/python3.7/site-packages']
Server time: Mon, 7 Sep 2020 11:21:54 +0000
I can't understand what is wrong, since I am not using a pages_routerequest anywhere. in my models.py I have:
from django.db import models
from django.contrib.postgres.fields import JSONField
class Coordinates(models.Model):
"""Model representing a route coordinate generated (e.g. Science Fiction, Non Fiction)."""
coordinates = JSONField()
def __str__(self):
"""String for representing the Coordinates objects"""
return self.coordinates
class RouteRequest(models.Model):
running_distance = models.FloatField()
user_location = models.CharField(max_length=8000)
EDIT: I have also applied makemigrations and migrate, and the bd was successfully created.
FIX: I was required to have a database in azure directly and I didn't know. For now just took the .save() part out and it worked
You should commit migrations on production server
python3 manage.py makemigrations # Optional if you control migrations on dev
python3 manage.py migrate
From first impression it seems you have missed to create them "db":
python manage.py migrate
python manage.py makemigrations REPLACE-WITH-YOUR-PROJECT-NAME-HERE
python manage.py migrate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.