are you running django using manage.py runserver?

On Tue, Feb 23, 2016 at 4:03 PM, Bernardo Garcia <botib...@gmail.com> wrote:

> Hi everyone Djangonauts
> :)
>
> Currently I am exposing a Django application (for the momento is just
> thier users schema) with Django Rest Framework and happen that each
> serialized model, in the url attribute, I have is the localhost machine
> address development and don't take the hostname of my production server
> machine which is located in amazon like as EC2 instance
>
>
> In this picture can detailed it.
>
>
> <http://i.stack.imgur.com/bDUfR.png>
>
>
>
> How to make for the url of each model that I've serialized take the
> hostname of the production machine in which the application is deployed? In
> this case, an amazon ec2 instance ...
>
>
> These are my serialized models userprofiles/serializers.py
>
>
> from django.contrib.auth.models import Groupfrom .models import User, 
> PlayerProfile, CoachProfile, ViewerProfilefrom rest_framework import 
> serializers
> # Serializers define the API representation# Exponse the model and their 
> fieldsclass UserSerializer(serializers.HyperlinkedModelSerializer):
>     class Meta:
>         model = User
>         fields = ('url','id', 'username', 
> 'password','first_name','last_name','email','is_active',
>                   
> 'is_staff','is_superuser','last_login','date_joined','is_player','is_coach',
>                   'is_viewer','photo',)
> class GroupSerializer(serializers.HyperlinkedModelSerializer):
>     class Meta:
>         model = Group
>         fields = ('url', 'name')
>
> class PlayerProfileSerializer(serializers.HyperlinkedModelSerializer):
>     class Meta:
>         model = PlayerProfile
>         fields = ('url', 'user','full_name','position',)
> class CoachProfileSerializer(serializers.HyperlinkedModelSerializer):
>     class Meta:
>         model = CoachProfile
>         fields = ('url', 'user','full_name',)
> class ViewerProfileSerializer(serializers.HyperlinkedModelSerializer):
>     class Meta:
>         model = ViewerProfile
>         fields = ('url', 'user','full_name','specialty')
>
>
>
> This is my urls.py global file (not belont to userprofiles application
> that contain all the serialized models.)
>
>
> from django.conf.urls import url, includefrom django.contrib import admin
> from .views import home, home_files
> from rest_framework import routersfrom userprofiles import views
> # Router provide an easy way of automatically determining the URL conf
> router = routers.DefaultRouter()
> router.register(r'users', views.UserViewSet)
> router.register(r'groups', views.GroupViewSet)
> router.register(r'players', views.PlayerProfileViewSet)
> router.register(r'coachs', views.CoachProfileViewSet)
> router.register(r'views', views.ViewerProfileViewSet)
>
>
> urlpatterns = [
>     url(r'^admin/', admin.site.urls),
>     url(r'^$', home, name='home'),
>
>     url(r'^(?P<filename>(robots.txt)|(humans.txt))$',
>         home_files, name='home-files'),
>
>     # Wire up our API using automatic URL routing.
>     url(r'^api/v1/', include(router.urls)),
>
>     # If you're intending to use the browsable API you'll probably also want 
> to add REST framework's
>     # login and logout views.
>     url(r'^api-auth/', include('rest_framework.urls', 
> namespace='rest_framework'))]
>
>
>
> And this is my userprofiles/views.py file in where I have expose the
> models serializeds
>
>
> from django.shortcuts import renderfrom django.contrib.auth.models import 
> Groupfrom .models import User, PlayerProfile, CoachProfile, ViewerProfile
> from rest_framework import viewsetsfrom .serializers import UserSerializer, 
> GroupSerializer, PlayerProfileSerializer, CoachProfileSerializer, 
> ViewerProfileSerializer
> # Create your views here.
> # Viewsets define the behavior of the viewclass 
> UserViewSet(viewsets.ModelViewSet):
>     """
>     API endpoint that allows users to be viewed or edited.
>     """
>     queryset = User.objects.all().order_by('-date_joined')
>     serializer_class = UserSerializer
> class GroupViewSet(viewsets.ModelViewSet):
>     """
>     API endpoint that allows groups to be viewed or edited.
>     """
>     queryset = Group.objects.all()
>     serializer_class = GroupSerializer
> class PlayerProfileViewSet(viewsets.ModelViewSet):
>     """
>     API endpoint that allows players to be viewed or edited.
>     """
>     queryset = PlayerProfile.objects.all()
>     serializer_class = PlayerProfileSerializer
> class CoachProfileViewSet(viewsets.ModelViewSet):
>     """
>     API endpoint that allows coachs to be viewed or edited.
>     """
>     queryset = CoachProfile.objects.all()
>     serializer_class = CoachProfileSerializer
> class ViewerProfileViewSet(viewsets.ModelViewSet):
>     """
>     API endpoint that allows viewers to be viewed or edited.
>     """
>     queryset = ViewerProfile.objects.all()
>     serializer_class = ViewerProfileSerializer
>
>
> Any orientation or support about it, I will be grateful :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d1fedabf-b8ed-4f32-ad1a-5799ab85ca3a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d1fedabf-b8ed-4f32-ad1a-5799ab85ca3a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tKkA6zctvaN3SDHrUz9ta4_E9ZhkC76XeadfLCFZMYr%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to