How to send parameters to templates and adjust the page url by path?

20 views
Skip to first unread message

lingo...@gmail.com

unread,
Dec 12, 2018, 10:21:26 PM12/12/18
to Django users
Hello,

How to send parameters to templates and adjust the page url by path?

regards,

Saeed

Ira Abbott

unread,
Dec 12, 2018, 11:04:05 PM12/12/18
to Django users
hi,

This is not much to go on:  The 'parameters' are called 'context'

You can read: 

to learn about templates and context. 

adding context in a view is done by adding context to a view as follows:

    def get_context_data(self, *args, **kwargs):
        data = super().get_context_data(*args, **kwargs)
        data['title'] = 'New User Signup'
        data['login_url'] = '/accounts/login/'
        return data

'adjust the page url path' could mean one of two things:
- access the url path in the view (self.request.path) and then adjust context accordingly would simply the path this way and adjust 'data'
- change the url to which a page responds or assign a new url to a view - this is done in urls.py via a regualr expression.

Please elaborate - you have to provide information to get it.

Regards,

Ira

Saeed Pooladzadeh

unread,
Dec 13, 2018, 4:29:13 AM12/13/18
to Django users
Thank you Ira

در چهارشنبه 12 دسامبر 2018، ساعت 19:21:26 (UTC-8)، lingo...@gmail.com نوشته:
Reply all
Reply to author
Forward
0 new messages