Re: using API to populate db
Never mind. I saw the issue about having to create Question(something='something') rather than just Question() and that solved the problem. Is this viewed as a bug or just an unfortunate circumstance? Todd On Apr 5, 2006, at 11:08 PM, Todd O'Bryan wrote: > > I've exported some old data, in an old (somewhat terrible) format as > XML, and I'm trying to read it back in and populate a Django model. > > When I try to save an object, however, I get this error: > >File "/Users/tobryan1/Documents/eclipse/workspace/django-projects/ > dmi_mr/../dmi_mr/load_questions.py", line 34, in load_questions > dbq.save() >File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ > python2.4/site-packages/Django-0.91-py2.4.egg/django/db/models/ > base.py", line 158, in save > pk_val = self._get_pk_val() >File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ > python2.4/site-packages/Django-0.91-py2.4.egg/django/db/models/ > base.py", line 76, in _get_pk_val > return getattr(self, self._meta.pk.attname) > AttributeError: 'Question' object has no attribute 'id' > > Isn't the model supposed to assign the id, or do I have to do that > myself? > > Todd > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
using API to populate db
I've exported some old data, in an old (somewhat terrible) format as XML, and I'm trying to read it back in and populate a Django model. When I try to save an object, however, I get this error: File "/Users/tobryan1/Documents/eclipse/workspace/django-projects/ dmi_mr/../dmi_mr/load_questions.py", line 34, in load_questions dbq.save() File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/site-packages/Django-0.91-py2.4.egg/django/db/models/ base.py", line 158, in save pk_val = self._get_pk_val() File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/site-packages/Django-0.91-py2.4.egg/django/db/models/ base.py", line 76, in _get_pk_val return getattr(self, self._meta.pk.attname) AttributeError: 'Question' object has no attribute 'id' Isn't the model supposed to assign the id, or do I have to do that myself? Todd --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
mr: DateField and "global name 'date_query' is not defined" error
I stumbled upon this error message after porting a project to magic-removal. In the admin, if I try to get the list view for something like: class SomeModel(models.Model): title = models.CharField(maxlength=200) date_due = models.DateField(blank= True, null=True) class Admin: date_hierarchy ='date_due' I get this confusing error: "Exception Value: global name 'date_query' is not defined Exception Location: magic-removal/django/db/models/query.py in iterator, line 479" it took me sometime to realize that you can't have 'date_hierarchy' on a datefield that can be blank. anyways, I though I'd post it here in case someone struggles over this too. ps: on trunk I get no error. --~--~-~--~~~---~--~~ 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: Locale from URL Middleware
On 4/5/06, Simon Willison <[EMAIL PROTECTED]> wrote: > > On 5 Apr 2006, at 12:26, limodou wrote: > > > Why you need do this? Because django can auto judge the language from > > your browser request http head, or context settings, or settings. If > > you like , you can provide a language selection in web page, and > > that's enough. The url doesnot need to be special processed I think. > > I for one much prefer the language to be specified in the URL rather > than being derived from the browser settings. I would prefer this > behaviour to be supported (at least as an option) in Django core. I > know that language detection based on browser HTTP headers is a > feature of the HTTP specification, but personally I believe that it's > a mistake in the spec. Here's my reasoning: > > 1. Serving up content from the same URL in a different language > depending on browser settings is an idea that is based on the ideal > situation where each translation is a perfect representation of the > content's underlying meaning. This is clearly not a realistic > proposition. Some languages have phrases that do not perfectly > translate to other languages, and translations may not be perfect in > any case due to human error. The French version of a page is > fundamentally different from the English version, and I believe that > the URL should reflect that. > > 2. Passing URLs around. If I copy and paste the URL of a page and > send it to a friend / post it to my weblog, my expectation is that > they will see exactly what I see. Likewise, if I quote something and > cite the original URL, my expectation is that I'm pointing back to > the source of that quote. Changing the content based on the language > header breaks that expectation. Again, I know it's part of the HTTP > spec - but it's so rarely implemented that very few users expect it > to happen. > > 3. Related to the above: What if I spot a typo in a page and want to > report it to the site owner? Sending them the URL is no longer enough > - I have to tell them my browser's language setting as well. > > Given the above, I much prefer the approach taken by most sites that > feature content in multiple languages where the language code is > included somewhere in the URL. > > That's not to say that the user's browser language setting should be > ignored - you can use it to inform them that the page is available in > their preferred language (maybe with a nice big note at the top of > the page, written in their native language of course). > > Tim Berners-Lee and the W3C may disagree with me on this one, but I'm > convinced that using URLs to distinguish between languages is smarter > than relying on browser settings alone. > > Cheers, > > Simon > The reasons are good enough. And I think these things are more concerned with application. Maybe someone doesn't need it I think, or current status in django is enough. If you want to implement it, I can give my opinion.Firstly it should be optional. Secondly, I also think maybe we need to resolve the apps prefix first. Because how to design the url. Just set the locale string after domain? http://domain.com/en http://domain.com/zh_CN Or permit user set it every where he want? http://domain/page/en http://domain/page/zh_CN -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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: A model which is recursively referring to itself in Magic Removal
On Wednesday 05 April 2006 21:35, Rudolph wrote: > Is that an inconsistancy to be removed (ie a bug)? No, it's intended behaviour. The _set stuff is only there because for the 'other' end of these relationships it is possible that there is no name defined, so there needs to be a way of coming up with name automatically. The way it is at present allows you to write stuff like myobject.children.filter(..etc), rather than myobject.child_set Luke -- "Despair: It's always darkest just before it goes pitch black." (despair.com) Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/ --~--~-~--~~~---~--~~ 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: ImageField upload_to
timster wrote: > Should the super() method work even though I'm not using MR? No. super().save() only works in MR. You'll need the _pre_save() and _post_save() hooks in .91 or trunk. -- --Max Battcher-- http://www.worldmaker.net/ "I'm gonna win, trust in me / I have come to save this world / and in the end I'll get the grrrl!" --Machinae Supremacy, Hero (Promo Track) --~--~-~--~~~---~--~~ 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: ImageField upload_to
timster wrote: > Should the super() method work even though I'm not using MR? No. super().save() only works in MR. You'll need the _pre_save() and _post_save() hooks in .91 or trunk. -- --Max Battcher-- http://www.worldmaker.net/ "I'm gonna win, trust in me / I have come to save this world / and in the end I'll get the grrrl!" --Machinae Supremacy, Hero (Promo Track) --~--~-~--~~~---~--~~ 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: Locale from URL Middleware
Glad I am not alone :) There is a little irritation in using the middleware posted above because I obviously have to account for the language in all lines in my urls.py (r'(\w\w/)?... and so on). I would prefer for this to have the same result as using an "include" statement, ie the prefix would be cut off. Going to look into that tomorrow, if anyone knows where to look, a finger in the right direction would be well appreciated. --~--~-~--~~~---~--~~ 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: Stupid newbie question about documentation
... and don't forget the excellent Django API browser here: http://djangoapi.quamquam.org/magic-removal/ Derek --~--~-~--~~~---~--~~ 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: Stupid newbie question about documentation
On 4/5/06, arthur debert <[EMAIL PROTECTED]> wrote: > 1) fire the shell (cd to your project dir) then: >python manage.py shell >from django.contrib.auth.models import User >dir(User) or dir(User,objetcts.all()[0]) User.__doc__ will also get you this information, in a form which lets you conveniently copy, paste and fill in values to instantiate a new User. -- "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 -~--~~~~--~~--~--~---
Re: Stupid newbie question about documentation
Thank you, thank you, thank you. On Apr 5, 2006, at 5:10 PM, arthur debert wrote: > I guess what you are looking for is: > u = User.objects.get(username='namehere') > > but you could also: > > 1) fire the shell (cd to your project dir) then: >python manage.py shell >from django.contrib.auth.models import User >dir(User) or dir(User,objetcts.all()[0]) The second one works. I forgot that attributes wouldn't show up on classes, just instances. > 2) on the admin site, on the top bar there's a "Documentation" link > (mut have docutils installed ) this is very usefull for newbies, I use > it all the time. As a side bonus you get to see ForeignKey and > ManyToMany methods also. Oh. That *is* nice. > 3) checkout the source itself, since you are using this sintax you're > probably using magic-removal, then you can see the python module in : > django/contrib/auth/models.py This is where I finally found the answer. A bit of a pain, but not too awful. Isn't there a Javadoc equivalent for Python? --~--~-~--~~~---~--~~ 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: Stupid newbie question about documentation
Hi Todd. I guess what you are looking for is: u = User.objects.get(username='namehere') but you could also: 1) fire the shell (cd to your project dir) then: python manage.py shell from django.contrib.auth.models import User dir(User) or dir(User,objetcts.all()[0]) 2) on the admin site, on the top bar there's a "Documentation" link (mut have docutils installed ) this is very usefull for newbies, I use it all the time. As a side bonus you get to see ForeignKey and ManyToMany methods also. 3) checkout the source itself, since you are using this sintax you're probably using magic-removal, then you can see the python module in : django/contrib/auth/models.py arthur --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Stupid newbie question about documentation
In m-r, I want to write u = User.objects.get(login='namehere') except that login isn't the name of the attribute. Where can I look to find all the attributes of an instance? I know about the dir() function, but it just gives me methods, right? Is there someplace Python-internal to do this, or do I have to look in the Django documentation. And, if the latter, where? Thanks much, and sorry about the newbiness, Todd --~--~-~--~~~---~--~~ 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: A model which is recursively referring to itself in Magic Removal
Is that an inconsistancy to be removed (ie a bug)? Rudolph --~--~-~--~~~---~--~~ 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: Help with performance?
Here's one technique for optimizing cases where you just get too many queries: http://code.djangoproject.com/wiki/CookBookPreloadRelated --~--~-~--~~~---~--~~ 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: Help with performance?
Joseph, actually the page behind that link describes my profiling hack for the internal webserver, not mod_python. --~--~-~--~~~---~--~~ 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: Locale from URL Middleware
I would like to add another good reason: Another nice effect language codes in the URL is that search engine crawlers can easily get all your content. My customers often want something like this: www.example.com -> site in the main language of your visitors www.example.nl -> site in Dutch www.example.com/nl-nl/ -> site in Dutch etc. I would highly appreciate such middleware. Rudolph --~--~-~--~~~---~--~~ 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: Help with performance?
It's also useful to inspect {{sql_queries}} (see core/context_processors.py). If Django is doing tons of SQL queries, you'll have to sort out how to optimize. I reduced the number of queries on one of my more complex pages from over 6000 to just five. I'll contribute something about this on the Django wiki in a moment... --~--~-~--~~~---~--~~ 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: How do I handel multiple foriegn keys in single model
First you retrieve the person and e-mail type objects, then add a PersonEmail object using them. --~--~-~--~~~---~--~~ 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: How do I handel multiple foriegn keys in single model
Kenneth, what, many persons can have the same e-mail address?!? --~--~-~--~~~---~--~~ 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: Locale from URL Middleware
I very much agree with Simon and Jan. A middleware like this would be nice to have in django.contrib. One useful enhancement would be the ability to specify in where in the URL the language can be specified. On one of my sites the syntax of the URL is always /userid/locale/page... so it would be safest to have the middleware only accept locale codes from the second part of the URL. --~--~-~--~~~---~--~~ 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: ImageField upload_to
Thanks for the reply Ian. I seem to have solved this for the most part. The second message in that thread was very helpful. I was able to use that solution almost exactly. I added the following save() method to my model: def save(self): if self.image: import shutil from os import path from django.conf import settings pathname, filename = path.split(self.image) new_image = path.join(pathname, '%s-%s' % (str(self.gallery_id), filename)) new_location = path.join(settings.MEDIA_ROOT, new_image) old_location = path.join(settings.MEDIA_ROOT, self.image) if new_location != old_location: shutil.move(old_location, new_location) self.image = new_image print self.image super(Image, self).save() I decided to add the gallery_id to the image filename rather than as a subfolder. It still prevents duplicate filenames -- which is what I wanted -- but it is more simple. However, when I call the save() function, it chokes on the last line: >>> from django.models.gallery import galleries, images >>> i = images.get_object(pk=1) >>> i.image 'gallery/audi-01.jpg' >>> i.save() gallery/1-audi-01.jpg Traceback (most recent call last): File "", line 1, in ? File "/.../gallery/models/gallery.py", line 44, in save super(Image, self).save() AttributeError: 'super' object has no attribute 'save' Should the super() method work even though I'm not using MR? --~--~-~--~~~---~--~~ 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: django-admin and manage.py without shell-access
On 4/5/06, òÏÍÁÎ éÍÁÎËÕÌÏ× <[EMAIL PROTECTED]> wrote: > Thank you for your reply > > 2006/4/5, limodou <[EMAIL PROTECTED]>: > > > > I think the answer is NO. And I have a question, if you haven't telnet > > access, and how to configure your settings.py and how to configure > > your web server config? > > settings.py and .htaccess are configured locally then uploaded on a server > For that matter, I don't see why you can ftp up all the files. After all, you should have a copy running on a test box. True, some of the settings and config stuff might be different, and it isn't exactly easy to edit/upload/test, edit/upload/test ..., but it works. The only other concern is the db setup. However, assuming you are using the same db on your test box, save all the sql output from manage.py to files and then input them into whatever db cleint the host offers. Again, not as elegant, but it works. -- Waylan Limberg [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 -~--~~~~--~~--~--~---
Re: Locale from URL Middleware
Op wo, 05-04-2006 te 16:34 +0100, schreef Simon Willison: > I for one much prefer the language to be specified in the URL Or sometimes using a cookie... > rather > than being derived from the browser settings. I would prefer this > behaviour to be supported (at least as an option) in Django core. I > know that language detection based on browser HTTP headers is a > feature of the HTTP specification, but personally I believe that it's > a mistake in the spec. Here's my reasoning: [snip 3 good reasons] One more reason is when you are using someone else's computer and you don't prefer the same language as the owner. (That owner might also be a "cybercafé" or such.) -- Jan Claeys --~--~-~--~~~---~--~~ 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: A model which is recursively referring to itself in Magic Removal
Rudolph wrote: > parent = models.ForeignKey('Item', blank = True, null = True, > related_name = 'child',) > > When trying to get the childs of an object by issueing > item.child_set.all(), it raises an exception: > 'Item' object has no attribute 'child_set'. Because you used related_name='child', you must also use item.child.all(). It seems that _set stuff is added only when relation name is not explicitly given. -- Nebojša Đorđević - nesh Studio Quattro - Niš - SCG http://studioquattro.biz/ http://djnesh.blogspot.com/ | http://djnesh-django.blogspot.com/ | http://djangoutils.python-hosting.com/ Registered Linux User 282159 [http://counter.li.org] --~--~-~--~~~---~--~~ 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: Locale from URL Middleware
On 5 Apr 2006, at 12:26, limodou wrote: > Why you need do this? Because django can auto judge the language from > your browser request http head, or context settings, or settings. If > you like , you can provide a language selection in web page, and > that's enough. The url doesnot need to be special processed I think. I for one much prefer the language to be specified in the URL rather than being derived from the browser settings. I would prefer this behaviour to be supported (at least as an option) in Django core. I know that language detection based on browser HTTP headers is a feature of the HTTP specification, but personally I believe that it's a mistake in the spec. Here's my reasoning: 1. Serving up content from the same URL in a different language depending on browser settings is an idea that is based on the ideal situation where each translation is a perfect representation of the content's underlying meaning. This is clearly not a realistic proposition. Some languages have phrases that do not perfectly translate to other languages, and translations may not be perfect in any case due to human error. The French version of a page is fundamentally different from the English version, and I believe that the URL should reflect that. 2. Passing URLs around. If I copy and paste the URL of a page and send it to a friend / post it to my weblog, my expectation is that they will see exactly what I see. Likewise, if I quote something and cite the original URL, my expectation is that I'm pointing back to the source of that quote. Changing the content based on the language header breaks that expectation. Again, I know it's part of the HTTP spec - but it's so rarely implemented that very few users expect it to happen. 3. Related to the above: What if I spot a typo in a page and want to report it to the site owner? Sending them the URL is no longer enough - I have to tell them my browser's language setting as well. Given the above, I much prefer the approach taken by most sites that feature content in multiple languages where the language code is included somewhere in the URL. That's not to say that the user's browser language setting should be ignored - you can use it to inform them that the page is available in their preferred language (maybe with a nice big note at the top of the page, written in their native language of course). Tim Berners-Lee and the W3C may disagree with me on this one, but I'm convinced that using URLs to distinguish between languages is smarter than relying on browser settings alone. Cheers, Simon --~--~-~--~~~---~--~~ 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: Locale from URL Middleware
I understand how django does it. Unfortunately I am forced to maintain a web structure that requires this functionality so that's why I wrote it. But I actually prefer this over the ambiguity in the browser settings which most people do not set anyway and the extra step required to select the right language if someone sends you a url that ends up in the wrong language. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
magic-removal ebuild
For the gentooers, I've built a magic removal svn ebuild If anyone wants it, pvt-me --~--~-~--~~~---~--~~ 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: Locale from URL Middleware
On 4/5/06, atlithorn <[EMAIL PROTECTED]> wrote: > > Just in case anyone is interested... I wrote my own middleware class to > support selecting languages from the URL itself. eg: > > www.example.com - default english > www.example.com/de - same page with german trans > > It was a simple copy-paste of the LocaleMiddleWare from the distro: > Why you need do this? Because django can auto judge the language from your browser request http head, or context settings, or settings. If you like , you can provide a language selection in web page, and that's enough. The url doesnot need to be special processed I think. -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Locale from URL Middleware
Just in case anyone is interested... I wrote my own middleware class to support selecting languages from the URL itself. eg: www.example.com - default english www.example.com/de - same page with german trans It was a simple copy-paste of the LocaleMiddleWare from the distro: ## from django.utils.cache import patch_vary_headers from django.utils import translation class LocaleURLMiddleware: def get_language_from_request (self,request): from django.conf import settings import re supported = dict(settings.LANGUAGES) lang = settings.LANGUAGE_CODE[:2] check = re.match(r"/(\w\w)/.*", request.path) if check is not None: t = check.group(1) if t in supported: lang = t return lang def process_request(self, request): language = self.get_language_from_request(request) translation.activate(language) request.LANGUAGE_CODE = translation.get_language() def process_response(self, request, response): patch_vary_headers(response, ('Accept-Language',)) translation.deactivate() 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 -~--~~~~--~~--~--~---
Re: ANN:Woodlog Testing
Limodou, Thanks a lot for the explanation and help. Best 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 -~--~~~~--~~--~--~---
Re: ANN:Woodlog Testing
On 4/5/06, PythonistL <[EMAIL PROTECTED]> wrote: > > Limodou, > Thanks a lot for your help. > Now I understand much better. > Best regards, > L. You are welcome. -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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: ANN:Woodlog Testing
Limodou, Thanks a lot for your help. Now I understand much better. Best 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 -~--~~~~--~~--~--~---
Re: ANN:Woodlog Testing
On 4/5/06, PythonistL <[EMAIL PROTECTED]> wrote: > > Limodou, > Thanks for replies. > I am also working on a application that more users should be used by. > So, I would like to learn a little more how to create > url dynamicly( on fly). Can you please let me know where in you > file(s) you make that. > Thanks a lot > L. > First you should define url pattern in urls.py, just like: in ursl.py you will find: (r'^blog/(?P.*?)/', include('apps.woodlog.urls')), and in apps/woodlog/urls.py you will find: urlpatterns = patterns('', (r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\d+?).html$', 'apps.woodlog.views.detail'), (r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', 'apps.woodlog.views.day'), (r'^(?P\d{4})/(?P\d{1,2})/$', 'apps.woodlog.views.month'), (r'^/?$', 'apps.woodlog.views.index'), (r'^categories/(?P\w+)/?$', 'apps.woodlog.views.view_category'), (r'^(?P\d{4})/(?P\d{2})/(?P\d{2})/(?P\d+?).html/addcomment/$', 'apps.woodlog.views.add_comment'), ) So from two level url parsing, you will get 'username' and other parameter. And you can process username in your view code, just like: def index(request, user_name): try: user = User.objects.get(username=user_name) except ObjectDoesNotExist: return Http404(), "Doesn't exist this user!" objects = user.entry_set.entries() page = Page(request, objects, paginate_by=__get_paginate_by(user), urlprefix=get_app_root('blog') + '/' + user_name + '/') context = RequestContext(request, {'page':page, 'blog_id':user_name}) return theme_render_to_response('woodlog/list', user, context_instance=context) So the user is retrieved from User model according to username. And later, I pass the user_name as 'blog_id' in RequestContext, so I can use the 'blog_id' variable in template. In templte just like woodlog/list, you can use 'blog_id' to create your url: {{ blog_id }} That's all. -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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: django-admin and manage.py without shell-access
Thanks, it looks like a satisfactory decision for the "poor man's hosting" --~--~-~--~~~---~--~~ 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: ANN:Woodlog Testing
Limodou, Thanks for replies. I am also working on a application that more users should be used by. So, I would like to learn a little more how to create url dynamicly( on fly). Can you please let me know where in you file(s) you make that. Thanks a lot 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 -~--~~~~--~~--~--~---
Re: django-admin and manage.py without shell-access
Roman wrote: >I need to place my django-powered web site on a server which haven't >SSH-access (ftp only). Can I execute analogues of "django-admin" and >"manage.py" through web interface? > > There is no web interface but you can write a script with something like this: from django.core import management management.install('app_name') And execute it in server. Look in core/management.py for more options. --~--~-~--~~~---~--~~ 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: django-admin and manage.py without shell-access
On 4/5/06, Roman <[EMAIL PROTECTED]> wrote: > > I need to place my django-powered web site on a server which haven't > SSH-access (ftp only). Can I execute analogues of "django-admin" and > "manage.py" through web interface? > Is there something like web-wrapper for these commands? > I think the answer is NO. And I have a question, if you haven't telnet access, and how to configure your settings.py and how to configure your web server config? -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django-admin and manage.py without shell-access
I need to place my django-powered web site on a server which haven't SSH-access (ftp only). Can I execute analogues of "django-admin" and "manage.py" through web interface? Is there something like web-wrapper for these commands? Thank you. -- Roman --~--~-~--~~~---~--~~ 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: ANN:Woodlog Testing
On 4/5/06, PythonistL <[EMAIL PROTECTED]> wrote: > > Limodou,thank you for your reply. > I am sorry but I do not fully understand your answer > > You say that every user has his own blog but also that there is not > user > directory. But when I want to use my blog as a user, I have a different > URL, e.i.a directory is also different, from another user. > I would guess that every user must have a directory with some files.Or > am I wrong? Because url can be create dynamicly, so every user can have different url, just like: http://djangocn.org/blog/limodou http://djangocn.org/blog/pythonlist And in django, I saved almost everything in database. All posts store in Entry table, and they can be grouped by user field. So if I want to show all posts of a user, I can: posts = user.entry_set.all() > > What is advantage of xmlrpc access that you implemented it? > There are some xmlrpc apis used in blog system, just like bloggerAPI, metaweblogAPI, and woodlog supports these standard xmlrpc api, so you can edit your blog in an offline blog editor, and you don't need to open a browser and sign in the blog system to edit your post. Using these tools, you can also easily backup your blog. And these apis also can be used in other purposes. > Thank you for your reply. > L. > -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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: ANN:Woodlog Testing
Limodou,thank you for your reply. I am sorry but I do not fully understand your answer You say that every user has his own blog but also that there is not user directory. But when I want to use my blog as a user, I have a different URL, e.i.a directory is also different, from another user. I would guess that every user must have a directory with some files.Or am I wrong? What is advantage of xmlrpc access that you implemented it? Thank you for your reply. 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 -~--~~~~--~~--~--~---
Re: ANN:Woodlog Testing
On 4/5/06, PythonistL <[EMAIL PROTECTED]> wrote: > > Hello Limodou, > It looks very nice. > Can you please answer my question? > What is the file rpc.py for? woodlog support xmlrpc access. So rpc.py is a xmlrpc functions congif file. > Does every user have his own blog in his directory? Yes. Woodlog is a multi-user blog system. But there is not user directory, because all posts are saved in database. And every post has a user field. > And what files must every user have in his directory and which can be > common(the same )? > Thank you for your reply > L. So no need such directory. -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~-~--~~~---~--~~ 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: ANN:Woodlog Testing
Hello Limodou, It looks very nice. Can you please answer my question? What is the file rpc.py for? Does every user have his own blog in his directory? And what files must every user have in his directory and which can be common(the same )? Thank you for your reply 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 -~--~~~~--~~--~--~---