[patch] Generating slug for words with accents
Hello, I have problem with submiting ticket in trac (details below) with my patch, so I decided to post it here. - Short summary: [patch] Generating slug for words with accents Full description: In my language (czech) there are a lot of characters with accents. When I type titles in admin forms, the slug field autogenerated values are incorect (for example:title="sršeň", autogenerated slug="sre"; correct is "srsen"). So I wrote little patch to urlify.js code, which first convert all accents chars to their ASCII equivalent. For now, my code respect only czech accents. I will be glad, If some others of you add your own national characters. Priority: normal Component: Admin interface Severity: normal Version: SVN Keywords: slug urlify - Trac error Trac detected an internal error: Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 299, in dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 189, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.3/site-packages/trac/ticket/web_ui.py", line 104, in process_request self._do_create(req, db) File "/usr/lib/python2.3/site-packages/trac/ticket/web_ui.py", line 163, in _do_create self._validate_ticket(req, ticket) File "/usr/lib/python2.3/site-packages/trac/ticket/web_ui.py", line 47, in _validate_ticket for field, message in manipulator.validate_ticket(req, ticket): File "build/bdist.linux-i686/egg/tracspamfilter/adapters.py", line 40, in validate_ticket File "build/bdist.linux-i686/egg/tracspamfilter/api.py", line 74, in test herror: (1, 'Unknown host') (I was trying to submit ticket from FreeBSD 5.4 system & Firefox 1.5.0.1) Regards Michal --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- Index: django/contrib/admin/media/js/urlify.js === --- django/contrib/admin/media/js/urlify.js (revision 3657) +++ django/contrib/admin/media/js/urlify.js (working copy) @@ -1,4 +1,20 @@ +function replAccents(s) +{ +// from and to strings must have same number of characters +var from = 'áčďéěíňóřšťúůýžÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ'; +var to = 'acdeeinorstuuyzACDEEINORSTUUYZ'; +for (var i = 0; i != s.length; i++) { +var x = from.indexOf(s[i]); +if (x != -1) { +r = new RegExp(from[x], 'g'); +s = s.replace(r, to[x]); +} +} +return s; +} + function URLify(s, num_chars) { +s = replAccents(s); // changes, e.g., "Petty theft" to "petty_theft" // remove all these words from the string before urlifying removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from",
Re: import opml file
feedjack is a lot of stuff, it exports opml but it doesnt import opml any ideas for importing opml > > you might want to check out FeedJack http://www.feedjack.org/ > > it's done a lot of stuff in that area. > > > > regards > > Ian > > > > On 24/08/2006, at 5:42 PM, a wrote: > > > > > > > > hi guys how do i import opml file in django > > > using syndication > > > > > > i m tryin to build an rss reader > > > thanks > > > > > > > -- > > Ian Holsman > > [EMAIL PROTECTED] > > http://personalinjuryfocus.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Rolling my own basic authentication?
magus wrote: > I'd like to roll my own basic authentication for a web service, i.e. I > don't want to use the contrib.auth module. If possible I'd like to > avoid relying on the server for this. Anyone who can offer some > pointers on how to raise a 401 on a request that doesn't contain the > Authentication: header? > > The 401 also needs to contain the realm, how would I do that? > > /M Something like this? response = HttpResponse() response.status_code = 401 response['WWW-Authenticate'] = 'Basic realm="%s:%s' % ( request.META["SERVER_NAME"], request.META["SERVER_PORT"]) return response --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
serving static with mod_python and django
Hello, I have the following lines in /etc/apache2/sites-available/default: DocumentRoot /var/www Options FollowSymLinks AllowOverride None Alias /debian/ /mnt/sda1/ibr/debian/ Options Indexes FollowSymLinks Order allow,deny Allow from all SetHandler python-program ... When I try to access http://localhost/debian/ , I get Django's nice 404 error message. http://httpd.apache.org/docs/2.0/mod/core.html#location says Location directives are processed after the Directory directives. Can I have Django accessible at /, and other content still accessible under other directories? Thanks in advance, Baurzhan. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: User Registration weirdness. Ian, help!
Thanks Don. That, and some other issues identified by Alain Dazzi have been resolved in Release 329. It is recommended that people using these login routines in their own code should upgrade ASAP. On 26/08/2006, at 4:37 PM, Don Arbow wrote: > > On Aug 25, 2006, at 12:31 PM, Waylan Limberg wrote: >> >> On 8/25/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >>> >> [snip] >>> >>> I've gone through and stripped out every extra space I can find, >>> thinking that was the problem, but still that dang trailing slash >>> comes >>> down to the next line. Ideas? >>> >> For what its worth, Gmail does indeed display that on 2 lines (only >> the ending / on line 2), but is correctly includes both lines as a >> single link with the ending slash. In other words, it looks funny, >> but >> it still points to the correct url. >> >> The problem comes with email clients that do not automaticly (or >> correctly) convert urls to links. The user may not select and copy >> the >> second line as part of the url... > > > > The old school solution was to surround the url with angle brackets > <>. Intelligent mail readers would recognize this and display the url > correctly. > > http://www.w3.org/Addressing/URL/5.1_Wrappers.html > > Why do people put angle brackets around : > > http://ideas.4brad.com/node/443 > > Don > > > > -- Ian Holsman [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Generic views and manipulating data before saving
Hi, I've spent many hours trying to get the following to work (I'm not blaming Django - I'm very new to Python and Django, it was late etc). To hopefully make the solution easier to find in Google, I write it here. Suggestions for improvement are welcome. Question: using generic views, how to alter the data user has POST-ed? For example for setting the "last updated by"-field. models.py: lastupdatedby = models.ForeignKey(User) *_detail.html: {{object.lastupdatedby}} In the views.py I have a wrapper method, that modifies the data that has been POST-ed and then passes it along to generic views for validating and saving. @login_required def limited_update_object(*args, **kwargs): #The fields that are handled by Django are in "follow", for example: #follow = {'lastupdatedon': False} <-- auto_now=True #kwargs['follow'] = follow request = args[0]<-- is this safe? if request.POST: new_data = request.POST.copy() new_data[ 'lastupdatedby' ] = str( request.user.id ) request._post = new_data return update_object(*args, **kwargs) The question I have yet to find an answer: is there a more convenient way for debugging and examining the data than raise Http404, str(new_data)? Regards, Andres --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: serving static with mod_python and django
Baurzhan Ismagulov wrote: > Hello, > > I have the following lines in /etc/apache2/sites-available/default: > > DocumentRoot /var/www > > Options FollowSymLinks > AllowOverride None > > > Alias /debian/ /mnt/sda1/ibr/debian/ > > Options Indexes FollowSymLinks > Order allow,deny > Allow from all > > > > SetHandler python-program > ... > > When I try to access http://localhost/debian/ , I get Django's nice 404 > error message. http://httpd.apache.org/docs/2.0/mod/core.html#location > says Location directives are processed after the Directory directives. > Can I have Django accessible at /, and other content still accessible > under other directories? Yes. You should Directories describing '/debian/' _after_ your '' for this general rule not overwrite more specific ones. Also you may have to convert your to --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Generic views and reverse url lookup?
Petar Marić wrote: > I'm checking out reverse url resolving and I can't help but wonder: > What happenes when we use generic views? Will it still work? Hm... Looks like they wouldn't :-(. This'll require some thinking... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Re: import opml file
I've found that using XMLObject (http://www.freenet.org.nz/python/xmlobject/) is a simple way to get the feed information from an OPML feed, then you can read the feed however you like (e.g. with Feedparser (www.feedparser.org)). Something like this should get you started: from xmlobject import XMLFile opml = XMLFile(path="/path/to/file.opml") for person in x.root.body.outline: print "Name: " + str(person.text) print "Feed: " + str(person.xmlUrl) --Jon On 26/08/06, a <[EMAIL PROTECTED]> wrote: > > feedjack is a lot of stuff, it exports opml but it doesnt import opml > any ideas for importing opml > > > you might want to check out FeedJack http://www.feedjack.org/ > > > it's done a lot of stuff in that area. > > > > > > regards > > > Ian > > > > > > On 24/08/2006, at 5:42 PM, a wrote: > > > > > > > > > > > hi guys how do i import opml file in django > > > > using syndication > > > > > > > > i m tryin to build an rss reader > > > > thanks > > > > > > > > > > -- > > > Ian Holsman > > > [EMAIL PROTECTED] > > > http://personalinjuryfocus.com/ > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: serving static with mod_python and django
Hello Ivan, thanks for your fast response! On Sat, Aug 26, 2006 at 01:19:20PM +0400, Ivan Sagalaev wrote: > > Can I have Django accessible at /, and other content still accessible > > under other directories? > > Yes. You should Directories describing '/debian/' _after_ your > '' for this general rule not overwrite more specific ones. > Also you may have to convert your to Hmm, I've converted to and put it after : DocumentRoot /var/www Options FollowSymLinks AllowOverride None SetHandler python-program ... Alias /debian /mnt/sda1/ibr/debian Options Indexes FollowSymLinks Order allow,deny Allow from all works if I comment out . If not, I get the following response: Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 301, in HandlerDispatch assert (type(result) == type(int())), \ AssertionError: Handler 'django.core.handlers.modpython' returned invalid return code. What is wrong here? With kind regards, Baurzhan. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Migrating my development environment to Django
Hello everyone, I am currently trying to migrate away from PHP to my new favorite programming language for web development, Python. I've developed web RAD toolkit in PHP [1] but got tired of doing everything on my own. Django seemed like the best replacement. I immediately liked the DB Models, the templates and the dispatcher. The automatically generated admin frontend is also very impressive. I find the Forms/Manipulators somewhat confusing but I think I'll also get the hang of it. I have two questions which I was unable to answer by reading the docs and the source (I hope I did not oversee anything...) * How can I create a new FormField? Where can I specify which FormField to use for a DB field? * I would like to reuse the table view (f.e. the user list) for other Models. Is that possible outside of the Django administration? (I'd also need custom column renderers; I was unable to find a place where I could define how columns are rendered) Thanks in advance for helpful answers! Matthias [1]: http://spinlock.ch/projects/swisdk/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: serving static with mod_python and django
Baurzhan Ismagulov wrote: > Hmm, I've converted to /debian> and put it after : > > DocumentRoot /var/www > > Options FollowSymLinks > AllowOverride None > > > > SetHandler python-program > ... > > > Alias /debian /mnt/sda1/ibr/debian > > Options Indexes FollowSymLinks > Order allow,deny > Allow from all > > > works if I comment out . Oh I've forgot. It happens because Apache still passes all requests to mod_python because of SetHandler set in the first rule. In subsequent locations you have to also reset it with SetHandler None. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Migrating my development environment to Django
Matthias Kestenholz wrote: > * How can I create a new FormField? Where can I specify which > FormField to use for a DB field? Inherit your class from django.forms.FormField and at the very least override render() method. Other methods that you might want to override depending on your field are do_html2python, get_validation_errors, convert_post_data. Their tasks are documented their docstrings in django.forms. To assign a FormField class to a DB field class you implement get_manipulator_field_objs method of the DB class. It returns a list of FormField classes (list is here because such fields as DateTimeField are represented with two form controls). For an example I can suggest you to look in my own TagsField app where I've created a descendant of a ManyToManyField: http://softwaremaniacs.org/media/soft/tags/tags.zip , look into fields.py BTW, this is already some advanced use of Django. Why do you need to make your own form fields? May be the problem can be solved easier... > * I would like to reuse the table view (f.e. the user list) for > other Models. Is that possible outside of the Django > administration? (I'd also need custom column renderers; I was > unable to find a place where I could define how columns are > rendered) I haven't play much with admin interface so may be others could answer. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: serving static with mod_python and django
Ivan, On Sat, Aug 26, 2006 at 02:26:28PM +0400, Ivan Sagalaev wrote: > Oh I've forgot. It happens because Apache still passes all requests to > mod_python because of SetHandler set in the first rule. In subsequent > locations you have to also reset it with SetHandler None. It worked, thanks much! With kind regards, Baurzhan. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: my private django repository goes public
Yeah i tried that, but i'm getting the following error message: svn co http://svn.sourceforge.net/viewvc/django-userlibs/trunk/ django-userlibs svn: PROPFIND request failed on '/viewvc/django-userlibs/trunk' svn: PROPFIND of '/viewvc/django-userlibs/trunk': 301 Moved (http://svn.sourceforge.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-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 -~--~~~~--~~--~--~---
Re: [patch] Generating slug for words with accents
On Sat, 2006-08-26 at 10:05 +0200, Michal wrote: > Full description: In my language (czech) there are a lot of characters > with accents. When I type titles in admin forms, the slug field > autogenerated values are incorect (for example:title="sršeň", Is it a hornet? > autogenerated slug="sre"; correct is "srsen"). That's right. I've been experiencing the same thing. > I will be glad, If some others of you add your own national characters. I'm attaching a modified patch with Polish characters added. -- Maciej Bliziński http://automatthias.wordpress.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- Index: django/contrib/admin/media/js/urlify.js === --- django/contrib/admin/media/js/urlify.js (revision 3657) +++ django/contrib/admin/media/js/urlify.js (working copy) @@ -1,4 +1,20 @@ +function replAccents(s) +{ +// from and to strings must have same number of characters +var from = 'áčďéěíňóřšťúůýžąćęłńóśżźÁČĎÉĚÍŇÓŘŠŤÚŮÝŽĄĆĘŁŃÓŚŻŹ'; +var to = 'acdeeinorstuuyzacelnoszzACDEEINORSTUUYZACELNOSZZ'; +for (var i = 0; i != s.length; i++) { +var x = from.indexOf(s[i]); +if (x != -1) { +r = new RegExp(from[x], 'g'); +s = s.replace(r, to[x]); +} +} +return s; +} + function URLify(s, num_chars) { +s = replAccents(s); // changes, e.g., "Petty theft" to "petty_theft" // remove all these words from the string before urlifying removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from",
Re: my private django repository goes public
Hi, for svn checkout or export the correct trunk-url is http://svn.sourceforge.net/svnroot/django-userlibs/trunk Regards, Dirk -- "Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Generic views and pagination links
Gnissem wrote: > I am using generic views to produce a paginated specimen list. In the > list, you can click on a specimen to get the generic view detail. > After viewing the detail, the user will likely want to go back to the > specimen list, on the page where the link came from. Pressing the back > button works, but I'd like to give the user a link to take them back. > How do I go this? > > I tried passing the page number from the generic list view into the > generic detail view with a url like: /specimen/244/?page=7. However > there does not seem to be any way to access GET data in the template. > Since there is no view, it can't be retrieved there and passed to the > template. (And in general it seems like it would be nice to pass GET > values directly into a template without needing the intervention of a > view. Is this possible? > > Thanks in advance for help. I am new to Django so excuse me if I have > missed something obvious You need to wrap the generic detail view with your own detail view which passes the specific GET variable you need through the "extra_context" dictionary. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problem accessing users and groups in Admin
Hi, I would like to know what to look for to solve this problem. When I access http://127.0.0.1:8000/admin/ I get Groups Users in the Autho Fieldset. If I click on Users http://127.0.0.1:8000/admin/auth/user/ I get a list of all the users. When I click on any of them: http://127.0.0.1:8000/admin/auth/user/1/ like the superuser in this case: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/admin/auth/user/1/ Or starting again from admin: http://127.0.0.1:8000/admin/ I click in the +Add shortcut for Users: http://127.0.0.1:8000/admin/auth/user/add/ . DoesNotExist at /admin/auth/user/add/ Request Method: GET Request URL: http://127.0.0.1:8000/admin/auth/user/add/ Exception Type: DoesNotExist Exception Value: Exception Location: /usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py in __get__, line 163 Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/views/decorators/cache.py" in _wrapped_view_func 39. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/admin/views/main.py" in add_stage 243. manipulator = model.AddManipulator() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/manipulators.py" in __init__ 69. self.fields.extend(f.get_manipulator_fields(self.opts, self, self.change)) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in get_manipulator_fields 226. field_objs, params = self.prepare_field_objs_and_params(manipulator, name_prefix) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in prepare_field_objs_and_params 215. field_objs = self.get_manipulator_field_objs() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in get_manipulator_field_objs 627. choices = self.get_choices_default() File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in get_choices_default 631. return Field.get_choices(self, include_blank=False) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/__init__.py" in get_choices 292. return first_choice + [(x._get_pk_val(), str(x)) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/contrib/auth/models.py" in __str__ 48. return "%s | %s" % (self.content_type, self.name) File "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/fields/related.py" in __get__ 163. raise self.field.rel.to.DoesNotExist DoesNotExist at /admin/auth/user/add/ Request information GET No GET data POST No POST data . What should I try to look for to solve this problem? Luis P. Mendes --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: [patch] Generating slug for words with accents
Maciej Bliziński wrote: > On Sat, 2006-08-26 at 10:05 +0200, Michal wrote: >> Full description: In my language (czech) there are a lot of characters >> with accents. When I type titles in admin forms, the slug field >> autogenerated values are incorect (for example:title="sršeň", > > Is it a hornet? Yes it is, my Slavic brother :) > >> autogenerated slug="sre"; correct is "srsen"). > > That's right. I've been experiencing the same thing. > >> I will be glad, If some others of you add your own national characters. > > I'm attaching a modified patch with Polish characters added. > Thank you. I also added a few of Slovak characters (Czech and Slovak was brothers too, and they have similar alphabet). > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- Index: django/contrib/admin/media/js/urlify.js === --- django/contrib/admin/media/js/urlify.js (revision 3657) +++ django/contrib/admin/media/js/urlify.js (working copy) @@ -1,4 +1,20 @@ +function replAccents(s) +{ +// from and to strings must have same number of characters +var from = 'áÄÄéÄÃÅóÅÅ¡Å¥ÃºÅ¯Ã½Å¾Ä ÄÄÅÅóÅżźäľĺôÅÃÄÄÃÄÃÅÃÅŠŤÃŮÎÄÄÄÅÅÃÅŻŹÃĽĹÃÅ'; +var to = 'acdeeinorstuuyzacelnoszzallorACDEEINORSTUUYZACELNOSZZALLOR'; +for (var i = 0; i != s.length; i++) { +var x = from.indexOf(s[i]); +if (x != -1) { +r = new RegExp(from[x], 'g'); +s = s.replace(r, to[x]); +} +} +return s; +} + function URLify(s, num_chars) { +s = replAccents(s); // changes, e.g., "Petty theft" to "petty_theft" // remove all these words from the string before urlifying removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from",
DNS lookups in development server?
Hi. Which DNS lookups for client addresses does the Django development server do, and why? Background for my question: I'm running a Windows installation in a VMWare machine and use that to check the IE-compatibility of my HTML. That used to work just fine. I've just tried it again and the development server was handling client requests at a rate of almost exactly one every three seconds! Using NETSTAT on the Windows/VM machine showed a number of established connections, the HTTP server was just very slooow in handling them. After I added an entry for my VM machine (mapping the machine name to the virtual IP address) to /etc/hosts on my development machine (the once running Django, not the one in the VM), the request were again processed at the usual speed. This leads me to the conclusion that something in the development server does some form of DNS lookup and needs to wait for a DNS timeout before being able to service the request. Since the development server will probably not always be used in fully networked environments with a full DNS, maybe it would be worthwhile checking out which function is dependent upon these DNS lookups and either cache the data (i.e. you checked once - don't check again) or just disdable the function. Or is there a switch to "django.-admin runserver" which would disable this feature (whatever it is)? (In case it helps -- I'm on SVN revision 3238) Daniel --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: problems with unicode in website
On 8/26/06, Eugene Pyvovarov <[EMAIL PROTECTED]> wrote: > > hello everybody. I'm new in django... just want to create base apps > from tutorial on djangoproject website. > I am using mysql 4.1 and python 2.4, django from svn > When I create database in iso-8859-1 - all stuff working good, but when > I befin to do the same website and making my database in utf-8 encoding > - I have folowing errors, when I want to authorize in the system as > admin: > > Inherite view http://paste.e-scribe.com/1334/ > Copy\paste view: http://paste.e-scribe.com/1335/ > > please help me.. You apparently have a binary collation, which causes MySQLdb to return text-like columns as arrays of characters. There are enough use cases that this breaks that I'm going to fix it in MySQLdb-1.2.2 (beta perhaps this weekend). In a nutshell, binary collations make character columns (CHAR, VARCHAR, TEXT) come back as arrays. I'm going to change this so they come back as normal strings. Non-binary collations will cause them to be returned as unicode strings if use_unicode=True; otherwise they will also be strings. -- This message has been scanned for memes and dangerous content by MindScanner, and is believed to be unclean. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: DNS lookups in development server?
I think this has been fixed in a more recent revision than what you are running: http://code.djangoproject.com/changeset/3530 Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: DNS lookups in development server?
Karen Tracey wrote: > I think this has been fixed in a more recent revision than what you are > running: > http://code.djangoproject.com/changeset/3530 You're right. I should have checked. Would have saved me a lot of typing ;-)) Thanks. Daniel --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: User Registration weirdness. Ian, help!
I've been looking at creating a registraion view but am not sure on the best way, although the Zyons style email for registration link system seems good. But I am not sure whether it is wise to just ask for a potential users email without giving them any prospect of registration. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Application Prefix
On 8/24/06, Ivan Sagalaev <[EMAIL PROTECTED]> wrote: > I've created a template tag that wraps it to be usable in templates: > [...] > It's a bit limited since it works only with positional arguments in > views but not with keyword ones. This is not hard to do in code since > 'reverse' function itself already support it. I just couldn't come up > with a nice syntax for a tag :-) Nice, Ivan! I've been meaning to write something like this...Would you be willing to contribute it to the framework? Adrian -- Adrian Holovaty holovaty.com | djangoproject.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ado_mssql introspection patch
I've completed a patch* (http://code.djangoproject.com/ticket/2563) for ado_mssql database introspection. I'd appreciate it if those few of you out there who use Djagno/mssql could test it out and provide some feedback. Thanks, Sean * The patch depends on the changes in http://code.djangoproject.com/ticket/2358 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Kate syntax highlighting for django html templates.
I got sick of kate highlighting my django template vars/tags as errors, so I put this together. It highlights tags, vars, filters, and comments. You can also use Ctrl+[Shift+]D to [un]comment using {% comment %}{% endcomment %}. It's really pretty simple, but I thought it was worth sharing. Get it here: http://media.matthewmarshall.org/djangotemplate.xml Drop it into ~/.kde/share/apps/katepart/syntax/ and you're ready to go! MWM --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Can't download flup
Hello, I want to play with django as a FastCGI-Server and need the package flup for this. So I tried to download it on http://www.saddi.com/software/flup/, but this site is down/has no content. I searched for a mirror or an alternative download-site, but can't find any. So does have anybody the egg-File or a tarball of this package and can make it available online? Thanks Kai Kammerer --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problems with "import settings"
Hi Folks, I have startetd a project/app , created a Model. All fine in Python-Interpreter an >>>import kb.models >>> works fine. But the same in a file occurs erros like raise EnvironmentError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) EnvironmentError: Could not import settings '/home/tk/Documents/Projekte/djangoprj/kassenbuch/settings' (Is it on sys.path? Does it have syntax errors?): No module named /home/tk/Documents/Projekte/djangoprj/kassenbuch/settings The DJANGO_SETTINGS_MODULE Variable is set. Why does it works in the Python-Interpreter but not in a File??? Thx Timothy --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
view.py as class not just methods
Hi, I'm relatively new to django and maybe my question is stupid, but... Is it possible to map in urls.py some url not to function in views.py (which has first argument with HttpRequest) but to some class methot? In that case each instance of such class would be created when session starts and for subsequnt calls would be served as self ? I know, I know that HttpRequest has session member and I can use it. But maybe it would be good idea to have such url ==> class.method mapping. thanks, skink --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
database newby question
Hello Django users, i just started working with django and i really can't figure out even with the tutorial how i can get some info out of the database. i have the following database models class LoginInfo(models.Model): lab_id = models.IntegerField(maxlength=10) password = models.CharField(maxlength=20) class Modules(models.Model): user = models.ForeignKey(LoginInfo) lupus = models.IntegerField(maxlength=1) apa = models.IntegerField(maxlength=1) def __str__(self): return self.lupus,self.apa i imported 2 users in the model LoginInfo the first is lab_id = '100' and the second is lab_id = '200' how do i put in the data in the class Modules ? what i thought i had to do was first create a object from the LoginInfo class like p = LoginInfo.objects.get(lab_id='100') and next just put in the data in the Modules class like p.module_set.create(lupus=1,apa=0) but i get the following error message AttributeError: 'LoginInfo' object has no attribute 'module_set' does anyone know what i'm doing wrong, thanks in advance for your help richard --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ado_mssql introspection patch
I've posted a patch that adds full introspection functionality for ado_mssql backends (http://code.djangoproject.com/ticket/2563). I'd appreciate it if those of you who run Django/mssql could test it out and let me know if any problems are found. Thanks, Sean * Note: the patch relies on the changes in http://code.djangoproject.com/ticket/2358 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
view.py as class not just methods
Hi, I'm relatively new to django and maybe my question is stupid, but... Is it possible to map in urls.py some url not to function in views.py (which has first argument with HttpRequest) but to some class methot? In that case each instance of such class would be created when session starts and for subsequnt calls would be served as self ? I know, I know that HttpRequest has session member and I can use it. But maybe it would be good idea to have such url ==> class.method mapping. thanks, skink --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
generic views for ajax ?
Hi, I know the discussion about django and ajax compatible response. The 'hardliners' say that you only need to implement your own kind of template - which is true for all time, but I would prefer a much more generic way to get the response from the views. I made a server-side django library for ajax response Json, JsonRpc, or simple XmlRpc available here: http://svn.sourceforge.net/svnroot/django-userlibs/trunk/libs.ajax/ Currently I build generic date_based and generic list_detail views for ajax-response. Like to here any comments. Regards, Dirk -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Webdav access - OT
Curtis <[EMAIL PROTECTED]> írta: > PyFileServer - http://pyfilesync.berlios.de/pyfileserver.html seems to > be very similar (at least in theory) to what you want. It's a WSGI > WebDav server. Although not refreshed a year ago, i'll check it. Seem to be quite what i needed. Thank you Curt. Anna __ Adómegtakarítás augusztusban? Ne dobja ki pénzét feleslegesen! http://www.klikkbank.hu/befektetes/index.html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: database newby question
[EMAIL PROTECTED] wrote: > i imported 2 users in the model LoginInfo the first is lab_id = '100' > and the second is lab_id = '200' > how do i put in the data in the class Modules ? > > what i thought i had to do was first create a object from the LoginInfo > class like > p = LoginInfo.objects.get(lab_id='100') > > and next just put in the data in the Modules class like > p.module_set.create(lupus=1,apa=0) try p.modules_set.create(lupus=1,apa=0) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Application Prefix
Adrian Holovaty wrote: > Nice, Ivan! I've been meaning to write something like this...Would you > be willing to contribute it to the framework? Sure, as usually :-) Have you are: http://code.djangoproject.com/ticket/2606 I also added a docstring that may be a bit clumsy and will certainly require a proof-read. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: ado_mssql introspection patch
Sorry for the double-post :)On 8/25/06, Sean De La Torre <[EMAIL PROTECTED]> wrote: I've posted a patch that adds full introspection functionality forado_mssql backends (http://code.djangoproject.com/ticket/2563). I'dappreciate it if those of you who run Django/mssql could test it out and let me know if any problems are found.Thanks,Sean* Note: the patch relies on the changes inhttp://code.djangoproject.com/ticket/2358 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: database newby question
that for the advice, that wasn't really smart i should have figured that one out. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Problems with "import settings"
I had a similar problems because I did not set up proper permissions on files. If your Django runs under Linux too, you can check the permissions if it helps Regards, L --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Catching an IntegrityError
Hi, I'm trying to figure out how to catch an IntegrityError. Simply using the following doesn't work correctly. I'm guessing that the IntegrityError class isn't available. The code: try: # code here catch IntegrityError: # code here Generates the following error: NameError at /admin/planetx/feed/1/ global name 'IntegrityError' is not defined I thought I found a solution in the following thread, but it seems to have been written prior to magic removal, and the given solution no-longer seems to work: http://groups.google.com/group/django-developers/tree/browse_frm/month/2006-01/8769f73b6963a674?rnum=21&_done=%2Fgroup%2Fdjango-developers%2Fbrowse_frm%2Fmonth%2F2006-01%3F#doc_b37d705150060fd7 Any hints would be much appreciated. --Jon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
inverted index for python
i was looking for the inverted index module cici-mills and chris had presented at pycon 1996 digicool or a similar inverted index for python http://www.digicool.com/releases/unsupported/InvertedIndex/ if you can share it it ll be great --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
symlink mess
HiI know this is unrelated to Django. But I guess I mucked up my django sym links, by linking it number of times.How do I remove the multiple level of sym links. This is a Linux newbie question. But has me stumped. When I run setup.py install from updated svn directory, I get this errorerror: django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django: Too many levels of symbolic links Anyone can adviceGeorge W --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Unicode, unicode, more unicode
What does one need to do to set up MySQL to handle Unicode with Django? I found that I could not input Unicode characters in the admin interface when using MySQL as the back end. Everything works perfectly out of the box with Postgres, though. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Diamanda wiki v.0.0.2
Things you love django for: http://www.fotosik.pl/pokaz_obrazek/pelny/553d3c6ab6cca377.html As for basic markup - safe HTML powered by Strip-O-Gram http://www.zope.org/Members/chrisw/StripOGram :) hm.. we could add a wysiwyg in a popup ^_^ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Catching an IntegrityError
IntegrityErrors are thrown by the Python Database API. If using mysql, you should code this: from mysqldb import IntegrityError If using postgres you should code this: from psycopg, import IntegrityError Don --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Filter "date" and FormFieldWrapper attribute error
Hi, when displaying a form for a new object, I'm trying to set a default value for a date field using a filter in a template, like so: {{ form.somefield|date:"Y-m-d" }} This gives me an error: 'FormFieldWrapper' object has no attribute 'year'. What am I doing wrong (I'm using generic views)? The other solution for providing default values, that unfortunately doesn't work either, is to set these in the view, when the request is GET (again, generic views): def limited_create_object(*args, **kwargs): #... if request.POST: # else: new_data = request.GET.copy() new_data[ 'somefield' ] = str( ...) request._get = new_data return create_object( *args, **kwargs) The problem with this approach lies in create_update.py, line 56: new_data = manipulator.flatten_data() i.e. the data gets overwritten. What am I missing? Any help would be greatly appreciated. Regards, Andres --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Reversed url lookup.
Apparently in the current trunk reversed urllookup is kind of(!!) working. After toying with it a little bit I found one issue: The main method, reverse, only returns the resulting matched url. Not the rule (the regex and extra arguments) it matched. There is no reliable way of knowing which kwargs got matched and which ones have been ignored. I needed to know to pass the unmatched arguments as querystring. Moreover it would be nice to know what arguments have been passed to the rule. For example adding the parameter https:True would then allow me to build the urls as https. But never mind, it already s quite usefull as it is. I made a template helper tag, to use it in your templates. """ reversed urllookup tag Usage: --- {% load urlhelpers %} {% url_for 'main.views.index' "request.method" request.path foo ok= "bar" method=request.method sub=9 %} --- The first parameter is the view the url will point to. For the second and following parameters you can use named parameters like foo=bar. Parameters and named parameters will be evaluated. If it doesn't evaluate then the string is used. In the above example this means, assuming you use requestContext as your context, that "request.method" => request.method foo => foo "bar" => bar request.method => GET I'd be nice to have a middleware that prepopulated the named paramaters if they have already been given for a certain view If you copy/paste this code, be sure to remove references to logging, rclogging (request cycly logging if you wondered) is my homebrewn interface to python logging. """ from django.template import Library, Node, resolve_variable, TemplateSyntaxError from django.core.urlresolvers import reverse from django.db.models import get_model from lib.rclogging import logger import re register = Library() def find_url_for_view(view , *args , **kwargs): # url = reverse(view, *args , **kwargs ) # logger.debug(args) # logger.debug(kwargs) from django.conf import settings urlconf = settings.ROOT_URLCONF url = reverse(view, args = args , kwargs = kwargs) # logger.debug(re.split(r"[/.]" , url)) # now i want to append a query string # i want to use the unmatched kwargs for this # ideally reverse would also return the matched regexp, sadly it doesn't # i'll naively see what values have been matched query_string = "&".join(["=".join([k, str(v)]) for k , v in kwargs.items() if not str(v) in re.split(r"[/.]" , url)]) logger.debug(query_string) if len(query_string) > 0: query_string = "?" + query_string return url + query_string class ReversedUrlNode(Node): def __init__(self , view , *args , **kwargs): self.args = args self.kwargs = kwargs self.view = view def safe_resolve(self , var , context): try: outvar = resolve_variable(var , context) except: outvar = var logger.debug("%s = %s" % (var ,outvar) ) return outvar def render(self , context): args = [self.safe_resolve(v , context) for v in self.args] kwargs = dict([(k, self.safe_resolve(v , context)) for k , v in self.kwargs.items()]) view = self.safe_resolve(self.view , context) try: url = find_url_for_view(view , *args , **kwargs) except: logger.warn("reversed lookup did a booboo") url = "n/a" # url = find_url_for_view(self.view , *args , **kwargs) return url @register.tag() def url_for(parser , token): raw = re.sub(r'\s*=\s*' , "=" , token.contents) # logger.debug(raw) bits=raw.split() if len(bits) < 2: raise TemplateSyntaxError, "url_for need atleast one argument: url_for my.view" args = [] kwargs = {} view = bits[1] for bit in bits[2:]: pos_is = bit.find("=") if pos_is == -1: args.append(bit) else: kwargs[bit[:pos_is]] = bit[1+pos_is:] # logger.debug("kwargs[%s] = %s" % (bit[:pos_is] , bit[1+pos_is:])) return ReversedUrlNode(view , *args , **kwargs) A few gotcha's: As I didn't feel like rewriting the lookup procedure (I guess it is still alpha at best anyways) I use an extremely naïve way of determining whether an keyword argument matched. I then build a querystring with the remaining armuments. Needless to say, this might slipup.. The second: if the view you want to create the url for a view that does does not already exists reversed urllookup will not work. (wile unreversed throws a cuyu error page) The third: I didn't want to throw errors, so if reverse lookup goes wrong, "n/a" will be the url. I guess you'll want to change that behaviour. --~--~-~--~~~---~--~~ 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
Re: symlink mess
On 08/26/06 21:47, george webzary wrote: > Hi > > > I know this is unrelated to Django. But I guess I mucked up my django sym > links, by linking it number of times. > > How do I remove the multiple level of sym links. This is a Linux newbie > question. But has me stumped. > > When I run setup.py install from updated svn directory, I get this error > > error: > django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django/django: > Too many levels of symbolic links > Hi George Looks like you have a symlink named django inside your django installation which points back to it self. Try something like this: cd /path/to/svn/checkout/django ls -al if you see a symlink in there named django remove it: rm django And all should be fine again. hope this helps ps: you can reproduce this kind of problem like this: mkdir $HOME/test cd /tmp/ ln -s $HOME/test test cd /tmp/test ln -s $HOME/test test After that you'll have a endless hierarchy of symlinks. e.g. /tmp/test/test/test/test//test --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
waiting 1.0
Hello, I'm an enthusiast Django newbie and I need some direction from you: I saw around many django people saying that many things will change in 1.0. I noted also that some tutorial around the web is labeled as "obsolete". Maybe my question is stupid, but, is it worth that I start dive into Django now at 0.95 time instead of waiting until 1.0? Basics will change a lot after release 1.0? Thanks for any advice. Picio --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: waiting 1.0
There will be rather more new stuff that total change of the current API. 0.95 is quite new release and 1.0 won't come out soon. My advice is to use Django 0.95 - learn it and when the /trunk in SVN starts getting serious 1.0 features then update to django-trunk and play with the new stuff part by part as it get merged in SVN :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Can't download flup
When recently up websites go down you can always try using the "Coral Content Distribution Network". http://coralcdn.org/ Here's a mirror. http://www.saddi.com.nyud.net:8080/software/flup/ http://www.saddi.com.nyud.net:8080/software/flup/dist/ http://www.saddi.com.nyud.net:8080/software/flup/dist/flup-0.5-py2.4.egg --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: problems with unicode in website
thanks. when i change collation to utf8_unicode_ci; - all begin to work fine. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: generic views for ajax ?
Dirk, I think that it's a great option. It doesn't advocate a specific framework or method even. AJAX views will be very similar to html views and I agree that having some generic views for AJAX is a great addition to the Django community, even if it doesn't get added to the core. Corey On Aug 26, 2006, at 12:58 PM, [EMAIL PROTECTED] wrote: > > Hi, > > I know the discussion about django and ajax compatible response. > The 'hardliners' say that you only need to implement your own kind > of template - which is true for all time, but I would prefer a much > more generic way to get the response from the views. > > I made a server-side django library for ajax response Json, > JsonRpc, or simple XmlRpc available here: http:// > svn.sourceforge.net/svnroot/django-userlibs/trunk/libs.ajax/ > > Currently I build generic date_based and generic list_detail views > for ajax-response. > > Like to here any comments. > > Regards, > Dirk > -- > > > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
complex expressions in many-to-many relationships
Hi all, May be I'm too demanding to django Db API, but anyway.. OK, I have many-to-many relationship Story >-< Image. I want to get all images which bound to a story and with 'caption' or 'img' fields applied search condition string 'conditionString'. If I write (ver 0.91): from django.models.webwire import stories, images from django.core.meta import Q conditionString = 'test me' story = stories.get_object(pk=73) boundImages = story.get_image_list(complex=( \ ( Q(image__caption__icontains = conditionString) \ | Q(image__img__icontains = conditionString)) )) I have exception: Traceback (most recent call last): File "", line 1, in ? File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\utils\functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) TypeError: method_get_many_to_many() got an unexpected keyword argument 'complex' OK, let's go from other side: boundImages = images.get_list(complex=( ( Q(caption__icontains = conditionString) \ | Q(img__icontains = conditionString)) & Q(stories__id__exact=story.id))) Other exception: Traceback (most recent call last): File "", line 1, in ? File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\utils\functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py", line 1415, in function_get_list return list(function_get_iterator(opts, klass, **kwargs)) File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py", line 1393, in function_get_iterator select, sql, params = function_get_sql_clause(opts, **kwargs) File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py", line 1621, in function_get_sql_clause tables2, join_where2, where2, params2, _ = _parse_lookup(kwargs.items(), opts) File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py", line 1493, in _parse_lookup tables2, join_where2, where2, params2, table_count = kwarg_value.get_sql(opts, table_count) File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py", line 301, in get_sql tables2, join_where2, where2, params2, table_count = val.get_sql(opts, table_count) File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py", line 363, in get_sql return _parse_lookup(self.kwargs.items(), opts, table_count) File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py", line 1601, in _parse_lookup _throw_bad_kwarg_error(kwarg) File "c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py", line 1475, in _throw_bad_kwarg_error raise TypeError, "got unexpected keyword argument '%s'" % kwarg TypeError: got unexpected keyword argument 'stories__id__exact' Question: Do I have syntax error(-s) or it's simply impossible to write such expressions in django? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: generic views for ajax ?
On 8/26/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I know the discussion about django and ajax compatible response. The > 'hardliners' say that you only need to implement your own kind of template - > which is true for all time, but I would prefer a much more generic way to get > the response from the views. I think the ideal would be to have generic views accept an additional parameter which tells them how to format the response -- whether to return HTML, or to serialize to XML or JSON (since we've got object serialization already). See ticket #2553, which is where it's been proposed: http://code.djangoproject.com/ticket/2553 -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Sending an html email
Hi, I am using the template to build the email content. I included links in it but the email are sent in plain text, not in html. What is the way to go to send html email ? Eventually, i'd like to add images too. Thanks in advance for your help Rem --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Flatpage content with dynamic navigation toolbar - is it possible?
I use a base navigation template that has the right rail, and the rest of my templates extend that base template to put in the content - All of my views grab a category list. Flatpages are perfect for the about us, contact us, etc. sections of my site, but my navigation bar needs this category list, and I'd like to keep it dynamic. Though the content is pretty static, I'd like to keep be able to use flatpages to make updates more simple for my partners. Is there any way to accomplish this, or should I just create a couple of views for these sections and hard code the content in the template? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
verbose_name option not working...
In my models, I have added the options "verbose_name" and "verbose_name_plural" to make my models easier to understand in the admin interface. However, even though I have added these options in my models, the admin interface still displays the model's name in the default camel case style. Is there something else I am supposed to add in order for these names to be used? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---