I had a database with following fields listingName,slug,property,city,place,ownerName,room,water,amenities,price,summary,phoneNumber,phone_image,email I didn't want phone_image field so i removed it from models.py and applied the following command
python manage.py makemigrations rentals
python manage.py migrate
But i get below error
OperationalError at /admin/rentals/rental/
no such column: rentals_rental.phone_image
so i deleted my database first and then applied the command python manage.py migrate but still getting the same error though my models do not have phone_image field.
It works in localhost but not in remote. As i have hosted my application in digital ocean with nginx and gunicorn.
admin.py
from django.contrib import admin
from rentals.models import Rental,Gallery
class InlineGallery(admin.TabularInline):
model = Gallery
fk_name = 'rental'
class RentalAdmin(admin.ModelAdmin):
inlines = [
InlineGallery,
]
admin.site.register(Rental,RentalAdmin)
admin.site.register(Gallery)
models.py
ownerName = models.CharField(_("Owner's Name"),max_length=255, blank=True,null=True,
help_text=_("Owner's Full Name"))
email = models.CharField(max_length=120,blank=True,null=True)
phoneNumber = models.PositiveIntegerField(blank=False,null=True,
help_text=_("Phone number of contact person"))
listingName = models.CharField(_("Lisitng Name"), max_length=255, blank=False,null=True,
help_text=_("Title of the rental space"))
slug = models.SlugField(unique=True,blank=True,null=True)
summary = models.TextField(max_length=500, blank=True,null=True,help_text=_("Description of the rental space"))
property = models.CharField(_("Property type"),max_length=10,null=True)
room = models.PositiveIntegerField(_("No of Rooms"), blank=False, null=True,
help_text=_("Number of bedrooms available"))
price = models.PositiveIntegerField(blank=False,null=True,
help_text=_("Rental price of the space per month"))
city = models.CharField(_("City"), max_length=255, blank=False,null=True,
help_text=_("City of the rental space"))
place = models.CharField(_("Place"), max_length=255, blank=False,null=True,
help_text=_("Place of the rental space"))
water = models.CharField(_("water facilities"),max_length=50,null=True,
help_text=_("Is there water facility?"))
amenities = models.CharField(_("amenities"),max_length=100,blank=True,null=True)
phone_image = models.CharField(blank=True, help_text='image form of the phone number', max_length=2048, null=True)
is_published = models.BooleanField(default=True)
created_on = models.DateTimeField(auto_now_add=True)
modified_on = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.listingName
I have two migrations file inside migration folder
0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-03-30 14:23
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Gallery',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(blank=True, null=True, upload_to='upload/')),
],
options={
'verbose_name_plural': 'Galleries',
'verbose_name': 'Gallery',
},
),
migrations.CreateModel(
name='Rental',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ownerName', models.CharField(blank=True, help_text="Owner's Full Name", max_length=255, null=True, verbose_name="Owner's Name")),
('email', models.CharField(blank=True, max_length=120, null=True)),
('phoneNumber', models.PositiveIntegerField(help_text='Phone number of contact person', null=True)),
('listingName', models.CharField(help_text='Title of the rental space', max_length=255, null=True, verbose_name='Lisitng Name')),
('slug', models.SlugField(blank=True, null=True, unique=True)),
('summary', models.TextField(blank=True, help_text='Description of the rental space', max_length=500, null=True)),
('property', models.CharField(max_length=10, null=True, verbose_name='Property type')),
('room', models.PositiveIntegerField(help_text='Number of bedrooms available', null=True, verbose_name='No of Rooms')),
('price', models.PositiveIntegerField(help_text='Rental price of the space per month', null=True)),
('city', models.CharField(help_text='City of the rental space', max_length=255, null=True, verbose_name='City')),
('place', models.CharField(help_text='Place of the rental space', max_length=255, null=True, verbose_name='Place')),
('water', models.CharField(help_text='Is there water facility?', max_length=50, null=True, verbose_name='water facilities')),
('amenities', models.CharField(blank=True, max_length=100, null=True, verbose_name='amenities')),
('phone_image', models.CharField(blank=True, help_text='image form of the phone number', max_length=2048, null=True)),
('is_published', models.BooleanField(default=True)),
('created_on', models.DateTimeField(auto_now_add=True)),
('modified_on', models.DateTimeField(auto_now_add=True)),
],
options={
'verbose_name_plural': 'Rents',
'verbose_name': 'Rent',
},
),
migrations.AddField(
model_name='gallery',
name='rental',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='gallery', to='rentals.Rental', verbose_name='Rental'),
),
]
0002_remove_rental_phone_image.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-04-20 02:01
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('rentals', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='rental',
name='phone_image',
),
]
How can i overcome this issue? Do i need to provide any more information?
Thanks