Django cannot be used by large web sites?

193 views
Skip to first unread message

asj2008

unread,
Feb 11, 2008, 12:02:57 PM2/11/08
to Django users
We are hitting an error that disables the entire website when we have
more than 255 web pages...this is the error we see..has anyone seen
this before? It does not seem to be in the documentation....

ImproperlyConfigured at /products/

Error while importing URLconf 'company.urls': more than 255 arguments
(urls.py, line 339)
Request Method: GET
Request URL: http://www.company.com/products/
Exception Type: ImproperlyConfigured
Exception Value: Error while importing URLconf 'company.urls': more
than 255 arguments (urls.py, line 339)
Exception Location: /opt/csw/lib/python2.3/site-packages/django/core/
urlresolvers.py in _get_urlconf_module, line 255
Python Executable: /
Python Version: 2.3.5

Tim Chase

unread,
Feb 11, 2008, 12:17:10 PM2/11/08
to django...@googlegroups.com
> Error while importing URLconf 'company.urls': more than 255 arguments
> (urls.py, line 339)

It might help to include a slice of your urls.py for the
statement(s) surrounding line 339. And perhaps signatures of
called code.

There are a couple possibilities that occur to me, but without
seeing the code, it's hard to tell. Functions/methods can
certainly take more than 255 parameters, though it may have to be
done through *args/**kwargs format; or the parsing regexp may be
phenomenally complex.

-tim


Jonathan Ballet

unread,
Feb 11, 2008, 12:21:06 PM2/11/08
to django...@googlegroups.com

It seems you exceeded a Python limit on the number of parameters passed to a function.

I cannot find anything in the Python's documentation on such limit (any hints would be appreciated),
but a look at Python's source code shows that this error is raised in a function which parses
parameters list (Python/ast.c, line 1847, in r60723)

So, what are your solutions ?

Try to refactor your urls (more than 255 urls patterns is quite a lot IMHO), or split the call to
the "patterns" function into several calls, like this :

urlpatterns = patterns('',
...
)
urlpatterns += patterns('',
...
)


- Jonathan

James Bennett

unread,
Feb 11, 2008, 12:27:17 PM2/11/08
to django...@googlegroups.com
On Feb 11, 2008 11:17 AM, Tim Chase <django...@tim.thechases.com> wrote:
> There are a couple possibilities that occur to me, but without
> seeing the code, it's hard to tell. Functions/methods can
> certainly take more than 255 parameters, though it may have to be
> done through *args/**kwargs format; or the parsing regexp may be
> phenomenally complex.

Yeah, you have to use *args/**kwargs, otherwise you can't pass more
than 255 arguments.

Not that I've ever tried and run into this and then double-checked it
in Python's source or anything... ;)


--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

James Bennett

unread,
Feb 11, 2008, 12:28:18 PM2/11/08
to django...@googlegroups.com
On Feb 11, 2008 11:02 AM, asj2008 <asjb...@gmail.com> wrote:
> We are hitting an error that disables the entire website when we have
> more than 255 web pages...this is the error we see..has anyone seen
> this before? It does not seem to be in the documentation....

It's a limit hard-coded into Python itself. Sounds like you need to
modularize your URLs a bit...

Alex Ezell

unread,
Feb 11, 2008, 1:04:14 PM2/11/08
to django...@googlegroups.com
Does anyone else think that 255 urls seems a little crazy?

There's got to be a way to build some regexs and views to deal with
those pages in a little more dynamic way.

Then again, without seeing any of it, it could be totally cool. /me shrugs

/alex

a sanjuan

unread,
Feb 11, 2008, 1:32:04 PM2/11/08
to django...@googlegroups.com
that worked...than you! :-)

James Bennett

unread,
Feb 11, 2008, 5:01:02 PM2/11/08
to django...@googlegroups.com
On Feb 11, 2008 12:04 PM, Alex Ezell <aez...@gmail.com> wrote:
> Does anyone else think that 255 urls seems a little crazy?

Yes. This sort of thing is what mechanisms like include() are for.

a sanjuan

unread,
Feb 11, 2008, 9:43:20 PM2/11/08
to django...@googlegroups.com
We use includes...those are actually 255 CONTENT pages...

James Bennett

unread,
Feb 11, 2008, 9:51:51 PM2/11/08
to django...@googlegroups.com
On Feb 11, 2008 8:43 PM, a sanjuan <asjb...@gmail.com> wrote:
> We use includes...those are actually 255 CONTENT pages...

You have over 255 URLs which don't offer any logical way to break them up?

a sanjuan

unread,
Feb 12, 2008, 12:52:32 AM2/12/08
to django...@googlegroups.com
yes. the pages already make use of includes and of course inheritance, but each page has unique text content. it is a big commercial website

James Bennett

unread,
Feb 12, 2008, 1:13:51 AM2/12/08
to django...@googlegroups.com
On Feb 11, 2008 11:52 PM, a sanjuan <asjb...@gmail.com> wrote:
> yes. the pages already make use of includes and of course inheritance, but
> each page has unique text content. it is a big commercial website

You know, if you've got a bunch of pages with different text, you can
use a database to store the text and then only use a few URL patterns
to represent all of them... do you think that, for example,
ljworld.com has one URL pattern per story?

Roboto

unread,
Feb 12, 2008, 9:12:31 AM2/12/08
to Django users
... I'm going to assume that they did that if they're building a
commercial website, otherwise it would have been pointless to bring
django in.
That being said, maybe they setup the urls to mimic RoR url system?
/cart/edit
/cart/save
/cart/details/item/qty/save =P haha yea, I'm reaching here on the last
one...

On Feb 12, 1:13 am, "James Bennett" <ubernost...@gmail.com> wrote:

Brett Parker

unread,
Feb 12, 2008, 10:00:54 AM2/12/08
to django...@googlegroups.com
On 12 Feb 06:12, Roboto wrote:
>
> ... I'm going to assume that they did that if they're building a
> commercial website, otherwise it would have been pointless to bring
> django in.
> That being said, maybe they setup the urls to mimic RoR url system?
> /cart/edit
> /cart/save
> /cart/details/item/qty/save =P haha yea, I'm reaching here on the last

But then you'd just write a dispatcher, surely!

--
Brett Parker

flo...@gmail.com

unread,
Feb 12, 2008, 5:50:22 PM2/12/08
to Django users
('^cart/', include('mysite.cart.urls')),
Reply all
Reply to author
Forward
0 new messages