initial commit
This commit is contained in:
17
apps/gallery/resources.py
Normal file
17
apps/gallery/resources.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from import_export import resources, fields
|
||||
from import_export.widgets import ForeignKeyWidget
|
||||
|
||||
from apps.gallery.models import Gallery
|
||||
from apps.users.models import User
|
||||
|
||||
class GalleryResource(resources.ModelResource):
|
||||
uploaded_by = fields.Field(
|
||||
column_name='uploaded_by',
|
||||
attribute='uploaded_by',
|
||||
widget=ForeignKeyWidget(User, 'username')
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Gallery
|
||||
fields = ('id', 'title', 'description', 'image', 'uploaded_by',
|
||||
'alt_text', 'file_size', 'width', 'height', 'is_public', 'created_at')
|
||||
Reference in New Issue
Block a user