You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gcm/v1/device/register/ post request works perfect with default django-gcm model but if I extend device model to add user field and make POST request, it fails without any response.
My extended model is as follows,
####models.py
from django.conf import settings from django.db import models
from gcm.models import AbstractDevice
class Device(AbstractDevice):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
####Added my app url in main urls.py
url(r'', include('contrib.device.urls')),
####my app urls.py
from django.conf.urls import patterns, include, url
from tastypie.api import Api
from .resources import AuthResource
from gcm.resources import DeviceResource
from tastypie.authentication import ApiKeyAuthentication
class AuthResource(DeviceResource):
class Meta(DeviceResource.Meta):
authentication = ApiKeyAuthentication()
def get_queryset(self):
qs = super(AuthResource, self).get_queryset()
# to make sure that user can update only his own devices
return qs.filter(user=self.request.user)
def form_valid(self, form):
form.instance.user = self.request.user
return super(AuthResource, self).form_valid(form)
#### Code added in settings.py
App added under INSTALLED_APPs
'contrib.device',
'tastypie',
'gcm',
Variables added
GCM_APIKEY = "My App key"
GCM_DEVICE_MODEL = 'contrib.device.models.Device'
What I am doing wrong? Please help.
Thank you.
The text was updated successfully, but these errors were encountered:
gcm/v1/device/register/ post request works perfect with default django-gcm model but if I extend device model to add user field and make POST request, it fails without any response.
My extended model is as follows,
####models.py
from django.conf import settings from django.db import models
from gcm.models import AbstractDevice
class Device(AbstractDevice):
user = models.ForeignKey(settings.AUTH_USER_MODEL)
####Added my app url in main urls.py
url(r'', include('contrib.device.urls')),
####my app urls.py
from django.conf.urls import patterns, include, url
from tastypie.api import Api
from .resources import AuthResource
gcm_api = Api(api_name='v1')
gcm_api.register(AuthResource())
urlpatterns = patterns('',
url(r'^gcm/', include(gcm_api.urls)),
)
####resources.py
from gcm.resources import DeviceResource
from tastypie.authentication import ApiKeyAuthentication
class AuthResource(DeviceResource):
#### Code added in settings.py
App added under INSTALLED_APPs
'contrib.device',
'tastypie',
'gcm',
Variables added
GCM_APIKEY = "My App key"
GCM_DEVICE_MODEL = 'contrib.device.models.Device'
What I am doing wrong? Please help.
Thank you.
The text was updated successfully, but these errors were encountered: