objects.get overhead: at least 2 times slower than a select
Why is my select is 2 times faster than objects.get(name=domain)? Why is there so much overhead? d = Domain.objects.get(name=domain) [...] Checked 9 domains at 1434 domain/s Now if instead I just do: cursor.execute("""SELECT id,name from "DNS_domain" WHERE name='%s' """ % domain) row = cursor.fetchone() Checked 9 domains at 3659 domain/s I am using django latest trunk and postgresql 8.2 The domain relation contains 180 million records. class Domain(models.Model): name = models.CharField("domain name", maxlength=255, unique=True) source = models.ForeignKey(History, verbose_name="Source") CREATE TABLE "DNS_domain" ( "id" serial NOT NULL PRIMARY KEY, "name" varchar(255) NOT NULL UNIQUE, "source_id" integer NOT NULL REFERENCES "Log_history" ("id") DEFERRABLE INITIALLY DEFERRED ); Thanks, K. --~--~-~--~~~---~--~~ 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: is 40 MB RAM enough?
On Aug 27, 4:47 pm, Paul Rauch <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Kenneth Gonsalves schrieb:> Hi, > > > I have a site on WebFaction with 40 MB RAM. It is a very small site > > in the sense that it is used for administering an organisation, so > > would have just 2-3 users at a time, mainly doing admin stuff. The > > only load is when pdf reports are being generated. Leaving apache > > untweaked, the RAM usage shoots up - well over the 40 MB limit. I set > > MaxRequestsPerChild to 3. Even then, the limit gets crossed pretty > > fast. The question is: do I go on trying to tweak Apache? Or do I go > > in for more RAM? > > you might want to try another webserver, > maybe lighttpd and then run django as fastcgi. > at least its said to be more performant. > > http://www.djangoproject.com/documentation/fastcgi/ In terms of memory consumed, in practice using fastcgi wouldn't make that much difference. This is because by far the bulk of memory used is by the Django application itself. If the increase in memory is due principally to the PDF generation, and the incidence of PDF generation is low, they would be better off factoring out the PDF generation into a separate script if they can, which is then executed from the Django application using os.system or the popen modules. This will match better with how WebFaction calculates memory usage, as they only have a problem with long running processes over the 40MB limit if I remember correctly. By factoring it out into a script, the memory consuming process is then ephemeral and memory only gets consumed for a short time. As a result, it wouldn't matter if for that short time it goes over 40MB in size. Obviously if the one script is consuming absolute huge amounts of memory, then they may have an issue. The only other solution which may work within the bounds of WebFaction's memory limits is to use mod_wsgi with Apache instead of mod_python. If you have a 4 process limit on long running processes, ensure you are using 'worker' MPM in Apache and limit the number of Apache child processes to 2. Then use mod_wsgi daemon mode to have one daemon process with many threads which runs your Django instance. Also create a second daemon process with mod_wsgi and delegate only the subset of URLs from your Django application which generate the PDFs to this second daemon process. In other words, one daemon process is used to run all parts of the application except for the URLs which do the PDF generation. These URLs are instead delegated to run in a distinct daemon process. Because the PDF daemon process isn't handling all URLs for the application, it will not accumulate any cached modules and data related to the URLs not being handled, thus the base memory should be less for that process. This will give you greater headroom for the memory consuming PDF operations. Because the PDF URLs are in a separate daemon process, one can also set a small value for maximum number of requests for that process to keep restoring memory usage back to a low level in case there is memory usage creep. By using daemon mode of mod_wsgi you have also moved the Python application out of the main Apache child processes and thus those process will be smaller and as a result may handle static file requests better. Because mod_wsgi gives you these more flexible means of delegating what runs in what processes, it will be interesting if this might affect in the future, when mod_wsgi starts to be adopted more, how WebFaction determines how much memory you use. For example, if you can restrict Apache to using 2 child process to handle static files and for proxying to the daemon processes, with these process then being small, eg < 10MB, one could possibly argue that you should be allowed a greater memory limit for the daemon process running the Python application. Ie., instead of allow 4 * 40MB process, why not allow 2 * 20MB + 2 * 60MB processes. That is calculate it across all processes as a combined total rather than put a maximum on the size of any one process. BTW, choosing one system over another based on perceived performance is not a good idea. The differences in performance between mod_python, mod_wsgi or fastcgi solutions get totally swallowed up as soon as you load on a big Django application, especially one that uses a database, as the bottleneck is then elsewhere. You are therefore better off choosing a solution based on ease of configuration and management and for the options it has for controlling memory usage and security. Graham --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--
Web developement with Python
I need a clear info on why Python is good for enterprise web developement . Can Python be used for a website having several 100 page hits /sec ? I am not bothered of coding complexity . How about linux OS, ,Python and DB2 express edition for webdevelopement? Ambrose PeterMary.com -- coming soon --~--~-~--~~~---~--~~ 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: How to fill in a comboField in a form
Hello, I don't know how to do it, I have the same problem. I manage to do it defining the combo with the select html tag in the template directly but what I really want to use it in the way you explain (with form.ComboField). Any ideas? On 23 ago, 12:47, altahay <[EMAIL PROTECTED]> wrote: > Hello, > > I defined my form with a comboField like: > > class addressForm (forms.Form): >... >language = forms.ComboField() >... > > and I fill in like that: > >languages = Language.objects.all() > >data = { > ... > 'language': languages, > ... } > > but what I see in the navigator is a text box with the description of > the languages instead a combo. > > Anaybody knows what I'm doing wrong? --~--~-~--~~~---~--~~ 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: How to fill in a comboField in a form
ComboField takes a list of fields that should be used to validate a value, in that order. >>> f = ComboField(fields=[CharField(max_length=20), EmailField()]) If you just need a dropdown select then use choiceField >>>t = [('test','select')] >>>f = forms.ChoiceField(choices=t) On Aug 23, 4:47 pm, altahay <[EMAIL PROTECTED]> wrote: > Hello, > > I defined my form with a comboField like: > > class addressForm (forms.Form): >... >language = forms.ComboField() >... > > and I fill in like that: > >languages = Language.objects.all() > >data = { > ... > 'language': languages, > ... } > > but what I see in the navigator is a text box with the description of > the languages instead a combo. > > Anaybody knows what I'm doing wrong? --~--~-~--~~~---~--~~ 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: is 40 MB RAM enough?
Yes it is, I am running a huge site on webfaction 40 MB, performance wise its excellent. On Aug 27, 7:57 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > Hi, > > I have a site on WebFaction with 40 MB RAM. It is a very small site > in the sense that it is used for administering an organisation, so > would have just 2-3 users at a time, mainly doing admin stuff. The > only load is when pdf reports are being generated. Leaving apache > untweaked, the RAM usage shoots up - well over the 40 MB limit. I set > MaxRequestsPerChild to 3. Even then, the limit gets crossed pretty > fast. The question is: do I go on trying to tweak Apache? Or do I go > in for more RAM? > -- > > regards > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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: Newbie: How to create different person models that share a profile model?
In case you didn't read it before: Here is very enlightening summary of things you can do with user model: http://www.amitu.com/blog/2007/july/django-extending-user-model/ regards -- Jakub Wiśniowski --~--~-~--~~~---~--~~ 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: Dynamic OR queries
Steven Armstrong skrev: > Chris Hoeppner wrote on 08/25/07 18:40: > >> Hi there! >> >> I was just wondering how to dynamically "or" together an indetermined >> quantity of Q objects. They're constructed from a string like q=a+b+c, >> which would get stiched together as "(Q(field=a) | Q(field=b) | >> Q(field=c))". Any clue on how to do it with unknown parameters? It will >> need to work with a+b, just like a+b+c+d+e+f+g+h... You get it :) >> > > from django.db.models import Q > > fields = 'a+b+c+d+e'.split('+') > > query = Q(field=fields.pop(0)) > for field_value in fields: > query = query | Q(field=field_value) > mylist = MyModel.objects.filter(query) > Or, if you prefer a more functional style: from django.db.models import Q import operator fields = 'a+b+c+d+e'.split('+') query = reduce(operator.or_,(Q(field=field_value) for field_value in fields), Q()) mylist = MyModel.objects.filter(query) (only tested for syntax) Nis --~--~-~--~~~---~--~~ 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: is 40 MB RAM enough?
On Aug 27, 12:57 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > Hi, > > I have a site on WebFaction with 40 MB RAM. It is a very small site > in the sense that it is used for administering an organisation, so > would have just 2-3 users at a time, mainly doing admin stuff. The > only load is when pdf reports are being generated. Leaving apache > untweaked, the RAM usage shoots up - well over the 40 MB limit. I set > MaxRequestsPerChild to 3. Even then, the limit gets crossed pretty > fast. The question is: do I go on trying to tweak Apache? Or do I go > in for more RAM? BTW, have you also made sure you have read: http://blog.webfaction.com/tips-to-keep-your-django-mod-python-memory-usage-down Maybe your size problems are due to not turning debug off. Graham --~--~-~--~~~---~--~~ 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: is 40 MB RAM enough?
On 27-Aug-07, at 3:05 PM, Iapain wrote: > Yes it is, I am running a huge site on webfaction 40 MB, performance > wise its excellent. what is your RAM usage? How did you tweak apache to achieve that? -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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: is 40 MB RAM enough?
On 27-Aug-07, at 4:07 PM, Graham Dumpleton wrote: >> in for more RAM? > > BTW, have you also made sure you have read: > > http://blog.webfaction.com/tips-to-keep-your-django-mod-python- > memory-usage-down yes > > Maybe your size problems are due to not turning debug off. it's off -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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: Web developement with Python
This is a very broad question, with some very ill-defined adjectives :-) Generally, given enough resources then Django can scale up to websites of 'enterprise' (what does that actually mean?) level. As is stated in the FAQ [1], Django sites have happily held up to million hits/hour slashdottings. I believe the site in question was chicagocrime.org. As for the operating system and webserver, I'd say that the majority of sites which are written in Django run on a Linux (this is anecdotal evidence, however, I have no hard numbers to back this up with). A lot of people use Apache with mod_python, and a lot of people use Apache with flup and mod_fastcgi. Another option is lighttpd[2]. Once you can give us a clearer idea on what your application will do, and your performance expectations, I'm sure that there are people who can advise you on deployment. As for DB2, it is not a supported database backend, so you'd be on your own, but if you're not worried about 'coding complexity', then the addition of a DB2 backend would be something that I'm sure the developers would gladly accept into Django trunk :-) Go for it! --Jon [1] http://www.djangoproject.com/documentation/faq/#is-django-stable [2] http://www.lighttpd.net/ On 8/27/07, AMBROSE <[EMAIL PROTECTED]> wrote: > > I need a clear info on why Python is good for enterprise web > developement . > > Can Python be used for a website having several 100 page hits /sec ? > > I am not bothered of coding complexity . > > How about linux OS, ,Python and > DB2 express edition for webdevelopement? > > Ambrose > PeterMary.com -- coming soon > > > > > --~--~-~--~~~---~--~~ 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: modeling db inheritance
could you please be more specific? On 8/25/07, Michael Elsdoerfer <[EMAIL PROTECTED]> wrote: > > > I needed a very similar thing and I ultimately decided to use a "type" > char > field in the base model that would contain the model name of the subtype. > > Michael > > > -Original Message- > > From: django-users@googlegroups.com [mailto: > [EMAIL PROTECTED] > > On Behalf Of Ernesto Rodriguez Reina > > Sent: Friday, August 24, 2007 7:38 PM > > To: Django users > > Subject: modeling db inheritance > > > > > > Hello, > > I'm need to model a table inheritance in a new project i'm working on, > but > > i > > don't know the best way to do it. > > > > Here is an explample of what i need: > > > > class User(models.Model): > > firstname = models.CharField(maxlength=100) > > lastname = models.CharField(maxlength=100) > > > > # This should inherit User > > class Student(models.Model): > > school= models.ForeignKey(School) > > > > # This should inherit User > > class Teacher(models.Model): > > school= models.ForeignKey(School) > > students = models.ManyToMany(Students) > > > > # This should inherit User > > class Manager(models.Model): > > pass > > > > I think it could be adding a ForeingKey to User, but, how to know, > having > > a > > User if it is Student, Teacher or Manager? > > > > Any ideas? > > > > Best Reagards, > > > > -- > > Lic. Ernesto Rodríguez Reina > > Facultad de Matemática y Computación, UH. > > http://profesores.matcom.uh.cu/~erreina/ > > > > > > > > -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ 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: Django app for locations? (countries, provinces, cities, venues...)
Austin Govella skrev: > Is there an existing Django app for managing locations? > > Specificall, countries, states/provinces, cities, and specific > locations with addresses. > > > > (I was just adding such an app to my project, but thought I might be > duplicating someone better effort...) > Greenpeace did something like this for their "Cool The Planet" project, AKA "Custard Melt. Blog is here: http://weblog.greenpeace.org/melt/ Not sure what the status is. Nis --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
dynamic links
hey i want to make a link in my template dynamic. e.g. I want to click on a "rubric" that links to a view that displays all the content. I have the following URL patterns to reach the rubric: /rubric/view and to reach the content /bullet///view --> the link i need in the template that renders the rubrics Does anyone have an idea how i can get the day_id and rubric_id in a link, if they are not attributes of the model that is being displayed? (if i were hard coding with PHP i would just make them get or post parameters) thanks for your help stephane --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Meta options`
how can I add my custom options to the Meta model class? -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
memcache: getting all cached keys?
I´ve just used Fredriks cache view (http://effbot.org/zone/django- memcached-view.htm) and now I´d like to additionally display all cached sites/fragments. Question is: How do I get all the sites/fragments currently in cache? Thanks, patrick --~--~-~--~~~---~--~~ 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: objects.get overhead: at least 2 times slower than a select
On 8/27/07, Kugutsumen <[EMAIL PROTECTED]> wrote: > > Why is my select is 2 times faster than objects.get(name=domain)? > > Why is there so much overhead? Have a look at the code. :) > d = Domain.objects.get(name=domain) [...] > Checked 9 domains at 1434 domain/s > > Now if instead I just do: > > cursor.execute("""SELECT id,name from "DNS_domain" WHERE name='%s' > """ > % domain) > row = cursor.fetchone() > > Checked 9 domains at 3659 domain/s If you're going to select 90,000 domains, is there no way you can batch it? Or, is there no way you can cache them? > I am using django latest trunk and postgresql 8.2 > The domain relation contains 180 million records. Do they change often? Often relative to select? > class Domain(models.Model): > name = models.CharField("domain name", maxlength=255, > unique=True) ... Consider making name the primary key rather than letting AutoField do it. This removes a bit of overhead in Django, but also provides clustered lookup, assuming this is a lookup that you really need to be fast... --~--~-~--~~~---~--~~ 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: objects.get overhead: at least 2 times slower than a select
On 8/27/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > On 8/27/07, Kugutsumen <[EMAIL PROTECTED]> wrote: > > > > Why is my select is 2 times faster than objects.get(name=domain)? > > > > Why is there so much overhead? > > Have a look at the code. :) Ah, one more thing-- try commenting out the signalling. There's a known performance issue there. --~--~-~--~~~---~--~~ 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: using django components outside of django
Lee Connell wrote: > Will there be an issue using the django ORM in twisted, being an > asynchronous framework? Is there going to be threading issues i need > to be aware of? Yes, there are issues. :-) The ORM, as the whole of Django, is synchronous code, and not aware of the async events execution model. Therefore, each call to the ORM will block the reactor. This *may* not be an issue if you use SQLite, as most calls will return "soon enough"; this is the approach used in Divmod's Axiom. However, if you use an out-of-process, networked DB server, network latency comes into play, and you'll be better off wrapping the ORM calls in deferToThread, thus using the Twisted threadpool. Sad, but such is life. :-) Another issue is integrating Django behind Twisted's web server. Again, Django is blocking code, therefore integration with web2, via WSGI, is again done using deferToThread and the threadpool. I started writing a Django-Twisted handler to avoid this, but that effort is currently suspended. -- Nicola Larosa - http://www.tekNico.net/ Itamar Shtull-Trauring: reactor.stop() is the way to go, yes. Call it when you want the program to start. Nicola Larosa: To be able to do that you would have to recall John and George from heaven, reform the Beatles, pay them a lot to compose "Stop Me Down", and use that as the sound theme. -- April 2007 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
UnicodeDecodeError with memcache
With using the cache_page decorator, I´m getting a Unicode Error on my page: UnicodeDecodeError at /spezialprogramme/ 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in range(128) Any ideas? Thanks, Patrick --~--~-~--~~~---~--~~ 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: UnicodeDecodeError with memcache
> UnicodeDecodeError at /spezialprogramme/ > 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in > range(128) try using smart_str, it it doesnt work then use less restrictive decode --~--~-~--~~~---~--~~ 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: is 40 MB RAM enough?
> what is your RAM usage? How did you tweak apache to achieve that? I didnt check RAM usage, but site always work like express instead i did clean coding and tried to optimize my code. --~--~-~--~~~---~--~~ 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: UnicodeDecodeError with memcache
so you say I should use __str__ instead of __unicode__, right? according to the django-docs, that´s not recommended though ... On 27 Aug., 16:40, Iapain <[EMAIL PROTECTED]> wrote: > > UnicodeDecodeError at /spezialprogramme/ > > 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in > > range(128) > > try using smart_str, it it doesnt work then use less restrictive decode --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Audit Trail updates (was Re: Marty Alchin's AuditTrail)
perrito666 wrote: > Ah thank you, ill keep an eye, so far the only think I did to it was a > small hack to handle the error raised by trying to copy a fk to the > audit table but it is a not very clean hack. > Perrito. Took me an extra couple of days, but I've got all my modifications to AuditTrail posted here: http://code.djangoproject.com/wiki/AuditTrail Important bits: 1) ForeignKey and OneToOneFields supported (won't say fully tested for all cases, but they work in the simple ones) 2) Deletes are now tracked with saves (you can turn this behavior off if you want) 3) Type of change is tracked (currently can only distinguish between (insert/update) as a pair and delete) 4) Extra tracking fields on the audit models (and global fields that can be attached to all auditable models from one place) that can be tied into threadlocals (for tracking current user) 5) Different managers for instances and the class, so there are multiple options on how to filter (by only history of the current instance, or by the history of all things changed) I'm sure there's other things, but take a look and try it out. I'd be happy to get some feedback on this, what does and doesn't work for people, and especially some edge case testing like serialization. gav --~--~-~--~~~---~--~~ 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: objects.get overhead: at least 2 times slower than a select
On 8/27/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > Ah, one more thing-- try commenting out the signalling. There's a > known performance issue there. Even without it, the ORM will be slower, and should be expected to be slower -- doing a straight select doesn't involve much overhead because it can return very simple data structures, while the ORM has to create one instance of the relevant model class for each row returned. There will never be a situation where that's as fast as the straight select. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: dynamic links
> i want to make a link in my template dynamic. e.g. I want to click on > a "rubric" that links to a view that displays all the content. I have > the following URL patterns to reach the rubric: /rubric/view and to > reach the content /bullet///view --> the link i > need in the template that renders the rubrics I'd strongly recommend you to form your url in models.py. Create a function to your bullet class named get_absolute_url() and call it in template Today --~--~-~--~~~---~--~~ 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: dynamic links
On 8/27/07, Rufman <[EMAIL PROTECTED]> wrote: > Does anyone have an idea how i can get the day_id and rubric_id in a > link, if they are not attributes of the model that is being displayed? > (if i were hard coding with PHP i would just make them get or post > parameters) http://www.djangoproject.com/documentation/templates/#url -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: objects.get overhead: at least 2 times slower than a select
On 8/27/07, James Bennett <[EMAIL PROTECTED]> wrote: > There will never be a situation where that's as fast as the > straight select. from __future__ import wayback_machine :) --~--~-~--~~~---~--~~ 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: objects.get overhead: at least 2 times slower than a select
On Aug 27, 2007, at 2:05 AM, Kugutsumen wrote: > cursor.execute("""SELECT id,name from "DNS_domain" WHERE name='%s' > """ > % domain) > row = cursor.fetchone() If you do just need those two fields, and no object methods, you can use the "values" queryset method. Something like: d = Domain.objects.filter(name=domain).values('id', 'name')[0] from: http://www.djangoproject.com/documentation/db-api/#values-fields That will still likely be slightly slower than a direct sql call, but should speed things up by eliminating the object creation. -johnn --~--~-~--~~~---~--~~ 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: generating PDF using Reportlab's SimpleDocTemplate
You are absolutely right. I have tested this approach and for my purposes it is working great. Thanks for the insight. On Aug 23, 9:50 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote: > You can probably skip the StringIO. HttpResponses support a file-like > interface, so you can write directly to them. Try passing the > HttpResponse directly to the SimpleDocTemplate constructor instead. > > --Ned.http://nedbatchelder.com/blog > > > > abrightwell wrote: > > Nevermind, the main problem I seemed to be having was "associating" > > the pdf with the HttpResponse. Instead of writing the PDF to a file, > > I found through some more research that all you need to is use a > > StringIO buffer and then write the value of the buffer to the > > HttpResponse. I found this information in some other posts and other > > random places out there. Based on those, here is a brief example of > > what is currently working for me. > > > example: > > > # all necessary imports > > > buffer = StringIO() > > doc = SimpleDocTemplate(buffer, pagesize) > > ... # compile all information for pdf. > > doc.build(information) > > response.write(buffer.getvalue()) > > buffer.close() > > return response > > > On Aug 23, 1:12 pm, abrightwell <[EMAIL PROTECTED]> wrote: > > >> So, I have been playing around with reportlab and django in order to > >> generate pdf's of information from my application. I have played with > >> the example of using reportlab found in the django documentation but > >> it seems a bit tedious for my purposes (painting everyline). Being > >> able to use SimpleDocTemplate would seem to be the better approach. > >> Has anyone used it in this way? > > -- > Ned Batchelder,http://nedbatchelder.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Anonymous Users
Reading the auth docs for Djano 0.96, it appears to me that there is no model backing the idea of an anonymous user. Before I read the docs I was expecting that I could let my model refer to users and some of them would be anonymous, some of them real. Now I'm sure that the Django developers have good reason to have designed things as they did, but how have others dealt with modeling the idea of a possibly anonymous user? -- Darrin --~--~-~--~~~---~--~~ 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: Help with Django installation on OSX 10.4.10
If I remember correctly, you'll see the file listing if you don't have handlers set properly for the location. What is in your httpd.conf or virtual host config file for the htdocs directory? I'm assuming you've looked at: http://www.djangoproject.com/documentation/modpython/ - syd On Aug 27, 1:25 am, Brandon Taylor <[EMAIL PROTECTED]> wrote: > Hi Joe, > > One more question... > > So Django is woring correctly which is great, but I can't seem to get > mod_python working for Apache 2. I have the latest version of Apache > 2.2.4 and mod_python 3.3.1. I've added the "LoadModule" call to my > httpd.conf and Apache isn't complaining. > > I moved my 'test_project' into my 'htdocs' folder and restarted > Apache, but instead of seing the django welcome screen, I see a > listing of my files. > > Is there anything else I need to be doing to Apache to get it to run > the Python files? > > TIA, > Brandon > > On Aug 26, 11:00 pm, "Joseph Heck" <[EMAIL PROTECTED]> wrote: > > > Use the path settings from my earlier post - that fits perfectly with > > MacPorts and should do you. > > > -joe > > > On 8/26/07, Brandon Taylor <[EMAIL PROTECTED]> wrote: > > > > Hi everyone, > > > > I scrapped my custom install of Python 2.4.4 and Django in favor of an > > > install from MacPorts. So, now I have Python 2.5.1 and Django > > > installed. > > > > But, now when I run python in bash, I get version 2.3.5. Mac Ports has > > > insalled everything to /opt/local/var/macports/software > > > > I have django-admin.py, python2.5, python2.5-config, smtpd2.5.py and > > > pydoc2.5 in /opt/local/bin > > > > Can someone help me get the correct path settings in bash_profile, > > > profile, bash_login or whatever files I need to edit? I would really > > > appreciate the help. I'm anxious to get started with Python and > > > Django. > > > > TIA, > > > Brandon > > > > On Aug 26, 1:34 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > > > > On 26-Aug-07, at 11:51 AM, Brandon Taylor wrote: > > > > > > -bash: django-admin.py: command not found > > > > > what happens if you run /usr/local/bin/django-admin.py, that is, with > > > > the full path name. If it runs, then it means your path does not > > > > contain /usr/local/bin. If it doesnt run, your alias is borked. > > > > > -- > > > > > regards > > > > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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: Newbie: How to create different person models that share a profile model?
On Aug 24, 7:28 pm, "Ariel Mauricio Nunez Gomez" <[EMAIL PROTECTED]> wrote: > Note: The user profile part was taken from this useful blog entry on James > Bennet > site:http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model Yeah, that's the advice I keep seeing when this question comes up. The trouble is, if you read all the comments below it, is that the admin interface makes it LOOK LIKE you can edit the UserProfile information inline with the "built-in" User fields, but in actual fact, the changes or additions you make get *discarded*. That's not just useless, it's misleading and dangerous. I'm not sure whether it's a bug in Django or just a mistake I made in my UserProfile model definition, but since I only need a couple people doing admin-level upkeep, I just shrugged and made sure they know they have to go create/edit the UserProfile object separately. --~--~-~--~~~---~--~~ 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: how to get class name from a relation name
Thanks Russell, it works with the get_accessor_name() method combinated with the model attribute. 2007/8/23, Russell Keith-Magee <[EMAIL PROTECTED]>: > > > On 8/22/07, Grégoire Cachet <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I would like to get the class name from a relation name (OneToOne) > ... > > I want to get the class of the object a.modelb (ie ModelB) without > > instanciating a ModelA. Is there a clever way to get it from the model > > definition ? or do I have to check every case like : > > I'm not entirely sure I understand exactly what it is you want to do; > but you might be able to use the contents of the _meta object. In > particular, > > ModelA._meta.get_all_related_objects() > > will return you a list of RelatedObjects; these RelatedObjects are > wrappers around the models that have relations to ModelA. Digging into > the RelatedObject instances will let you do things like: > > [r.model for r in ModelA._meta.get_all_related_objects()] > > which will be a list of the classes that have relations to ModelA. > > Yours, > Russ Magee %-) > > > > -- Grégoire --~--~-~--~~~---~--~~ 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: Anonymous Users
I am not sure what exactly you want to model in regard to an 'anonymous' user. By definition, these would be users of an application that nothing is required to be known about and can only access information that is provided by views that do not require authenticated users. Generally, if you want to track or store any information about a specific user, you probably would want to create a specific user object/db record for the user and require them to authenticate. If you could be a bit more specific as far as what you would like to know about anonymous users, and how long you would like that information to persist it may be helpful for the list users to respond. -rfd On Aug 27, 10:33 am, "Darrin Thompson" <[EMAIL PROTECTED]> wrote: > Reading the auth docs for Djano 0.96, it appears to me that there is > no model backing the idea of an anonymous user. > > Before I read the docs I was expecting that I could let my model refer > to users and some of them would be anonymous, some of them real. > > Now I'm sure that the Django developers have good reason to have > designed things as they did, but how have others dealt with modeling > the idea of a possibly anonymous user? > > -- > Darrin --~--~-~--~~~---~--~~ 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: Web developement with Python
To answer your specific question about can Django handle 100 page hits/sec, the answer is yes. Like any other technology, how you achieve that scale depends on a lot of things other than just the framework. There's a nice (but not detailed) interview about Pownce at http://immike.net/blog/2007/07/06/interview-with-leah-culver-the-making-of-pownce/ - which I suspect is one of the higher traffic sites that actively use Django. Never mind the little guys like the Washington Post... -joe On 8/27/07, AMBROSE <[EMAIL PROTECTED]> wrote: > I need a clear info on why Python is good for enterprise web > developement . > > Can Python be used for a website having several 100 page hits /sec ? > > I am not bothered of coding complexity . > > How about linux OS, ,Python and > DB2 express edition for webdevelopement? > > Ambrose > PeterMary.com -- coming soon > > > > > --~--~-~--~~~---~--~~ 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: Anonymous Users
On 8/27/07, r_f_d <[EMAIL PROTECTED]> wrote: > > Generally, if you want to track or store any > information about a specific user, you probably would want to create a > specific user object/db record for the user and require them to > authenticate. If you could be a bit more specific as far as what you > would like to know about anonymous users, and how long you would like > that information to persist it may be helpful for the list users to > respond. I'm building a real estate search. I have existing and future competition. It's to my advantage to track a few preferences and favorites for anonymous users before they register. I'm pretty sure it isn't that hard and I'm not the first to implement it. -- Darrin --~--~-~--~~~---~--~~ 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: Anonymous Users
On 8/27/07, Darrin Thompson <[EMAIL PROTECTED]> wrote: > I'm building a real estate search. I have existing and future > competition. It's to my advantage to track a few preferences and > favorites for anonymous users before they register. > > I'm pretty sure it isn't that hard and I'm not the first to implement it. I think you just want to use sessions: http://www.djangoproject.com/documentation/sessions/ Jay P. --~--~-~--~~~---~--~~ 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: Anonymous Users
On 8/27/07, Darrin Thompson <[EMAIL PROTECTED]> wrote: > I'm building a real estate search. I have existing and future > competition. It's to my advantage to track a few preferences and > favorites for anonymous users before they register. http://www.djangoproject.com/documentation/sessions/ -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: objects.get overhead: at least 2 times slower than a select
Thanks John, I am going to try that. That's what I was looking for. And to answer Jeremy, I don't understand why would I want to have name as a primary key. The surrogate autofield primary key does a much better job being referenced as a foreign key all over the place. Using adaptive-readahead by Wu Fengguang gave about 30% increase in performance. I'll probably have that particular relation (table) which is central to my project in ram in a patricia or judy tree. I wish postgresql would support patricia tries, there is a research project (not public) at purdue called SP-GiST which should enable patricia indexes. On Aug 27, 10:19 pm, John Melesky <[EMAIL PROTECTED]> wrote: > On Aug 27, 2007, at 2:05 AM, Kugutsumen wrote: > > > cursor.execute("""SELECT id,name from "DNS_domain" WHERE name='%s' > > """ > > % domain) > > row = cursor.fetchone() > > If you do just need those two fields, and no object methods, you can > use the "values" queryset method. Something like: > > d = Domain.objects.filter(name=domain).values('id', 'name')[0] > > from:http://www.djangoproject.com/documentation/db-api/#values-fields > > That will still likely be slightly slower than a direct sql call, but > should speed things up by eliminating the object creation. > > -johnn --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
request_started signal
Hi guys, I´m improving my forum app and I letting moderator add warnings to users. A moderator can´t add a warning to a user if this user got a warning on the last 2 minutes (to avoid 2 moderators give warning with the same subject). I don´t know how to trigger the admin interface and, when the warning is sent, verify if the user got a warning on last 2 minutes, if so, redirect to an error page. I think to use request_started signal, but I don´t know how to use signals with request objects. I used it only with models. Do someone know if I can trigger the request of the admin interface? Thanks in advance... Michel Thadeu Sabchuk --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
"Declarative" Forms with the Django newforms
Hi, I have posted about a simple way to reuse your model definition in a more flexible manner than the form_for_model way, and I want also to have a more nice html rendering than the as_p or as_table methods can do. if your are interested this is link , and there is also a demo project to download: http://smelaatifi.blogspot.com/2007/08/declarative-forms-django-newforms.html any comments or suggestions will be appreciate :) --~--~-~--~~~---~--~~ 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: Error when creating thumbnails based on a class that is edit_inline
Looking more into the problem i noticed that when I do a 'assert False, self.get_photo_filename()' I get nothing in return. When I do the same thing (without edit_inline) I get the the filename of the image. Does anybody know why when I use edit_inline my self.get_photo_filename statement from within my Photo save method doesn't work? Above is my code Thanks Greg wrote: > Hello, > I'm having a problem when I try to create thumbnails for a class that > is has edit_inline. Here are my two models: > > class Collection(models.Model): > name = models.CharField(maxlength=200) > collectionslug = models.SlugField(prepopulate_from=["name"]) > photo = models.ImageField(upload_to='site_media/') > description = models.TextField(maxlength=1000) > manufacturer = models.ForeignKey(Manufacturer) > type = models.ForeignKey(RugType) > material = models.ForeignKey(RugMaterial) > > class Style(models.Model): > name = models.CharField(maxlength=200, core=True) > color = models.CharField(maxlength=100) > color_cat = models.ForeignKey(ColorCategory) > image = models.ImageField(upload_to="site_media/") > simage = models.ImageField(upload_to="site_media/thumbnails/", > editable=False) > mimage = models.ImageField(upload_to="site_media/thumbnails/", > editable=False) > theslug = models.SlugField(prepopulate_from=('name',), blank=True, > editable=False) > manufacturer = models.ForeignKey(Manufacturer, blank=True, > editable=False) #Can delete > collection = models.ForeignKey(Collection, > edit_inline=models.TABULAR, num_in_admin=6) > topsellers = models.BooleanField() > newarrivals = models.BooleanField() > closeout = models.BooleanField() > manufacturer = models.ForeignKey(Manufacturer) > sandp = models.ManyToManyField(Choice, limit_choices_to = > {'choice__id': 2}) > > def save(self): > if not self.simage: > THUMBNAIL_SIZE = (50, 50) > THUMBNAIL_SIZE2 = (600, 450) > > self.save_simage_file(self.get_image_filename(), '') > self.save_mimage_file(self.get_image_filename(), '') > > photo = Image.open(self.get_image_filename()) > photo2 = Image.open(self.get_image_filename()) > >if photo.mode not in ('L', 'RGB'): > photo = photo.convert('RGB') > > if photo2.mode not in ('L', 'RGB'): > photo2 = photo2.convert('RGB') > photo.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS) > photo2.thumbnail(THUMBNAIL_SIZE2, Image.ANTIALIAS) > > photo.save(self.get_simage_filename()) > photo2.save(self.get_mimage_filename()) > > super(Style, self).save() > > / > > When I go into the Style class I can successfully create my two > thumbnail images when I save a style. However, when i display my > styles within my collection class (edit_inline) and I create a new > style and select save then I get the following error: > > IOError at /admin/rugs/collection/2/ > [Errno 2] No such file or directory: u'c:/django/site_media\ > \thumbnails > > // > > Can I not create thumbnails when my class is edit_inline? > > Thanks --~--~-~--~~~---~--~~ 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: Problem in current svn TRUNK
On Wed 11 Jul 2007, Michael Radziej wrote: > Hi, > > you're using the alpha version of SuSE ... well ... there might very well > be a problem very deep in one of the libraries. The alpha releases aren't > very reliable. I'd suggest that you try it with another OS. Hi Guys I would like to point out that this problem still exists in Django post SVN 5608 (I just tried again with 6022). Since I initially reported this bug, I have moved from a 32bit to a 64bit notebook and have moved from "openSUSE 10.3 (i586) Alpha5" to a new install of "openSUSE 10.3 (X86-64) Beta2". Given that openSUSE 10.3 is going to be released soon, and that this is a 100% repeatable problem which only occurs post the unicode merge in Django, I would really appreciate if one of the developers could take the time to have a look at it. Regards -- Peter Nixon http://peternixon.net/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
single sign on for integrated django,trac and phpBB site
Hi, I found this: http://automatthias.wordpress.com/2006/12/18/killing-phpbb-softly/ excellent post about phpBB and Django integration. I was wondering if anyone has integrated single sign on with trac?..it seems trac uses .htaccess and not a database table so maybe it is not possible? Thanks Ian -- http://ianlawrence.info --~--~-~--~~~---~--~~ 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: Newbie: How to create different person models that share a profile model?
Thanks a lot for pointing that out. My apologies. So, for other readers of the thread: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, edit_inline=models.TABULAR, num_in_admin=1,min_num_in_admin=1, max_num_in_admin=1,num_extra_on_change=0) : Makes the profile show up in admin but fields DO NOT GET SAVED. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Authenticating Django against FreeRADIUS
Maybe this code I whipped up tonight to teach Django to speak RADIUS will be usefull to someone... http://peternixon.net/news/2007/08/27/open-source/authenticating-django-against-freeradius/ Cheers -- Peter Nixon http://peternixon.net/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem in current svn TRUNK
On 7/11/07, Peter Nixon <[EMAIL PROTECTED]> wrote: ... > In any case, I listed the important packages in use on the system: > postgresql-server-8.2.4-5 > python-2.5.1-12 > python-psycopg2-2.0.6-2.5 > python-django-snapshot-5646-1 > > While these are all new packages, the only one which is "unstable" is django, > with all the others being point upgrades of existing stable releases. Hi Peter, I'm sorry we're not more cooperative, but I think your respondents are limited because reproducing the problem requires SUSE. At any rate, I am curious if you can isolate the issue further. Obviously, the svn trunk does work for people in general. This failure sounds a bit log segfaulting from a single process loading incompatible versions of a library. Someone else in this thread reported that the problem doesn't occur when using psycopg, but does with psycopg2. Can you check ldd for psycopg2? Does the crash occur when the cursor is created, or executed, or...? Can you run the same code outside of Django (but using psycopg2 and the same data structures going into the cursor)? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
newforms.form_for_model() does not map CharField with choices into SELECT
I am generating a form for a model that contains a CharField with choices. According to the documentation I expect to see this translated into a SELECT form field but all I get is a simple TEXT form field: models.py: class Publication(models.Model): PUBLICATION_TYPES = ( ('B', 'Book'), ('P', 'Periodical'), ('D', 'DVD'), ('C', 'CD'), ('O', 'Other'), ) type = models.CharField(maxlength=1, choices=PUBLICATION_TYPES) ... >>> from django import newforms as forms >>> pubform = forms.form_for_model(Publication) >>> pf = pubform() >>> pf.as_table() u'Type:\n... Any idea? --~--~-~--~~~---~--~~ 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: How to access upload_to property of FileField in views?
In view: upload_to = Jewel._meta.get_field( "file" ).upload_to --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
QuerySet & memory
Hello, I've thought, that QuerySets whose are iterated does not allocate memory for all objects. But simple test shows otherwise. When I iterate through SomeModel.objects.all() I get same memory consumption like with list(SomeModel.objects.all()). It is very frustrating, because with test database (which is definitely not as large as production one) with approximately 3 records I get about two GB of memory per process. Iterating through all records in my app is a special case, but needed one. So my question is: Is (or should be) there a difference between iterating and enumerating objects? Is there any way to load object on demand only, so to use memory only roughly equal to sizeof(SomeModel)? -- Tomas Kopecek e-mail: permonik at mesias.brnonet.cz ICQ: 114483784 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
AttributeError
I'm unshelving an object that i wrote in the views module and a get AtributeError, 'module' object has no attribute Myobject. And run one of its functions. Any idea what i am doing wrong?? Jorge Hugo Murillo Pinpoint customers who are looking for what you sell. http://searchmarketing.yahoo.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Neo-Cons: Make Bush Dictator Of The World
Neo-Cons: Make Bush Dictator Of The World Maniacal right-wing Family Security Matters organization, which has ties to Cheney, Rumsfeld and Perle, carries screed that calls for Bush to declare martial law, become emperor of the planet, lifetime president, and ethnically cleanse Iraq by means of nuclear genocide Prison Planet | August 17, 2007 Paul Joseph Watson If you thought Stu Bykovsky's call for a new 9/11 was the lowest the Neo-Cons could sink, think again. A right-wing foundation with links to Dick Cheney has called for Bush to be made lifetime president, ruler of the world, and for Iraq to be ethnically cleansed of Arabs by means of a nuclear holocaust. The Family Security Matters organization masquerades as an independent "think tank" yet was highly influential in President Bush's re- election in 2004 and has links to top Neo-Con ideologues. The outfit poses as an advocacy group for a new breed of goose- stepping brownshirts - so-called "security moms," who are noted for their blind obedience to neo-conservatism as a result of believing every ounce of fearmongering that emanates from the Bush administration on the inevitability of mass casualty terror attacks. "In late 2004, Media Matters for America discovered that the phone number listed on FSM's website actually belonged to the Center for Security Policy (CSP), a rabidly hardline foreign policy outfit run by former Reagan administration figure Frank Gaffney," reports Right Web . The Center for Security Policy is an umbrella organization that includes the National Security Advisory Council, whose members hold senior positions within the Bush administration itself. Former and current members include Dick Cheney, Richard Perle, Elliott Abrams and the organization has also given awards to Donald Rumsfeld. The FSM foundation itself also has ties to the Anti-Defamation League, the International Women's Forum, numerous nationwide television and print media outlets, and includes on its board of advisors Neo-Con radio host Laura Ingraham and former director of the U.S. Central Intelligence Agency, James Woolsey. Representatives of FSM also routinely appear as guests on Fox News and their website is a cesspool of anti-American fervor - acting as a cheerleader for the invasion of Iran, the warrantless wiretapping program ( opponents of which are labeled "traitors" ) and lauds the Patriot Act as "An irreplaceable tool utilized by our Secret Service to keep us safe." In an August 3rd article, contributing editor and philosopher Philip Atkinson penned a feverish diatribe that calls for the end of democracy, for Bush to be made ruler of the world as Julius Caesar was made emperor of Rome, for Bush to be made lifetime President in the U.S., and for Iraq to be ethnically cleansed by means of nuclear genocide and re-populated with Americans. The comments are so fundamentally sick and twisted that the reader must absorb the following passages in full to recognize the true depravity of what the Neo-Con fringe truly embrace. After calling democracy 'the enemy of truth and justice', Atkinson openly calls for genocide and mass slaughter. The simple truth that modern weapons now mean a nation must practice genocide or commit suicide. Israel provides the perfect example. If the Israelis do not raze Iran, the Iranians will fulfill their boast and wipe Israel off the face of the earth. The wisest course would have been for President Bush to use his nuclear weapons to slaughter Iraqis until they complied with his demands, or until they were all dead. Bush should be taking foreign policy tips from imperial dictator Julius Caesar, according to frustrated Neo-Cons. He then cites Julius Caesar, the reviled dictator of the Roman Empire, as an example of how Bush should engage in rampant ethnic cleansing. When the ancient Roman general Julius Caesar was struggling to conquer ancient Gaul, he not only had to defeat the Gauls, but he also had to defeat his political enemies in Rome who would destroy him the moment his tenure as consul (president) ended. Caesar pacified Gaul by mass slaughter; he then used his successful army to crush all political opposition at home and establish himself as permanent ruler of ancient Rome. If President Bush copied Julius Caesar by ordering his army to empty Iraq of Arabs and repopulate the country with Americans, he would achieve immediate results: popularity with his military; enrichment of America by converting an Arabian Iraq into an American Iraq (therefore turning it from a liability to an asset); and boost American prestiege while terrifying American enemies. Atkinson then concludes by stating such actions would allow Bush to declare martial law, become permanent President of the U.S. and eventually ruler of the entire world. He could then follow Caesar's example and use his newfound popularity with the military to wield military power to become the first permanent president of America, and end the civil chaos caused by the continually squa
Re: QuerySet & memory
On 8/27/07, Tomas Kopecek <[EMAIL PROTECTED]> wrote: > I've thought, that QuerySets whose are iterated does not allocate memory > for all objects. QuerySet.iterator does what you want. QuerySet.__iter__ (the python method that is called from the for loop) returns an iterator over the results of QuerySet._get_data, which does store a results cache. The design fits the expectation that you'll more frequently be iterating a smallert result set for the same queryset, and that shouldn't hit the database twice, so the results are stored. But that obviously isn't what you want in this case. One other point-- the DB-API provides cursor.fetchmany, and Django's iterator uses this correctly. However, some database libraries default to a client-side cursor, meaning that even though the API provides chunking semantics, the library still brings back the entire resultset in one go. I can't remember what psycopg1 does, but psycopg2 defaults to client-side cursor. It is possible to do server-side cursors using names, but Django doesn't do this. Fixing this has been (low) on my to-do list for a long time. In the common case of small result sets, client-side cursors are generally a win since they do only one hop to the DB and all of the results fit in memory easily. Anyway, either do as Doug B suggests, iterating over slices, or do as I suggest, directly calling QuerySet.iterator. Doug B is wrong that there isn't much difference, though. There certainly is when you have an expensive query whose results don't fit into memory. Five Worlds of Software, recommended reading: http://www.joelonsoftware.com/articles/FiveWorlds.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: QuerySet & memory
There isn't much difference. Once you ennumerate,slice, or iterate a queryset that's when the actual database query occurs. It will pull in all matching object in order to save you additional queries. Why not iterate in batches, by slicing the query? That way if you set you step to say 100, you'll have at most 100 records in memory at a time. If the records add or delete during your process it might not be so good though. count = SomeModel.objects.all().count() steps=100 offset=0 for i in range(0,count,steps): offset=offset+steps for o in SomeModel.objects.all()[i:offset] # do your stuff You could also do a query to select all ids using .values(), and iterate that using .get() to fetch each individually, or filter with or'd Q objects to get batches. value_fetch = SomeModel.objects.all().values("id") for row in value_fetch: o=SomeModel.objects.get(pk=row['id']) # do your stuff --~--~-~--~~~---~--~~ 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: QuerySet & memory
On 8/27/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > QuerySet.iterator does what you want. I was going to follow up with a documentation link, but it appears we lost the documentation for QuerySet.iterator at some point. Opened a ticket In any case, Jeremy's right: the "iterator" method returns a generator which fetches the data in chunks and only instantiates objects when they're actually needed, yielding them one at a time as you iterate over it. So you can replace a call to 'all()' with a call to 'iterator()', or chain 'iterator()' on after a call to 'filter()', and you should see greatly improved memory usage for situations where you're dealing with huge numbers of objects. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: is 40 MB RAM enough?
On 27-Aug-07, at 8:18 PM, Iapain wrote: >> what is your RAM usage? How did you tweak apache to achieve that? > > I didnt check RAM usage, but site always work like express instead i > did clean coding and tried to optimize my code. this is the command that webfaction uses to check RAM usage: "ps -u yourusername -o rss,pid,command" could you run it and check the output. Apparently they run this command now and then, and if it shows over 40 MB, you get a notice from them. -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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: Error loading MySQLdb module
where might I find the PYTHONPATH variable? On Aug 11, 6:39 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 8/11/07, Kelsey Ruger <[EMAIL PROTECTED]> wrote: > > > I have the same problem even though I have installedMySQLdb. > > Open up a Python interpreter, and try: > > importMySQLdb > > If you see an ImportError,MySQLdbmay have been installed into a > location that's not on your Python import path; you can fix this by > changing the environment variable PYTHONPATH to include the directory > into whichMySQLdbwas installed (not the location ofMySQLdbitself, > but the directory in which it can be found), like so: > > export PYTHONPATH=/dir/where/mysqldb/lives:$PYTHONPATH > > Placing that in the file '.bashrc' in your home directory will cause > it to be set automatically for you any time you open up a shell. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: dynamic links
> > http://www.djangoproject.com/documentation/templates/#url I tried that already...but its not working for me...or i just don't know whats happening. I always get a link to the current page. i.e the page links to itself. i can't seem to find more documentation to the url tag, so that i could solve this problem. Im going to try lapains solution...just have to find out how that works:) --~--~-~--~~~---~--~~ 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: UnicodeDecodeError with memcache
I´m sorry for bothering again, but our site has to be online soon and I ´m currently not able to use the cache_page decorator (which makes me a bit nervous). I did some research on smart_str, but I don´t know how and where to use it and I also don´t see why this should solve the problem. any feedback is highly appreciated. btw: I´m able to use the low-level cache. thanks, patrick On 27 Aug., 16:52, patrickk <[EMAIL PROTECTED]> wrote: > so you say I should use __str__ instead of __unicode__, right? > according to the django-docs, that´s not recommended though ... > > On 27 Aug., 16:40, Iapain <[EMAIL PROTECTED]> wrote: > > > > UnicodeDecodeError at /spezialprogramme/ > > > 'ascii' codec can't decode byte 0x80 in position 0: ordinal not in > > > range(128) > > > try using smart_str, it it doesnt work then use less restrictive decode --~--~-~--~~~---~--~~ 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: is 40 MB RAM enough?
> could you run it and check the output. 14.28 MB --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---