Hello all, I have been perplexed for a few hours due to an error that arises when I migrate, when I run makemigrations it says there have been no changes detected, even when i delete the database itself, and when i run migrate it says the engine is improperly configured even though we are just using the default sqlite at the moment, and haven’t changed that part of the settings.py file. The only issue that i can really see that would occur would be due to my linking of cloudinary, though all AI models I’ve taken this to seem to disagree.
Cloudinary Integration, which uses a .env file
from cloudinary_storage.storage import MediaCloudinaryStorage
from pathlib import Path
from dotenv import load_dotenv
import cloudinary
import cloudinary.uploader
import cloudinary.api
import os
load_dotenv()
cloudinary.config(
cloud_name=os.getenv('CLOUDINARY_CLOUD_NAME'),
api_key=os.getenv('CLOUDINARY_API_KEY'),
api_secret=os.getenv('CLOUDINARY_API_SECRET')
)
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'
MEDIA_URL = '/media/'
Database Configuration
BASE_DIR = Path(__file__).resolve().parent.parent
DATABASES = {
'default': {
'ENGINE':'django.db.backends.sqlite3',
'NAME':BASE_DIR/'db.sqlite3',
}
}
Models.py file for extra context:
from django.db import models
from django.contrib.auth.models import User
from cloudinary.models import CloudinaryField
class Image(models.Model):
def __str__(self):
return f"Image {self.id}"
def get_upload_to(self, instance, filename):
if isinstance(instance, Product):
return f'products/{instance.id}/{filename}' # Folder for products
elif isinstance(instance, Blog):
return f'blogs/{instance.id}/{filename}' # Folder for blogs
elif isinstance(instance, Event):
return f'events/{instance.id}/{filename}'
elif isinstance(instance, Impact):
return f'impacts/{instance.id}/{filename}'
elif isinstance(instance, Job):
return f'jobs/{instance.id}/{filename}'
else:
return f'services/{instance.id}/{filename}'
file = CloudinaryField('image', folder=get_upload_to) # Cloudinary field for each image
class MembershipTier(models.Model):
name = models.CharField(max_length=100)
price = models.FloatField() #could also use DecimalField
features = models.JSONField() #array of strings
description = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
is_active = models.BooleanField(default=True)
def __str__(self):
return self.name
class Organisation(models.Model):
name = models.CharField(max_length=255)
about = models.TextField()
website = models.URLField()
email = models.EmailField()
facebook = models.URLField(blank=True, null=True)
instagram = models.URLField(blank=True, null=True)
twitter = models.URLField(blank=True, null=True)
membership_tier = models.ForeignKey(MembershipTier, on_delete=models.SET_NULL, null=True, blank=True)
leadership_type = models.CharField(max_length=100)
location = models.CharField(max_length=255)
legal_structure = models.CharField(max_length=100)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
beneficiaries = models.JSONField(blank=True, null=True)
keywords = models.JSONField(blank=True, null=True)
is_active = models.BooleanField(default=True)
def __str__(self):
return self.name
class Service(models.Model):
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
title = models.CharField(max_length=100)
images = models.ManyToManyField(Image, blank=True) # Link to multiple images
description = models.TextField()
def __str__(self):
return self.title
class Product(models.Model):
name = models.CharField(max_length=100)
type = models.CharField(max_length=50)
description = models.TextField()
images = models.ManyToManyField(Image, blank=True) # Link to multiple images
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
sizes = models.JSONField(blank=True, null=True) #array of ints, could be array of strings
is_active = models.BooleanField(default=True)
def __str__(self):
return self.name
class Profile(models.Model):
#in-built django user includes username, email, password already
user = models.OneToOneField(User, on_delete=models.CASCADE)
full_name = models.CharField(max_length=255, blank=True)
is_active = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.user.username
class Blog(models.Model):
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
title = models.CharField(max_length=255)
images = models.ManyToManyField(Image, blank=True) # Link to multiple images
text = models.TextField()
created_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
posted_at = models.DateTimeField()
updated_at = models.DateTimeField()
def __str__(self):
return self.title
class Impact(models.Model):
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
title = models.CharField(max_length=255)
funders = models.JSONField(blank=True, null=True)
beneficiaries = models.JSONField(blank=True, null=True)
images = models.ManyToManyField(Image, blank=True) # Link to multiple images
impact_report = models.TextField()
is_active = models.BooleanField(default=True)
def __str__(self):
return self.title
class Event(models.Model):
holder = models.CharField(max_length=255, default="Wild n' Kind")
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
event_link = models.URLField()
date = models.DateField()
time = models.TimeField(blank=True, null=True)
title = models.CharField(max_length=255)
field = models.CharField(max_length=50)
is_active = models.BooleanField(default=True)
def __str__(self):
return self.title
class Job(models.Model):
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
title = models.CharField(max_length=255)
description = models.TextField()
salary = models.FloatField(blank=True, null=True)
closing_date = models.DateField()
opening_date = models.DateField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
is_active = models.BooleanField(default=True)
url = models.URLField(blank=True, null=True)
images = models.ManyToManyField(Image, blank=True) # Link to multiple images
yt_vid = models.URLField(blank=True, null=True)
def __str__(self):
return self.title
If I have provided insufficient information please let me know, any advice would be extremely appreciated!