Re: question about url

2014-01-09 Thread Tom Evans
On Thu, Jan 9, 2014 at 11:06 AM, luca72  wrote:
> Hello
> i have defined an url as:
>
> (r'^tipi/(\w)', 'polls.views.tipi'),

The word 'tipi', followed by a forward slash, followed by a SINGLE
'word' character, and then any other characters before the end of the
URL (but none of them will be captured as an argument to your view,
only the first word character.)

>
> the template is:
>
> (not relevant)
>
> the view is:
> def tipi(request,a):
>   if a == 'Barbaresco':
> testo = ['Wine name: BARBARESCO','Region: Piedmont']
> titolo = 'Wines'
> variabile = 'vino'
> return render_to_response('vini.html',{'testo':testo,'titolo':titolo,
> 'testo':testo,'variabile':variabile,})
>
> But i get that i don't have a http response where is the error?

The view only returns a http response if a == 'Barbaresco', if it is
any other value then your view returns nothing. A view must *always*
return a HttpResponse, in every circumstance.

Also, because of the URL issue I pointed out earlier, a will never
equal 'Barbarseco'; at most it will be 'B'.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1LijkLw6Ef9U2%2BOp0zCAZHeaW_YLhiFHEeFHnVpCz2iFg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: question about url

2014-01-09 Thread Avraham Serour
you are probably opening the wrong url, I also suggest using $ at the end
of the regex


On Thu, Jan 9, 2014 at 1:06 PM, luca72  wrote:

> Hello
> i have defined an url as:
>
> (r'^tipi/(\w)', 'polls.views.tipi'),
>
> the template is:
>
> 
> {% if variabile == "vino" %}
>   
>   {% for a in lista_vini %}
>   {{a}}
>   {% endfor %}
>   
>   {% endif %}
> 
>
> the view is:
> def tipi(request,a):
>   if a == 'Barbaresco':
> testo = ['Wine name: BARBARESCO','Region: Piedmont']
> titolo = 'Wines'
> variabile = 'vino'
> return render_to_response('vini.html',{'testo':testo,'titolo':titolo,
> 'testo':testo,'variabile':variabile,})
>
> But i get that i don't have a http response where is the error?
>
> Thanks Luca
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a1c96c85-0190-465d-a23f-8ad04d2b5792%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6t%2BAK6d3piQ%2B0Ef53N4NKeokHjvkJQjTF%3DuHqCUqjrRW%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


question about url

2014-01-09 Thread luca72
Hello
i have defined an url as:

(r'^tipi/(\w)', 'polls.views.tipi'),

the template is:


{% if variabile == "vino" %}
  
  {% for a in lista_vini %}
  {{a}}
  {% endfor %}
  
  {% endif %}


the view is:
def tipi(request,a):
  if a == 'Barbaresco':
testo = ['Wine name: BARBARESCO','Region: Piedmont']
titolo = 'Wines'
variabile = 'vino'
return render_to_response('vini.html',{'testo':testo,'titolo':titolo, 
'testo':testo,'variabile':variabile,})

But i get that i don't have a http response where is the error?

Thanks Luca

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a1c96c85-0190-465d-a23f-8ad04d2b5792%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about URL namespaces

2013-01-07 Thread Amirouche
*tl;dr* if you do not reuse the same django application several times it is 
not useful.

The following is a messy don't hesitate to ask for clarification so that me 
or someone else can contribute more documentation regarding this topic, 
there is probably more than that but that's what I understood.

On Wednesday, January 2, 2013 9:28:06 AM UTC+1, Dae_James wrote:
>
> So what does instance actually mean here?


To understand instance you need to understand *application* *in the urls*.
 

>  Does it just mean another copy of the app directory with a different 
> directory name?
>

No, it's just about urls and views, it's *another copy of the urls* and 
notably any model mechanics should be handled separatly (!) (I explain 
below how it can be done). «application_namespace» can possibly be 
something else that the (generic) application name, it is actually refering 
the an application in the website point of view not the code point of view, 
even if most of the time those are the same. It can be something else when 
you have a set of urls for one application say you have a favorite 
application it has two set of urls:

- navigation of favorites: list, detail, search views, every users has 
access to those urls 
- private favorites handling: add, change, delete and also probably list, 
search and detail with specific UI to edit a favorite, the page served by 
this urls are specific to the current user

So, given the above setup you can have two application namespaces 
«favorites-public» and «favorites-user» in one «django application» see [0]

It makes sens to have two urlpatterns in the generic app because you can 
hook them separatly in the url router.


> 在 2012年12月30日星期日UTC+8上午3时06分03秒,Ryan Blunden写道:
>>
>> I've never used this feature but I believe it was created so that for a 
>> single Django project, you could provide multiple administration apps. For 
>> example, you might have one for customers and one for back office staff 
>> that expose different models, have different permissions etc.
>>
>
Yes, it used by the admin because it wants to be generic and be reusable 
thus generic apps should also use namespaced urls see [0] it is not admin 
specific, application_namespace and instance_namespace are used in 
different situations:

- application_namespace removes the need to namespace url names like it was 
done before, for instance the index would be named «admin-index» and every 
view will need to use the same scheme because if the admin urls are 
included in another app it could clash with other named urls, instead now 
you use the include(urlpatterns, application_namespace, instance_namespace) 
you can keep the url names sane and still profit from namespacing offered 
by the include. Hence, IMO, application_namespace should be provided by the 
generic app developper.

- instance_namespace should be set by the user of the application when he 
or she wants to refer to a particular instance of the urls, say you include 
twice the admin appplication you have to provide an instance_namespace if 
you want to be able to refer to one or the other admin app. Before 
namespaces it was not possible to reuse the application urlpatterns, you 
had to rebuild all the patterns with names like «customer-admin-index» and 
«manager-admin-index» 

Regarding the 
reversethe
 documentation is not laking I think but I made an mini-example app as 
an urls.py file that you can drop as your projects 
urlsso that you can experiment with it, the 
output is:

If no current_app is provided, reversing by application_namespace will 
match the last included url
   
   - reverse(app_ns:one, current_app=None): /app/instance_three/one
   - reverse(app_ns:two, current_app=None): /app/instance_three/two

If you set current_app to an instance_namespace it reverse to the *current 
instance* of the application namespace
   
   - reverse(app_ns:one, current_app=instance_ns_two): /app/instance_two/one
   - reverse(app_ns:two, current_app=instance_ns_two): /app/instance_two/two

If you reverse using *instance_namespace* whatever the current_app it will 
be resolved to the instance url
   
   - reverse(instance_ns_one:two, current_app=instance_ns_one): 
   /app/instance_one/two
   - reverse(instance_ns_one:two, current_app=instance_ns_two): 
   /app/instance_one/two
   - reverse(instance_ns_one:two, current_app=instance_ns_three): 
   /app/instance_one/two

Gotcha I think, when urls are namespaces you can't resolve them without a 
namespace, in this example for instance reverse('one') raise an 
UnresolvedUrl exception (at least without current_app...)

 

> So to answer your question about what "application" means in this context, 
>> it means a Django application (e.g. django.contrib.admin).
>>
>
Yes and no, most of the time it's true but not all the time, it's 
«application» from a website perspective, not django code 

Re: Question about URL namespaces

2013-01-02 Thread Dae_James
So what does instance actually mean here?  Does it just mean another copy 
of the app directory with a different directory name?

在 2012年12月30日星期日UTC+8上午3时06分03秒,Ryan Blunden写道:
>
> I've never used this feature but I believe it was created so that for a 
> single Django project, you could provide multiple administration apps. For 
> example, you might have one for customers and one for back office staff 
> that expose different models, have different permissions etc.
>
> So to answer your question about what "application" means in this context, 
> it means a Django application (e.g. django.contrib.admin).
>
> Cheers,
> Ryan
>
> On 29/12/2012, at 4:44 AM, "Dae James"  
> wrote:
>
> When I was reading django's URL document, I come across "URL namespaces".
> The raw sentence is "When you need to deploy multiple instances of a 
> single application, it can be helpful to be able to differentiate between 
> instances."
> I'm very confused here. What the application here refer to? Does it mean  
> models ? Or something else I don't know?
> Thank you~~
>  
> --
> Dae James
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django...@googlegroups.com
> .
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com .
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UElaFuMkhv0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Question about URL namespaces

2012-12-29 Thread Ryan Blunden
I've never used this feature but I believe it was created so that for a single 
Django project, you could provide multiple administration apps. For example, 
you might have one for customers and one for back office staff that expose 
different models, have different permissions etc.

So to answer your question about what "application" means in this context, it 
means a Django application (e.g. django.contrib.admin).

Cheers,
Ryan

On 29/12/2012, at 4:44 AM, "Dae James"  wrote:

> When I was reading django's URL document, I come across "URL namespaces".
> The raw sentence is "When you need to deploy multiple instances of a single 
> application, it can be helpful to be able to differentiate between instances."
> I'm very confused here. What the application here refer to? Does it mean  
> models ? Or something else I don't know?
> Thank you~~
>  
> Dae James
> -- 
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Question about URL namespaces

2012-12-29 Thread Dae James
When I was reading django's URL document, I come across "URL namespaces". 
The raw sentence is "When you need to deploy multiple instances of a single 
application, it can be helpful to be able to differentiate between instances."
I'm very confused here. What the application here refer to? Does it mean  
models ? Or something else I don't know?
Thank you~~




Dae James

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Newbie question about url and seo

2010-08-20 Thread Karim Gorjux
On Fri, Aug 20, 2010 at 18:19, David Euzen  wrote:
> Hello,
>
> you should think of it in terms of ressource, not of file. URLs are
> about ressources not about files even if sometimes ressources are
> files.

Thanks for your answer. Was very useful!

Have a nice day.

-- 
Karim Gojux
www.karimblog.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Newbie question about url and seo

2010-08-20 Thread David Euzen
Hello,

you should think of it in terms of ressource, not of file. URLs are
about ressources not about files even if sometimes ressources are
files.

Django's way to build URLs is flexible. URLs built this way can make
much more sense that URLs built upon file path. ie
www.yourdomain.com/articles/20101/08/20/your_article_title is way
clearer than www.yourdomain.com/article.php?id=15820

Web crawlers collect URLs, I think they don't bother wether URL
contains a file path or not (but I'm not a expert on this topic). And
the more the URL is clear, the best the ressource is ranked.
I've read many times about clear URLs in SEO good practices.

On 20 août, 14:02, Karim Gorjux  wrote:
> Hi all! This is my first post here in the list, I'm new in django and
> python but I really found it fun and exciting so here we are!
> My first question is pretty simple. I noted that the url I create
> using urls.py are cleaned and pretty but there is no index.html or
> simila. It seems that every url point to a directory. Is that good in
> terms of SEO?
>
> I guess that is even better than the old fashion way with the
> index.something, but I don't know.
>
> Thanks in advance
>
> --
> Karim Gojuxwww.karimblog.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Newbie question about url and seo

2010-08-20 Thread Karim Gorjux
Hi all! This is my first post here in the list, I'm new in django and
python but I really found it fun and exciting so here we are!
My first question is pretty simple. I noted that the url I create
using urls.py are cleaned and pretty but there is no index.html or
simila. It seems that every url point to a directory. Is that good in
terms of SEO?

I guess that is even better than the old fashion way with the
index.something, but I don't know.

Thanks in advance

-- 
Karim Gojux
www.karimblog.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Question about {% url %}

2007-08-07 Thread Tim Chase

>  r'^order_by_(?P-?(title|attachment|date))/(?P[0-9]+)/',
> 
> regex error


While I'm not sure on it, you might try making that a
non-capturing group using "(?:...)":

r'^order_by_(?P-?(?:title|attachment|date))/(?P[0-9]+)/'

which may be less ambiguous to a reverse regexp-parser (which it
sounds like might be used here).  However, with multiple
possibilities, reversal of the regexp may not be feasible.  You
may have to uglify them as multiple URLs:

r'^order_by_(?P-?title)/(?P[0-9]+)/'
r'^order_by_(?P-?attachment)/(?P[0-9]+)/'
r'^order_by_(?P-?date)/(?P[0-9]+)/'

in your urls.py that they're more uniquely identifiable...even if
they each point to the same view.

-tim






--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question about {% url %}

2007-08-07 Thread Margaret

the question is

 r'^order_by_(?P-?(title|attachment|date))/(?P[0-9]+)/',

regex error

On 7/29/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Sun, 2007-07-29 at 06:55 +, ZhangshenPeng wrote:
> > when you use url pattern [a-z]+ and named it , then use in {% url
> > %} ,everything is all right .
> > when I change
> > [a-z]+
> > into
> > (title|attachment|date)
> > django report error "unbalanced parenthesis".
> > how to fix my code to do the right thing ?
> > think
> >
> > code as below
> > ###
> > url.py:
> >
> > urlpatterns = patterns('',
> > url(
> >   r'^order_by_(?P-?(title|attachment|date))/(?
> > P[0-9]+)/',
> >   object_list,
> >   name="white_paper_list"
> >),
> > )
>
> I suspect this is caused by the slightly limited reverse reg-exp parsing
> we have at the moment. Ticket #2977 has a patch to try and fix this.
> Hopefully I'll be checking in something very close to that this week. In
> the meantime, you might want to try the patch on your local system to
> see if it does handle that case.
>
> Regards,
> Malcolm
>
>
>
> >
>


-- 
[EMAIL PROTECTED]
13585201588

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question about {% url %}

2007-08-07 Thread Margaret

anyone resolved this question???

On 7/29/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Sun, 2007-07-29 at 06:55 +, ZhangshenPeng wrote:
> > when you use url pattern [a-z]+ and named it , then use in {% url
> > %} ,everything is all right .
> > when I change
> > [a-z]+
> > into
> > (title|attachment|date)
> > django report error "unbalanced parenthesis".
> > how to fix my code to do the right thing ?
> > think
> >
> > code as below
> > ###
> > url.py:
> >
> > urlpatterns = patterns('',
> > url(
> >   r'^order_by_(?P-?(title|attachment|date))/(?
> > P[0-9]+)/',
> >   object_list,
> >   name="white_paper_list"
> >),
> > )
>
> I suspect this is caused by the slightly limited reverse reg-exp parsing
> we have at the moment. Ticket #2977 has a patch to try and fix this.
> Hopefully I'll be checking in something very close to that this week. In
> the meantime, you might want to try the patch on your local system to
> see if it does handle that case.
>
> Regards,
> Malcolm
>
>
>
> >
>


-- 
[EMAIL PROTECTED]
13585201588

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question about {% url %}

2007-07-29 Thread Malcolm Tredinnick

On Sun, 2007-07-29 at 06:55 +, ZhangshenPeng wrote:
> when you use url pattern [a-z]+ and named it , then use in {% url
> %} ,everything is all right .
> when I change
> [a-z]+
> into
> (title|attachment|date)
> django report error "unbalanced parenthesis".
> how to fix my code to do the right thing ?
> think
> 
> code as below
> ###
> url.py:
> 
> urlpatterns = patterns('',
> url(
>   r'^order_by_(?P-?(title|attachment|date))/(?
> P[0-9]+)/',
>   object_list,
>   name="white_paper_list"
>),
> )

I suspect this is caused by the slightly limited reverse reg-exp parsing
we have at the moment. Ticket #2977 has a patch to try and fix this.
Hopefully I'll be checking in something very close to that this week. In
the meantime, you might want to try the patch on your local system to
see if it does handle that case.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Question about {% url %}

2007-07-29 Thread ZhangshenPeng

when you use url pattern [a-z]+ and named it , then use in {% url
%} ,everything is all right .
when I change
[a-z]+
into
(title|attachment|date)
django report error "unbalanced parenthesis".
how to fix my code to do the right thing ?
think

code as below
###
url.py:

urlpatterns = patterns('',
url(
r'^order_by_(?P-?(title|attachment|date))/(?
P[0-9]+)/',
object_list,
name="white_paper_list"
 ),
)

template.htm:

update

error message:

Traceback (most recent call last):
File "" in ?

  error at /white_paper/order_by_date/1/
  unbalanced parenthesis


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---