Vote count:
0
One of my view redirects to a another URL which looks something like this:
http://ift.tt/1eWHwsE
I want to hide all the parameters that is passed and instead have my "unicode" in there. I only want to hide them. I do not want to remove them. Meaning, I need those parameters to process in the next view.
Currently I have:
Models.py
class Searches(models.Model):
SELLER_CHOICES=(('OWNER','owner'),
('DEALER','dealer'),
('BOTH','both'), )
#search_id = models.IntegerField(primary_key=True)
user = models.ForeignKey(User)
make = models.CharField(max_length=100, blank=True)
model = models.CharField(max_length=100, blank=True)
keywords = models.CharField(max_length=100, blank=True)
max_price = models.IntegerField(blank=True, null=True)
min_price = models.IntegerField(blank=True, null=True)
max_year = models.IntegerField(blank=True, null=True)
min_year = models.IntegerField(blank=True, null=True)
pic_only = models.NullBooleanField()
search_title_only = models.NullBooleanField()
owner_dealer_all = models.CharField(max_length=10,choices=SELLER_CHOICES,verbose_name='owner/dealer')
class Meta:
#managed = False
db_table = 'Searches'
verbose_name_plural = "Searches"
def __unicode__(self):
return "%s %s %s-%s" %(self.make,self.model,self.max_year,self.min_year)
def get_absolute_url(self):
#slug=
#return reverse('postings.views.detail',args=[model_to_dict(self)])
#return reverse('postings.views.detail',args=[str(self.id)])
return reverse('display_postings_results', args=[model_to_dict(self)])
URLpatterns:
urlpatterns = patterns('',
url(r'^results/(?P<args>.*)/$',
'postings.views.detail',name='display_postings_results'),
)
view ( I will do more processing with the incoming args. but this is the simplest example)
def detail(request,args):
return HttpResponse(args)
currently, it is working fine. and it displays the passed the args in the browser. but the URL is ugly. I want to hide that and pass some kind of slug. but still pass the args to the view
asked 49 secs ago
Aucun commentaire:
Enregistrer un commentaire