ANNOUNCE: importd 0.2.0 released
Hello everyone, I am pleased to announce I have released 0.2.0 of importd. Documentation: http://pythonhosted.org/importd/. ChangeLog <https://github.com/amitu/importd/blob/master/ChangeLog.rst>: - BACKWARD INCOMPATIBLE: remove atexit magic, d.main() is the replacement - gunicorn cleanly exits now - tests, support django 1.4.3 and 1.5.1 for each of python 2.6, 2.7 and 3.3 - less magic, no more sys.modules tweaking - runserver now reloads when any file changes - added auto generated MANIFEST.in (using check-manifest) - added support for mounting urls to custom locations Feedback appreciated, Thanks -- Amit Upadhyay amitu.com [+1 (408) 464-8800] -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
[ANN] fhurl release 0.1.1
http://packages.python.org/fhurl/ This is a generic view for form handling. First release. Feedback and comments appreciated. -- Amit Upadhyay +91-9820-295-512 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
hi
Hey, Checkout www.RemindMeSam.com . -- Amit Upadhyay Via - www.remindmesam.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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ANN: django google contacts importer
Hi, I just wrote a helper app to import contacts from Google. http://github.com/amitu/dgci/tree/master Anybody willing to help me write a similar dyci for Yahoo!? :-) -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
mobile cookie related issue, is it a bug in django?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I found that request.user is not set on all requests when accessing my under development website from mobile. I have put the following in one of my middlewares for debugging: class MyMiddleware(object): def process_request(self, request): ... print request.META.get( "REMOTE_ADDR", "NO IP" ), request.vuser, request.path, request.META.get( "HTTP_COOKIE" ), request.COOKIES [request.vuser is derived from request.user, if its None, it means request.user was AnonymousUser] And here is the output when accessing from a Nokia N70 builtin browser over Vodafone network. 10.16.30.201 None /sms/1490/by/bombaylives/ $Version=0;sessionid=993578dc3196af8e97a5cbdfca4336f9;$Path=/;sessionid=ba5be2a4b6d3b2544a8c696574fa8fde;$Path=/ {'sessionid': 'ba5be2a4b6d3b2544a8c696574fa8fde'} [19/Sep/2008 17:40:26] "GET /sms/1490/by/bombaylives/ HTTP/1.1" 200 2215 10.16.30.201 rahulg /static/sid/logomobile.png $Version=0;sessionid=ba5be2a4b6d3b2544a8c696574fa8fde;$Path=/;sessionid=993578dc3196af8e97a5cbdfca4336f9;$Path=/ {'sessionid': '993578dc3196af8e97a5cbdfca4336f9'} [19/Sep/2008 17:40:30] "GET /static/sid/logomobile.png HTTP/1.1" 304 0 10.16.30.201 rahulg /sms/25506/by/arunprasath007/ $Version=0;sessionid=ba5be2a4b6d3b2544a8c696574fa8fde;$Path=/;sessionid=993578dc3196af8e97a5cbdfca4336f9;$Path=/ {'sessionid': '993578dc3196af8e97a5cbdfca4336f9'} [19/Sep/2008 17:41:13] "GET /sms/25506/by/arunprasath007/ HTTP/1.1" 200 2539 10.16.30.201 rahulg /static/sid/logomobile.png $Version=0;sessionid=ba5be2a4b6d3b2544a8c696574fa8fde;$Path=/;sessionid=993578dc3196af8e97a5cbdfca4336f9;$Path=/ {'sessionid': '993578dc3196af8e97a5cbdfca4336f9'} [19/Sep/2008 17:41:42] "GET /static/sid/logomobile.png HTTP/1.1" 304 0 I am getting two cookies from browser by name sessionid, and django is using the last one it receives for looking for getting sessionid. Has anyone else faced this or similar issue? If not can someone tell me how do I go about debugging this? Am using pre1.0 trunk r3331. - -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: http://getfiregpg.org iD8DBQFI050eaRcPJ4NxgJIRAkuPAJ9IR0ee/YOan6T0B0r8eHt3YDcVDgCgjY4J gdtKz9QhewQr46MT6CMCOZo= =DeyL -END PGP SIGNATURE- --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: memchached issue on ubuntu
On Wed, Jun 25, 2008 at 2:30 AM, Alex Ezell <[EMAIL PROTECTED]> wrote: > If this is what is in your settings file exactly: > > CACHE_BACKEND = "memcached:///127.0.0.1:11211/" > > It looks to me like you have an extra slash there before your IP > address. Meaning that when this string gets parsed in the cache > backend, it's probably getting nothing for an IP. This was it. Thanks a million. I need more coffee when working late in the night :-) -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: memchached issue on ubuntu
On Tue, Jun 24, 2008 at 9:29 PM, Michael Wieher <[EMAIL PROTECTED]> wrote: > > now I would just run the same test you ran earlier, try to set data in > the cache, now that the cache itself exists The memcached server was already running. I tried the test again anyways, same result. -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: memchached issue on ubuntu
On Tue, Jun 24, 2008 at 9:19 PM, Michael Wieher <[EMAIL PROTECTED]> wrote: > > I don't know how djano uses memcached, but have you like, looks to me > as if you need an instance of memcached running locally, listening on > its default port. Thanks, I just checked and I do, I started it thus: > Start memcached: $ memcached -v Its running on a diff console on same machine [my laptop]. Any other thing I should double check? -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
memchached issue on ubuntu
Hi, Am trying get django working with memcached. I am running a few month old trunk. Start memcached: $ memcached -v settings.py contains: CACHE_BACKEND = "memcached:///127.0.0.1:11211/" shell: $ python manage.py shell [EMAIL PROTECTED] mcm_server_add3():2087: unable to lookup/resolve host: No such file or directory: Name or service not known Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) Type "copyright", "credits" or "license" for more information. IPython 0.8.2 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: from django.core.cache import cache In [2]: cache.set("k", 12) [EMAIL PROTECTED] mcm_server_connect_next_avail():2322 In [3]: cache.get("k") [EMAIL PROTECTED] mcm_server_connect_next_avail():2322 In [4]: Am using cmemcache library: http://leavingcorporate.com/2008/05/04/installing-cmemcache-on-ubuntu/ Anyone familiar with whats going on? TIA. -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: extending user model, a different approach
On 7/26/07, James Bennett <[EMAIL PROTECTED]> wrote: > > On 7/25/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > > I realized a new way to extend user models, it is simpler than official > > get_profile approach of django[1] as there is only one model to work > with, > > and relationships are kept on the right model, and gives a less hacky > feel > > than "replaces_module" method[2]. > > Personally, I'd disagree about it feeling "hacky"; it's using internal > metasystem methods to pry open the model class and shove things into > it, which is, well, hacky ;) :-) In this solution, however, every site shoves all its customization > straight into the User model that's shared among them all, which > raises a lot of ugly questions about what happens when those > customizations collide with one another. Keeping per-site > customization in a manageable, separate namespace is a good thing ;) Well, AUTH_PROFILE_MODULE is not going away, it can be used in multi site cases, but for simpler cases, this approach is much simpler. Also this can be used to extend any django.contrib model, you can add "favicon_url" in Site, or "description" in auth.Group for example. -- Amit Upadhyay http://www.amitu.com/blog/ +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
extending user model, a different approach
Hi, I realized a new way to extend user models, it is simpler than official get_profile approach of django[1] as there is only one model to work with, and relationships are kept on the right model, and gives a less hacky feel than "replaces_module" method[2]. User.add_to_class("openid", models.URLField(blank=True)) User._meta.admin.fields += ( ("AmitCom Extensions", { 'fields': ('openid', ) }), ) *class* UserExtension(object): *def* _get_comments(self): *return* Comment.objects.get(user=self, is_public=True) public_comments = property(_get_comments) *del* _get_comments User.__bases__ = User.__bases__ + ( UserExtension, ) Read my blog post about the same[3] for a longer discussion about pros and cons. How does it sound? 1. http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model 2. http://code.djangoproject.com/wiki/ExtendedUserModel 3. http://www.amitu.com/blog/2007/july/django-extending-user-model/ -- Amit Upadhyay http://www.amitu.com/blog/ +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: reverse pagination
On 7/23/07, Nis Jørgensen <[EMAIL PROTECTED]> wrote: > > Is there anything in your proposal that isn't solved by using something > like > > MyModel.objects.order_by('some_field') > > for the queryset passed to the paginator? This will reverse the order of objects, you do not want to show the oldest post on the main page of your blog. What I am suggesting only changes the page numbering. -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
reverse pagination
Hi, You are all aware of object pagination, search results, your photo on flickr, stories on reddit, all have a next page/previous page paradigm. Django makes it trivially easy to create such pages by providing object_list generic view. There are some problems with the current implementation of pagination that we see around, page no 0/1 is assigned to the latest objects in the list. While in search result this makes little difference, in other cases it has a few consequences. In reddit for example, you are on the main page, you see 25 stories there, you take 10 minutes to go through all of them, and click next. There is a good chance that 3-5 stories on the first page would have moved to now second page, and you will see them again. Not a good experience, but acceptable. You spend next 3-4 hours working, and click back to see the stories on the first page, you are taken to page 0, and there are good chances you have missed 12 stories that moved from first page to second, as your current page labelled second page became third. This is all quite confusing if you think about it. [I am assuming from this discussion the stories changing their relative rankings for simplicity, you can take example of flickr group photos, they also change rapidly, and order does not change there]. Another problem is, I am page 26 of this flickr group, and I see some fellow has posted 8 nice photos to the group. I bookmark the page, and come back later/email it to a friend, and by the time the page is visited again, 100s of new photos has been added and the content of page 26 is now on page 29 or so. The last consequence of this is caching difficulty. If a group has 5 thousand pages worth 30 photos each, and one more photo gets added, either the page number of the photos in each page will change for 5 thousand of those pages. This will happen on each photo being added, and there for the page can hardly be ever cached. I propose a solution to this problem, I call it reverse pagination, and this blog is currently using a patched django to demonstrate it. In reverse pagination, page no 0/1 is assigned to the older page ever. When on reddit home page, and click next, you will not go to page 2, you will jump to page 20566 or something like that. The content of page 20566 will never change, only the content of latest page would be changing while new items are being added. This means all pages other than the main page can be cached for the rest of the life span of the website. And user will not face the other two problems I listed above. Only downside is on the main page/latest page, you will upto 19 items if you paginate by 10 items per page. Here is the patch for django. http://code.djangoproject.com/ticket/4956 http://www.amitu.com/blog/2007/july/reverse-pagination/ Feedbacks appreciated! -- Amit Upadhyay http://www.amitu.com/blog/ +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: image bundle for django
On 6/12/07, Rob Hudson <[EMAIL PROTECTED]> wrote: > > One thought I had to counter that would be to group small images > together, then medium sized images, then large images. Depending on > how many images your website actually uses, this would need to be > tuned, but maybe it would help alleviate the wait. Also, grouping One of the ideas in my mind to extend this proof of concept was "named bundles". I was looking at them because of CSS issues, but same can be applied to both. I like the simplicity here, that you do not have to define bundles and use them in two separate steps, but what google does, making creation of bundle a conscious extra step, a little bit of hassle but more flexible for such requirements. Lets say we write a command line script "create_bundle" [lets say, part of manager.py if it gets to django proper], that will take a bundle name, and a set of images as input and create the bundle. Then in template files we can refer to the bundle names in {% img %} tag. create_bundle script will have to store the metadata about the names of images that have gone in the bundle and their relative order in some other place. These are additional complexities to tackle, nothing really difficult, a little inconvenient. We can probably go with both kind of bundles, if {% img %} supplies a bundle name, use named bundle, otherwise do what is being done current. Anyway, it's an interesting idea and nice to see an implementation. On 6/12/07, Justin Lilly <[EMAIL PROTECTED]> wrote: Also, I'm not sure if this is bug or design, but if you use this method, you > can't save the picture without a rather large hassel. > I am not sure I understood your concern here. There are many things wrong, its just a prototype, I am assuming the images are /static/something.ext and are all saved in the MEDIA_DIRECTORY. Suggestions welcome. [I was thinking what if the images are served from a different host, S3?, all those cases will cause problems and will have to be thought before it can go beyond prototype stage to candidate for contrib]. On 6/13/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > I really like this idea, but my needs are different. > > I don't need resizing of images in the bundle, and I don't like the > idea of loading all the original images in the bundle to determine > offsets in the final. Server side resizing was compulsory as otherwise the background technique would not work. AFAIK. Browser will just show the part of image, and does not shrink the background to fit. I see you're using mx.Misc.OrderedMapping. Does that do anything that > django.utils.datastructures.SortedDict doesn't do? > Nothing, I dint knew about it. -- Amit Upadhyay Vakow! www.vakow.com +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Multiple Profiles
On 5/9/07, Vinay Sajip <[EMAIL PROTECTED]> wrote: > > One simple problem with Amit's approach, as written, is that you have > to deal with "fuser" and "duser", which feels a little kludgy (I > realise he was just demonstrating the concept, but the problem still > remains that you want to think of all the profile information as just > part of the user model. Is the intention just to avoid saying > user.get_profile().xxx? Can't this be done by judiciously overriding > __getattribute__ in User, to delegate to a profile if one is defined? Agree with you. I was suggesting this solution as a part of multiple type of user scenario, where profile itself would be different. For us, we have endusers, and businesses, and we require different kind of profiles for both of them. .get_profile() does not handle this situation (AFAIK). -- Amit Upadhyay Vakao! +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
Re: Multiple Profiles
On 5/8/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > > On 5/8/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > > I would recommend you take a look at lost-theories.com source code. One > anti > > pattern that django docs seems to recommend is use > > django.contrib.auth.models.User as your main user model > ... > > and user.get_profile().friends.all() sounds wrong. > > With this you can say fuser.friends.get(). Natural. > > Replying to Django-user rather than Django-dev. For context, please read the approach for extending User models as I borrowed from lost-theories source code: http://groups.google.com/group/django-developers/msg/55889eafe381a09b -- Amit Upadhyay Vakao! +91-9820-295-512 --~--~-~--~~~---~--~~ 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?hl=en -~--~~~~--~~--~--~---
how to iterate over a subset of model.all
Lets say I have a Author and Article models, related via many to many. On the profile view of authors I want to show the articles they contributed to, but not all of them. The number is purely a decision of the designer, how does one do a limit/offset in template? -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: DSN useful for database settings?
On 5/10/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote: Exactly. That's precisely what I pointed out in the (now closed)ticket for this feature request. Settings files are pure Python for areason -- this sort of flexibility.Let's move onto more pressing improvements to the framework, shall we? It would be good for django if work like this is a little more encouraged. Its a good patch, complete with unittests and docs, and if it cant go to django main (even i am on -1 on both and -0 on DSN being the way to specify settings), it sure can go to the examples. We keep on harping the main advantage of using python for settings file is that we can do programmatic stuff in it, what could be better example than a settings.py example which demonstrates this. All I am saying is dont just throw out a decently done work.-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay +91-9867-359-701 --~--~-~--~~~---~--~~ 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: Erro on access svn repository
On 5/6/06, Victor Godoy Poluceno <[EMAIL PROTECTED]> wrote: Hello,This error occurred when having access the repository snv of developmentof django, for download of the current version of django.[[EMAIL PROTECTED] Django]$ svn co http://code.djangoproject.com/svn/django_src/svn: Requisição REPORT falhou em '/svn/!svn/vcc/default'svn: REPORT de '/svn/!svn/vcc/default': 400 Bad Request (http://code.djangoproject.com)I'm sorry about my english.You are probably behind a (transparent?) proxy that does not support HTTP REPORT required by svn. Get the latest code from http://www.amitu.com/django_mr.tar.gz, updated few minutes back. [I update this file every 12 hours from latest svn for my personal use, feel free to use this link.] www.djangoprojects.com admins, can we have nightly svn builds please? -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay +91-9867-359-701 --~--~-~--~~~---~--~~ 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: Feed rss and xml
On 4/10/06, coulix <[EMAIL PROTECTED]> wrote: hi i amnage to make the feed working, but when a user clic on it iwould it to be an xml file with foo.xml formal, actually now its onlyfoo so rss agregators still works but when you clic on it, t ask how to open it ect.For debugging, I did this: Index: django/utils/feedgenerator.py===--- django/utils/feedgenerator.py (revision 2116) +++ django/utils/feedgenerator.py (working copy)@@ -117,7 +117,8 @@ self.url, self.length, self.mime_type = url, length, mime_type class RssFeed(SyndicationFeed):- mime_type = 'application/rss+xml' + #mime_type = 'application/rss+xml'+ mime_type = 'text/xml' def write(self, outfile, encoding): handler = SimplerXMLGenerator(outfile, encoding) handler.startDocument() Come to think of it, it is still there, and every feed aggregator, atleast the ones I or my clients have tried, consumes this without any problem. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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?
On 4/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Well, yeah. But bascially a three-line Python script with a simpleget_list(), returning two small elements, should not be taking seven seconds.I am not surprised about it. One of the three line you are talking about is something like from django.models.mymodel import *, and this alone takes some time to happen. May be m-r is a little better in initialization. Design your scripts keeping this in your mind, create the whole script in python, and not invoking python as a helper process used in some loop maybe better. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: Module imports in models
Hi Clint,This is due to magic that django performs on models. The class you defined lands up in some other module that django created, and module level imports are not passed along. You can solve your problem either by importing within the _pre_save, or define your Meta class as: class Meta: module_constants = globals()On 3/15/06, Clint Ecker <[EMAIL PROTECTED]> wrote: I'm using Django 0.91-svn if that matters On 3/14/06, Clint Ecker < [EMAIL PROTECTED]> wrote: I'm having an odd problem when trying to import some python modules in my Django models. Things just aren't working how I'd expect:The broken model is below. The problem occurs when _post_save is called, it will error out on the "thumbs_dir = os.path..." line because it says that "os" is not globally defined. This doesn't seem to jive with all my other python experience. If I import the module at the top of my file, I should be able to use it all over the place. To fix the problem, I can move the "from django.conf.settings import MEDIA_ROOT import os.path import Image" inside the _post_save(self) method. Any ideas why my conventional python wisdom is failing me here?### Begin Broken Links Model ###from django.core import metafrom django.conf.settings import MEDIA_ROOTimport os.pathimport Imageclass Link(meta.Model): uri = meta.URLField() link_name = meta.CharField(maxlength=255) source_name = meta.CharField(maxlength=255) clicks = meta.IntegerField(default=0) pub_date = meta.DateTimeField() thumbnail = meta.ImageField(upload_to="uploads") approved = meta.BooleanField(default=False) def __repr__(self): return self.uri def _post_save(self): size = 100, 150 thumbs_dir = os.path.dirname(self.get_thumbnail_filename()) + "/thumbnails/" thumbsfile = thumbs_dir + "tn_" + os.path.basename(self.get_thumbnail_filename()) infile = self.get_thumbnail_filename() outfile = thumbsfile im = Image.open(infile) im.thumbnail(size) im.save(outfile,quality=100) class META: admin = meta.Admin() def get_thumb_url(self): import os.path tnd = "/thumbnails/" tnp = "tn_" fs = self.get_thumbnail_url () return os.path.dirname(fs) + tnd + tnp + os.path.basename(fs)### End Broken Links Model ###Thanks,Clint -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: specifying a model with a field computed from other fields
On 3/10/06, Gavin <[EMAIL PROTECTED]> wrote: I want expenditures to be a ForeignKey, but I want to create it basedon values entered (num_units * unit_cost, account).My question: How can I create a foreign key based on the values enteredfor other fields? _pre_save() is a function that if you define for your model, will be called just before the model is saved in the database. You can put your logic there. -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: why is my view for a submitted form not getting a POST?
On 3/9/06, Glenn Tenney <[EMAIL PROTECTED]> wrote: see http://www.djangoproject.com/documentation/forms/ in the finishedversion of the "create_form" template it uses "action="" with no trailing slash.A . means the current page, and given the page was generated by django, which always adds a / to all page URLs its gauranteed that current page will end with a /. . is django way of handling form is there is any, makes it more "portable", one less thing to change when you are relocating your pages on your site, and your template need not know the actual page where the form would be deployed. Django facilitates these things as best practices, you are completely free to follow whatever your requirements tell you. Its usually recommended to serve the form in the GET request and handle it in POST request on the same url. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: Attn. Dreamhost users
On 3/8/06, Hans-Christian Holm <[EMAIL PROTECTED]> wrote: I'm a bit reluctant to switching hosts. I haven't had my DH account for thatlong, but they have offered great value for money so far, and there seems tobe a few Django apps running happily there already. And switching is so boring work.I have faced a few issues but my django application on dreamhost is wroking fine otherwise. Once in a while [1-2 such mails per day, their stats page say I execute about 200-400 thousand queries a day], I would get Mysql dies while executing the query, but the nature of my application is such that a one odd failures can be ignored. BTW I have not yet put any caching, so I am making upto 5 queries per scond on their mysql server, and don't face any hiccups. The only issue I have faced there is twice in about 2 months of deployment of my application my application will stop to respond, will wait for 2 minutes or so and then give me 500 server internal error, in the process it would create tens of core files. This problem has fixed automatically on both occasions in 5-10 minutes. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: Attn. Dreamhost users
On 3/8/06, PythonistL <[EMAIL PROTECTED]> wrote: But how can I kill ALL of them?One by one something like:kill processNumber?pkill is your friend. I use "pkill -9 python2.4" on abovenet for most code changes. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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 import view
On 3/6/06, tomass <[EMAIL PROTECTED]> wrote: (r'^jobmonitor/$', include('greenleaftech.jobmonitor.views.index')),try: (r'^jobmonitor/$', 'greenleaftech.jobmonitor.views.index'),include is used to include a different urls file for further resolution. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: view on site
Hi Mary,Put (r'^r/', include('django.conf.urls.shortcut')), in your URLConf.On 3/2/06, Mary Adel <[EMAIL PROTECTED]> wrote:i created my website using flatpages and they are amazing for me and i am very happy for that but their is a button on the page on the righthand side called (view on site) and when i clicked on it it gave meerror says page not found what should i do to make this button work -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: order_with_respect_to
On 2/24/06, patrick k <[EMAIL PROTECTED]> wrote: did that. exactly the same error.Enabling template debugging won't solve your problem, it will just help you pin point it. The errors should be the same, but the output should also include some template code, with a few line in red, post those lines, or attach your template. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: order_with_respect_to
On 2/24/06, patrick k <[EMAIL PROTECTED]> wrote: here it is (i´m not sure if you need all of this ...): TemplateSyntaxError: Caught an exception while rendering.This is a template syntax error, you can put a TEMPLATE_DEBUG=True in your settings file and restart server to help you find about template error. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: order_with_respect_to
Hi Patrick,good point.i´d still appreciate some help with my initial question though. Can you please post the exact error that you are getting? -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay +91-9867-359-701 --~--~-~--~~~---~--~~ 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: order_with_respect_to
On 2/24/06, va:patrick.kranzlmueller <[EMAIL PROTECTED]> wrote: class Filmstarts(meta.Model): id = meta.AutoField('ID', primary_key=True)Why are you doing this? Every model has a file named `id` if you do not specify any primary_key. If there is no strong reason to do it, consider removing this line, and recreating tables. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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 POST
On 2/24/06, Vladimir <[EMAIL PROTECTED]> wrote: action=""> method="POST">Hi,This is a very common newbie mistake, make that action="">.-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: SetEnv issue
Hi Kenneth,Are you using VirtualHosts? I had problem with them on some machine, and I moved to someother without virtual hosts and it worked. On 2/23/06, Kenneth Kalmer <[EMAIL PROTECTED]> wrote: GuysI've scoured google, this list and the docs for two days now and Isimply can't get django to work with mod_python. Here is some detailfirst:httpd-2.0.52-22.ent.centos4python-2.3.4-14.1 mod_python-3.1.3-5.1MySQL-python-1.0.0-1.RHEL4.1This is a seperate httpd instance to the one with PHP5 in. So, I havetwo instances running, one for PHP5 and a different one formod_python.First I followed the normal "Testing mod_python" steps creating the mptest handler and it worked. Then I import pyexpat and MySQLdb totest them and they worked.Playing around I got to this point now where I have the following codein a .htaccess file<.htaccess> SetEnv DJANGO_SETTINGS_MODULE myproject.settingsSetEnv foo barAddHandler mod_python .pyPythonHandler mptestPythonAutoReload OnPythonDebug Onand this in mptest.py import pyexpatimport MySQLdbfrom mod_python import apacheimport os, sys, thread, timedef handler(req):req.content_type = 'text/plain'req.send_http_header()req.write ('mptest.py\n')req.write(os.environ['foo'])req.write(str(sys.path))return apache.OKand the output ismptest.pyMod_python error: "PythonHandler mptest" Traceback (most recent call last): File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line299, in HandlerDispatchresult = object(req) File "/home/clearplanet.co.za/public_html/python/mptest.py", line 33, in handlerreq.write(os.environ['foo']) File "/usr/lib/python2.3/UserDict.py", line 19, in __getitem__def __getitem__(self, key): return self.data[key]KeyError: 'foo' So, no matter what I "SetEnv", it doesn't run through mod_python to myscripts. Apart from the SetEnv issue, I've imported most of the djangomodules into the above code as recommended by Adrian in the docs, and they all imported successfully, or at least until something triggersthe django handler to take over and it complains about theDJANGO_SETTINGS_MODULE not being set.The catch here is, I did this after I had problems with my actual project not working. My original project shows the django 404 wheneverI request a page that isn't configured in urls.py, but whenever Iaccess a view that does exist I get the all too popular "Segfault (11)" and mod_python reloads the django handler.I've tried everything I can think of, and every suggestion that hasbeen made on the list to date, but to no avail. Can anyone suggestsome additional steps that I can take to produce valuable information? How will I get the SetEnv directives working correctly?I'm off to bed now, I'll check my mail as soon as I hit the desk again...Thanks in advance--Kenneth Kalmer [EMAIL PROTECTED][EMAIL PROTECTED] statshttp://fah-web.stanford.edu/cgi-bin/main.py?qtype=userpage=kenneth%2Ekalmer Blog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: only show something(form) if javascript-enabled
On 2/21/06, gabor <[EMAIL PROTECTED]> wrote: what is the standard way to only show a form if the user has_javascript_-enabled?Use id="integrity_form" style="display:none" in the form, and then document.getElementById("integrity_form").style.display = "block", ofcourse this won't happen unless _javascript_ is enabled. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: two object returned for exact pk lookup
On 2/15/06, Maniac <[EMAIL PROTECTED]> wrote: If it's MySQL then it looks very much like threading issues (withPostgres it fails somewhat differently). There is a patch fixing it inhttp://code.djangoproject.com/ticket/463 Hi Maniac,Thanks for the pointer, I applied the patch and my application has been running without those scary mails since last 6-8 hours. Adrian, what is the stutus on that bug, can you please apply it to trunk? -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: Template Does Not exist Error
On 2/20/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Hi all,I'm using { % extends "parent" % } and I'm getting a "...template doesnot exist error" for the parent template.I have the two templates in the same directory and they are in a subfolder of my template directory.Use {% extends "subfolder/parent" %} if they are in a subfolder of templates directory. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: urllib2.open failing in Django?
On 2/20/06, Ned Batchelder <[EMAIL PROTECTED]> wrote: I have some code in a Django view that makes a request on anotherserver. It uses urllib2 to make an SSL connection to the server andrequest a page. Here's the code:I dont know about https, but I am doing a lot of fetching page over http, and parsing html in my django application, and its working like a charm. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: Manipulator and views problem, where to save object ?
On 2/20/06, coulix <[EMAIL PROTECTED]> wrote: Seems like i was just unlucky in the number 5 - 6 - 8if i use a field which appears in my model with,null = Trueit seems like the validator is not eve called, is it a feature ?That may be the case, I have not tried it with null=True as yet so cant say anything. otherwise when its called i get an error :isFoo() takes exactly 3 arguments (2 given) Exception Location:/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/formfields.pyin get_validation_errors, line 70Remove 'self' from function definition. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: Manipulator and views problem, where to save object ?
On 2/20/06, coulix <[EMAIL PROTECTED]> wrote: Hum i cant spot the type expect the 500 as comments ?On 2/20/06, coulix < [EMAIL PROTECTED]> wrote: #Validatordef isValideImageWeight(self, field_data, all_data):print field_dataif len(field_data["content"] > 10 ) : # 500,000 bytes (100kB)raise validators.ValidationError, "Le fichier ne dois pas depasser100kb"In your isValideImageWeight, you have used if len(field_data["content"] > 10 ):You will get a 500 internal error as len on boolean gives TypeError. What you want is: if len(field_data["content"]) > 10: Best wishes,-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay +91-9867-359-701 --~--~-~--~~~---~--~~ 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: Manipulator and views problem, where to save object ?
On 2/20/06, coulix <[EMAIL PROTECTED]> wrote: #Validatordef isValideImageWeight(self, field_data, all_data):print field_dataif len(field_data["content"] > 10 ) : # 500,000 bytes (100kB)raise validators.ValidationError, "Le fichier ne dois pas depasser100kb"Typo? -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: Manipulator and views problem, where to save object ?
On 2/20/06, coulix <[EMAIL PROTECTED]> wrote: Hello,i have a simple goal, displaying a form, populate it, save it to thedatabase.At the execption of a new validator to check the weight of the imagesent.First point i need to write my own manipulator which is pretty much a copy of the model, i only want to add a validator to one field (image)the other default one suite me well how do i achieve this wihtoutrepeating myself. You can replace your manipulator with the following: manipulator = recettes.AddManipulator()manipulator.fields[8].validator_list.append(isValideImageWeight)# 8 here refers to position of image field in your model, correct it if # it is not so. u can use print recettes.AddManipulator().fields to see the # fields in order.After writting this manipulator, i realise i need a save() function what is it intended to do ?Normally every manipulator should implement a save() and it should do whatever you want your form precessing logic is.-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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 problem at dreamhost
On 2/20/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I have had this exact same experience. I do not know what causes it tohappen or what makes it fix itself. I thought the problem was relatedto the new svn feature. Have you started using that? I do not use the new svn feature, but I have used command line svn since before they started the new feature. I have a few domains hosted at dreamhost (on different machines). Onemachine has had problems (squirm) while another machine has been fine.How do you get a new machine? Will I have to create a new account? -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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 problem at dreamhost
On 2/20/06, Eugene Lazutkin <[EMAIL PROTECTED]> wrote: Nope, never seen it. I suggest to verify .htaccess file and test fcgiwithout Django trying to reproduce the problem. If you didn't modifyDjango (like svn-up it), you may have some problems with disk space(unlikely) or database (unlikely too), but it makes sense to check it too. The problem is it happens intermittently, only twice with me so far, that too for not more than an hour, in that one hour, whatever I do does not fixes it, while it will fix itself after a while. Its got fixed just now, and I got a core file. Now my problem is I am serving some _javascript_ that is embedded in the head of tens of blogs and firefox(atleast) will not render anything till before it has either got a 404 for _javascript_s in head or have timed out. Two minute delay will kill my service if it stops my clients blog from loading. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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 problem at dreamhost
Hi,I am facing a weird issue with dream host, day before yesterday my django application stopped serving requests, I have not done anything, and its been working since about a month, and now it waits for minutes before give me 500 interneral server error. Also I get lots of core files in my domain folder. Has anyone seen something like this happening with their django application hosted on dreamhost? -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: forward references
from django.models.myapp import articlesOn 2/18/06, Rock <[EMAIL PROTECTED]> wrote: -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: Web Services
Hi,Check out http://nerdierthanthou.nfshost.com/2005/09/soaped-django.html and http://nerdierthanthou.nfshost.com/2005/09/xmlrpc-support-for-django.html before you go on implementing something.On 2/18/06, mateja < [EMAIL PROTECTED]> wrote:Chaos,I too am interested in adding XML-RPC functionality to django. I have not done anything more about this past just dreaming about it.I'm very familiar with how to do this in Java, but I've been lookingfor an excuse to start a django project. Here are some thoughts... A google search for 'python xml-rpc' turned up these links, which Iwill peruse further:http://www.pythonware.com/products/xmlrpc/ http://www-128.ibm.com/developerworks/webservices/library/ws-pyth10.htmlhttp://sourceforge.net/projects/py-xmlrpc/Also, I'd check if the SOAPy project has anything to offer. I don't know if this project is still alive, because it's pretty old.By 'direct access' do you mean having a user access management servicefor django? Like, being able to create groups of users with different permissions on different resources?As far as remote exceptions are concerned, XML-RPC supports these.Look here for more info. Yes, I know it's in Java, but you get thepicture. http://www-128.ibm.com/developerworks/xml/library/ws-tip-jaxrpc.htmlI can't imagine this post was very helpful, I just wanted to let youknow that there's someone out there who feels your pain. ;)Mateja Blog: http://www.rootshell.be/~upadhyay+91-9867-359-701 --~--~-~--~~~---~--~~ 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: two object returned for exact pk lookup
On 2/15/06, Maniac <[EMAIL PROTECTED]> wrote: It may be threading... What http server and what database you use? Ifhttp is Apache does it use threaded worker?Threading? Thats surprizing, I am using apache with fastcgi, as documented on http://wiki.dreamhost.com/index.php/Django. Database is MySQL [MySQL 5.0.18-standard-log]. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: two object returned for exact pk lookup
Hi,I just got another mail for some other pk, and I got three objects, I am starting to get worried, I am planning to take my service out of beta coming weekend, and this has shaken my confidence. get_object_or_404 should lead to 404 exception for any exception I guess. But much more importantly than that, I would like the fix the real problem. Any clues? I am running django as fastcgi over dreamhost, in case if it helps.On 2/15/06, Amit Upadhyay <[EMAIL PROTECTED] > wrote:Hi,Today I got this in mail: File "/home/amitu/django_projects /amitucom/apps/blogger/js_views.py", line 57, in jsma blog = get_object_or_404(blogs, pk=blog_id) File "/home/amitu/django_src/django/core/extensions.py", line 39, in get_object_or_404 return mod.get_object(**kwargs) File "/home/amitu/django_src/django/utils/functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/home/amitu/django_src/django/core/meta/__init__.py", line 1358, in function_get_object assert len(obj_list) == 1, "get_object() returned more than one %s -- it returned %s! Lookup parameters were %s" % (opts.object_name, len(obj_list), kwargs)AssertionError: get_object() returned more than one Blog -- it returned 2! Lookup parameters were {'pk': '3'}How can I get more than one Blog when I am specifying pk. This happens just once, while that page is accessed more than hundreads of times everyday, I am getting a clean output when I do it on python prompt: >>> from django.models.blogger import *>>> blogs.get_object(pk=3)Anything Else @ http://nerdierthanthou.nfshost.com/ Can anyone tell me the possible reason for the same? I am completely baffled.Thanks,-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay +91-9867-359-701 -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
two object returned for exact pk lookup
Hi,Today I got this in mail: File "/home/amitu/django_projects/amitucom/apps/blogger/js_views.py", line 57, in jsma blog = get_object_or_404(blogs, pk=blog_id) File "/home/amitu/django_src/django/core/extensions.py", line 39, in get_object_or_404 return mod.get_object(**kwargs) File "/home/amitu/django_src/django/utils/functional.py", line 3, in _curried return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items())) File "/home/amitu/django_src/django/core/meta/__init__.py", line 1358, in function_get_object assert len(obj_list) == 1, "get_object() returned more than one %s -- it returned %s! Lookup parameters were %s" % (opts.object_name, len(obj_list), kwargs)AssertionError: get_object() returned more than one Blog -- it returned 2! Lookup parameters were {'pk': '3'}How can I get more than one Blog when I am specifying pk. This happens just once, while that page is accessed more than hundreads of times everyday, I am getting a clean output when I do it on python prompt: >>> from django.models.blogger import *>>> blogs.get_object(pk=3)Anything Else @ http://nerdierthanthou.nfshost.com/ Can anyone tell me the possible reason for the same? I am completely baffled.Thanks,-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay +91-9867-359-701
Re: How to find the label for a value
On 2/13/06, Leeuw van der, Tim <[EMAIL PROTECTED]> wrote: The choices for the form are specified in your model. Django uses thesechoices for it's form-display.It would make sense to me if Django would also provide an easy way foryou to display such 'nice' values in your interface. Django already does it. If you have specified choices for any member my_member of model MyModel, django will add a get_my_member_display() function to MyModel objects. -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: How to find the label for a value
On 2/11/06, Luke Plant <[EMAIL PROTECTED]> wrote: On Saturday 11 February 2006 13:14, Luke Plant wrote:> context['choices'] = CHOICES.items()Just remembered - this doesn't guarantee ordering, you'll need to handlesorting of the choices list somehow. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/414283 -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: Is context variable 'user' automatic in templates?
On 2/12/06, Luke Plant <[EMAIL PROTECTED]> wrote: On Saturday 11 February 2006 22:00, Roberto Aguilar wrote:> I've noticed that in certain instances, in a flatpage, for example,> the user context variable is available in my templates. However,> most of the time I have to explicity provide it like when using > render_to_response. Is this a bug, feature, or am I just not doing> something right?The 'user' context variable is provided by 'DjangoContext' (morespecifically, by one of the 'processors' that DjangoContext uses: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-djangocontext )DjangoContext is used by all the generic views (including flatpage). If you want it in your own views, just use DjangoContext instead ofContext, passing the 'request' object into the DjangoContextconstructor.Or if you are using render_to_response/string shortcuts, use something like: render_to_response('template', context_instance=DjangoContext(request))-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: Dynamic choices
On 2/8/06, Chetan Vaity <[EMAIL PROTECTED]> wrote: class MyModel(meta.Model): id = meta.AutoField(primary_key = True) name = meta.CharField(maxlength=20, unique=True) location = meta.CharField(maxlength=100, choices=getLocationChoices()) What I notice is that whenever an entry is added to LDAP, it is not reflected in the SelectField drop-down on the create form for the model. But if I simply restart the Apache httpd server, the drop-down is correctly populated. Can someone tell me why this is so?This is so because getLocationChoices() is calculated when model is being created. To solve your problem you can do the following:manipulator = mymodels.AddManipulator() # or ChangeManipulatormanipulator.fields[2].choices = getLocationChoices() # using 2 here is flaky, but# we dont have any other workaround other than looping our the fields tuple and# finding the one we are looking for. in the view where you are using it. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: Removing the Magic Branch release schedule
On 2/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I have just realized how awesome having multiple inheritance will be, so I amwondering if there is a guess at a release date for Django 0.92?I guess I just try out the branch itself until the release is made. I have another question, my application works with trunk, and will be broken with 0.92, is there any plan to branch the trunk before merging the magic removal, and supporting it for sometime while existing applications can test/migrate? -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: how to reference another function inside mode class
On 2/3/06, sam <[EMAIL PROTECTED]> wrote: I was tring to write a custom function inside a mode class, say X:class X(meta.Model):i = meta.IntegerField()...def foo(self):return bar(self.i)If I define bar() in the same model file, django complained the "NameError -- global name bar does not exist". How do I get aroundthis?You have to use self.bar to refer to bar defined in the same class. What if I want to define bar() in another file under the sameapp/models directory -- how do I refer it in my model file?You will have to import that module in the function where you intend to call it. You can also use module constants, refer http://www.djangoproject.com/documentation/model_api/-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: possible to validate a subset of a model's fields?
On 1/31/06, Oliver Rutherfurd <[EMAIL PROTECTED]> wrote: Hi Amit,> I would recommend creating your own FormManipulators, one for each page.> Validate page level manipulator and save the content in request.session, and> when you are done on the last page, pick out all the saved temproary states > and insert it in the database.Thanks for the suggestion, but saving to the db after every page is arequirement of the app. If someone fills out a page and comes back aweek, or even a year later, everything they previously entered should be in the db.In that case the best approach would be to split to model in different ones, and use One2One to link them together [have a main model, like user or user_resume, and put create models like user_resume_personal, user_resume_workex, user_resume_kungfuskill and so on, and put a One2One in all user_resume_* to a user_resume]. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: possible to validate a subset of a model's fields?
On 1/31/06, Oliver Rutherfurd <[EMAIL PROTECTED]> wrote: The use case for this is a long registration process, where differentdata points from individual models are split across multiple pages.The application needs to save data collected after every step, so theuser doesn't have to start from scratch if they leave the site and return later. As a silly example, let's say that name is collected onpage 1, phone # on page 2. Both are required and both live in a'person' table -- and I want to save the model after page 1. I would recommend creating your own FormManipulators, one for each page. Validate page level manipulator and save the content in request.session, and when you are done on the last page, pick out all the saved temproary states and insert it in the database. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: FileField :: mx file size
On 1/30/06, Maniac <[EMAIL PROTECTED]> wrote: Amit Upadhyay wrote:> It would be good to have a general django wide setting specifying the> maximum length allowed for POST data, if underlying server allowed it.Django just doesn't control these things. Read my answer in this very thread, it's http-server and browser that don't let it happen.Umm.. I have not done any research on this, but if that was the case projects like http://sean.treadway.info/demo/upload/ and http://encodable.com/filechucker/ wouldn't have been possible. May be some webservers do not support it, and maybe there would be some issues related to terminating connection if file size is larger, but having this may be good. No time for investigating it right now, but existence of those projects imply its doable, even if its a hack, atleast on some servers.-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: FileField :: mx file size
On 1/30/06, tonemcd <[EMAIL PROTECTED]> wrote: I didn't think you could do that - find out the size of an file toupload *before* it's uploaded, and act upon it. I've wanted to do thatin CGI, Perl, PHP and Zope, and never figured out how to do it (itwould have saved a few embarrasing incidents in the past; the 170 Mbyte powerpoint, the CD!! that was uploaded, etc. etc.)http://api.rubyonrails.com/classes/ActionController/UploadProgress.html -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: I need some directions to auth system and stuff
On 1/27/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I`ve got couple of questions about auth system. Just a directions..1. How do I extend base User class? I`ve read about subclassing, but it was two month ago and it was not very clear.. Is there any new method?I think you are talking about http://code.djangoproject.com/wiki/ExtendedUserModel . I have not tried it, and do not know the actual benefit, but if you follow the following steps you may not have to worry about it. Some one please correct me if I am wrong. 2. I want to have login form on each page. How should I process form,if I want to stay inside built-in auth system? Dunno what should myView be.One option is to use the django login page for form processing, but if you do that you will miss the django's super cool error reporting in the same form feature. Also may be you want to have a remember me kind of check box in the login page. This is what I recommend: from django.parts.auth.formfields import AuthenticationFormclass LoginManipulator(AuthenticationForm): def __init__(self, request): AuthenticationForm.__init__(self, request) self.fields.append( formfields.CheckboxField(field_name="remember") )def index(request): manipulator = LoginManipulator(request) redirect_to = request.REQUEST.get ('next','') if request.POST: # If data was POSTed, we're trying to create a new Place. new_data = request.POST.copy() # Check for errors. errors = manipulator.get_validation_errors (new_data) if not errors: # No errors. This means we can save the data! request.session[users.SESSION_KEY] = manipulator.get_user_id() request.session.delete_test_cookie () if request.REQUEST.has_key('next'): return HttpResponseRedirect(request.REQUEST['next']) else: return HttpResponseRedirect("../home/") else: request.session.set_test_cookie () errors = new_data = {} # Create the FormWrapper, template, context, response. form = formfields.FormWrapper(manipulator, new_data, errors) return render_to_response('myapp/index', {'form': form, 'signin_page': True, 'redirect_to': redirect_to}, context_instance=DjangoContext(request))Note: You can see I have just ignored the remember me checkbox for now, here you can set permanent cookie etc, which I havent done so far. Relevant snippet from my template:{% if user.is_anonymous %} {% if redirect_to %} action="" redirect_to }}"> {% else %} action=""> {% endif %} Sign in{% if form.has_errors %}Email or password incorrect{% endif %} {{ form.username }} {{ form.password }} {{ form.remember }} And the logout view is:def logout(request): del request.session[users.SESSION_KEY] return HttpResponseRedirect("../") Finally change the file django_src/django/views/auth/login.py and edit the following line:LOGIN_URL = '/accounts/login/'to make it read:LOGIN_URL = '/my_login_page/' where my_login_page is the page where you want you login page to be, if your login form is in all the pages, you may still have a page devoted to login, explaining why one should login to your system. HTH, PS: Should be wikified I guess.-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: How do I get POST variables in my template
On 1/27/06, tonemcd <[EMAIL PROTECTED]> wrote: Cheers Eric, but 'debug' doesn't seem to work in an intuitive way - atleast to me ;)e.g.{% debug %}Hi tonemcd, What exactly are you trying to do? If you just want to inspect the variables passed to view code, why dont you use a "assert False" somewhere in the view and django will produce an error page containing all post and get variables along with other info. I would say this is django way of inspecting headers and post/get data. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: help with keeping a counter in a template
On 1/21/06, coowwa <[EMAIL PROTECTED]> wrote: datelists = dailytodos.get_list(order_by=["-date"])My question: if I want to limit the number of todo items that displayson this page to say 20You are looking for http://www.djangoproject.com/documentation/db_api/#limiting-selected-rows-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: Do I use @login_required to extend authentication?
On 1/17/06, tonemcd <[EMAIL PROTECTED]> wrote: Seriously, this is a major thing for any kind of migration we have inmind from Zope -> Django, so any thoughts on how to do this would begreatly appreciated.Hi,In my personal experience, django authentication framework is very thin, and you can bypass it completely without much penalty and use one of your own. What you get by django anuthentication is @login_required, request.user and user auto variable in DjangoContext Context for templates. The internals or request.user magic is pretty trivial, request.session[users.SESSION_KEY] is queried to get the user_id, and request.user is initialized with corresponding user. If you are ready to write a @ldap_login_required decorator which make sure request.session[users.SESSION_KEY] is a valid ldap user id, or redirects to you custom login pagewrite a check_password_and_get_id_else_exception(username, password) to be used by login handling view, which sets the returned id to request.session[users.SESSION_KEY] use get_ldap_user(request) instead of request.user, andmanually set the the user variable in the django context, you are done, that is almost all you need. Please don't let lack of features in defauld django authentication framework deter you from using the rest of it. We need better documentation to instill confidence in developers for the same, but what django provides is very simiplistic and you can write your custom authentication etc very easily. Also read: http://nerdierthanthou.nfshost.com/2006/01/django-tips.html-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
Re: Bulk delete?
On 1/14/06, Amit Upadhyay <[EMAIL PROTECTED]> wrote: As of having check boxes to select multiple item in admin views, I would much rather prefer "edit selected", where you can bulk edit items, delete being just one of the operations. Its like iTunes edit multiple song screenshot attached, for each field put a checkbox before that filed, and just try to imitate what iTunes does there. [May be put a little bit of ajax and have a togglable div displaying the current vaules of objects selected]. Please tell me if I am not being clear enough. And for paginated view where there are too many items to show on the same page, it would be good to have a admin tray to hold currently selected items for later "multi-edit", something like picasa tray, spanning multiple pages, both list and detail ones, which can hold items from different models, and clicking edit all showing a series of multi-edit pages for each model held in the admin tray. I wish I had time to implement all this :-(-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701 picasa-tray.png Description: PNG image
Re: Managing static media urls
On 1/14/06, Greg <[EMAIL PROTECTED]> wrote: your folder structure. This issue seems especially pertinent for Djangobecause although the mechanism for assembling several apps together onone server is a sweet way to make it easy to combine and reconfigure applications, having to specify a single global MEDIA_ROOT/MEDIA_URLkind of limits it. You can't just put static files in the samedirectory as the template files, like JSP developers (for instance)often do. It'd be convenient if each app had "media" subdirectory or something to go with its models, views, and templates. And actually,the admin app is an excellent example of this! But admin has to haveits own special setting (ADMIN_MEDIA_PREFIX) and handler to make itwork. Is there any suggested strategy for how other apps can have their own media directories too? What's the common practice? Static files are best served by basic http servers and not django. Django tries to support serving static files, but that is only for convenience in development. Just now I finished deploying a django project under mod_pythong/apache, and my approach was to setup a /static url pointing to a directory containing static files and I setup django's static file serving view for that, I did that till the development lasted, and then I moved it to apache, and put a: SetHandler Nonelike directive in apache conf to bypass django for them. I have setup apache to server / using django. /static contained directores for different application, modified ADMIN_MEDIA_PREFIX to point to this location, and developed my other application assuming my static files will be available at /static/myapp/. The only thing I am missing in this approach is: my 404 views are not called when some file is unavailable, and ugly looking apache default comes up. I can change apache's 404 page to someother, but it seems it has to be static html file, not explored it much, but then its not really too bad. -- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701