Продолжайте получать ошибку ниже
Это происходит после выполнения миграции.
OperationalError at /admin/accounts/picture/
no such table: accounts_picture
def get_image_filename(instance,filename):
id = instance.product.id
return "picture_image/%s" % (id)
def path_and_rename(instance, filename):
upload_to = 'images'
ext = filename.split('.'[-1])
if instance.pk:
filename = '{}.{}'.format(instance.pk, ext)
else:
filename = '{}.{}'.format(uuid4().hex, ext)
return os.path.join(upload_to, filename)
class Picture(models.Model):
product_pic = models.ImageField(null=True, blank=True,upload_to=path_and_rename)
product = models.ForeignKey(Product, null=True, on_delete=models.SET_NULL )
date_created = models.DateTimeField(auto_now_add=True, null=True)
Эта ошибка появляется при попытке доступа к моей модели изображений в админке.
Есть ли способ решить эту проблему?
User = get_user_model()
class UserAdmin(BaseUserAdmin):
# The forms to add and change user instances
form = UserAdminChangeForm
add_form = UserAdminCreationForm
# The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin
# that reference specific fields on auth.User.
list_display = ('email', 'admin')
list_filter = ('admin','staff','active')
fieldsets = (
(None, {'fields': ('email', 'password')}),
('Personal info', {'fields': ()}),
('Permissions', {'fields': ('admin','staff','active')}),
)
# add_fieldsets is not a standard ModelAdmin attribute. UserAdmin
# overrides get_fieldsets to use this attribute when creating a user.
add_fieldsets = (
(None, {
'classes': ('wide',),
'fields': ('email', 'password1', 'password2')}
),
)
search_fields = ('email',)
ordering = ('email',)
filter_horizontal = ()
admin.site.register(User,UserAdmin)
admin.site.unregister(Group)
@admin.register(Profile, Tag, Product, Order, Address,Picture)
class ViewAdmin(ImportExportModelAdmin):
pass
См. выше для admin.py, я считаю, что может быть проблема с моим admin.py.