mod_python's request.META["SERVER_PORT"] small bug
Seems I have found small bug in core/handlers/modpython.py. Namely request.META["SERVER_PORT"] under apache is always set to 0. This is because its set to self._req.server.port in modpython.py line 88. mod_python's docs say (http://www.modpython.org/live/current/doc-html/pyapi-mpsrv-mem.html#l2h-174): port Integer. TCP/IP port number. Same as CGI SERVER_PORT. This member appears to be 0 on Apache 2.0, look at req.connection.local_addr instead (Read-Only So I think it should be: 'SERVER_PORT': str(self._req.connection.local_addr[1]), Because self._req.connection.local_addr[1] is an integer I think it should be string as other headers are. skink --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Shared Hosting suggestion
You may check http://www.djangodomain.com as well. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Test-Mail
Timothy Kesten wrote: > Hi Folks, > > sorry for this mail but I 've been getting no any Mail on this list since end > of august. That's why I try this. Yes, there's something going on with the spamfilter. My posts, but if u see this it's only if i'm the OP, get caught by the spamfilter somehow. Though my GMail mailbox it's full of Viagra stuff that doesn't get caught... now i said it... let's see if "viagra" trigged the spamfilter. ;-) Lorenzo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: DNS Change when moving site from PHP to Django
Also, you could setup things like "www2." and "media2." subdomains and point their DNS A records to the new site (and configure the new hosting account to handle them). On 9/21/06, keukaman <[EMAIL PROTECTED]> wrote: Thanks Ian. I continue to be impressed with this group and how helpfuleveryone is.Ian Holsman wrote:> put a entry in your /etc/hosts (or the windows equivalent )>> On 21/09/2006, at 8:03 AM, keukaman wrote: >> >> > I have a project where I am going to redesign a PHP/MySQL site into> > Django/Postgres.> >> > The site will be moved from a shared environment to a new, shared > > environment.> >> > One area that I am not sure about is how to set up the new site before> > changing the DNS settings to point to the new hosting facility. For> > instance, I won't be able to use " media.sitename.com" for my media> > files in the new Django site until I have moved the site.> >> > Any suggestions?> >> > > > >>> --> Ian Holsman> [EMAIL PROTECTED]-- Cam McVey[EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Python 2.5 anyone
On Thursday 21 September 2006 05:44, John DeRosa wrote: > Oliver Andrich wrote: > > Hi, > > > > I am running Django 0.95 . And so far I can't see any problems. > > How'd you do it? > > I'm on Windows XP. I installed Python 2.5 from python.org without a > problem. > > But then I found that pysqlite Windows binaries for Python 2.5 don't > exist, and neither does setuptools. Trying to install Django 0.95 on > top of Python 2.5 gives me this: pysqlite2 comes bundled with python 2.5. 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 -~--~~~~--~~--~--~---
Re: ManytoMany uploading.
On Thu, 2006-09-21 at 06:30 +, pflouret wrote: > try this: > > new_profile = UserProfile(user=new_user, permissions=permissions) > new_profile.save() > new_profile.courses = courses > new_profile.save() Tried that. Failed with "'str' object has no attribute '_get_pk_val'". -- No violence, gentlemen -- no violence, I beg of you! Consider the furniture! -- Sherlock Holmes Gabriel Puliatti [EMAIL PROTECTED] predius.org signature.asc Description: This is a digitally signed message part
Re: Problem accessing users and groups in Admin
> error" (status code 500) is the right error to be returning here. Don't > worry about that; it's doing the right thing. well yeah.. from my POV the "right" thing would be to not show these errors at all and rather work as expected :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
settings.py help please
Hi, I am Django newbee as well as getting familiar with MySQL and Python itself. I use OS X 10.4 and I amtrying to follow Django tutorial. I am testing everything on Django testing server. I have a problem with settings.py. Django is installed properly, I guess. When di import django I have no error message. MySQL works well too. However when I run syncdb.py I get this message: mysql> create database test_dj; Query OK, 1 row affected (0.02 sec) mysql> \q Bye zehi:~ zehi$ cd mysite/ zehi:~/mysite zehi$ ls __init__.py manage.py settings.pycurls.pyc __init__.pycsettings.py urls.py zehi:~/mysite zehi$ vi settings.py zehi:~/mysite zehi$ python manage.py syncdb Traceback (most recent call last): File "manage.py", line 11, in ? execute_manager(settings) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py", line 1319, in execute_manager execute_from_command_line(action_mapping, argv) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py", line 1243, in execute_from_command_line action_mapping[action]() File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py", line 426, in syncdb from django.db import connection, transaction, models, get_creation_module File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/__init__.py", line 11, in ? backend = __import__('django.db.backends.%s.base' % settings.DATABASE_ENGINE, '', '', ['']) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/backends/mysql/base.py", line 12, in ? raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb Can somebody help me? I am stacked here for several days already. Thank you. zehi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
And here is how looks settings before running syncdb.py zehi:~/mysite zehi$ vi settings.py # 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', ) ROOT_URLCONF = 'mysite.urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates". # Always use forward slashes, even on Windows. ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: ManytoMany uploading.
On Thu, 2006-09-21 at 06:42 -0500, Gabriel Puliatti wrote: > On Thu, 2006-09-21 at 06:30 +, pflouret wrote: > > try this: > > > > new_profile = UserProfile(user=new_user, permissions=permissions) > > new_profile.save() > > new_profile.courses = courses > > new_profile.save() > > Tried that. Failed with "'str' object has no attribute '_get_pk_val'". If you are assigning to a many-to-many attribute, you need to be assigning a set or list of objects (the objects being the things pointed to by the many-to-many field). You are attempting to assign a string. After you get your courses string from your form, you need to turn them into the appropriate objects (whether that means retrieving the objects from the database or creating them from scratch) and then assign that list of objects to new_profile. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
On Thu, 2006-09-21 at 11:47 +, zehi wrote: > Hi, > > I am Django newbee as well as getting familiar with MySQL and Python > itself. I use OS X 10.4 and I amtrying to follow Django tutorial. I am > testing everything on Django testing server. > > I have a problem with settings.py. Django is installed properly, I > guess. When di import django I have no error message. MySQL works well > too. > > However when I run syncdb.py I get this message: > > mysql> create database test_dj; > Query OK, 1 row affected (0.02 sec) [...] > zehi:~/mysite zehi$ python manage.py syncdb [...] > line 12, in ? > raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb > module: No module named MySQLdb > > > Can somebody help me? I am stacked here for several days already. Looks like you don't have the MySQLdb Python module installed (the piece that tells Python how to communicate with MySQL). This is a separate module -- it doesn't come standard with Python. If you think you do have this module already installed, the following should work from a Python prompt. >>> import MySQLdb If that raises any errors (and I suspect it will at the moment in your case), then you don't have the module installed correctly. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: ManytoMany uploading.
Hello Gabriel, Instead of courses = new_data['courses'] use courses = new_data.getlist('courses') The "courses" is not a string, but a class similar to a list type (I don't remember the name of that class). The last item of that list is the representation of that class. Therefore, you see 2 if something till 2 is selected and you see 3 if something until 3 is selected. And "getlist" is the method to get a list of all its items (i.e.: [1,3]). I hope this will help you to solve your problem. To make it clear what is what, play around with Python IDE: python manage.py shell Good luck! Aidas Bendoraitis [aka Archatas] On 9/21/06, Gabriel Puliatti <[EMAIL PROTECTED]> wrote: > Hey, I'm trying to write a manytomany into the database. I have created > the form correctly, using {{ form.courses }}, and I can upload > everything. The problem comes when writing the data to the database. I > take the field as following: > courses = new_data['courses'] > And then to write it, I do the following: > new_profile = UserProfile(user=new_user, > courses=courses, > permissions=permissions) > > Problem is, I get "'courses' is an invalid keyword argument for this > function". > > If I try to print courses, I get a number. 1 if I choose the first > option, 2 if I choose option 2 and 1 or just 2, and 3 if I choose three > in any way, with others or alone. > > What exactly do I need to do with this to write it into the database? > > > -- > No violence, gentlemen -- no violence, I beg of you! Consider the > furniture! > -- Sherlock Holmes > > Gabriel Puliatti > [EMAIL PROTECTED] > predius.org > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
> raise ImproperlyConfigured, "Error loading MySQLdb module: > %s" % e django.core.exceptions.ImproperlyConfigured: Error > loading MySQLdb module: No module named MySQLdb Your python installation lacks the python-module name 'MySQLdb' to access MySQL databases. If you were on Debian, you would probably just apt-get install python-mysqldb and be done. But for Mac OS X you should ask the right guru's or search at google for web site ´a la "Installing Django on Mac OS X". --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
Thank you guys, Last login: Thu Sep 21 13:33:04 on ttyp1 Welcome to Darwin! zehi:~ zehi$ python Python 2.4.3 (#1, Mar 30 2006, 11:02:15) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb Traceback (most recent call last): File "", line 1, in ? ImportError: No module named MySQLdb >>> Even Django is installed properly (I think...)). Not sure how to install MySQLdb . for OS X 10.4 I am following "Installing Django on Mac OS X" word by word, but still can't get things run. Somebody have some experience? Thank you, zehi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: ManytoMany uploading.
On 9/21/06, Aidas Bendoraitis <[EMAIL PROTECTED]> wrote: > courses = new_data.getlist('courses') Hm, I used that. I can print new_data.getlist('courses') and get the list, but when I try to assign it to a variable for writing, I get "'str' object has no attribute '_get_pk_val'" However, this only happens when I do new_profile.save(). When I try to write what you said, it works and I can print, but the same happens when trying to save. -- No violence, gentlemen -- no violence, I beg of you! Consider the furniture! -- Sherlock Holmes Gabriel Puliatti [EMAIL PROTECTED] predius.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
Has your Music model a __str__ method? Maybe you get nothing using {{ form.music }} because it is represented in no way. Have you tried {{ form.music.title }} or similar? As far as I know, instance.music_id refers to the id of the related object whereas instance.music refers to the object itself. Good luck! Aidas Bendoraitis [aka Archatas] On 9/20/06, patrickk <[EMAIL PROTECTED]> wrote: > > > Am 20.09.2006 um 21:40 schrieb Ivan Sagalaev: > > > > > patrickk wrote: > >> thanks. the data is sent now, but > >> - how do I save the data in my custom manipulator, referring to: > >> temp.set_music(data['music']) > > > > It looks like 0.91 syntax. If you're using contemporary Django it > > should > > look like this: > > > > temp.music = Music.objects.filter(id__id=data['music']) > > doesn´t work. > I also tried: > temp.music = Music.objects.filter(id__id=data.getlist('music')) > > > > >> - how do I display the data (already in the database) on my site, > >> ref. to: > >> new_data = user_profile_manipulator.flatten_data() > >> > >> additionally: I don´t understand why I have to write > >> {{ form.music_id }} instead of {{ form.music }} - it´s the same with > >> foreign keys. > > > > In fact {{ form.music }} should work... > > doesn´t work either - when using {{ form.music }} I get nothing, with > {{ form.music_id }} the output looks ok. > > > > > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
On 9/21/06, zehi <[EMAIL PROTECTED]> wrote: > > Thank you guys, > > Last login: Thu Sep 21 13:33:04 on ttyp1 > Welcome to Darwin! > zehi:~ zehi$ python > Python 2.4.3 (#1, Mar 30 2006, 11:02:15) > [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import MySQLdb > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named MySQLdb > >>> > > Even Django is installed properly (I think...)). > > Not sure how to install MySQLdb . for OS X 10.4 > > I am following "Installing Django on Mac OS > X" word by word, but still can't get things run. > Under the "Get your database running" section of the install doc, it states that you have to have MySQLdb already installed. It also provides a link to where you can get MySQLdb. It's up to you to go to that link and download/install the package. In short, you'll download it, go to the download directory inside Terminal.app, and type 'python setup.py install' You also have to make sure you have MySQL itself installed (ie. the actual database, not just the Python wrappers). 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 -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
Aidas Bendoraitis wrote: > Has your Music model a __str__ method? Maybe you get nothing using {{ > form.music }} because it is represented in no way. In fact {{ form.music }} has nothing to do with the model itself. It's a manipulator's field and should be represented as a group of checkboxes. I have no idea why it's not working... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
On 21-Sep-06, at 6:28 AM, zehi wrote: > Not sure how to install MySQLdb . for OS X 10.4 > > I am following "Installing Django on Mac OS > X" word by word, but still can't get things run. > > Somebody have some experience? Hi zehi, Bob Ippolito built an OS X package for MySQLdb. You can get it here: http://pythonmac.org/packages/py24-fat/ Beau --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Python 2.5 anyone
On 9/20/06, John DeRosa <[EMAIL PROTECTED]> wrote: [snip] > > It seems a little screwy for a file in a directory called "sqlite3" to > do an import from "pysqlite2". But that's what it does. > What you need to realize is that "sqlite" refers to the database, while "pysqlite" are the python bindings to that database. SQLite is currently up to version 3.x. The python bindings required to use SQLite3 are up to version 2.x - thus "pysqlite2". It would seem that in Python2.5 they tried to avoid this confusion by naming the python bindings the same as the version of SQLite they are a wrapper for. While this certainly makes sense, it is not backward compatable as any existing projects would be importing from pysqlite2 as you found out. It looks this this is being addressed in ticket 2772 [1]. For more info on the new sqlite3 wrapper, see [2]. [1]: http://code.djangoproject.com/ticket/2772 [2]: http://docs.python.org/dev/whatsnew/modules.html#SECTION000144 -- Waylan Limberg [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: way to tell admin *not* to display a model?
That gives me an error in the admin: (1054, "Unknown column 'page_text._order' in 'order clause'") My case is almost identical to the example in the documentation: class Text(models.Model): page = models.ForeignKey(Page, db_index=True, edit_inline=models.STACKED) # ... class Meta: order_with_respect_to = 'page' I also noticed a bug, I think: With class Admin ordering the inlined models were ordered by the column I provide. With class Meta ordering they are not. Meta ordering does order them in their own model list but not if the model is inlined. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Problem with patch 2070
Problem verified. It may be that the file is parsed as text and not a file somehow. So fieldstorage does not make a temporary file. Got no solution so far. :| --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: variable multiple filter question
DavidA escreveu: > You build up a dynamic "and" query with a term for each checked box in > the UI. Then you use that compound query to filter your model objects. > > Now that I think about it, since this is an "and" you could also do: > > def my_view(request): > query = {} > for i in range(1, 13): > chk = "var%d" % i > if request.has_key(chk) and request[key]: > query[chk] = True > > objects = MyModel.objects.filter(**query) > I would like to thank you all for your help. I'm using an expression similar to the above example and it works flawlessly! Regards, Luis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
thanks for your help (especially ivan). are there any workarounds? I´m still not able to save and retrieve the m2m-data. and since I have to meet a deadline I´m getting kind of nervous. thanks, patrick Am 21.09.2006 um 16:52 schrieb Ivan Sagalaev: > > Aidas Bendoraitis wrote: >> Has your Music model a __str__ method? Maybe you get nothing using {{ >> form.music }} because it is represented in no way. > > In fact {{ form.music }} has nothing to do with the model itself. > It's a > manipulator's field and should be represented as a group of > checkboxes. I have no idea why it's not working... > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: threadlocals with limit_choices_to in models
:| Apologiz for saying it worked!!! It doesn't work after some times even after restarting apache every 15 minutes!!! So the question is always there. And it seems I am not the only to hav this problem --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Django Security
I'm preparing to make a case for switching many of my library's stupendously fugly JSP applications to Django. There are many selling points to Django (ease of use, speed, etc.) However, there's one point that I'd like more information on: Security. Although I know that Django has a great track-record with security, I still need more concrete evidence to show to non-web-app people to convince them that Django is easily secured. Listing the major websites that run Django is one way to convince them of this, but I still need more. Are there any Django security presentations or papers out there that would help me make my case to the higher-ups? Perhaps there are some tutorials about securing Django webapps which I can use to show how Django is easily secured? Thanks in advance- Tyson Tate --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Handling 404
Let me refrase this. When having DEBUG = True in settings.py I'm getting django's nice 404 error pages. However, when I switched DEBUG to False I started getting the above traceback. I was expecting to start getting the contents of the 404.html template I wrote. What am I missing? regards, Filipe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Best way to run dev and production site concurrently on same server? (take 2)
Found this thread on the same topic http://groups.google.com/group/django-users/browse_frm/thread/7a2d69fa8748ba68 ..but it got closed. I want to do the same things as the OP in that thread: > I've recently completed a first milestone of a project and want to > publish it. I've got two URLs: www.mydomain.com and dev.mydomain.com. > I'm not too concerned if dev is public, I just don't want to break the > production website while I'm developing. > > What's the best way to handle this? The difference between what I'm trying to do and the OP in that thread is (apparently) that I've got different databases for each subdomain. The problem I'm having is that the www domain is using the settings for the test domain, and ends up pulling from its database. At this point, I can't tell if I'm having an apache config problem, a mod_python directive problem, or a django problem. The relevant portions of my two vhost definitions: ServerName test.mysite.com ### setup django stuff SetEnv DJANGO_SETTINGS_MODULE mysite.settings SetHandler python-program PythonHandler django.core.handlers.modpython PythonAutoReload On PythonDebug On PythonPath "['/home/django-code/test.mysite.com/'] + sys.path" PythonInterpreter mysite-test ServerName mysite.com ServerAlias www.mysite.com ### setup django stuff SetEnv DJANGO_SETTINGS_MODULE mysite.settings SetHandler python-program PythonHandler django.core.handlers.modpython PythonDebug Off PythonPath "['/home/django-code/www.mysite.com/'] + sys.path" PythonInterpreter mysite-www www settings file: /home/django-code/www.mysite.com/mysite/settings.py test settings file: /home/django-code/test.mysite.com/mysite/settings.py PYTHONPATH doesn't contain any references to either (only base Python components & locations) I've double-checked each settings.py file and verified that the DB info is in fact different, so it's nothing that obvious (at least to me). I suspect that my issue isn't Django related at all, but I couldn't be sure. I didn't *think* that the sites angle (as covered in the original thread) was relevant to my situation, since I've got completely separate databases for each. Any pointers? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: ManytoMany uploading.
On 9/21/06, Gabriel Puliatti <[EMAIL PROTECTED]> wrote: > Hm, I used that. I can print new_data.getlist('courses') and get the > list, but when I try to assign it to a variable for writing, I get > "'str' object has no attribute '_get_pk_val'" > > However, this only happens when I do new_profile.save(). When I try to > write what you said, it works and I can print, but the same happens > when trying to save. Never mind, it's fixed now. I followed Malcolm's advice and got the things from the database, using the id. Took me a while to figure it out. :P Thanks for all, guy. -- No violence, gentlemen -- no violence, I beg of you! Consider the furniture! -- Sherlock Holmes Gabriel Puliatti [EMAIL PROTECTED] predius.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Sample code for progress bar using patch 2070?
Would anyone be willing to share the important bits of code required to use the progress bar included in UploadProgress.js from the 2070 patch? I've never done anything with ajax before and am a little lost on how this is supposed to work. Thanks! Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
patrickk wrote: > are there any workarounds? > I´m still not able to save and retrieve the m2m-data. and since I > have to meet a deadline I´m getting kind of nervous. In your view code you use flatten_data() but I can't see it defined in your custom manipulator. This must raise an exception but since you say that it kinda works (just not right) I suspect you have omitted it from you mail. Can you post it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
Still not successfull When trying to install MySQLdb I'm getting this error: zehi:~/Desktop/MySQL-python-1.2.1_p2 zehi$ python setup.py build sh: line 1: mysql_config: command not found sh: line 1: mysql_config: command not found sh: line 1: mysql_config: command not found sh: line 1: mysql_config: command not found sh: line 1: mysql_config: command not found running build running build_py copying MySQLdb/release.py -> build/lib.macosx-10.4-fat-2.4/MySQLdb error: could not delete 'build/lib.macosx-10.4-fat-2.4/MySQLdb/release.py': Permission denied zehi:~/Desktop/MySQL-python-1.2.1_p2 zehi$ Not sure what's wrong? Thank you, zehi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
flatten_data() doesn´t relate to the custom manipulator but to model resp. the changemanipulator. btw, the table we´re talking about is extending the user model, it´s a one-to-one relation - but I guess that shouldn´t be the problem. i just reinstalled the whole project, generated all the tables and refilled them. nothing changed. patrick Am 21.09.2006 um 22:02 schrieb Ivan Sagalaev: > > patrickk wrote: >> are there any workarounds? >> I´m still not able to save and retrieve the m2m-data. and since I >> have to meet a deadline I´m getting kind of nervous. > > In your view code you use flatten_data() but I can't see it defined in > your custom manipulator. This must raise an exception but since you > say > that it kinda works (just not right) I suspect you have omitted it > from > you mail. Can you post it? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
patrickk wrote: > flatten_data() doesn´t relate to the custom manipulator but to model > resp. the changemanipulator. I see now... And if I'm guessing correctly you're creating a FormWrapper from user_profile_manipulator that just doesn't have that checkbox field. Anyway making two manipulators is unnecessary and I can't even imagine how is this supposed to work :-). Now, if I understand your task you want a form for your user profile but with multiple checkboxes for 'music' field. Right? Then you can inherit you manipulator from automatic UserProfile.ChangeManipulator and replace this field with what you need: class UserProfileManipulator(UserProfile.Manipulator): def __init__(self, id): UserProfile.Manipulator.__init__(self, id) # Finding and removing standard field for field in self.fields: if field.field_name == 'music': self.fields.remove(field) break # Adding custom field MUSIC_CHOICES = [(str(c.id), str(c)) for c in Music.objects.all()] self.fields.append(forms.CheckboxSelectMultipleField( 'music', choices=MUSIC_CHOICES)) Does it make sense? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: threadlocals with limit_choices_to in models
ibson wrote: > :| > Apologiz for saying it worked!!! It doesn't work after some times even > after restarting apache every 15 minutes!!! > So the question is always there. And it seems I am not the only to hav > this problem Yep. I've also a problem with this, but for me it's simply doesn't work at all. I'm using the info in http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser plus "limit_choices_to" like ibson but with no success. Anyone could bring some light on this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
well, now I´m totally confused. I though that´s exactly what custom manipulators are here for: "You can easily create your own custom manipulators for handling custom forms." (django documentation). more below ... Am 21.09.2006 um 22:47 schrieb Ivan Sagalaev: > > patrickk wrote: >> flatten_data() doesn´t relate to the custom manipulator but to model >> resp. the changemanipulator. > > I see now... And if I'm guessing correctly you're creating a > FormWrapper > from user_profile_manipulator that just doesn't have that checkbox > field. that´s right. user_profile_manipulator doesn´t have that checkbox field. in the model, the relation is defined as: music = models.ManyToManyField(Music, blank=True, null=True, related_name='music') at this point, there is nothing defined about *how* to display that relation (e.g. using checkboxes). > > Anyway making two manipulators is unnecessary and I can't even imagine > how is this supposed to work :-). as mentioned above, I thought that´s the primary use-case for custom manipulators: the custom manipulator handles the custom form the changemanipulator handles the data is that wrong? > > Now, if I understand your task you want a form for your user > profile but > with multiple checkboxes for 'music' field. Right? Then you can > inherit you manipulator from automatic > UserProfile.ChangeManipulator and > replace this field with what you need: > > class UserProfileManipulator(UserProfile.Manipulator): >def __init__(self, id): > UserProfile.Manipulator.__init__(self, id) > > # Finding and removing standard field > for field in self.fields: >if field.field_name == 'music': > self.fields.remove(field) > break > > # Adding custom field > MUSIC_CHOICES = [(str(c.id), str(c)) >for c in Music.objects.all()] > self.fields.append(forms.CheckboxSelectMultipleField( >'music', >choices=MUSIC_CHOICES)) > > Does it make sense? some thoughts on that: 1. if I do it that way, I´m having checkboxes in the admin-interface, right? 2. is that the standard way to do it? it seems really complicated (ref. to finding and removing fields)? 3. instead of "finding and removing a field" - why not write a custom manipulator, add specific validation etc.? your suggestion might work, but (to me) it doesn´t seem like the "django way" to do that. thanks a lot for your help. gotta get some sleep, 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 -~--~~~~--~~--~--~---
Re: settings.py help please
On Sep 21, 2006, at 1:17 PM, zehi wrote: > > Still not successfull > > When trying to install MySQLdb I'm getting this error: > > zehi:~/Desktop/MySQL-python-1.2.1_p2 zehi$ python setup.py build > sh: line 1: mysql_config: command not found > sh: line 1: mysql_config: command not found > sh: line 1: mysql_config: command not found > sh: line 1: mysql_config: command not found > sh: line 1: mysql_config: command not found > running build > running build_py > copying MySQLdb/release.py -> build/lib.macosx-10.4-fat-2.4/MySQLdb > error: could not delete > 'build/lib.macosx-10.4-fat-2.4/MySQLdb/release.py': Permission denied > zehi:~/Desktop/MySQL-python-1.2.1_p2 zehi$ > > Not sure what's wrong? You probably need the source code headers for MySQL, at least that's how it works with psycopg (the Postgres python bindings library). That is a separate package you need to install, it should have a name like MySQL-devel. Make sure that you read the README. Don --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
patrickk wrote: > well, now I´m totally confused. > I though that´s exactly what custom manipulators are here for: > "You can easily create your own custom manipulators for handling > custom forms." (django documentation). All manipulators handle forms: - prepare initial data - validate data - save data or redisplay the form with errors Automatic manipulators just know how to construct their fields based on model's fields. > that´s right. user_profile_manipulator doesn´t have that checkbox field. > in the model, the relation is defined as: > music = models.ManyToManyField(Music, blank=True, null=True, > related_name='music') > > at this point, there is nothing defined about *how* to display that > relation (e.g. using checkboxes). In fact there is a default representation for every Django data field. For ManyToManyField it is SelectMultipleField. > as mentioned above, I thought that´s the primary use-case for custom > manipulators: > the custom manipulator handles the custom form > the changemanipulator handles the data > > is that wrong? Yes. One manipulator is intended to handle one form entirely. You need a custom manipulator only if an automatic one doesn't work as you want it. > some thoughts on that: > 1. if I do it that way, I´m having checkboxes in the admin-interface, > right? No. Admin code won't know anything about your manipulator and will use automatic ChangeManipulator (with SelectMultiple for your 'music'). For completeness: to make it work in admin you could create a new _model_ field as a subclass of ManyToManyField and make CheckboxMultipleField its default manipulaator field class. > 2. is that the standard way to do it? it seems really complicated > (ref. to finding and removing fields)? I wouldn't call it "standard" but for me it seems pretty straightforward. I use it often and have convenience function for removing fields by name. > 3. instead of "finding and removing a field" - why not write a custom > manipulator, add specific validation etc.? You could. This is truly depend on the amount of differences between automatic behavior and what you want. If you want a form that is mostly similar to an automatic one but with some small bits changed then it makes sense to change automatic behavior. Because if you create a custom manipulator you will need to repeat all the definitions for all the fields that automatic manipulators do based on model. And keep updating manipulator when you change a model. But if your form is more custom and consists mostly of fields that don't belong to one model then it is more convenient to create a custom manipulator from scratch. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
syncdb threw exception because libpq.so.4 could not be found
I am a newbee with django. I tried to run "python manage.py syncdb" on RHEL 4.0 Linux box and got the following. It looks like django did not have its lib path set correctly. Please advise on how I can rectify this problem. Thanks in advance. python manage.py syncdb Traceback (most recent call last): File "manage.py", line 11, in ? execute_manager(settings) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/core/management.py", line 1319, in execute_manager execute_from_command_line(action_mapping, argv) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/core/management.py", line 1243, in execute_from_command_line action_mapping[action]() File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/core/management.py", line 426, in syncdb from django.db import connection, transaction, models, get_creation_module File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/__init__.py", line 11, in ? backend = __import__('django.db.backends.%s.base' % settings.DATABASE_ENGINE, '', '', ['']) File "/usr/lib/python2.3/site-packages/Django-0.95-py2.3.egg/django/db/backends/postgresql/base.py", line 12, in ? raise ImproperlyConfigured, "Error loading psycopg module: %s" % e django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: libpq.so.4: cannot open shared object file: No such file or directory --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: syncdb threw exception because libpq.so.4 could not be found
On Thu, 2006-09-21 at 15:54 -0700, [EMAIL PROTECTED] wrote: > I am a newbee with django. > > I tried to run "python manage.py syncdb" on RHEL 4.0 Linux box and got > the following. It looks like django did not have its lib path set > correctly. Please advise on how I can rectify this problem. This looks like a Python installation problem, rather than a Django one. It's basically going to depend a lot on how your system is set up. Does importing psycopg work from the interactive prompt? For example, `--> python Python 2.4.3 (#1, Jun 13 2006, 11:46:22) [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import psycopg >>> Hopefully the same error will appear at that point (it should do, since you are seeing the error at syncdb time). It sounds like psycopg was not built against the version of PostgreSQL you have installed on your system, or something like that. Does ldd /usr/lib64/python2.4/site-packages/psycopgmodule.so (adjust the path to point to your real Python site-packages directory) provide any clues. It should show that this is linked against libpq.so.4 and also provide a pointer to where it thinks libpq.so.4 can be found. Something like libpq.so.4 => /usr/lib64/libpq.so.4 (0x2abdd000) If you see ??? after the "=>", then you either don't have Postgresql installed (unlikely), or you need to start looking at things like /etc/ld.so.conf to get the right library paths pulled in or setting up LD_LIBRARY_PATH correctly. Google around for things like LD_LIBRARY_PATH or consult your sys-admin if you have trouble fixing that. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
On 9/21/06, Don Arbow <[EMAIL PROTECTED]> wrote: > > On Sep 21, 2006, at 1:17 PM, zehi wrote: > > > > Still not successfull > > > > When trying to install MySQLdb I'm getting this error: > > > > zehi:~/Desktop/MySQL-python-1.2.1_p2 zehi$ python setup.py build > > sh: line 1: mysql_config: command not found > > sh: line 1: mysql_config: command not found > > sh: line 1: mysql_config: command not found > > sh: line 1: mysql_config: command not found > > sh: line 1: mysql_config: command not found > > running build > > running build_py > > copying MySQLdb/release.py -> build/lib.macosx-10.4-fat-2.4/MySQLdb > > error: could not delete > > 'build/lib.macosx-10.4-fat-2.4/MySQLdb/release.py': Permission denied > > zehi:~/Desktop/MySQL-python-1.2.1_p2 zehi$ > > > > Not sure what's wrong? > > The MySQL on OS X installs some binaries into /usr/local/mysql/bin. Make sure that directory is on your PATH before running the setup.py install. 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 -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
I don´t want to stress your help, but do you know where to find an example on using a custom manipulator for *updating* data. question is, where does the custom manipulator gets the data (stored in the database) from. the way I did it so far: 1. using a changmanipulator to get and display the data 2. using a custom manipulator to handle the form, do validation and save the data when you´re saying that I should only use *one* manipulator, there has to be a possibility to get the data with the custom manipulator. something like: manipulator = UserProfile.MyCustomManipulator(user_id) sorry for being slow off the mark here, but that really contradicts my reading of the documentation. thanks again, patrick Am 21.09.2006 um 23:27 schrieb Ivan Sagalaev: > > patrickk wrote: >> well, now I´m totally confused. >> I though that´s exactly what custom manipulators are here for: >> "You can easily create your own custom manipulators for handling >> custom forms." (django documentation). > > All manipulators handle forms: > - prepare initial data > - validate data > - save data or redisplay the form with errors > > Automatic manipulators just know how to construct their fields > based on > model's fields. > >> that´s right. user_profile_manipulator doesn´t have that checkbox >> field. >> in the model, the relation is defined as: >> music = models.ManyToManyField(Music, blank=True, null=True, >> related_name='music') >> >> at this point, there is nothing defined about *how* to display that >> relation (e.g. using checkboxes). > > In fact there is a default representation for every Django data field. > For ManyToManyField it is SelectMultipleField. > >> as mentioned above, I thought that´s the primary use-case for custom >> manipulators: >> the custom manipulator handles the custom form >> the changemanipulator handles the data >> >> is that wrong? > > Yes. One manipulator is intended to handle one form entirely. You > need a > custom manipulator only if an automatic one doesn't work as you > want it. > >> some thoughts on that: >> 1. if I do it that way, I´m having checkboxes in the admin-interface, >> right? > > No. Admin code won't know anything about your manipulator and will use > automatic ChangeManipulator (with SelectMultiple for your 'music'). > > For completeness: to make it work in admin you could create a new > _model_ field as a subclass of ManyToManyField and make > CheckboxMultipleField its default manipulaator field class. > >> 2. is that the standard way to do it? it seems really complicated >> (ref. to finding and removing fields)? > > I wouldn't call it "standard" but for me it seems pretty > straightforward. I use it often and have convenience function for > removing fields by name. > >> 3. instead of "finding and removing a field" - why not write a custom >> manipulator, add specific validation etc.? > > You could. This is truly depend on the amount of differences between > automatic behavior and what you want. > > If you want a form that is mostly similar to an automatic one but with > some small bits changed then it makes sense to change automatic > behavior. Because if you create a custom manipulator you will need to > repeat all the definitions for all the fields that automatic > manipulators do based on model. And keep updating manipulator when you > change a model. > > But if your form is more custom and consists mostly of fields that > don't > belong to one model then it is more convenient to create a custom > manipulator from scratch. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: settings.py help please
On 22-Sep-06, at 1:47 AM, zehi wrote: > Not sure what's wrong? sudo python setup.py build install -- 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 -~--~~~~--~~--~--~---
Filtering foreign key by User (LazyUser)
Hey, I'm basically trying to filter a foreign key (using limit_choices_to) by an user (just like in this thread http://groups.google.com/group/django-users/browse_thread/thread/8006b7e493ef877d/79d5c10c3abab725?lnk=st&q=limit_choices_to+threads&rnum=2#79d5c10c3abab725) The model is quite simply, as you may guess: class Practica(models.Model): asignatura = models.ForeignKey(Asignatura, blank=False, limit_choices_to = {'owner' : ##current_user##}) class Asignatura(models.Model): owner = models.ForeignKey(User, blank=False, limit_choices_to={'is_staff__exact' : 1}) The first limit_choices_to is the one which is not working. I tried threadlocals (http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser) unsucessfully ( limit_choices_to = {'owner' : get_current_user()}) ). I realized that the evaluation of get_current_user() wasn't done during runtime but just once at the very beggining. So I guessed that a lazy version of get_current_user should be needed for that (as Luke suggested in this other thread: http://groups.google.com/group/django-users/browse_thread/thread/5d89dc0c2aa3927b/f19dba6f48bb6060?lnk=gst&q=lazyuser&rnum=1#f19dba6f48bb6060) And then I discovered LazyUser in django/contrib/auth/middleware.py (http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/middleware.py?rev=3754) It is not documented any where, and not found very much information about. Neither it is used in django trunk code. So I tried to use it with limit_choices_to like somekind of LazyDate(), but with, again, no results. Also I'm not pretty sure what kind of object it returns. Maybe some django-guru could help me in this?? I'm very surprised this is not a hot django topic and not so much information can be found in google about it. I can't believe that no one has needed this before... thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: seeking clarification: custom manipulator foreign key / many-to-many
patrickk wrote: > I don´t want to stress your help, but do you know where to find an > example on using a custom manipulator for *updating* data. > > question is, where does the custom manipulator gets the data (stored > in the database) from. > the way I did it so far: > 1. using a changmanipulator to get and display the data > 2. using a custom manipulator to handle the form, do validation and > save the data > > when you´re saying that I should only use *one* manipulator, there > has to be a possibility to get the data with the custom manipulator. > something like: manipulator = UserProfile.MyCustomManipulator(user_id) Since it's custom manipulator it's all up to you how to retrieve data. The most straightforward way is to copy the common behavior: implement flatten_data: class MyCustomManipulator(forms.Manipulator): def __init__(self, id): self.original_object = Model.objects.get(pk=id) self.fields= [ ... ] def flatten_data(): return dict([(field.name, getattr(t, field.attname)) for field in self.original_object._meta.fields]) This is a very simple implementation of flatten_data. It doesn't handle ManyToManyField for example. But the idea is that you have to return a dict with keys corresponding to your manipulator field names. > sorry for being slow off the mark here, but that really contradicts > my reading of the documentation. Why that? Docs never say that you should use different manipulators for giving away and accepting data. However it really lacks more advanced examples of using custom manipulators... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---