Question

Error running python manage.py migrate

Posted November 2, 2021 103 views
PythonDjangoPython FrameworksDevelopmentDigitalOcean App Platform

When I try step 4, I try to launch: python manage.py migrate. I’m getting this error and I don’t know how to fix it. In my PC everything works correctly.

Request Method: GET
Request URL:    https://xxxxxx.ondigitalocean.app/
Django Version: 3.1.4
Exception Type: ProgrammingError
Exception Value:    
relation "weatherapi_weatherstation" does not exist
LINE 1: ...gitude", "weatherapi_weatherstation"."token" FROM "weatherap...
                                                             ^
Exception Location: /workspace/.heroku/python/lib/python3.8/site-packages/django/db/backends/utils.py, line 84, in _execute
Python Executable:  /app/.heroku/python/bin/python
Python Version: 3.8.9
Python Path:    
['/workspace/.heroku/python/bin',
 '/workspace',
 '/workspace/.heroku/python/lib/python38.zip',
 '/workspace/.heroku/python/lib/python3.8',
 '/workspace/.heroku/python/lib/python3.8/lib-dynload',
 '/workspace/.heroku/python/lib/python3.8/site-packages']
Server time:    Tue, 02 Nov 2021 12:52:05 +0000

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

My Weatherapi models.py:

from uuid import uuid1
from django.db import models


def generate_uid():
    return uuid1().hex


# Create your models here.
class WeatherStation(models.Model):
    uid = models.CharField(max_length=32, db_index=True, unique=True, default=generate_uid)
    name = models.CharField(max_length=256, default="No name")
    created_at = models.DateTimeField(auto_now_add=True)
    latitude = models.FloatField()
    longitude = models.FloatField()
    token = models.CharField(max_length=40, unique=True,)

    def __str__(self):
        return self.name


class WeatherRecord(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    temperature = models.DecimalField(default=None, max_digits=4, decimal_places=2)
    humidity = models.DecimalField(default=None, max_digits=4, decimal_places=2)
    pressure = models.DecimalField(default=None, max_digits=6, decimal_places=2)
    state = models.IntegerField(default=0)
    weather_station = models.ForeignKey(WeatherStation, on_delete=models.CASCADE, default=None)

    class Meta:
        ordering = ['-created_at']