Re: Django on REDHAT ES
On 1/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: i have installed both the following: libevent-1.2-1 and memcached-1.1.13 rebooted apache2 and still get the same error... any further ideas? Install the Python memcached bindings. See the Memcached section here: http://www.djangobook.com/en/beta/chapter14/ Adrian -- Adrian Holovaty holovaty.com | djangoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django on REDHAT ES
i have installed both the following: libevent-1.2-1 and memcached-1.1.13 rebooted apache2 and still get the same error... any further ideas? --~--~-~--~~~---~--~~ 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 on REDHAT ES
On Jan 5, 2007, at 12:41 AM, [EMAIL PROTECTED] wrote: InvalidCacheBackendError: Memcached cache backend requires the 'memcache' library It sounds like you're trying to use memcached for caching. what i have installed: httpd-2.0.52 mod_python-3.1.3-5.1 postgresql-server-8.1.3-1.el4s1.2 postgresqlclient7-7.4.8-2.el4s1.1 python-2.3.4-14.3 python-devel-2.3.4-14.3 python-docs-2.3.4-14.3 python-imaging-1.1.5-1.el4.rf python-psycopg-1.1.21-1.2.el4.rf subversion-1.1.4-2.ent However, it looks like you've installed neither memcached, nor the python-memcached library. Both are available online; does installing them help? Adam --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django on REDHAT ES
Yes, it seems like a dumb idea, but has anyone had any success getting it to run? ~ do you have any pointers you can share? i am getting the following error in my browser: = Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib64/python2.3/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/home/code/django/core/handlers/modpython.py", line 190, in handler return ModPythonHandler()(req) File "/home/code/django/core/handlers/modpython.py", line 160, in __call__ self.load_middleware() File "/home/code/django/core/handlers/base.py", line 27, in load_middleware mod = __import__(mw_module, '', '', ['']) File "/home/code/django/middleware/sessions.py", line 3, in ? from django.utils.cache import patch_vary_headers File "/home/code/django/utils/cache.py", line 22, in ? from django.core.cache import cache File "/home/code/django/core/cache/__init__.py", line 54, in ? cache = get_cache(settings.CACHE_BACKEND) File "/home/code/django/core/cache/__init__.py", line 51, in get_cache cache_class = getattr(__import__('django.core.cache.backends.%s' % BACKENDS[scheme], '', '', ['']), 'CacheClass') File "/home/code/django/core/cache/backends/memcached.py", line 8, in ? raise InvalidCacheBackendError, "Memcached cache backend requires the 'memcache' library" InvalidCacheBackendError: Memcached cache backend requires the 'memcache' library = what i have installed: httpd-2.0.52 mod_python-3.1.3-5.1 postgresql-server-8.1.3-1.el4s1.2 postgresqlclient7-7.4.8-2.el4s1.1 python-2.3.4-14.3 python-devel-2.3.4-14.3 python-docs-2.3.4-14.3 python-imaging-1.1.5-1.el4.rf python-psycopg-1.1.21-1.2.el4.rf subversion-1.1.4-2.ent --~--~-~--~~~---~--~~ 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: AttributeError: 'WSGIRequest' object has no attribute 'user'
It would seem that something is happening between the authentication middleware setting request.__class__.user and the context processor reading it. Couple things to try if you're in a debugging mood: After line 11 in django/contrib/admin/middleware.py: request.__class__.user = LazyUser() +print 'Middleware:', request.user Add that line to see if it's actually being set. Now as the first line in whatever view this is happening in, do the same thing: def index_view(request): +print 'View:', request.user This should at least narrow down where in the code request.user is being obliterated... --~--~-~--~~~---~--~~ 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: In Model or Manager? (Sorting, calculations, and non-savable fields)
Brian Beck wrote: class Payment(models.Model): ... class Custom: def sortable_fields = ['amount', 'received_date'] That last line should of course just be: sortable_fields = ['amount', 'received_date'] --~--~-~--~~~---~--~~ 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: In Model or Manager? (Sorting, calculations, and non-savable fields)
ringemup wrote: Does that apply to the actual sorting of the data as well? It seems to me that it's something most efficiently accomplished at the database level. If sorting will always be done by field in the model (and not some complex combination, for example), and SQL orders it how you're expecting, then I'd say sure, do the sorting with order_by in the model manager or a custom manager method. And then... what fields it's sortable on (e.g. you can sort by name, but not by slug) seems to me to be a property of the model. Not in terms of which column headers are linked for sorting in the display (which is very clearly view or template logic), but in terms of what sorting keywords would be allowed/rejected in the view when processing the URL -- should the view refer back to the model for that? Especially since I'm going to require several views for each data type, and it seems a shame to maintain the sortable-fields list separately for each one. On one hand, the fields it's sortable on really is a property of the view you're looking to write. But it is nice to keep it attached to the model, much like the admin app views are customizable through your model. If you try to add, say, a sortable_fields attribute to Meta, your models won't validate since it checks the Meta class. If I were doing this, I'd use one of these approaches: class Payment(models.Model): ... class Custom: def sortable_fields = ['amount', 'received_date'] class Payment(models.Model): ... @classmethod def get_sortable_fields(cls): return ['amount', 'received_date'] Now, why not in the manager? Because as far as I can tell, every method of the default manager performs a query. Sure, you could add these things there, but it breaks this convention. So, here's my recommendation: - Non-saveable fields: Use a custom class attribute or method (these aren't instance-specific, right?). - Calculations: Most likely this performs a query. Put it in the manager. - Sorting: Take the fields the view wants to sort by and check them against the sortable fields attribute or method on your model, call order_by or a custom manager method that does the sorting (since this will perform a query). --~--~-~--~~~---~--~~ 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: AttributeError: 'WSGIRequest' object has no attribute 'user'
On 10/18/06, Tyson Tate <[EMAIL PROTECTED]> wrote: ... I've got the following in settings.py: TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.auth", ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', ) Thanks in advance for any ideas! Sorry, I'm stumped. :-/ --~--~-~--~~~---~--~~ 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 models on one form
I am trying to get your solution 1 to work for the case of multiple instances of the same model. The forms looks good, but the problem is that all fields have the same name (because the forms are generated from the same model). Is there any way around that? Or do I have to write a custom manipulator in this case? It seems as if I'm SOOO close... Thanks! On Dec 8 2006, 7:47 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: On 12/9/06, Brian Morton <[EMAIL PROTECTED]> wrote: > I am trying to write a customformthat will handle updates for several > models. What is the best way to do this? Do I have to write a custom > manipulator to handle the data? Or can I create a hybrid view of > several different default manipulators?There are at least two approaches, which you have pretty much suggested in your question. 1) Write your view and construct 2 manipulators, and 2 FormWrappers, and pass them both into the template; on Post, validate and save both manipulators. This is exactly the same as the normal 'edit' view pattern, except that you double up on the use of forms and manipulators. 2) Write a customized manipulator that covers both models, and create a view that instantiates that manipulator. 1 will probably be easier to get going, but requires a sort of code duplication. 2 is more complex, and is ultimately more flexible, Either way, you will need to write your own view. The other thing you might want to look at is the newforms library. Adrian is in the process of developing a replacement for theForm/Manipulator approach. The biggest missing piece is the 'createformfrom Model' aspect, but you are looking to create a customized hybridformanyway. No guarantees, but it might be worth a look. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 with inclusion_tag
On Jan 4, 6:42 pm, "Jorge Gajon" <[EMAIL PROTECTED]> wrote: On 1/4/07, stoKes <[EMAIL PROTECTED]> wrote: > On Jan 4, 12:10 pm, "Jorge Gajon" <[EMAIL PROTECTED]> wrote: > > Hi Adam, > > On 1/3/07, stoKes <[EMAIL PROTECTED]> wrote: > > > base.html > > > {% showmenu %} > > > {% for service in services %} > > > {{ > > > service.name }} > > > {% endfor %} > > > but receiving this error: > > > Exception Type: TemplateSyntaxError > > > Exception Value:Invalid block tag: 'showmenu'Try putting {% load showmenu %} before the call to the tag, for example: > > {% load showmenu %} > > {% showmenu %} > > {% for service in services %} > > {{service.name }} > > {% endfor %} > > The {% load %} tag loads a .py file that contains your custom tags. In > > this case it will try to load the file > > /project/templatetags/showmenu.py > > If the .py file with your custom tags had a different name, for > > example "mytags.py" then you would need to type a {% load mytags %} in > > your template before using your custom tags. > Hey Jorge, > I had tried that, however, this is the error I got : > Exception Type: TemplateSyntaxError > Exception Value:'showmenu' is not a valid tag library: Could not load > template library from django.templatetags.showmenu, No module named > showmenu > i've created other templatetags before that loaded perfectly if i did > it for a certain app, for example, > /project/myapp/templatetags/tag.py > but this is more of a global template tag so im not sure if my > procedure in doing this is correct or notOh I didn't noticed that little detail. But no, you can't have a "global" templatetag, your custom tags must be inside the 'templatetags' folder inside your app. This is what the documentation says about it: """The {% load %} tag looks at your INSTALLED_APPS setting and only allows the loading of template libraries within installed Django apps. This is a security feature: It allows you to host Python code for many template libraries on a single computer without enabling access to all of them for every Django installation. If you write a template library that isn't tied to any particular models/views, it's perfectly OK to have a Django app package that only contains a templatetags package.""" Hope it helps Regards, Jorge It does, thanks for clearing that up. What I think ill do is create a seperate layout APP and only views for things I need displayed "globally" and just have each other app extend its template off that. Thanks adam --~--~-~--~~~---~--~~ 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: Looking to move to Django, is it right for me?
On 05-Jan-07, at 8:42 AM, Brian Beck wrote: * Database access. You can still use Python's much lower-level DB-API to play with the database, and you can still make it look nice to use. Check out the raw SQL query in this Custom Managers example: http://www.djangoproject.com/documentation/model_api/#custom-managers Also, the project management commands like 'sqlreset' show you what the abstracted model is doing under the covers. and you can always directly access the database to add your own rules, triggers and whatnot. For example, check contraints are not implemented in django - easy to add your own. Only the readymade admin interface is not so easily customisable. But then it is easy to roll your own. -- 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: Looking to move to Django, is it right for me?
A lot of time has been spent on making Django not-too-magical while keeping the rapid development time. I've found that it rarely does too much automatic stuff behind my back. Just a couple examples of high-level stuff that isn't too-high-for-your-own-good: * Database access. You can still use Python's much lower-level DB-API to play with the database, and you can still make it look nice to use. Check out the raw SQL query in this Custom Managers example: http://www.djangoproject.com/documentation/model_api/#custom-managers Also, the project management commands like 'sqlreset' show you what the abstracted model is doing under the covers. * Templating. Templates really are just text files, no structure is forced upon you, nothing gets changed around or added behind the scenes. --~--~-~--~~~---~--~~ 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: Looking to move to Django, is it right for me?
On 05-Jan-07, at 8:17 AM, Mojave wrote: The only thing I'm concerned with is that the tutorials I've read about Django show it off as almost too easy and automatic. While I will welcome the ability to quickly get a site up and running, I also like to tinker. Is Django something that will give me the best of both worlds: high level development, but also the ability to go low-level? django specialises in this -- 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: django.core.handlers.modpython imported several times
Adrian Holovaty wrote: On 1/4/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > FWIW, it amazes me sometimes that although Django can be made to work > on mod_python that very few if any Django developers I have seen > exhibit any real knowledge about how Apache/mod_python works. As a > consequence I keep seeing incorrect statements and advice being made > about mod_python on lists and also in Django documentation. These > problems extend to there also being some potentially questionable code > in the mod_python adaptor for Django as well. Although I have pointed > out at times that what is being said doesn't make sense or is wrong, no > one seems to make an attempt to address it. Hi Graham, Could I trouble you to bring up those issues again? I did a quick search and assume you're talking about this comment of yours: http://www.djangoproject.com/documentation/modpython/#c2029 And: http://www.djangoproject.com/documentation/faq/#c2813 The latter comments are relevant to actual Django source code as it appears to rely internally on being able to pass information around in os.environ. If such information is different for different requests, this will be a problem in a multithreaded Apache MPM such as worker on UNIX or winnt on Windows. The problems with worker MPM suggested by first link above may well be accounted for by use of os.environ if Django is relying on it in some way. But then, the problem should also affect winnt MPM on Windows as well as it also is multithreaded, but there has been no suggestion of problems on Windows, only worker MPM on UNIX. This is why the inability of anyone to clarify why the worker MPM shouldn't be used is a bit frustrating. For the record, I should state I don't use Django myself, I only keep an eye out for any connections between it and mod_python and try and correct any wrong comments about mod_python I see. 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 -~--~~~~--~~--~--~---
Looking to move to Django, is it right for me?
I'm looking to move away from my Perl cgi background and into something more powerful, cleaner and standard. Django and Ruby on Rails both look interesting. The only thing I'm concerned with is that the tutorials I've read about Django show it off as almost too easy and automatic. While I will welcome the ability to quickly get a site up and running, I also like to tinker. Is Django something that will give me the best of both worlds: high level development, but also the ability to go low-level? 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 -~--~~~~--~~--~--~---
Django Admin ForeignKey display
Hello, When using the types ForeignKey or CharField (with the "choices" option) in a model, I am finding that the resultant form elements are truncating the display of default values. Does anyone know of a simple way to avoid this? Thanks, CL --~--~-~--~~~---~--~~ 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.core.handlers.modpython imported several times
On 1/4/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote: FWIW, it amazes me sometimes that although Django can be made to work on mod_python that very few if any Django developers I have seen exhibit any real knowledge about how Apache/mod_python works. As a consequence I keep seeing incorrect statements and advice being made about mod_python on lists and also in Django documentation. These problems extend to there also being some potentially questionable code in the mod_python adaptor for Django as well. Although I have pointed out at times that what is being said doesn't make sense or is wrong, no one seems to make an attempt to address it. Hi Graham, Could I trouble you to bring up those issues again? I did a quick search and assume you're talking about this comment of yours: http://www.djangoproject.com/documentation/modpython/#c2029 Adrian -- Adrian Holovaty holovaty.com | djangoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Why so slow?
On 1/4/07, David Abrahams <[EMAIL PROTECTED]> wrote: ... If I log into the server and run "top" while trying to access pages, I don't see any alarming jumps in CPU load; the hungriest processes typically stay in single-digit (or below) percentages of CPU usage, so I doubt profiling is going to be much use. I don't really know where to start in debugging this. Most likely, KeepAlive is holding processes unavailable while sitting idle. Next most likely is # of child processes. Try fiddling with Min and MaxSpareServers. http://httpd.apache.org/docs/2.0/mod/prefork.html Next most likely is that you're serving media and django on the save httpd. More suggestions: http://www.jacobian.org/writing/2005/dec/12/django-performance-tips/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Why so slow?
I am developing a Django-based site, and it *really* seems to be slow... sometimes. It's running in an Apache virtual server on the same machine as my static site. When things are good, the Django-based site approaches the static site in speed, but when things are bad, there's just no comparison. At those times, my development server (local of course) is far, far faster. The slowness typically comes after not having accessed the site for a while. I suspected paging at first, but I don't think anything should be taking that much memory and I noticed that it tends to stay slow through several minutes of surfing, when everything should have long since been paged back in. I'm using the prefork MPM as recommended. I'm using the locmem cache. I'm not cacheing pages, but I am cacheing major HTML fragments -- the templating system is still running for each page. I was cacheing whole pages for a while and it didn't seem to make a difference, so I turned that off. If I log into the server and run "top" while trying to access pages, I don't see any alarming jumps in CPU load; the hungriest processes typically stay in single-digit (or below) percentages of CPU usage, so I doubt profiling is going to be much use. I don't really know where to start in debugging this. Any insight you might have is appreciated. -- Dave Abrahams Boost Consulting www.boost-consulting.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 -~--~~~~--~~--~--~---
Re: django.core.handlers.modpython imported several times
Adrian Holovaty wrote: On 1/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > here what I've got from my Apache2 error log: > > [Thu Jan 04 16:07:57 2007] [notice] mod_python: (Re)importing module > 'django.core.handlers.modpython' > [Thu Jan 04 16:08:06 2007] [notice] mod_python: (Re)importing module > 'django.core.handlers.modpython' > [Thu Jan 04 16:34:15 2007] [notice] mod_python: (Re)importing module > 'django.core.handlers.modpython' > > > I was wondering what could be the reason of it ? Hello, I've seen this Apache notice too, and I'm not sure what it is, but it's never caused any problems for me. :) With that said, I would be grateful if anybody could explain why that happens, and if we need to change something on Django's end so that, at the very least, people's logfiles won't get cluttered with this. These messages are generally quite normal. You will see the message the first time that Django module is imported for each Python interpreter instance in which it is used. Since on UNIX there can be multiple Apache child processes, you will see one for each child process created. This will normally be seen at Apache startup, but it might occur later as well as Apache decides to create additional child processes. Even for the same child process, you might see the message more than once if someone is running multiple Django instances within distinct named Python interpreters. You can eliminate the messages by ensuring you have: PythonDebug Off in the Apache configuration file, something that is recommended for production systems so that stack traces don't get displayed in web pages if Python code raises an exception which isn't caught and dealt with. BTW, in mod_python 3.3, it will show the process ID against these messages and distinguish an initial import and a reload. Ultimately though that will not matter for Django anyway, as in 3.3, mod_python will not try and load standard packages/modules on sys.path itself and will defer to standard Python module importer and so no message will be displayed as mod_python isn't loading it. FWIW, it amazes me sometimes that although Django can be made to work on mod_python that very few if any Django developers I have seen exhibit any real knowledge about how Apache/mod_python works. As a consequence I keep seeing incorrect statements and advice being made about mod_python on lists and also in Django documentation. These problems extend to there also being some potentially questionable code in the mod_python adaptor for Django as well. Although I have pointed out at times that what is being said doesn't make sense or is wrong, no one seems to make an attempt to address it. Graham Adrian -- Adrian Holovaty holovaty.com | djangoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: What's the proper use of LazyDate?
On 1/5/07, John DeRosa <[EMAIL PROTECTED]> wrote: What's the proper/recommended/improper/not-recommended use of models.LazyDate() in 0.95? I'm working on a project that picked up its use in 0.91-based code. There's a passing reference to it in the 0.90 docs, but nothing since then. There are references to it all over the web... E.g.: class UserReadComment(models.Model): scoop = models.ForeignKey(Scoop,raw_id_admin=True) [...snip...] last_read = models.DateTimeField(default=models.LazyDate(), auto_now=True) The purpose of LazyDate is to be a proxy around a date object that allows you to specify a date that won't be evaluated until it is used in a model. In your example, comment.last_read.day will return the day on which the instance was saved (similarly for other attributes of the date object). You can also provide arguments to the LazyDate that specify a timeDelta to apply; for example: limit_choices_to = {'date__gt' : models.LazyDate(days=-3)} would be a filter that keeps only those objects from the last three days. There is a tangential reference to LazyDate in the model API documentation, but otherwise, this is an area where some documentation could be useful. I've opened a ticket (#3231) for this issue. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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: Order SelectField items
I solved this by sorting the tuple of tuples outside of the add/create custom manipulators, then using that sorted list instead of ColorAccount.COLORS: col_list = list(ColorAccount.COLORS) col_list.sort(lambda x, y: cmp(x[1], y[1])) col_tuple = tuple(col_list) And then: forms.SelectField(field_name="fav_color",choices=col_tuple) I guess this was more of a python issue. --~--~-~--~~~---~--~~ 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: model referencing itself
Hi Aljosa, On 1/4/07, Aljosa Mohorovic <[EMAIL PROTECTED]> wrote: i'm trying to create a model which referencing itself and for this code i get this error: "name 'Chapter' is not defined" how do i do this or something similar? code: >>> from django.db import models class Chapter(models.Model): name = models.CharField(maxlength=200) content = models.TextField() prev = models.OneToOneField(Chapter) next = models.OneToOneField(Chapter) <<< Try with: prev = models.OneToOneField('self') next = models.OneToOneField('self') Regards --~--~-~--~~~---~--~~ 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: model referencing itself
i'm trying to create a model which referencing itself The documentation says : To create a recursive relationship -- an object that has a many-to-one relationship with itself -- use models.ForeignKey('self'). Chris --~--~-~--~~~---~--~~ 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 with inclusion_tag
On 1/4/07, stoKes <[EMAIL PROTECTED]> wrote: On Jan 4, 12:10 pm, "Jorge Gajon" <[EMAIL PROTECTED]> wrote: > Hi Adam, > > On 1/3/07, stoKes <[EMAIL PROTECTED]> wrote: > > > base.html > > {% showmenu %} > > {% for service in services %} > > {{ > > service.name }} > > {% endfor %} > > > but receiving this error: > > > Exception Type: TemplateSyntaxError > > Exception Value:Invalid block tag: 'showmenu'Try putting {% load showmenu %} before the call to the tag, for example: > > {% load showmenu %} > {% showmenu %} > {% for service in services %} > {{service.name }} > {% endfor %} > > The {% load %} tag loads a .py file that contains your custom tags. In > this case it will try to load the file > /project/templatetags/showmenu.py > > If the .py file with your custom tags had a different name, for > example "mytags.py" then you would need to type a {% load mytags %} in > your template before using your custom tags. > Hey Jorge, I had tried that, however, this is the error I got : Exception Type: TemplateSyntaxError Exception Value:'showmenu' is not a valid tag library: Could not load template library from django.templatetags.showmenu, No module named showmenu i've created other templatetags before that loaded perfectly if i did it for a certain app, for example, /project/myapp/templatetags/tag.py but this is more of a global template tag so im not sure if my procedure in doing this is correct or not Oh I didn't noticed that little detail. But no, you can't have a "global" templatetag, your custom tags must be inside the 'templatetags' folder inside your app. This is what the documentation says about it: """The {% load %} tag looks at your INSTALLED_APPS setting and only allows the loading of template libraries within installed Django apps. This is a security feature: It allows you to host Python code for many template libraries on a single computer without enabling access to all of them for every Django installation. If you write a template library that isn't tied to any particular models/views, it's perfectly OK to have a Django app package that only contains a templatetags package.""" Hope it helps Regards, Jorge --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Order SelectField items
Hello, This is a simplified example of what I'm trying to accomplish. In my model I have the following objects and fields: class ColorAccount(models.Model): COLORS = ( (0, 'Red'), (1, 'Orange'), (2, 'Yellow'), (3, 'Green'), ... ) fav_color = models.IntegerField(choices=COLORS) ... I then have a custom manipulator, which has the following field: forms.SelectField(field_name="fav_color", choices=ColorAccount.COLORS), My question is, is it possible to change the default order (corresponding integer values) of the items in the generated HTML menu ... without reassigning the integer values in the model? For instance, I would like the order to be alphabetical. Would this be something I could accomplish via the manipulator, or maybe back in the model? Thanks in advance, Andy --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Order SelectField items
Hello, This is a simplified example of what I'm trying to accomplish. In my model I have the following objects and fields: class ColorAccount(models.Model): WINE_VARIETALS = ( (0, 'Red'), (1, 'Orange'), (2, 'Yellow'), (3, 'Green'), ... ) fav_color = models.IntegerField(choices=COLORS) ... I then have a custom manipulator, which has the following field: forms.SelectField(field_name="fav_color", choices=ColorAccount.COLORS), My question is, is it possible to change the default order (corresponding integer values) of the items in the generated HTML menu ... without reassigning the integer values in the model? For instance, I would like the order to be alphabetical. Would this be something I could accomplish via the manipulator, or maybe back in the model? Thanks in advance, Andy --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
model referencing itself
i'm trying to create a model which referencing itself and for this code i get this error: "name 'Chapter' is not defined" how do i do this or something similar? code: from django.db import models class Chapter(models.Model): name = models.CharField(maxlength=200) content = models.TextField() prev = models.OneToOneField(Chapter) next = models.OneToOneField(Chapter) <<< Aljosa --~--~-~--~~~---~--~~ 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: CRUD design question
Now you're talking!!! Thanks for that, it's exactly what I was thinking. Basically I am trying to make a system where you show a list of records, allow the user to view the record, edit the record or add a new one. Similar to the admin interface, but with only a view option, so in case your a 'public' user you only get view access to the data. Thanks again for the help. John On 1/4/07, Tim <[EMAIL PROTECTED]> wrote: The HTML in the template is fairly easy to do: {% if object %} we have an object so we're updating {% else %} no object so we're inserting {% endif %} I'm not quite sure how you want to handle the viewing part though. In the form HTML, just create your form as if you are doing an update: {% if form.title.errors %} {{ form.name.errors|join:", "}} {% endif %} Event Description: {{ form.title }} Enter the name of the event. * if the form title in my example contains no data, it will show up empty. If it has data, it will be filled. Pretty easy. The tougher part is in the views. > --~--~-~--~~~---~--~~ 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: FormGen Script
On 04/01/07, Adrian Holovaty <[EMAIL PROTECTED]> wrote: On 1/4/07, Felix Ingram <[EMAIL PROTECTED]> wrote: > ScaffoldScript is dead; long live FormGen! > Using this script: http://code.djangoproject.com/wiki/FormGenScript > in this manner: python formGen.py -a MyApp -m Category Hey Felix, Have you seen django.newforms.form_for_model and form_for_fields? They're intended to do these things in a dynamic way. See the unit tests in tests/modeltests/model_forms/models.py for examples. Hi Adrian, Thanks for the pointer. I haven't seen form_for_fields; I look forward to the unittests. One 'problem' I've found with form_for_model (and the auto manipulators back in the day) is that it's tricky to tweak a single field if necessary. My longstanding problem has been that I need to edit a many2many field but the other table will contain over 100,000 rows. This takes a while to load into the select field and isn't really that helpful. I've been using a text field and chopping up the input to get the foreign values. It's quite tricky to swap out the select field and add the validators (especially in a maintainable way). Therefore I whipped up the script to spew out the forms which I then tweak as appropriate (I hope Fred doesn't look at it; he'll take my license away for sure). I'll be cheeky and ask my inheritance question again if that's okay: is it possible for a Form to inherit from another. I'd like a form for admin users which adds extra fields. Is something like this possible: class JoeUserForm(forms.Form): name = forms.CharField() class AdminForm(JoeUserForm): give_pay_rise = forms.BooleanField() Thanks again for the reply, Felix --~--~-~--~~~---~--~~ 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 projects one server
On Jan 4, 2007, at 9:55 AM, Robin Becker wrote: Is there a better way to handle this sort of thing using fastcgi or scgi? Can we get all requests from a particular host to be handled in only one group of processes. Our back end process doesn't respond well to being threaded and it can take a long time to complete so we seem to need a worker pool for each virtual host. I'm running nginx + fcgi for Django, so the below is in nginx's config format. But I'm assuming that lighttpd should be able to do something similar. Basically, in nginx, you can specify various upstream pools. For example: upstream blah { server unix:/tmp/blah.com_1.sock; server unix:/tmp/blah.com_2.sock; } upstream foo { server unix:/tmp/foo.com_1.sock; server unix:/tmp/foo.com_2.sock; } then in the site definitions: server { listen 80; server_name blah.com; location / { #insert FCGI params stuff here ... ## fastcgi_pass blah; } } server { listen 80; server_name foo.com; location / { #insert FCGI params stuff here ... ## fastcgi_pass foo; } } The above would tell nginx that for blah.com, use the pool described in upstream blah, load balancing between the entries. Same for foo.com. I'm using the the django+flup fcgi things described on the official site, but in theory, you could use apache as well, I suppose. --- David Zhou [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Workflow engine for python?
2007/1/4, mamcxyz <[EMAIL PROTECTED]>: Any docs about how write a workflow engine then? I'm really interested in this topic, I had to create a workflow too and I haven't any experience about that. Here is what I need: * a User can create Experiments * a User can create Processes Ok, simple. Now a User must be able to create a workflow of Experiments throw a Process in order to process chained Experiments in the right order. Each Process have his own order of Experiments. I hope I'm clear, do not hesitate to ask me if it's not the case. Any idea about this implementation will be really appreciated. Cheers, David --~--~-~--~~~---~--~~ 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: Running Multiple Sites/Apps with FastCGI... Where to start?
Tom, We run a number of sites using lighttpd and django off one code base. Yes, each site needs an entry in lighttpd.conf and each site has it's own settings file. Obviously you can set settings to allow each instance to have different templates or different installed apps. http://bus.glam.ac.uk/ and http://news.glam.ac.uk/ are examples. They both share roughly the same core code, but use different templates and some additional apps. regards Kevin --~--~-~--~~~---~--~~ 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: where does the old manipulator go?
Honza Kr�l wrote: Hi Ramdas, the "Right Way (tm)" how to solve this using newforms is: 1) subclass Field to create a field representing (and validating) username: class UserField( forms.Field ): def clean( self, value ): do what you must to verify username, throw validation error if you are not satisfied with the data I'd just like to point out that subclassing isn't the only way to add custom validation to a field, you can also implement the clean_FIELDNAME method on your form, or override the forms clean(), this is how I've done it: class RegistrationForm(forms.Form): username = forms.RegexField(r'^[a-zA-Z0-9_]{3,30}$', max_length = 30) <- rest of the fields here -> def clean_username(self): <- additional validation code here -> <- raise forms.ValidationError if data is invalid -> -+ enlight +- --~--~-~--~~~---~--~~ 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: CRUD design question
The HTML in the template is fairly easy to do: {% if object %} we have an object so we're updating {% else %} no object so we're inserting {% endif %} I'm not quite sure how you want to handle the viewing part though. In the form HTML, just create your form as if you are doing an update: {% if form.title.errors %} {{ form.name.errors|join:", "}} {% endif %} Event Description: {{ form.title }} Enter the name of the event. * if the form title in my example contains no data, it will show up empty. If it has data, it will be filled. Pretty easy. The tougher part is in the views. --~--~-~--~~~---~--~~ 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: close database connection ?
On 1/4/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I created a app with a pgsql database, the problem is that i often get the error to many clients connected to the database. I configured the database that 20 simaltanious connections can be made, still this error pops up once in a while even when i'm working alone on the app. Are you explicitly opening the database connection? This is an unusual problem, as far as I know. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
close database connection ?
Hello Django users, I'm a newby in using django for developing applications and experiencing some problems i hope some of you can assist me. I created a app with a pgsql database, the problem is that i often get the error to many clients connected to the database. I configured the database that 20 simaltanious connections can be made, still this error pops up once in a while even when i'm working alone on the app. My guess is that tha application keeps the database connection open for a amount of time and opens a new connection every time the database is aproached. Is there a way to close the connection after every db call or is there another solution besides upgrading the connections allowed on the db. thanks in advance for your help, richard mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Locking tables
Hello, I would like to know how I could lock a table or field ? My idea is to lock a table/s while one user is modifyng data until he confirms or cancel the operation. And if other user access to same data, he access in read-only mode. I wouldn't like to use transactions to do this operation, I would prefer something like get_for_update (ticket 2705) but this one is not still avaliable. 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 -~--~~~~--~~--~--~---
What's the proper use of LazyDate?
What's the proper/recommended/improper/not-recommended use of models.LazyDate() in 0.95? I'm working on a project that picked up its use in 0.91-based code. There's a passing reference to it in the 0.90 docs, but nothing since then. There are references to it all over the web... E.g.: class UserReadComment(models.Model): scoop = models.ForeignKey(Scoop,raw_id_admin=True) [...snip...] last_read = models.DateTimeField(default=models.LazyDate(), auto_now=True) ? John --~--~-~--~~~---~--~~ 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: FormGen Script
On 1/4/07, Felix Ingram <[EMAIL PROTECTED]> wrote: ScaffoldScript is dead; long live FormGen! Using this script: http://code.djangoproject.com/wiki/FormGenScript in this manner: python formGen.py -a MyApp -m Category Hey Felix, Have you seen django.newforms.form_for_model and form_for_fields? They're intended to do these things in a dynamic way. See the unit tests in tests/modeltests/model_forms/models.py for examples. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
FormGen Script
ScaffoldScript is dead; long live FormGen! Using this script: http://code.djangoproject.com/wiki/FormGenScript in this manner: python formGen.py -a MyApp -m Category will turn this model: class Category(models.Model): category = models.CharField(maxlength=50, unique=True) createdOn = models.DateField(auto_now_add=True) modifiedOn = models.DateField(auto_now=True) test = models.ManyToManyField(auth.User, verbose_name='This is a test field', related_name='test') test2 = models.OneToOneField(auth.User, verbose_name='test2', related_name='test2') Into this form: class CategoryForm(forms.Form): category = forms.CharField() createdon = forms.DateField() modifiedon = forms.DateField() test2 = forms.ChoiceField() this_is_a_test_field = forms.MultipleChoiceField() Not the greatest example but you get the idea. I've found it useful for when I need to tweak a couple of fields (which isn't easy without defining the whole form). Enjoy, Felix --~--~-~--~~~---~--~~ 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 with inclusion_tag
On Jan 4, 12:10 pm, "Jorge Gajon" <[EMAIL PROTECTED]> wrote: Hi Adam, On 1/3/07, stoKes <[EMAIL PROTECTED]> wrote: > base.html > {% showmenu %} > {% for service in services %} > {{ > service.name }} > {% endfor %} > but receiving this error: > Exception Type: TemplateSyntaxError > Exception Value:Invalid block tag: 'showmenu'Try putting {% load showmenu %} before the call to the tag, for example: {% load showmenu %} {% showmenu %} {% for service in services %} {{service.name }} {% endfor %} The {% load %} tag loads a .py file that contains your custom tags. In this case it will try to load the file /project/templatetags/showmenu.py If the .py file with your custom tags had a different name, for example "mytags.py" then you would need to type a {% load mytags %} in your template before using your custom tags. Regards, Jorge Hey Jorge, I had tried that, however, this is the error I got : Exception Type: TemplateSyntaxError Exception Value:'showmenu' is not a valid tag library: Could not load template library from django.templatetags.showmenu, No module named showmenu i've created other templatetags before that loaded perfectly if i did it for a certain app, for example, /project/myapp/templatetags/tag.py but this is more of a global template tag so im not sure if my procedure in doing this is correct or not Thanks, adam --~--~-~--~~~---~--~~ 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: where does the old manipulator go?
On Thu, Jan 04, 2007 at 07:59:10PM +0530, Ramdas S wrote: I am trying to move a user registration form code inspired heavily from http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration to newforms from oldforms. Does the newforms replace django.core.manipulators, if so how can I use it? Yes it does. I just converted my comments app[1] from oldforms to newforms. You might find it useful to look at the diff. http://refried.org/viewvc/viewvc.py?view=rev=150 Nate [1] It's a direct copy of freecomments hacked to make my migration from COREBlog easier. --~--~-~--~~~---~--~~ 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: where does the old manipulator go?
Hi Ramdas, the "Right Way (tm)" how to solve this using newforms is: 1) subclass Field to create a field representing (and validating) username: class UserField( forms.Field ): def clean( self, value ): do what you must to verify username, throw validation error if you are not satisfied with the data 2) create the Form: class RegistrationForm(forms.Form): username = UserField() passwd = forms.CharField( widget=forms.PasswordInput, max_length=121 ) email = forms.EmailField(.. 3) create the view (and urls.py entry for it): def register( request ): form = RegistrationForm( request.POST ) if form.is_valid(): data = form.clean_data hoooray, we have valid entry, do what you must return httpResponseRedirect('/') return render_to_response( "register.html", { 'form' : form } ) 4) create the template {{ form }} 5) enjoy hope this helps... Honza On 1/4/07, Ramdas S <[EMAIL PROTECTED]> wrote: I am trying to move a user registration form code inspired heavily from http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration to newforms from oldforms. Does the newforms replace django.core.manipulators, if so how can I use it? To save data using a form, how else can I use the newforms without using manipulators Advice appreciated Ramdas > -- Honza Kr l E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420 606 678585 --~--~-~--~~~---~--~~ 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 with inclusion_tag
Hi Adam, On 1/3/07, stoKes <[EMAIL PROTECTED]> wrote: base.html {% showmenu %} {% for service in services %} {{ service.name }} {% endfor %} but receiving this error: Exception Type: TemplateSyntaxError Exception Value:Invalid block tag: 'showmenu' Try putting {% load showmenu %} before the call to the tag, for example: {% load showmenu %} {% showmenu %} {% for service in services %} {{service.name }} {% endfor %} The {% load %} tag loads a .py file that contains your custom tags. In this case it will try to load the file /project/templatetags/showmenu.py If the .py file with your custom tags had a different name, for example "mytags.py" then you would need to type a {% load mytags %} in your template before using your custom tags. Regards, Jorge --~--~-~--~~~---~--~~ 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: HTTP_REFERER isn't set using Explorer
ringemup schreef: Julio's hit it on the nose. Not ot mention that Firefox actually has a hidden setting for that too, and some proxies (including AOL's) also block referrers. You might be best off explicitly passing the URL of the current page as a parameter. I still find it strange that only Explorer is affected and that Firefox handles everything ok. Anyway, i'll try and implement it as a parameter. Thanks for the info, Benedict --~--~-~--~~~---~--~~ 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: Workflow engine for python?
Any docs about how write a workflow engine then? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
multiple projects one server
I'm unsure if this is a simple to answer issue or not. We've been using django simply for a while and are now starting to use it in a more production like setting. Since apache is our preferred server we tried using a single apache server with mod_python in virtual hosts. Each virtual host had its own interpreter, but for various reasons we decided it was too hard to prevent intra-interpreter interactions. The main problem being our own C accelerators; we currently don't have time to rewrite these to allow easy use with multiple interpreters/threads. Currently I am trying a two level approach with proxying; it seems to work. The apache in the second level handles only one of the upper level virtual hosts and since they are in a different process no interactions can happen. Clearly we have more apache processes than before and the restarts are harder etc etc. Is there a better way to handle this sort of thing using fastcgi or scgi? Can we get all requests from a particular host to be handled in only one group of processes. Our back end process doesn't respond well to being threaded and it can take a long time to complete so we seem to need a worker pool for each virtual host. Any ideas welcome. -- Robin Becker --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
where does the old manipulator go?
I am trying to move a user registration form code inspired heavily from http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration to newforms from oldforms. Does the newforms replace django.core.manipulators, if so how can I use it? To save data using a form, how else can I use the newforms without using manipulators Advice appreciated Ramdas --~--~-~--~~~---~--~~ 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: Unpacking in template loops
Hi! I'm just a beginner with django but I miss this functionality too. I will be glad if django loops could unpack the values of the list. Regards, 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 -~--~~~~--~~--~--~---
Re: Unpacking in template loops
Hi! I'm just a beginner with django but I miss this functionality too. I will be glad if django loops could unpack the values of the list. Regards, 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 -~--~~~~--~~--~--~---
Re: HTTP_REFERER isn't set using Explorer
On 1/4/07, Benedict Verheyen <[EMAIL PROTECTED]> wrote: Hi, This is what goes wrong in explorer: the HTTP_REFERER isn't set. With Firefox, the HTTP_REFERER is set. Any idea how i can solve this? I had this problem with a client that was running Norton and somewhere in the program preferences there's an option to disable the browser referer. This is not exactly the name of the option, you'll have to search for it. Maybe there's some application blocking, specially if there's one installed that has privacy settings. -- Julio Nobrega - http://www.inerciasensorial.com.br --~--~-~--~~~---~--~~ 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 dynamic fields (good to know)
While working on a complex form using 'newforms' I had some problem with 'initial' data. I have multiple forms using the 'prefix' argument to get different keys for them. As far as I know (*please* correct me if I am wrong) the only way to set initial data dynamically is to create the fields in __init__. Form example ('obj' is object to get initial data from): >>> import django.newforms as forms >>> class DaForm(forms.Form): ... def __init__(self, obj, *args, **kw): ... super(DaForm, self).__init__(*args, **kw) ... self.fields['time'] = forms.TimeField(initial=obj.time) ... self.fields['name'] = forms.CharField(initial=obj.name) ... # etc. >>> # No form data as we are viewing the objects. >>> form1 = DaForm(obj1, prefix='obj1') >>> form2 = DaForm(obj2, prefix='obj2') The problem with the example above is that the initial data for 'form1' is overwritten by the initial data in 'form2' so both forms give the same output. This happens because 'self.fields' belongs to the class and not the object instance. To solve this, you need to override the 'fields' attribute of the object: >>> import django.newforms as forms >>> from django.utils.datastructures import SortedDict >>> class DaForm(forms.Form): ... def __init__(self, obj, *args, **kw): ... super(DaForm, self).__init__(*args, **kw) ... self.fields = SortedDict() ... self.fields['time'] = forms.TimeField(initial=obj.time) ... self.fields['name'] = forms.CharField(initial=obj.name) ... # etc. If you have static fields combined with dynamic fields you will need to repopulate 'self.fields' from the class version. Using 'self.fields = self.fields.copy()' does not work as it returns a normal 'dict' and not a 'SortedDict'. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
HTTP_REFERER isn't set using Explorer
Hi, I have a table where i want the users to be able to edit cells by clicking on them. Then they get the usual edit view and after the changes are saved, they are redirected back to the table view. I use this in my template: It works for Firefox but unfortunately we use Explorer here and Explorer doesn't work. In the edit view i have a system where i keep track of the referrer so i can redirect the user back to the correct page: page = request.META["HTTP_REFERER"] history[1] = history[0] history[0] = page This is what goes wrong in explorer: the HTTP_REFERER isn't set. With Firefox, the HTTP_REFERER is set. I tried to solve it by using a javascript function in the template that explicitly sets the document.referrer. The td code then looks like this: onclick="edit({{patient.id}})"> The javascript function: {% block extrahead %} // Only script specific to this form goes here. // General-purpose routines are in a separate file. function edit(id) { document.referrer=window.location; window.location='/patient/edit/id/' }; {% endblock %} Unfortunately, this doesn't work for both Firefox and Explorer. In Firefox the clicking doesn't work, in Explorer, the click doesn't work and gives an error. (runtime error on the document.referrer=window.location; line) Any idea how i can solve this? Thanks, Benedict --~--~-~--~~~---~--~~ 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: Sessions without cookies for mobile sites
Have you read http://www.djangobook.com/en/beta/chapter12/ ? --~--~-~--~~~---~--~~ 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: Sessions without cookies for mobile sites
Have you read http://www.djangobook.com/en/beta/chapter12/ ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---