Commit 242ecdab authored by Ben Waters's avatar Ben Waters

Work on geo model

parent 82d174e1
friendfinder
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="ffREST/settings.py" />
<option name="manageScript" value="manage.py" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.5 (/usr/bin/python)" project-jdk-type="Python SDK" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/friendfinder.iml" filepath="$PROJECT_DIR$/.idea/friendfinder.iml" />
</modules>
</component>
</project>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
This diff is collapsed.
......@@ -4,9 +4,13 @@ from rest_framework.authtoken.views import obtain_auth_token
from rest_framework import routers
from django.contrib import admin
from geo.views import LocationViewSet
admin.autodiscover()
router = routers.DefaultRouter()
router.register(r'locations', LocationViewSet)
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'ffREST.views.home', name='home'),
......
from django.contrib import admin
from .models import Location
# Register your models here.
class LocationAdmin(admin.ModelAdmin):
pass
admin.site.register(Location, LocationAdmin)
......@@ -9,7 +9,10 @@ class Location(models.Model):
objects = models.GeoManager()
def __unicode__(self): # __unicode__ on Python 2
def __unicode__(self):
return self.name
class
class LocationSerializer(serializers.ModelSerializer):
class Meta:
model = Location
fields = ('id', 'name', 'area', 'lon', 'lat')
from django.shortcuts import render
from rest_framework import viewsets
from rest_framework import permissions
from .models import Location, LocationSerializer
# Create your views here.
class LocationViewSet(viewsets.ModelViewSet):
queryset = Location.objects.all()
serializer_class = LocationSerializer
permission_classes = (permissions.IsAuthenticatedOrReadOnly,
IsOwnerOrReadOnly,)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment