Hi there,
I am trying to make migrations by running the following command:
python manage.py makemigrations
But, I am getting the error like this:
django.db.utils.ProgrammingError: (1146, "Table 'dinsos.mapping_penerima' doesn't exist")
I am using MySQL Database named as dinsos
.
Earlier my app was working fine with all the user migrations and stuff. When I made this new Model Anggota
and I also did zero migration on mapping app, I am getting the above mentioned error.
My mapping.models
is below:
class Anggota(models.Model):
nama_anggota=models.CharField(max_length=255)
def __str__(self):
return "{}.".format(self.nama_anggota)
class Penerima(models.Model):
id_anggota=models.ForeignKey(Anggota, on_delete=models.CASCADE)
nama = models.CharField(max_length=255)
alamat = models.CharField(max_length=255)
kabupaten = models.CharField(max_length=255)
kecamatan = models.ForeignKey(Kecamatan, on_delete=models.CASCADE)
desa = models.CharField(max_length=255)
latitude = models.FloatField(blank=True, null=True)
longitude = models.FloatField(blank=True, null=True)
jumlah_menerima = models.IntegerField(default=0, null=True)
foto_bukti = models.CharField(max_length=255, blank=True, null=True)
tahun = models.CharField(max_length=10, blank=True, null=True)
bansos = models.ForeignKey(Bansos, on_delete=models.CASCADE, null=True)
date = models.DateTimeField(auto_now_add=True, blank=True)
def save(self, *args, **kwargs):
if self.latitude is None and self.longitude is None:
location = geocoder.osm(self.desa+" "+self.kabupaten)
self.latitude = location.lat
self.longitude = location.lng
super(Penerima, self).save(*args, **kwargs)
def __str__(self):
return "{}. {}".format(self.id, self.nama)
my mapping.filters
is below:
class PenerimaFilter(django_filters.FilterSet):
b = []
k = []
t = []
for i in Penerima.objects.values_list('tahun', flat=True).order_by('tahun').distinct():
t.append((i,i))
for i in Bansos.objects.all().order_by('nama_bansos'):
b.append((i.id,i.nama_bansos))
for i in Kecamatan.objects.all().order_by('nama_kecamatan'):
k.append((i.id,i.nama_kecamatan))
tahun = django_filters.ChoiceFilter(
choices=t, label="", empty_label="Semua",
widget=forms.Select(attrs={'class': 'form-control', 'style':'border-color: #063970;border-radius: 10px;color: #063970'})
)
bansos = django_filters.ChoiceFilter(
choices=b, label="", empty_label="Semua",
widget=forms.Select(attrs={'class': 'form-control', 'style':'border-color: #063970;border-radius: 10px;color: #063970'})
)
kecamatan = django_filters.ChoiceFilter(
choices=k, label="", empty_label="Semua",
widget=forms.Select(attrs={'class': 'form-control', 'style':'border-color: #063970;border-radius: 10px;color: #063970'})
)
class Meta:
model=Penerima
fields={
}
please help me, i’m so frustrated TT TT thanks!!