Created
December 18, 2014 12:46
-
-
Save devmessias/3e4c8610aa6af17f7802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// meu diretório esta assim | |
Folder->djangoProject | |
Folder->djangoProject | |
Folder->app | |
Folder->static | |
Folder->uploads | |
Folder->services | |
setings.py | |
.... | |
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/uploads') | |
MEDIA_URL='/media/' | |
modesl.py | |
.... | |
Class Service(models.Model) | |
img = models.ImageField(upload_to='services') | |
//views.py | |
... | |
@api_view(['GET']) | |
def getServices(request): | |
services = Service.objects.all() | |
data=serializers.serialize('json',services) | |
return Response(data, status=status.HTTP_200_OK, content_type='application/json') | |
//Na requisicao ajax o importante é que retornara um array(infos) com as informações necessarias e o url da imagem é retornada | |
infos.img=services/nomedaimagem | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment