get url and add instance to a model with prefilled foreign key :django admin -


i have page in each contest shown in row. each row contains contest id , link other model names have foreign key contest. news model:

class news(models.model):     title = models.charfield(max_length=50, null=true)     description = models.textfield()     time = models.timefield( default= datetime.datetime.now().time())     contest = models.foreignkey(contest) 

i want use admin adding , changing these models. want when user clicks on 'news' has foreign key contest id=1, shows list of news value foreign key. use

{% instance in instances %}                     <tr class="{% cycle 'row1' 'row2' %}">                         <td>{{ instance.title }}</td>                         <td>{{ instance.starttime }}</td>                         <td>{{ instance.timespan }}</td>                         <td>{{ instance.date }}</td>                                               <td><a href="/admin/contestmanagement/news/?contest__id__exact={{ instance.id }}">news</a></td>                                        {% endfor %} 

now when click on link, shows list of news special contest id want. want know how can understand in template(change_list filtered contest id), contest id in page add news contest id , have do? (because current url is: /admin/contestmanagement/news/add/ <code>enter image description here</code> tried {{request}} in template, empty!! lot help

if {{request}} empty have add django.core.context_processors.request in template_context_processors of settings.py

see: https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request


Comments

Popular posts from this blog

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -