Commits

Anonymous committed f71e936

added more docs instead of keeping the example in shapes/urls.py therefore deleted shapes/urls/p

Comments (0)

Files changed (4)

  
  - Add `shapes` to your INSTALLED APPS.
  
- - Add `(r'^shapes/', include('shapes.urls')),` to your main project's urlpatterns
-  - This will expose two urls: '/shapes/upload/' and '/shapes/export/'.
+ - Check out the docs/ folder to see how to set up exports and uploads
   
- - Add SHP_UPLOAD_DIR = '/some/path' in your setting.py for the upload functionality.
- 
- - See shapes/urls.py to for example usage of export function
-  - Instantiate the ShpResponder class, associate an queryset and passed in a view.
-  
+ - Add SHP_UPLOAD_DIR = '/some/path' in your setting.py for the upload functionality.  
 
 Working with mercurial
 ----------------------
+django-shapes
+-------------
+
+Exporting Shapefiles in Urls
+============================
+
+Add something like this to your urls.py::
+ 
+  from django.conf.urls.defaults import *
+  from shapes import views
+ 
+  from world.models import WorldBorders
+  w = WorldBorders.objects.all()
+  shp_response = views.ShpResponder(w)
+  shp_response.file_name = 'World Borders'
+  
+  urlpatterns = patterns('',
+                       url(r'^export/$',shp_response),
+                       )
+
+
+Uploading Shapefiles in Urls
+============================
+
+Add something like this to your urls.py::
+ 
+  from django.conf.urls.defaults import *
+  from shapes import views
+  
+  urlpatterns = patterns('',
+                       url(r'^upload/$',views.upload),
+                       )
 django-shapes
 -------------
 
-Views
-=====
+Exporting Shapefiles in Views
+=============================
 
+Add something like this to your urls.py::
 
- * todo
+ (r'^worldshapes/', export),
+ 
+And then write a view like::
+
+  from shapes.views import ShpResponder
+  
+  def export(request):
+      from world.models import WorldBorders
+      w = WorldBorders.objects.all()
+      shp_response = ShpResponder(w)
+      shp_response.file_name = 'World Borders'
+      return shp_response.__call__()
+
+
+Uploading Shapefiles in Views
+=============================
+
+Add something like this to your urls.py::
+ 
+
+  (r'^upload/', upload),
+
+And then write a view like::
+
+  from django.shortcuts import render_to_response
+  from django.template import RequestContext
+  from shapes.forms import UploadForm
+  
+  def upload(request):
+      if request.method == 'POST':
+          form = UploadForm(request.POST, request.FILES)
+          if form.is_valid():
+              form.handle(request.FILES['file_obj'])
+              #form.save() # if a modelform
+              #form.cleaned_data['user'] = request.user
+              return render_to_response('uploaded.html', RequestContext(request,{}))
+      else:
+          form = UploadForm()
+      return render_to_response('upload.html', RequestContext(request,{'form': form}))

shapes/urls.py

-from django.conf.urls.defaults import *
-from shapes import views
-
-# Example Usage:
-# Create a queryset in your main urls.py or here
-# and pass to the ShpResponser class then
-# pass that class as the view function
-# which automatically calls __call__()
-
-# Test data here from: http://code.google.com/p/geodjango-basic-apps/
-
-from world.models import WorldBorders
-w = WorldBorders.objects.filter(pk__lt=20)
-shp_response = views.ShpResponder(w)
-shp_response.file_name = 'World Borders'
-#shp_response.proj_transform = 900913
-
-urlpatterns = patterns('',
-                       url(r'^upload/$',views.upload),
-                       url(r'^export/$',shp_response),
-                       )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.