How to link custom search with a view in a different app ?
# Create your views here.
from shapes.models import *
from openmaps.models import *
from django.shortcuts import render_to_response
from django.contrib.gis.shortcuts import render_to_kml
from openmaps.models import Open_Layers
from django import forms
from openmaps.forms import GeoForm
from django.contrib.gis.geos import GeometryCollection,
MultiPolygon, Polygon
from openmaps.forms import ReadOnlyForm
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from mapsearch.forms import SearchForm
from OsmMap.models import OsmLayers
from maps.models import Sdr_Layer
def map_search(request):
lcount = Open_Layers.objects.all()
form = SearchForm()
if request.method == 'POST':
form = SearchForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['LayerName']
a=OsmLayers()
b=Open_Layers()
c=Sdr_Layer()
data = []
data1=[]
data2=[]
data3=[]
data1 = OsmLayers.objects.filter(Layername__icontains=val)
data2 = Open_Layers.objects.filter(Layer_name__icontains=val)
data3 = Sdr_Layer.objects.filter(layer_name__icontains=val)
data.append(data1)
data.append(data2)
data.append(data3)
return render_to_response('searchresult.html', {'data':data})
else:
form = SearchForm()
else:
return render_to_response('mapsearch.html', {'form':form})
This is my view that returns the search data to searchresult.html .
From searchresult.html , all the returned data , when clicked on
should take it to a view called map_disp directly from the template .
I have read through the documentation , and this is what I inferred .
1. Pass the primary key id as a number to the map_disp view and then
use it to retrieve the date .
2. Change the urls.py so that the number is captured .
Where my doubt is this , what changes needs to be done in the view
code that I have shown here so that the number is sent .
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home