Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
URL externa pelo url patterns
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Hernani Fernandes  
View profile   Translate to Translated (View Original)
 More options May 25 2012, 9:46 am
From: Hernani Fernandes <hernan...@gmail.com>
Date: Fri, 25 May 2012 06:46:31 -0700 (PDT)
Local: Fri, May 25 2012 9:46 am
Subject: URL externa pelo url patterns
Olá pessoal,
alguém sabe como poderia criar um redirecionamento externo usando o
url patterns?
ex:

no template colocar algo como

{% url contato %}   <- assim toda vez que eu usar isso no template

no urlpatterns teria algo como

url (r'^http://www.google.com.br/$', 'contato',) <- ele substitui por
isso www.google.....

é bem estranho e provavelmente não exista, mas qual o mais próximo
disso?
Obrigado.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Henrique Bastos  
View profile   Translate to Translated (View Original)
 More options May 25 2012, 9:59 am
From: Henrique Bastos <henri...@bastos.net>
Date: Fri, 25 May 2012 10:59:26 -0300
Local: Fri, May 25 2012 9:59 am
Subject: Re: URL externa pelo url patterns

Dê uma olhada em namespaces: https://docs.djangoproject.com/en/dev/topics/http/urls/#defining-url-...

[]'s,
--
Henrique Bastos
+55 21 9618-6180
http://henriquebastos.net
Twitter: henriquebastos
Gtalk: henri...@bastos.net
Skype: henriquebastos.net

On 25/05/2012, at 10:46, Hernani Fernandes <hernan...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vinicius Mendes  
View profile   Translate to Translated (View Original)
 More options May 26 2012, 12:03 am
From: Vinicius Mendes <vbmen...@gmail.com>
Date: Sat, 26 May 2012 01:03:25 -0300
Local: Sat, May 26 2012 12:03 am
Subject: Re: URL externa pelo url patterns

O url patterns foi feito para mapear rotas dentro da sua aplicação para que
ela saiba que código executar ao receber uma requisição em determinada URL.
Ele não foi feito para fazer redirects externos.

Para isso existe o shortcut redirect [1], a generic view RedirectView [2] e
as classes HttpResponseRedirect (HTTP 302) [3] e
HttpResponsePermanentRedirect (HTTP 301) [4].

Se o que você quer é retornar uma URL externa ao chamar {% url contato %},
o seu problema não é no url patterns e sim na template tag que você está
utilizando. Talvez fazer uma outra template tag que resolva seu problema
seja melhor.

[1] https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#redirect
[2]
https://docs.djangoproject.com/en/dev/ref/class-based-views/#django.v...
[3]
https://docs.djangoproject.com/en/dev/ref/request-response/#django.ht...
[4]
https://docs.djangoproject.com/en/dev/ref/request-response/#django.ht...

Atenciosamente,
Vinicius Mendes
Engenheiro de Computação
Globo.com

2012/5/25 Henrique Bastos <henri...@bastos.net>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matheus Lima  
View profile   Translate to Translated (View Original)
 More options May 26 2012, 2:57 am
From: Matheus Lima <matheus...@gmail.com>
Date: Sat, 26 May 2012 03:57:07 -0300
Local: Sat, May 26 2012 2:57 am
Subject: Re: URL externa pelo url patterns

Você pode mapear uma url pra uma view que te redireciona pro link externo.
Eeria uma url normal, apontando pra uma view. Nessa view você faz o
redirect.

Em 26 de maio de 2012 01:03, Vinicius Mendes <vbmen...@gmail.com> escreveu:

--
Att,
*
*
*Matheus dos Santos Lima     ** <http://twitter.com/matheeusLimaaa>
<http://www.orkut.com.br/Main#Profile?rl=mp&uid=6921349383894587556>
  <http://www.facebook.com/profile.php?id=100001639854566> *
Bel. em Sistemas de Informação - UFS (2011.2)
CSM <http://www.scrumalliance.org/profiles/117413-matheus-dos-santos-lima>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vinicius Mendes  
View profile   Translate to Translated (View Original)
 More options May 26 2012, 7:55 am
From: Vinicius Mendes <vbmen...@gmail.com>
Date: Sat, 26 May 2012 08:55:27 -0300
Local: Sat, May 26 2012 7:55 am
Subject: Re: URL externa pelo url patterns

Se fizer uma view só pra fazer o redirect, você tá piorando a experiência
do usuário e sobrecarregando seu servidor desnecessariamente. Toda vez que
o usuário clicar no link, ele vai esperar seu servidor responder falando
que é um redirect para poder requisitar a url correta. A não ser que você
tenha algum outro bom motivo para ter essa view, é melhor não fazê-la.

Atenciosamente,
Vinicius Mendes
Engenheiro de Computação
Globo.com

2012/5/26 Matheus Lima <matheus...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Douglas Miranda  
View profile   Translate to Translated (View Original)
 More options May 26 2012, 1:38 pm
From: Douglas Miranda <douglasmirandasi...@gmail.com>
Date: Sat, 26 May 2012 10:38:13 -0700 (PDT)
Local: Sat, May 26 2012 1:38 pm
Subject: Re: URL externa pelo url patterns

Há algo que lhe impede de colocar direto no template isto? <a
href="http://google.com.br"..

Em sexta-feira, 25 de maio de 2012 09h46min31s UTC-4, Hernani Fernandes
escreveu:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matheus Lima  
View profile   Translate to Translated (View Original)
 More options May 26 2012, 3:05 pm
From: Matheus Lima <matheus...@gmail.com>
Date: Sat, 26 May 2012 16:05:54 -0300
Local: Sat, May 26 2012 3:05 pm
Subject: Re: URL externa pelo url patterns

A melhor forma seria o link direto, uma outra opção seria o direcionamento
pelo dominio mesmo. Mas ele quer poder usar a templatetag 'url', nenhuma
dessas duas soluções vai permitir.

Em 26 de maio de 2012 14:38, Douglas Miranda
<douglasmirandasi...@gmail.com>escreveu:

--
Att,
*
*
*Matheus dos Santos Lima     ** <http://twitter.com/matheeusLimaaa>
<http://www.orkut.com.br/Main#Profile?rl=mp&uid=6921349383894587556>
  <http://www.facebook.com/profile.php?id=100001639854566> *
 Bel. em Sistemas de Informação - UFS (2011.2)
CSM <http://www.scrumalliance.org/profiles/117413-matheus-dos-santos-lima>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Henrique Bastos  
View profile   Translate to Translated (View Original)
 More options May 27 2012, 7:29 am
From: Henrique Bastos <henri...@bastos.net>
Date: Sun, 27 May 2012 08:29:54 -0300
Local: Sun, May 27 2012 7:29 am
Subject: Re: URL externa pelo url patterns

Opa!

Posso estar equivocado, mas estou com a sensação de que ele deseja ter um
"banco de links" que podem mudar com certa frequência. Talvez o exemplo do
google.com tenha sido genérico d+.

Se esse for o caso, o que já vi acontecer em CMS onde o usuário deseja ser
capaz de atualizar os links, me parece que no contrib do django tem a app
redirects <https://docs.djangoproject.com/en/dev/ref/contrib/redirects/>que
pode servir de inspiração, apesar de não parecer ser exatamente a
solução desejada.

Abs,
--
Henrique Bastos <http://henriquebastos.net>

Curso Welcome to the Django <http://welcometothedjango.com.br>
Aprenda Python e Django na Prática!

Twitter: @henriquebastos <http://twitter.com/henriquebastos>
Skype: henriquebastos.net
+55 21 9618-6180

2012/5/26 Matheus Lima <matheus...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gileno Alves  
View profile   Translate to Translated (View Original)
 More options May 28 2012, 8:56 pm
From: Gileno Alves <gascf....@gmail.com>
Date: Mon, 28 May 2012 21:56:27 -0300
Local: Mon, May 28 2012 8:56 pm
Subject: Re: URL externa pelo url patterns

Concordo com Henrique,

também acho que seja isso que ele deseja e na verdade para não ter que
atualizar manualmente a url nos templates prefere chamar via uma
templatetag.

Uma solução seria criar outra templatetag para url's externas e adicionar
essas urls em um arquivo ou banco de dados, um model que armazenasse um
nome para a url e o valor por exemplo e usando as fixtures[1] do django
você poderia colocar as urls's

1 -  https://docs.djangoproject.com/en/1.4/howto/initial-data/

2012/5/27 Henrique Bastos <henri...@bastos.net>

--
Gileno Filho, Web Developer
http://www.gilenofilho.com.br | gascf....@gmail.com |
http://www.pycursos.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vinicius Mendes  
View profile   Translate to Translated (View Original)
 More options May 29 2012, 10:38 am
From: Vinicius Mendes <vbmen...@gmail.com>
Date: Tue, 29 May 2012 11:38:00 -0300
Subject: Re: URL externa pelo url patterns

Pelo que eu entendi, o que ele quer é criar um alias para um determinado
link de forma que ele possa trocar o link sem precisar substituir em todos
os lugares que ele foi utilizado. Se a intenção for essa, uma template
tag<https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/>que
receba como parametro uma chave para distinguir o link e obtenha o
link
de um mapeamento resolve o problema. Se existir demanda de alimentar o
mapeamento através de um CMS, faz sentido utilizar a app de redirects. Mas
lembre-se, como o Douglas e o Matheus sugeriram, a não ser que você
realmente tenha essas demandas que mencionei acima, a melhor solução é
utilizar o link diretamente.

Atenciosamente,
Vinicius Mendes
Engenheiro de Computação
Globo.com

2012/5/28 Gileno Alves <gascf....@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jayson Reis  
View profile   Translate to Translated (View Original)
 More options May 29 2012, 10:42 am
From: Jayson Reis <santosdosr...@gmail.com>
Date: Tue, 29 May 2012 11:42:58 -0300
Local: Tues, May 29 2012 10:42 am
Subject: Re: URL externa pelo url patterns

Você pode fazer assim.
from django.views.generic import RedirectView

url(r'^google/?$', RedirectView.as_view(url='http://google.com.br'),
name='contato')

e usar normalmente com {% url contato %}
Jayson Reis

2012/5/25 Hernani Fernandes <hernan...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hernani Fernandes  
View profile   Translate to Translated (View Original)
 More options May 29 2012, 12:01 pm
From: Hernani Fernandes <hernan...@gmail.com>
Date: Tue, 29 May 2012 09:01:26 -0700 (PDT)
Local: Tues, May 29 2012 12:01 pm
Subject: Re: URL externa pelo url patterns
galera, vocês são fodas! valeu a todos !

On 29 maio, 11:42, Jayson Reis <santosdosr...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »