OperationalError at /admin/weather/city/

Viewed 224

i am following this tutorial and it created migrations folder without any error but when i logon to localhost:8000/admin and click cities i get OperationalError at /admin/weather/city/

models.py

from django.db import models

# Create your models here.
class City(models.Model):
    name = models.CharField(max_length=25)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = 'cities'

views.py

import requests
from django.shortcuts import render

# Create your views here.
def index(request):

    url = 'http://api.openweathermap.org/data/2.5/weather?q={}&appid=###'

    city = 'Las Vegas'

    r = requests.get(url.format(city)).json()

    city_weather={
            'city':city,
            'temperature':r['main']['temp'],
            'description':r['weather'][0]['description'],
            'icon' : r['weather'][0]['icon'],
    }


    context = {'city_weather': city_weather}
    return render(request,'weather/weather.html',context)

after performing python manage.py makemigrations python manage.py migrate

0001_initial

# Generated by Django 3.0.3 on 2020-03-18 02:30

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='City',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=25)),
            ],
            options={
                'verbose_name_plural': 'cities',
            },
        ),
    ]

then added below code in admin admin.py

from django.contrib import admin
from .models import City
# Register your models here.

admin.site.register(City)

After several similar questions and answers i had deleted migration folder and again performed python manage.py makemigrations python manage.py migrate tried python manage.py migrate --run-syncdb too but all in vain getting the same error , please help stuck for long at this error btw my django version is 3.0.3

error message enter image description here

command promt message enter image description here

NOTE:- i had added 'weather'(my app name) in settings.py

1 Answers

python manage.py migrate <your_appname> zero then delete the folder and perform the migrations again

Related