Customizable Separator for slugify
Hi All, I'm wondering if anyone would find it useful to allow the slugify function to take an optional argument that would let us specify what type of separator to use. Sometimes it might be nice to let slugify use an underscore instead of a dash. I see that slugify is grouped with the template filters code so perhaps it's intent is only to be used as a template tag, but I've seen people using it in raw python code. SUGGESTED PSUDOCODE 200 def slugify(value, slug_separator='-'): 208 return mark_safe(re.sub('[-\s]+', slug_separator, value)) ORIGINAL CODE http://code.djangoproject.com/browser/django/trunk/django/template/defaultfilters.py 200 def slugify(value): 201 """ 202 Normalizes string, converts to lowercase, removes non-alpha characters, 203 and converts spaces to hyphens. 204 """ 205 import unicodedata 206 value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore') 207 value = unicode(re.sub('[^\w\s-]', '', value).strip().lower()) 208 return mark_safe(re.sub('[-\s]+', '-', value)) 209 slugify.is_safe = True 210 slugify = stringfilter(slugify) This is my first post on Django Developers, so I figure I'd introduce myself. My name is Joe and I'm a Django web developer in Chicago. I've been working with Django for a few years and find it a lot of fun! If this is the wrong place to ask, my apologies. Thanks for reading, Joe -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Re: AttributeError: module 'object' has no attribute events
On Tue, Jan 4, 2011 at 2:07 AM, Yo-Yo Mawrote: > I would head over the the django-users list (this one's for > development on Django itself): http://groups.google.com/group/django-users/ > Also, you might try Stack Overflow. It's a great place to get quick > answers. You might also try the django-nonrel forum [1]. Your question has almost nothing to do with Django itself -- the problem lies somewhere between AppEngine and the unofficial nonrel branch. [1] http://groups.google.com/group/django-non-relational Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Re: Doc idea: Split request & response?
On Tue, Jan 4, 2011 at 1:13 AM, Adam V.wrote: > The request & response docs for 1.3 look like: > Reference: Request/response objects | TemplateResponse objects > > > The first link has requests, associated request objects, and > responses. The second link has new derived response objects. > > What does anyone think about reorganizing this to: > Reference: Request objects | Response objects > > > The Request and supporting objects stay on the first page, the > Response objects move to the 2nd page and the new TemplateReponse docs > get merged in. Sounds like a good idea to me. Russ %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Re: Problem with validating ModelForm
Please post your question to the django-users mailing list. This list is for developers of Django itself. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Re: AttributeError: module 'object' has no attribute events
I would head over the the django-users list (this one's for development on Django itself): http://groups.google.com/group/django-users/ Also, you might try Stack Overflow. It's a great place to get quick answers. On Jan 3, 6:07 am, Ondřej Mirteswrote: > Hello, > I am new to Python/Django/App Engine world and I am trying to get > django-nonrel working on my Ubuntu 10.10 according to this > guide:http://www.allbuttonspressed.com/projects/djangoappengine > > I setup my project directory according to the guide: > > ond...@ondrej-ubuntu:~/django/pictag$ ll > total 68 > drwxrwxrwx 8 ondrej ondrej 4096 2011-01-03 13:53 ./ > drwxr-xr-x 4 ondrej ondrej 4096 2011-01-03 13:32 ../ > -rw-r--r-- 1 ondrej ondrej 348 2011-01-03 12:58 app.yaml > -rw-r--r-- 1 ondrej ondrej 69 2010-12-28 22:24 cron.yaml > drwxrwxrwx 2 ondrej ondrej 4096 2011-01-03 12:45 dbindexer/ > -rwxrwxrwx 1 ondrej ondrej 50 2010-12-28 22:24 dbindexes.py* > drwxrwxrwx 17 ondrej ondrej 4096 2011-01-03 13:53 django/ > drwxrwxrwx 8 ondrej ondrej 4096 2011-01-03 13:53 djangoappengine/ > drwxrwxrwx 4 ondrej ondrej 4096 2011-01-03 12:57 djangotoolbox/ > drwxr-xr-x 7 ondrej ondrej 4096 2011-01-03 12:48 .git/ > -rw-r--r-- 1 ondrej ondrej 58 2011-01-03 12:49 .gitignore > -rw-r--r-- 1 ondrej ondrej 649 2010-12-28 22:24 index.yaml > -rwxrwxrwx 1 ondrej ondrej 0 2011-01-03 13:33 __init__.py* > -rwxrwxrwx 1 ondrej ondrej 329 2011-01-03 13:53 manage.py* > -rwxrwxrwx 1 ondrej ondrej 1733 2010-12-28 22:24 settings.py* > -rw-r--r-- 1 ondrej ondrej 1935 2011-01-03 13:53 settings.pyc > drwxr-xr-x 2 ondrej ondrej 4096 2011-01-03 12:57 templates/ > -rwxrwxrwx 1 ondrej ondrej 272 2010-12-28 22:24 urls.py* > > I installed AppEngine SDK into /usr/local/google_appengine and I > modified my PYTHONPATH: > > ond...@ondrej-ubuntu:~/django/pictag$ $PYTHONPATH > bash: /usr/local/google_appengine/google: is a directory > > However, when I try to run the dev server, it shows this backtrace: > > ond...@ondrej-ubuntu:~/django/pictag$ ./manage.py runserver > Traceback (most recent call last): > File "./manage.py", line 4, in > import settings # Assumed to be in the same directory. > File "/home/ondrej/django/pictag/settings.py", line 4, in > from djangoappengine.settings_base import * > File "/home/ondrej/django/pictag/djangoappengine/settings_base.py", > line 6, in > setup_env() > File "/home/ondrej/django/pictag/djangoappengine/boot.py", line 64, > in setup_env > setup_project() > File "/home/ondrej/django/pictag/djangoappengine/boot.py", line 114, > in setup_project > from .utils import have_appserver, on_production_server > File "/home/ondrej/django/pictag/djangoappengine/utils.py", line 10, > in > from google.appengine.tools import dev_appserver > File "/usr/local/google_appengine/google/appengine/tools/ > dev_appserver.py", line 88, in > from google.appengine.api import appinfo > File "/usr/local/google_appengine/google/appengine/api/appinfo.py", > line 33, in > from google.appengine.api import yaml_builder > File "/usr/local/google_appengine/google/appengine/api/ > yaml_builder.py", line 29, in > from google.appengine.api import yaml_listener > File "/usr/local/google_appengine/google/appengine/api/ > yaml_listener.py", line 30, in > yaml.events.StreamStartEvent: 'StreamStart', > AttributeError: 'module' object has no attribute 'events' > > It looks like the "import yaml" command imports different yaml library > than SDK expects. I originally tried to setup the server with Python > 2.6, but I also tried 2.5 with the same result. > > I didn't google any solution successfully neither. > > Thanks for any suggestion. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Doc idea: Split request & response?
The request & response docs for 1.3 look like: Reference: Request/response objects | TemplateResponse objects The first link has requests, associated request objects, and responses. The second link has new derived response objects. What does anyone think about reorganizing this to: Reference: Request objects | Response objects The Request and supporting objects stay on the first page, the Response objects move to the 2nd page and the new TemplateReponse docs get merged in. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
AttributeError: module 'object' has no attribute events
Hello, I am new to Python/Django/App Engine world and I am trying to get django-nonrel working on my Ubuntu 10.10 according to this guide: http://www.allbuttonspressed.com/projects/djangoappengine I setup my project directory according to the guide: ond...@ondrej-ubuntu:~/django/pictag$ ll total 68 drwxrwxrwx 8 ondrej ondrej 4096 2011-01-03 13:53 ./ drwxr-xr-x 4 ondrej ondrej 4096 2011-01-03 13:32 ../ -rw-r--r-- 1 ondrej ondrej 348 2011-01-03 12:58 app.yaml -rw-r--r-- 1 ondrej ondrej 69 2010-12-28 22:24 cron.yaml drwxrwxrwx 2 ondrej ondrej 4096 2011-01-03 12:45 dbindexer/ -rwxrwxrwx 1 ondrej ondrej 50 2010-12-28 22:24 dbindexes.py* drwxrwxrwx 17 ondrej ondrej 4096 2011-01-03 13:53 django/ drwxrwxrwx 8 ondrej ondrej 4096 2011-01-03 13:53 djangoappengine/ drwxrwxrwx 4 ondrej ondrej 4096 2011-01-03 12:57 djangotoolbox/ drwxr-xr-x 7 ondrej ondrej 4096 2011-01-03 12:48 .git/ -rw-r--r-- 1 ondrej ondrej 58 2011-01-03 12:49 .gitignore -rw-r--r-- 1 ondrej ondrej 649 2010-12-28 22:24 index.yaml -rwxrwxrwx 1 ondrej ondrej0 2011-01-03 13:33 __init__.py* -rwxrwxrwx 1 ondrej ondrej 329 2011-01-03 13:53 manage.py* -rwxrwxrwx 1 ondrej ondrej 1733 2010-12-28 22:24 settings.py* -rw-r--r-- 1 ondrej ondrej 1935 2011-01-03 13:53 settings.pyc drwxr-xr-x 2 ondrej ondrej 4096 2011-01-03 12:57 templates/ -rwxrwxrwx 1 ondrej ondrej 272 2010-12-28 22:24 urls.py* I installed AppEngine SDK into /usr/local/google_appengine and I modified my PYTHONPATH: ond...@ondrej-ubuntu:~/django/pictag$ $PYTHONPATH bash: /usr/local/google_appengine/google: is a directory However, when I try to run the dev server, it shows this backtrace: ond...@ondrej-ubuntu:~/django/pictag$ ./manage.py runserver Traceback (most recent call last): File "./manage.py", line 4, in import settings # Assumed to be in the same directory. File "/home/ondrej/django/pictag/settings.py", line 4, in from djangoappengine.settings_base import * File "/home/ondrej/django/pictag/djangoappengine/settings_base.py", line 6, in setup_env() File "/home/ondrej/django/pictag/djangoappengine/boot.py", line 64, in setup_env setup_project() File "/home/ondrej/django/pictag/djangoappengine/boot.py", line 114, in setup_project from .utils import have_appserver, on_production_server File "/home/ondrej/django/pictag/djangoappengine/utils.py", line 10, in from google.appengine.tools import dev_appserver File "/usr/local/google_appengine/google/appengine/tools/ dev_appserver.py", line 88, in from google.appengine.api import appinfo File "/usr/local/google_appengine/google/appengine/api/appinfo.py", line 33, in from google.appengine.api import yaml_builder File "/usr/local/google_appengine/google/appengine/api/ yaml_builder.py", line 29, in from google.appengine.api import yaml_listener File "/usr/local/google_appengine/google/appengine/api/ yaml_listener.py", line 30, in yaml.events.StreamStartEvent: 'StreamStart', AttributeError: 'module' object has no attribute 'events' It looks like the "import yaml" command imports different yaml library than SDK expects. I originally tried to setup the server with Python 2.6, but I also tried 2.5 with the same result. I didn't google any solution successfully neither. Thanks for any suggestion. -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
Re: Problem with ``Model.objects.create``
Oh, sorry for the confusion, and thanks for the explaination. I thought that Django raised an IntegrityError in this case, and when it didn't happen I figured it was a bug. I will make a recommendation (observation). To provide a blank value a a model and have it validate with full_clean, you have to specify blank=True. I would suggest that to maintain integrity between your applications logic and the database, Django should raise an IntegrityError, if blank=False. On Jan 2, 6:53 pm, Russell Keith-Mageewrote: > On Mon, Jan 3, 2011 at 7:46 AM, Yo-Yo Ma wrote: > > I apologize ahead of time, if this bug is rather a user error. > > > If you have a model: > > > class Foo(Model): > > spam= CharField(max_length=30) > > xyz= CharField(max_length=30) > > > def __unicode__(self): > > return self.xyz > > > and you use it in the shell like this: > > Foo.objects.create(xyz="Hello") > > > > > No IntegrityError was raised, even though ``spam`` is a required field. > > Yes, 'spam' is a required field. And if you investigate a little > closer, you'll see that it has a value -- the empty string. > > You'll note that the following also works, and is entirely consistent > with get_or_create(): > > >>> obj = Foo(xyz='Hello') > >>> obj.save() > > For reasons of historical significance, the default value for all > fields (CharField or otherwise) is "", unless: > * a default is provided by the user, or > * You've overridden get_default, or > * You're using Oracle (which has it's own special difficulties with "" vs > None) > > Yours, > Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.