Re: Are URL namespaces optional or are they used by default by Django?

2018-01-10 Thread Stodge
Problem solved and apparently it was my silly mistake! While experimenting 
I added app_name to my urls files. Apparently this enables namespace 
support. So I removed them from my urls files and it works.

Thanks

On Thursday, 21 December 2017 10:38:36 UTC-5, Stodge wrote:
>
> I am porting an app from Django 1.6.x to 1.10.x and I'm hitting a problem 
> with URL namespaces. I don't specifically configure any namespaces in my 
> URLs but Django seems to think that all my app URLs are namespaced. The 
> documentation seems to imply that namespaces are optional and only 
> configured if provided, but my experience suggests otherwise. Would someone 
> be able to confirm if namespaces are optional (opt-in)? I'm really rather 
> confused at the moment about this. Thanks
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9126cdfd-81e5-48ee-97b9-ad62edaeff4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Are URL namespaces optional or are they used by default by Django?

2017-12-21 Thread Andréas Kühne
Hi again,

I don't understand what you mean then. Because you say that they are
namespaced. What I mean by that is that when using reverse, you have to
use:
reverse("license:edit_license", args=(1, )).

However, if this is the code you have used:
for app in settings.SITE_APPS.get_application_list():
url_prefix = r'^%s/' % app
urlpatterns += [
url(prefix, include(url_include)),

]

Then that won't work either - because you add the prefix variable to the
urlpattern and not the url_prefix variable. So this would add it the same
way I wanted to add it:

url('', include(url_include))

So I would fix that first at least.

Regards,

Andréas

2017-12-21 17:58 GMT+01:00 Stodge <sto...@gmail.com>:

> Thanks,
>
> My edit license URL is:
>
> url(r'^license/edit/(?P\d+)/$', views.edit_license, name=
> 'edit_license'),
>
> However, this is what I want and it has been this way for years. My URLs
> are organised:
>
> ///
>
> I don't think this explains why my URLs are all namespaced when I haven't
> changed my code and my code doesn't use namespaces. I'm really confused. :)
>
> Thanks again
> Mike
>
>
>
>
>
> On Thursday, 21 December 2017 11:38:42 UTC-5, Andréas Kühne wrote:
>>
>> Ok,
>>
>> You have not namespaced anything, but you have added the api name infront
>> of the URLs you are adding.
>>
>> So for example, I am guessing that you in your urls.py file for the
>> license app have added "/license/edit//" for the license
>> detail page? Because you have already added the license part with the
>> prefix you have added here:
>>
>> for app in settings.SITE_APPS.get_application_list():
>> url_prefix = r'^%s/' % app
>> urlpatterns += [
>> url(prefix, include(url_include)),
>>
>> ]
>>
>>
>> So you have added license twice, and therefore you will need to add it
>> twice when you call the urls as well.
>>
>> You should probably do this instead:
>> for app in settings.SITE_APPS.get_application_list():
>> url_prefix = r'^%s/' % app
>> urlpatterns += [
>> url('', include(url_include)),
>>
>> ]
>>
>>
>>
>> If you don't want that extra license part.
>>
>> Namespace is added the way you suggested via:
>> url('', include(url_include, namespace="license"))
>>
>> Also, it doesn't result in an extra app part (in this case license), it
>> only adds the namespace in the call to reserve, so if you had setup the
>> namespace like i wrote here, you would use:
>> reverse("license:license_detail", args=(1, ))
>>
>> Hope I have explained it good enough :-)
>>
>> Regards,
>>
>> Andréas
>>
>> 2017-12-21 17:02 GMT+01:00 Stodge <sto...@gmail.com>:
>>
>>> I am using a prefix when I include the URLs for each app:
>>>
>>> for app in settings.SITE_APPS.get_application_list():
>>> url_prefix = r'^%s/' % app
>>> urlpatterns += [
>>> url(prefix, include(url_include)),
>>>
>>> ]
>>>
>>> I just assumed this isn't using namespaces because I'm not using the
>>> namespace parameter on include()?
>>>
>>>
>>>
>>> On Thursday, 21 December 2017 10:38:36 UTC-5, Stodge wrote:
>>>>
>>>> I am porting an app from Django 1.6.x to 1.10.x and I'm hitting a
>>>> problem with URL namespaces. I don't specifically configure any namespaces
>>>> in my URLs but Django seems to think that all my app URLs are namespaced.
>>>> The documentation seems to imply that namespaces are optional and only
>>>> configured if provided, but my experience suggests otherwise. Would someone
>>>> be able to confirm if namespaces are optional (opt-in)? I'm really rather
>>>> confused at the moment about this. Thanks
>>>>
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/b471c11c-2d33-4f47-83a2-36209edd4ea0%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/b471c11c-2d

Re: Are URL namespaces optional or are they used by default by Django?

2017-12-21 Thread Stodge
Thanks,

My edit license URL is:

url(r'^license/edit/(?P\d+)/$', views.edit_license, name=
'edit_license'),

However, this is what I want and it has been this way for years. My URLs 
are organised:

///

I don't think this explains why my URLs are all namespaced when I haven't 
changed my code and my code doesn't use namespaces. I'm really confused. :)

Thanks again
Mike





On Thursday, 21 December 2017 11:38:42 UTC-5, Andréas Kühne wrote:
>
> Ok,
>
> You have not namespaced anything, but you have added the api name infront 
> of the URLs you are adding.
>
> So for example, I am guessing that you in your urls.py file for the 
> license app have added "/license/edit//" for the license 
> detail page? Because you have already added the license part with the 
> prefix you have added here:
>
> for app in settings.SITE_APPS.get_application_list():
> url_prefix = r'^%s/' % app
> urlpatterns += [
> url(prefix, include(url_include)),
>
> ]
>
>
> So you have added license twice, and therefore you will need to add it 
> twice when you call the urls as well.
>
> You should probably do this instead:
> for app in settings.SITE_APPS.get_application_list():
> url_prefix = r'^%s/' % app
> urlpatterns += [
> url('', include(url_include)),
>
> ]
>
>
>
> If you don't want that extra license part.
>
> Namespace is added the way you suggested via:
> url('', include(url_include, namespace="license"))
>
> Also, it doesn't result in an extra app part (in this case license), it 
> only adds the namespace in the call to reserve, so if you had setup the 
> namespace like i wrote here, you would use: 
> reverse("license:license_detail", args=(1, ))
>
> Hope I have explained it good enough :-)
>
> Regards,
>
> Andréas
>
> 2017-12-21 17:02 GMT+01:00 Stodge <sto...@gmail.com >:
>
>> I am using a prefix when I include the URLs for each app:
>>
>> for app in settings.SITE_APPS.get_application_list():
>> url_prefix = r'^%s/' % app
>> urlpatterns += [
>> url(prefix, include(url_include)),
>>
>> ]
>>
>> I just assumed this isn't using namespaces because I'm not using the 
>> namespace parameter on include()?
>>
>>
>>
>> On Thursday, 21 December 2017 10:38:36 UTC-5, Stodge wrote:
>>>
>>> I am porting an app from Django 1.6.x to 1.10.x and I'm hitting a 
>>> problem with URL namespaces. I don't specifically configure any namespaces 
>>> in my URLs but Django seems to think that all my app URLs are namespaced. 
>>> The documentation seems to imply that namespaces are optional and only 
>>> configured if provided, but my experience suggests otherwise. Would someone 
>>> be able to confirm if namespaces are optional (opt-in)? I'm really rather 
>>> confused at the moment about this. Thanks
>>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/b471c11c-2d33-4f47-83a2-36209edd4ea0%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/b471c11c-2d33-4f47-83a2-36209edd4ea0%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e29c8fd-f13d-4281-a047-622dc8868147%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Are URL namespaces optional or are they used by default by Django?

2017-12-21 Thread Andréas Kühne
Ok,

You have not namespaced anything, but you have added the api name infront
of the URLs you are adding.

So for example, I am guessing that you in your urls.py file for the license
app have added "/license/edit//" for the license detail page?
Because you have already added the license part with the prefix you have
added here:

for app in settings.SITE_APPS.get_application_list():
url_prefix = r'^%s/' % app
urlpatterns += [
url(prefix, include(url_include)),

]


So you have added license twice, and therefore you will need to add it
twice when you call the urls as well.

You should probably do this instead:
for app in settings.SITE_APPS.get_application_list():
url_prefix = r'^%s/' % app
urlpatterns += [
url('', include(url_include)),

]



If you don't want that extra license part.

Namespace is added the way you suggested via:
url('', include(url_include, namespace="license"))

Also, it doesn't result in an extra app part (in this case license), it
only adds the namespace in the call to reserve, so if you had setup the
namespace like i wrote here, you would use:
reverse("license:license_detail", args=(1, ))

Hope I have explained it good enough :-)

Regards,

Andréas

2017-12-21 17:02 GMT+01:00 Stodge <sto...@gmail.com>:

> I am using a prefix when I include the URLs for each app:
>
> for app in settings.SITE_APPS.get_application_list():
> url_prefix = r'^%s/' % app
> urlpatterns += [
> url(prefix, include(url_include)),
>
> ]
>
> I just assumed this isn't using namespaces because I'm not using the
> namespace parameter on include()?
>
>
>
> On Thursday, 21 December 2017 10:38:36 UTC-5, Stodge wrote:
>>
>> I am porting an app from Django 1.6.x to 1.10.x and I'm hitting a problem
>> with URL namespaces. I don't specifically configure any namespaces in my
>> URLs but Django seems to think that all my app URLs are namespaced. The
>> documentation seems to imply that namespaces are optional and only
>> configured if provided, but my experience suggests otherwise. Would someone
>> be able to confirm if namespaces are optional (opt-in)? I'm really rather
>> confused at the moment about this. Thanks
>>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b471c11c-2d33-4f47-83a2-36209edd4ea0%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b471c11c-2d33-4f47-83a2-36209edd4ea0%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCfOYNfWT0hd-szZ52FQTbFP-VZL2UxcfCX0-E2HJAP2ew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Are URL namespaces optional or are they used by default by Django?

2017-12-21 Thread Stodge
I am using a prefix when I include the URLs for each app:

for app in settings.SITE_APPS.get_application_list():
url_prefix = r'^%s/' % app
urlpatterns += [
url(prefix, include(url_include)),

]

I just assumed this isn't using namespaces because I'm not using the 
namespace parameter on include()?



On Thursday, 21 December 2017 10:38:36 UTC-5, Stodge wrote:
>
> I am porting an app from Django 1.6.x to 1.10.x and I'm hitting a problem 
> with URL namespaces. I don't specifically configure any namespaces in my 
> URLs but Django seems to think that all my app URLs are namespaced. The 
> documentation seems to imply that namespaces are optional and only 
> configured if provided, but my experience suggests otherwise. Would someone 
> be able to confirm if namespaces are optional (opt-in)? I'm really rather 
> confused at the moment about this. Thanks
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b471c11c-2d33-4f47-83a2-36209edd4ea0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Are URL namespaces optional or are they used by default by Django?

2017-12-21 Thread Stodge
Thanks Andreas,

I'm seeing three things;

1) Reverse URLs are failing until I specifically add the app's name as a 
namespace
2) The show_urls management command from the django_extensions project 
appears to show that all URLs have a namespace:

/license/license/edit// core.decorators.WVCheckLoginPermissions
() license:edit_license

3) All resource URIs in TastyPie are empty, which according to a ticket I 
found there seems to be caused by namespaces.

Thanks
Mike


On Thursday, 21 December 2017 10:47:28 UTC-5, Andréas Kühne wrote:
>
> Hi,
>
> Namespaces are completely optional - you don't have to use it if you don't 
> want to. 
>
> What is happening that makes you think otherwise? What errors are you 
> seeing?
>
> Regards,
>
> Andréas
>
> 2017-12-21 16:38 GMT+01:00 Stodge <sto...@gmail.com >:
>
>> I am porting an app from Django 1.6.x to 1.10.x and I'm hitting a problem 
>> with URL namespaces. I don't specifically configure any namespaces in my 
>> URLs but Django seems to think that all my app URLs are namespaced. The 
>> documentation seems to imply that namespaces are optional and only 
>> configured if provided, but my experience suggests otherwise. Would someone 
>> be able to confirm if namespaces are optional (opt-in)? I'm really rather 
>> confused at the moment about this. Thanks
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/2f722055-c058-4d06-b4e7-ca47b2511769%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/2f722055-c058-4d06-b4e7-ca47b2511769%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1816bc1d-c5ef-4814-9e11-2ce45c8db802%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Are URL namespaces optional or are they used by default by Django?

2017-12-21 Thread Andréas Kühne
Hi,

Namespaces are completely optional - you don't have to use it if you don't
want to.

What is happening that makes you think otherwise? What errors are you
seeing?

Regards,

Andréas

2017-12-21 16:38 GMT+01:00 Stodge <sto...@gmail.com>:

> I am porting an app from Django 1.6.x to 1.10.x and I'm hitting a problem
> with URL namespaces. I don't specifically configure any namespaces in my
> URLs but Django seems to think that all my app URLs are namespaced. The
> documentation seems to imply that namespaces are optional and only
> configured if provided, but my experience suggests otherwise. Would someone
> be able to confirm if namespaces are optional (opt-in)? I'm really rather
> confused at the moment about this. Thanks
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/2f722055-c058-4d06-b4e7-ca47b2511769%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2f722055-c058-4d06-b4e7-ca47b2511769%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCcqBOC2mLpfOm-hikHh3fE70iwLTZC6y%2BmOx%3DOd0E%2BvDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Are URL namespaces optional or are they used by default by Django?

2017-12-21 Thread Stodge
I am porting an app from Django 1.6.x to 1.10.x and I'm hitting a problem 
with URL namespaces. I don't specifically configure any namespaces in my 
URLs but Django seems to think that all my app URLs are namespaced. The 
documentation seems to imply that namespaces are optional and only 
configured if provided, but my experience suggests otherwise. Would someone 
be able to confirm if namespaces are optional (opt-in)? I'm really rather 
confused at the moment about this. Thanks

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2f722055-c058-4d06-b4e7-ca47b2511769%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL namespaces

2016-02-25 Thread James Schneider
On Thu, Feb 25, 2016 at 12:45 PM, Malik Rumi <malik.a.r...@gmail.com> wrote:

>
> Assuming it can be done, what is the proper way to namespace two models in
> the same app, where both use slugs in the url but have different views and
> templates?
>
> In the docs,
> https://docs.djangoproject.com/en/1.9/topics/http/urls/#url-namespaces,
> it talks about how to do this, but it always refers to 'applications'
> rather than 'models'.
>

That's because models are only a portion of the functionality of the
framework, and usually each app has multiple models associated with it.
URL's can and often do point to views that don't reference models at all.
Part of the philosophy of Django is loose-coupling of URL's and models (and
every other function of Django, as much as possible).

Normally the URL layout would match the intended application:

fruit/apple/
fruit/bananna/

Where you want to use something like:

apple/
bananna/

This isn't a technical restriction that you are dealing with, it is a
design issue. What if you wanted to list all of the fruit available?

#App based
fruit/ #list all fruit

#Model based
fruit/

However, now you've hit an inconsistency with your URL's and models, since
you probably don't have a concrete model named Fruit.

You can design your URL's however you like, just some food for thought.


> So can I do:
>
> *urls.py*
>
> url(r'^model1/', include('app.urls', appview4model1,
> namespace='app.model1')
>
> url(r'^model2/', include('app.urls', appview4model2,
> namespace='app.model2')
>
>
Sure, although I'm not sure if those namespace strings are valid. I use
dashes, and in this case i would just use 'model1' and 'model2'.


>
>
> *app.urls.py <http://app.urls.py>*
>
> app_name = "app.model1"
>
> urlpatterns [ ]
>
> app_name = "app.model2"
>
> urlpatterns [ ]
>
>
> Frankly, I want the shortest urls possible, so if there was a way to do
> this without putting 'model1' or 'model2' in the url, that would be great,
> but I'm not seeing a way around it - assuming the app_name = 'app.model1'
> thing even works.
>

If that's the case, use something like a letter and the PK of the object:
url(r'a/(?P\d+)/')

Short URL's are a great thing to have, but don't twist yourself into a
pretzel to attain them. Ultimately there are only marginal benefits. It's
means you need to simplify your URL structure, and you can already see what
kind of complication that simplification brings...


>
> Another option I thought of but don't know if possible:
>
> try url(r'^(?P) )
> except url(r'^modelname(?P) )
>
> I've never seen anything like that, though. If it did work, I doubt it
> would fit inside urlpatterns[ ], but maybe I could put it after?
>
> Or I could hack the code that handles url name collisions (once I find it)
>
>
There's no practical limit to what a url() tag can contain. URL's can be
thousands of characters long. If your models have a slug attached to them,
you can just use the slug at the top level of the URL structure. It will
likely incur a lookup for each type of model though, and you would need
some extra checking when creating/updating models to ensure that the slugs
are unique between the two. There are various tricks on how to do that
(usually in the save() method of your models) or a related table that keeps
a list of slugs used for both models with uniqueness enforced (maybe even a
GenericForeignKey). Your URL/view can also accept a slug and perform a
lookup against ModelA, and if it doesn't find anything, look again via
ModelB. This is slightly more challenging with a CBV, but is entirely
possible.

Using the bare slug at the top level also hampers your ability to generate
URL's elsewhere due to the overlap with other keywords (although still
possible if you are careful). Technically, keywords like 'contact' are
considered valid slugs, and may incur a lookup against ModelA/B when in
fact you wanted the user to see the contact page.

This method is exactly how URL shorteners work. The system provides the
slug/hash correlated to the real URL in the database, and the shortener
system redirects based on the matching real URL found for the hash.

Unless there is a business requirement for it, I would recommend for your
own sanity each model would live in its own namespace so that wouldn't have
to worry about overlapping slugs, etc.

You should also have a look at app namepaces vs. instance namespaces:
https://docs.djangoproject.com/en/1.9/topics/http/urls/#url-namespaces-and-included-urlconfs

-James

-- 
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.co

Re: URL namespaces

2016-02-25 Thread Alex Heyden
Models don't have views. Applications have views. URLs route to views, not
models. Include is basically an import for a urls.py file as a whole, so
there's no reason to import the same file multiple times unless you wanted
it to match multiple URLs.

What are you actually trying to do?

On Thu, Feb 25, 2016 at 2:45 PM, Malik Rumi <malik.a.r...@gmail.com> wrote:

>
> Assuming it can be done, what is the proper way to namespace two models in
> the same app, where both use slugs in the url but have different views and
> templates?
>
> In the docs,
> https://docs.djangoproject.com/en/1.9/topics/http/urls/#url-namespaces,
> it talks about how to do this, but it always refers to 'applications'
> rather than 'models'.
>
>
> So can I do:
>
> *urls.py*
>
> url(r'^model1/', include('app.urls', appview4model1,
> namespace='app.model1')
>
> url(r'^model2/', include('app.urls', appview4model2,
> namespace='app.model2')
>
>
>
> *app.urls.py <http://app.urls.py>*
>
> app_name = "app.model1"
>
> urlpatterns [ ]
>
> app_name = "app.model2"
>
> urlpatterns [ ]
>
>
> Frankly, I want the shortest urls possible, so if there was a way to do
> this without putting 'model1' or 'model2' in the url, that would be great,
> but I'm not seeing a way around it - assuming the app_name = 'app.model1'
> thing even works.
>
> Another option I thought of but don't know if possible:
>
> try url(r'^(?P) )
> except url(r'^modelname(?P) )
>
> I've never seen anything like that, though. If it did work, I doubt it
> would fit inside urlpatterns[ ], but maybe I could put it after?
>
> Or I could hack the code that handles url name collisions (once I find it)
>
>
> Thanks!
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fdb1ce25-0840-49d3-ab79-3011128a7207%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fdb1ce25-0840-49d3-ab79-3011128a7207%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYVRQvVCF5NUVwhcUX38SCxo_oxoxkS0MVn%3DGHf8y8GaXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


URL namespaces

2016-02-25 Thread Malik Rumi

Assuming it can be done, what is the proper way to namespace two models in 
the same app, where both use slugs in the url but have different views and 
templates? 

In the docs, 
https://docs.djangoproject.com/en/1.9/topics/http/urls/#url-namespaces, it 
talks about how to do this, but it always refers to 'applications' rather 
than 'models'.


So can I do:

*urls.py*

url(r'^model1/', include('app.urls', appview4model1, namespace='app.model1')

url(r'^model2/', include('app.urls', appview4model2, namespace='app.model2')



*app.urls.py*

app_name = "app.model1" 

urlpatterns [ ]

app_name = "app.model2"

urlpatterns [ ]


Frankly, I want the shortest urls possible, so if there was a way to do 
this without putting 'model1' or 'model2' in the url, that would be great, 
but I'm not seeing a way around it - assuming the app_name = 'app.model1' 
thing even works. 

Another option I thought of but don't know if possible:

try url(r'^(?P) )
except url(r'^modelname(?P) )

I've never seen anything like that, though. If it did work, I doubt it 
would fit inside urlpatterns[ ], but maybe I could put it after?

Or I could hack the code that handles url name collisions (once I find it)


Thanks!

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fdb1ce25-0840-49d3-ab79-3011128a7207%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL Namespaces

2014-03-07 Thread anubhav joshi
Thanks.
That was quite helpful.

Regards
Anubhav

-- 
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/1df3efc7-f9c4-49d6-a350-ab5a19dc5379%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL Namespaces

2014-03-05 Thread Jonathan Baker
Much like module namespacing, they allow you to group subitems in more
logical and descriptive ways while preventing naming collisions. So, if a
Django project has a blog, with a list of Posts at /blog/posts/, a sensible
url name for that pattern might be "post_list" (and using url names in your
application is a good thing). Now, say the same project also exposes a
public API, which includes includes Posts at the endpoint
/api/v1/blog/posts/. Since using url names is a good thing, what would you
name the API endpoint while not clobbering the already-defined 'post_list'
url name? Sure, something like 'api_post_list' might be acceptable for the
endpoint I just described, but I prefer the namespaced version
'api:post_list' for a few reasons:

1) You can define a namespace one time when you include a collection of URL
patterns into the top-level urls.py
2) Because you only have to do this once, changing namespaces is a matter
of changing one thing in one place
3) each url pattern in the namespace url pattern collection has no idea
it's even been namespaced, which means you can go on defining the url names
without having to remember some convention for preventing naming collisions
(since django takes care of the for you by following the namespace:url_name
pattern across the board).

Admittedly, this isn't very useful on small projects, but if you encounter
a situation like the one above (or your project grows very large), then the
potential for naming collisions very quickly becomes a reality.

Hope this helps,
Jonathan


On Wed, Mar 5, 2014 at 4:25 AM, anubhav joshi <anubhav9...@gmail.com> wrote:

> Can anyone explain how URL Namespaces work in django.
> Some examples would be great.
> (Apart from those in the docs.)
>
> Regards,
> Anubhav Joshi
>
> --
> 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/1d59cdb2-d375-493d-88ae-da2ece757eee%40googlegroups.com<https://groups.google.com/d/msgid/django-users/1d59cdb2-d375-493d-88ae-da2ece757eee%40googlegroups.com?utm_medium=email_source=footer>
> .
> 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/CAPMFOb68DHThkFMW2mPtNPLW2cs4pA4XOVcYi-PygPpWCvgkAw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


URL Namespaces

2014-03-05 Thread anubhav joshi
Can anyone explain how URL Namespaces work in django.
Some examples would be great.
(Apart from those in the docs.)

Regards,
Anubhav Joshi

-- 
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/1d59cdb2-d375-493d-88ae-da2ece757eee%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about URL namespaces

2013-01-07 Thread Amirouche
e it's true but not all the time, it's 
«application» from a website perspective, not django code perspective, see 
the above example with the favorite app. In the case of the admin it is the 
django application name.

[0] even if there is nothing django provides right now to easly provide a 
default application_namespace, application developpers can provide a 
partial<http://docs.python.org/2/library/functools.html#functools.partial>over 
an 
include<https://docs.djangoproject.com/en/dev/topics/http/urls/#including-other-urlconfs>that
 takes instance_namespace as argument and feed it to the include which 
allows to set the application namespace in the generic app and allow the 
user provide it's own instance_namespace.

What follows is a generalisation of [0] to also handle views configurations 
which probably needs to be done on an url application instance basis, 
otherwise said, including the exact same «website application» several 
times is not useful, there are other ways to do the same thing, but I think 
it is the best.

Now about the configuration of views, given the fact that «include» only 
namespace the urls not the application or the underlying models it uses, it 
is not some multitenancy machinery to automaticaly separate models cf. [1] 
you can dynamically generate the views based on some configuration and do 
that on a set of urls by using a class that looks like 
UrlCollection<https://github.com/django-composite/django-composite/blob/master/composite/urls.py>,
 
which is somewhat similar to django.contrib.admin.sites.AdminSite 
class<https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L29>
.

Basically what the AdminSite does is when urls is queried builds an 
urlpatterns based on some configuration namely 
AdminSite._registry<https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L248>
 then 
retrieve more urls in 
ModelAdmin<https://github.com/django/django/blob/master/django/contrib/admin/options.py#L366>.
 
Now the problem with the admin example is that it a) does not use GCBV b) 
is «dynamic» c) use itself another class to build its urls. 

Taking the favorite chimerical chimera favorite application from above, 
UrlCollection can be used like it's done in this 
gist<https://gist.github.com/4474863>to create three 
*website applications* from the same generic django application by properly 
configuring the views and instance namespaces while still staying DRY.

I'm working on a demo application of that but I need to get a 
ChangeList<https://github.com/django-composite/django-composite-admin/blob/master/admin/views/model/index.py#L65>up
 and running with actions also it uses composite 
views<https://django-composite.readthedocs.org/en/latest/api/composite.html#module-composite.views>but
 the UrlCollection thing is generic enough to be used with any sort of 
views, at least that's the plan ;) 


[1] 
https://developers.google.com/appengine/docs/python/multitenancy/overview 

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~~
>>
>>

-- 
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/-/SCUs3eBazQ4J.
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

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" <daed...@126.com > 
> 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" <daeda...@126.com> 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: How to use URL namespaces in tests?

2012-09-07 Thread e.generalov
Unfortunately in my case, no templates are used.

среда, 5 сентября 2012 г., 20:37:06 UTC+6 пользователь Natim написал:
>
> Ok it is quite easy, you are missing {% load url from future %} in your 
> template.
>
> Le jeudi 23 août 2012 09:25:54 UTC+2, e.generalov a écrit :
>>
>> Url patterns which provided by a django application should be 
>> addressedexternally in 
>> the form of "namespace:name". I guess it will be connected to the project as 
>> follows:
>>
>> project/urls.py
>>
>> urlpatterns = patterns('',
>> url('^something/', include('django_something.urls', 
>> namespace='something')))
>>
>> URL patterns module in the application looks like:
>>
>> django_something/urls.py
>>
>> urlpatterns = patterns('',
>> url('^$', show, name='show'))
>>
>> and I write a test:
>>
>> django_something/tests.py
>>
>> class ShowViewTest(TestCase):
>> urls = 'django_something.urls'
>>
>> def test_should_render_something_template(self):
>> url = reverse('something:show') # !!!
>> response = self.client.get(url)
>> self.assertIn('something.html', set([t.name for t in 
>> response.templates]))
>>
>> This test failes with exception "django NoReverseMatch 'something' is not 
>> a registered namespace" . How can I specify namespace 'something' in 
>> this case?
>
>

-- 
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/-/pZrdA5ZTyoAJ.
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: How to use URL namespaces in tests?

2012-09-05 Thread Natim
Ok it is quite easy, you are missing {% load url from future %} in your 
template.

Le jeudi 23 août 2012 09:25:54 UTC+2, e.generalov a écrit :
>
> Url patterns which provided by a django application should be 
> addressedexternally in 
> the form of "namespace:name". I guess it will be connected to the project as 
> follows:
>
> project/urls.py
>
> urlpatterns = patterns('',
> url('^something/', include('django_something.urls', 
> namespace='something')))
>
> URL patterns module in the application looks like:
>
> django_something/urls.py
>
> urlpatterns = patterns('',
> url('^$', show, name='show'))
>
> and I write a test:
>
> django_something/tests.py
>
> class ShowViewTest(TestCase):
> urls = 'django_something.urls'
>
> def test_should_render_something_template(self):
> url = reverse('something:show') # !!!
> response = self.client.get(url)
> self.assertIn('something.html', set([t.name for t in 
> response.templates]))
>
> This test failes with exception "django NoReverseMatch 'something' is not 
> a registered namespace" . How can I specify namespace 'something' in this 
> case?

-- 
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/-/J7Uo3tFSGzgJ.
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: How to use URL namespaces in tests?

2012-09-05 Thread Natim
I've got the same problem any ideas ?

Le jeudi 23 août 2012 09:25:54 UTC+2, e.generalov a écrit :
>
> Url patterns which provided by a django application should be 
> addressedexternally in 
> the form of "namespace:name". I guess it will be connected to the project as 
> follows:
>
> project/urls.py
>
> urlpatterns = patterns('',
> url('^something/', include('django_something.urls', 
> namespace='something')))
>
> URL patterns module in the application looks like:
>
> django_something/urls.py
>
> urlpatterns = patterns('',
> url('^$', show, name='show'))
>
> and I write a test:
>
> django_something/tests.py
>
> class ShowViewTest(TestCase):
> urls = 'django_something.urls'
>
> def test_should_render_something_template(self):
> url = reverse('something:show') # !!!
> response = self.client.get(url)
> self.assertIn('something.html', set([t.name for t in 
> response.templates]))
>
> This test failes with exception "django NoReverseMatch 'something' is not 
> a registered namespace" . How can I specify namespace 'something' in this 
> case?

-- 
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/-/sbDyYDqLnzMJ.
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.



How to use URL namespaces in tests?

2012-08-23 Thread e.generalov
Url patterns which provided by a django application should be 
addressedexternally in 
the form of "namespace:name". I guess it will be connected to the project as 
follows:

project/urls.py

urlpatterns = patterns('',
url('^something/', include('django_something.urls', 
namespace='something')))

URL patterns module in the application looks like:

django_something/urls.py

urlpatterns = patterns('',
url('^$', show, name='show'))

and I write a test:

django_something/tests.py

class ShowViewTest(TestCase):
urls = 'django_something.urls'

def test_should_render_something_template(self):
url = reverse('something:show') # !!!
response = self.client.get(url)
self.assertIn('something.html', set([t.name for t in 
response.templates]))

This test failes with exception "django NoReverseMatch 'something' is not a 
registered namespace" . How can I specify namespace 'something' in this 
case?

-- 
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/-/gu-nerRvUugJ.
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: Help in understanding URL Namespaces

2009-10-30 Thread Russell Keith-Magee

On Fri, Oct 30, 2009 at 6:03 PM, Continuation <selforgani...@gmail.com> wrote:
>
> I'm new to Django. Having a great time learning from the doc.
>
> Normally the doc explains the topics in hand very clearly. But on 1
> subject I'm still confused after going over the doc: URL Namespaces.
>
> Can someone explain to me what URL Namespaces is for and how does it
> work? Any external articles or tutorials that would help me?
>
> The doc mentioned something about multiple instances of an app, what
> does that mean? For example if I want to use an app (say
> django.contrib.comment) I'd add it to INSTALLED_APPS and start using
> it. So what's the purpose of creating multiple instances of an app and
> how exactly do I create multiple instances?

It's not about having multiple instances of an app in INSTALLED_APPS -
it's about having the URLs for an application deployment multiple
times in your urls.py.

For example - Say you want to have two administration interfaces: a
full admin interface for superusers, and a cut down admin interface
(that has a limited set of models, and maybe some extra helper views)
for editors. You can deploy one instance of the admin app at at
/admin, and the second instance at /editors.

However, both instances will have an "add new article" named URL (one
at /admin/content/article/add, and one at
/editors/content/article/add). You need to have a way to distinguish
the two named URLs, and namespaces is how you do this.

If you're just starting out, you probably don't need to worry about
URL namespaces too much. When you start writing your own reusable
apps, you'll need to pay more attention to URL namespaces, but for
now, get a handle on simple unnamespaced named URLs.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Help in understanding URL Namespaces

2009-10-30 Thread Continuation

I'm new to Django. Having a great time learning from the doc.

Normally the doc explains the topics in hand very clearly. But on 1
subject I'm still confused after going over the doc: URL Namespaces.

Can someone explain to me what URL Namespaces is for and how does it
work? Any external articles or tutorials that would help me?

The doc mentioned something about multiple instances of an app, what
does that mean? For example if I want to use an app (say
django.contrib.comment) I'd add it to INSTALLED_APPS and start using
it. So what's the purpose of creating multiple instances of an app and
how exactly do I create multiple instances?

Also what does URL Namespaces solve that Named URL doesn't?
--~--~-~--~~~---~--~~
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: {% url %} templatetag and url namespaces

2009-08-03 Thread Daybreaker

Thanks, I just reported and found that ticket with your little
help. :)

It seems this problem doesn't have trivial solutions -- I think it
should be documented clearly, or fixed (improved?) later.

On 8월4일, 오전11시59분, Russell Keith-Magee  wrote:
> 2009/8/4 Daybreaker :
>
>
>
> > I've fixed the wrong url templatetag to this:
>
> > {% url lab:bbs:view
> > url_key=lab_object.url_key,board_id=board.id,article_id=item.id %}
>
> The problem here is that namespaces can't contain parameters. For example:
>
> urlpatterns = patterns('myproject.lab.views',
> url(ur'^bbs/', include('myproject.bbs.urls', namespace='bbs')),
> )
>
> is legal, since bbs is a flat namespace, but:
>
> urlpatterns = patterns('myproject.lab.views',
> (ur'^(?P[-a-zA-Z0-9]+)/', include(extra_urlpatterns,
> namespace='lab')),
> ...
> )
>
> is not, because it is trying to parameterise the 'lab' namespace. This
> has been logged as #11559; a more detailed discussion of the problem
> (and some possible workarounds) can be found in that ticket.
>
> Yours
> Russ Magee %-)
--~--~-~--~~~---~--~~
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: {% url %} templatetag and url namespaces

2009-08-03 Thread Russell Keith-Magee

2009/8/4 Daybreaker :
>
> I've fixed the wrong url templatetag to this:
>
> {% url lab:bbs:view
> url_key=lab_object.url_key,board_id=board.id,article_id=item.id %}

The problem here is that namespaces can't contain parameters. For example:

urlpatterns = patterns('myproject.lab.views',
url(ur'^bbs/', include('myproject.bbs.urls', namespace='bbs')),
)

is legal, since bbs is a flat namespace, but:

urlpatterns = patterns('myproject.lab.views',
(ur'^(?P[-a-zA-Z0-9]+)/', include(extra_urlpatterns,
namespace='lab')),
...
)

is not, because it is trying to parameterise the 'lab' namespace. This
has been logged as #11559; a more detailed discussion of the problem
(and some possible workarounds) can be found in that ticket.

Yours
Russ Magee %-)

--~--~-~--~~~---~--~~
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: {% url %} templatetag and url namespaces

2009-08-03 Thread Daybreaker

I've fixed the wrong url templatetag to this:

{% url lab:bbs:view
url_key=lab_object.url_key,board_id=board.id,article_id=item.id %}

...but still I'm getting the error.

On 8월4일, 오전11시37분, Daybreaker  wrote:
> I've slightly fixed the pasted code for readability, and so the url
> templatetag example should be:
>
> {% url lab:bbs:view url_key article_id board_id %}
>
> On 8월4일, 오전11시34분, Daybreaker  wrote:
>
> > Hello,
> > I just started to use URL namespace that was added in the 1.1 release.
>
> > I have a somewhat complex url configurations like this:
>
> >http://dpaste.com/74963/
>
> > And in a template, the following url templatetag is used:
>
> > {% url myapp1:myapp2:view url_key id1 id2 %}
>
> > I'm getting an error continuously,
>
> > Reverse for 'view' with arguments '(u'asdfzxcv', 1L, 1L)' and keyword
> > arguments '{}' not found.
>
> > How should I fix the configurations?
--~--~-~--~~~---~--~~
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: {% url %} templatetag and url namespaces

2009-08-03 Thread Daybreaker

I've slightly fixed the pasted code for readability, and so the url
templatetag example should be:

{% url lab:bbs:view url_key article_id board_id %}

On 8월4일, 오전11시34분, Daybreaker  wrote:
> Hello,
> I just started to use URL namespace that was added in the 1.1 release.
>
> I have a somewhat complex url configurations like this:
>
> http://dpaste.com/74963/
>
> And in a template, the following url templatetag is used:
>
> {% url myapp1:myapp2:view url_key id1 id2 %}
>
> I'm getting an error continuously,
>
> Reverse for 'view' with arguments '(u'asdfzxcv', 1L, 1L)' and keyword
> arguments '{}' not found.
>
> How should I fix the configurations?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



{% url %} templatetag and url namespaces

2009-08-03 Thread Daybreaker

Hello,
I just started to use URL namespace that was added in the 1.1 release.

I have a somewhat complex url configurations like this:

http://dpaste.com/74963/

And in a template, the following url templatetag is used:

{% url myapp1:myapp2:view url_key id1 id2 %}


I'm getting an error continuously,

Reverse for 'view' with arguments '(u'asdfzxcv', 1L, 1L)' and keyword
arguments '{}' not found.


How should I fix the configurations?
--~--~-~--~~~---~--~~
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: Url Namespaces

2009-07-27 Thread Vitaly Babiy
Thanks, I knew it had to be somewhere in the docs.
Vitaly Babiy


On Sun, Jul 26, 2009 at 7:16 PM, Vasil Vangelovski
<vvangelov...@gmail.com>wrote:

>
> See this:
>
>
> http://docs.djangoproject.com/en/dev/topics/http/urls/#defining-url-namespaces
>
> On Mon, Jul 27, 2009 at 12:13 AM, Vitaly Babiy<vbabi...@gmail.com> wrote:
> > How does one go about registering a namespace?
> > I can't seem to find it in the docs.
> > Thanks,
> > Vitaly Babiy
> >
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
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: Url Namespaces

2009-07-26 Thread Joshua Russo
On Sun, Jul 26, 2009 at 9:13 PM, Vitaly Babiy  wrote:

> How does one go about registering a namespace?


Not quite sure what you mean by that, but my guess is that you are assuming
you need to register your namespace (modules?) before being able to import
them. If this is what you are asking, you don't. The import dot notation is
simply the directory structure, optionally followed by the file, optionally
followed by the object within the file.

It will use the PythonPath list variable to try to find the namespaces you
are referring to. This includes directories in python and your project.

For example, in my urls.py I have:
from django.contrib import admin

urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root)

This could also be written as:
from django.contrib.admin.site import root

urlpatterns = patterns('',
(r'^admin/(.*)', root)

This (roughly) represents:
C:\python25\Lib\site-packages\django\contrib\admin\site.py (function root())

--~--~-~--~~~---~--~~
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: Url Namespaces

2009-07-26 Thread Vasil Vangelovski

See this:

http://docs.djangoproject.com/en/dev/topics/http/urls/#defining-url-namespaces

On Mon, Jul 27, 2009 at 12:13 AM, Vitaly Babiy<vbabi...@gmail.com> wrote:
> How does one go about registering a namespace?
> I can't seem to find it in the docs.
> Thanks,
> Vitaly Babiy
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Url Namespaces

2009-07-26 Thread Vitaly Babiy
How does one go about registering a namespace?
I can't seem to find it in the docs.

Thanks,
Vitaly Babiy

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---