Re: no newforms.TextField() available?!?!?
James Bennett schrieb: > On 6/25/07, Jens Diemer <[EMAIL PROTECTED]> wrote: >> This works: >> mail_text = forms.CharField(widget=forms.Textarea) > > That's by design. Whether to show an input type="text" or a textarea > is a matter of widgets, so you differentiate between them by using > different widgets. > Thanks for the info ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
python manage.py startapp freepostcards
Dear Djangoers: I have thoroughly enjoyed the last few months on this list, yet I must take a temporary leave. Starting on the 30th I'm heading for a tour around SE Asia -- Hong Kong, China, Tibet, Laos, Cambodia and Vietnam. Eventually I will end up in Sydney. So why am I making this public? I wanted to make an offer to the community: if you want a postcard, shoot me a private email with a mailing address or PO box. There are going to be some long bus/train rides, and I need something to kill the time with. If you receive a postcard and feel like dropping a dollar into my paypal account to cover postage, that would be nice, but certainly not necessary. Cheers to Django, Kelvin -- Kelvin Nicholson Voice: +886 9 52152 336 Voice: +1 503 715 5535 GPG Keyid: 289090AC Data: [EMAIL PROTECTED] Skype: yj_kelvin Site: http://www.kelvinism.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: CachedDnsName - very slow under apache/mod_python ...
On Jun 26, 12:55 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2007-06-25 at 19:39 -0700, ZebZiggle wrote: > > Howdy! > > > Emails were taking 15s to send each. Upon investigation it came down > > to CachedDnsName in django.core.mail. Specifically, the > > socket.getfqdn() call. Also, it *always* happened, not just on > > startup. So it seems the call was timing out and the cache wasn't > > effective. > > > The strange part is, it works fine in a dev environment or from the > > production command line, but under apache/mod-python the killer time > > delay kicks in. > > > Any idea what could be different here? > > If that file is being reimported a lot because the Python processes are > restarting it will be run each time. You could try printing the PID -- > os.getpid() -- or something similar to verify that. Remembering that under mod_python to get a 'print' statement to appear in the Apache error log promptly you need to flush the stream Thus: import sys, os print os.getpid(), "Some message" sys.stdout.flush() To see in what way mod_python may be the cause, might suggest running your Apache with the Apache configuration: StartServers 1 ServerLimit 1 This will ensure that only one Apache child process is run and thus that each request goes to the same process. If there is therefore a delay because of this DNS caching setup, it should only occur on the first request and not subsequent requests. If instead it occurs on every request, then something more serious is happening. An alternative to changing Apache configuration is to stop Apache and run it in debug mode. apachectl stop httpd -X In this mode it runs everything in one process, ie., not even a separate child process. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQLdb problem
This solution would work if the version of Python I had installed was 2.4, unfortunately I am on 2.5 does not have a binary package for 2.5 and it seems that a work around is not around. I am wondering if I can just uninstall 2.5 and install 2.4 and go from there. Thanks for trying to put me on the right track StephenF. -Silhyon On Jun 20, 11:10 pm, StephenF <[EMAIL PROTECTED]> wrote: > Silhyon, > I had a similar problem with MySQLdb concerning a different Library on > my MacBook pro. > > Check out this > page:http://www.agapow.net/programming/python/installing-mysqldb > > Towards the bottom of his post you will see a bit about "Later News" > where he describes a problem similar to yours. > The fix for me was to "delete the mySQLdb egg and delete the line > referring to it in the easy-install.pth file." and then reinstall > MySQLdb using the Mac Binary Package instead of from the tarball. > > Hopefully this will work for you as well, > -Stephen > > On Jun 20, 10:11 am, Silhyon <[EMAIL PROTECTED]> wrote: > > > I am trying to install MySqldb on my Macbook Pro for development > > purpose, but I keep running into problems when I check to see if > > MySQLdb has installed right when I use it in the python console. > > Before I get to the problem I should let everyone know the specs of my > > machine. > > > I am running OSX 10.4.9 on a "Santa Rose" Macbook Pro > > Python Version: 2.5 (r25:51918) > > MySql Version: 5.0.41 > > MySQLdb Version: 1.2.2 > > > Now the problem I am running into seem similar to the one that was > > causing a MySQL with ruby on rails. The problem was rails not being > > able to find where the new install had put MySQL's > > libmysqlclient_r.dylib. > > > Here is the print out I am getting: > > > Traceback (most recent call last): > > File "", line 1, in > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > > python2.5/site-packages/PIL/__init__.py", line 19, in > > > File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 7, in > > > > File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 6, in > > __bootstrap__ > > ImportError: dlopen(/Users/silhyon/.python-eggs/MySQL_python-1.2.2- > > py2.5-macosx-10.3-fat.egg-tmp/_mysql.so, 2): Library not loaded: /usr/ > > local/mysql/lib/mysql/libmysqlclient_r.15.dylib > > Referenced from: /Users/silhyon/.python-eggs/MySQL_python-1.2.2- > > py2.5-macosx-10.3-fat.egg-tmp/_mysql.so > > Reason: image not found > > > I am unsure of how to fix this problem and googling has got me > > nothing. Any help would be appreciated on this matter. Also I am > > fairly new to Django and Python itself but am ok with using the > > terminal and with terminal commands. > > > Thanks to all answers 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?hl=en -~--~~~~--~~--~--~---
Re: CachedDnsName - very slow under apache/mod_python ...
On Jun 25, 11:55 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > (for example, a setting for the fqdn so that we don't even do the lookup > if the setting exists). I like that idea. I should be able to just set DNS_NAME myself from the calling module. Let me investigate. Thx guys, Sandy --~--~-~--~~~---~--~~ 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: list_filter in newforms-admin doesn't worj
On Mon, 2007-06-25 at 16:10 +, abe wrote: > > I'm using the newforms-admin branch, and have specified > some admin options for a Experiment model like this > > > class ExperimentalDataOptions(admin.ModelAdmin): > list_display = > ('project_name','experiment_nr','experiment_date','short_title') > search_fields = > ('experiment_nr','project_name','experiment_date','title') > list_filter = ('project_name',) # > 'experiment_date','project_name',) > > > if I leaveout the list_filter line it works ok. > with list_filter I get the following message > > AttributeError at /yyy/admin/zb/experimentaldata/ > type object 'ModelAdmin' has no attribute 'manager' > Request Method: GET > Request URL: https://xxx.xxx.xxx.xxx/yyy/admin/zb/experimentaldata/ > Exception Type: AttributeError > Exception Value: type object 'ModelAdmin' has no attribute 'manager' > Exception Location: /usr/lib/python2.3/site-packages/django/contrib/ > admin/filterspecs.py in __init__, line 161 > Python Executable:/usr/bin/python > Python Version: 2.3.4 > > > Any idea how to get this working? I can't immediately see what is wrong. You'll either have to dive into the code and work out what should be happening, or file a ticket in Trac. Bugs reported to this list are not too likely to be remembered by the newforms-admin developers when they next come to work on the code. It's just too high-volume here to be an effective bug reporting forum. If you do file a ticket, include the smallest example possible that fails. That might be a single field model with an admin class that only has list_filter or something. That will make it easier for somebody to repeat the problem. 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?hl=en -~--~~~~--~~--~--~---
Re: Forms and formating error messages
On Mon, 2007-06-25 at 08:22 -0700, AnaReis wrote: > Hi, > I was trying to change the way in which the errors are presented in a > form. > I tried to put them in: > {{field.label}}:{{field}}{% if > field.field.required %}*{%endif%} td>{%if field.errors%}{{field.errors}} span>{%endif%} > but I still get them formatted as an and I would like the errors > to appear as simple text.. I'm beginning to suspect this is a slight design flaw in newforms: the presentation of error messages is hard-coded into the way the ErrorList class (in newforms.utils) is used in the HTML rendering. I can think of a couple of backwards-compatible ways we might be able to change this. I'll bounce some ideas of the developers list. > I tried these instructions in this page: > http://code.djangoproject.com/wiki/TemplatedForm > But I can't seem to make it work.. > I have this error on my models.py: Exception Value: name > 'TemplatedForm' is not defined > I understand that I have to import something, I just don't know how to > import it... You have to import TemplatedForm from whichever file you defined it in. Both TemplatedForm and the new form subclass you are creating are just classes in your Python code. Import them as you would any othre class in Python. Regards, Malcolm -- How many of you believe in telekinesis? Raise my hand... http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: CachedDnsName - very slow under apache/mod_python ...
On Mon, 2007-06-25 at 19:39 -0700, ZebZiggle wrote: > Howdy! > > Emails were taking 15s to send each. Upon investigation it came down > to CachedDnsName in django.core.mail. Specifically, the > socket.getfqdn() call. Also, it *always* happened, not just on > startup. So it seems the call was timing out and the cache wasn't > effective. > > The strange part is, it works fine in a dev environment or from the > production command line, but under apache/mod-python the killer time > delay kicks in. > > Any idea what could be different here? If that file is being reimported a lot because the Python processes are restarting it will be run each time. You could try printing the PID -- os.getpid() -- or something similar to verify that. I remember hearing second-hand about this happening to somebody else and wasn't paying enough attention at the time to realise it might be a real problem. It's worth tweaking a bit if you can work out the circumstances (for example, a setting for the fqdn so that we don't even do the lookup if the setting exists). (Every time I look at that code, I remember how much I dislike DNS_NAME as the constant. Darn backwards compatibility hack!) Regards, Malcolm -- I've got a mind like a... a... what's that thing called? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: CachedDnsName - very slow under apache/mod_python ...
I'm not sure. Each Apache instance may have to populate this, so it could be noticed several times. Keep investigating! Thinking more about it, perhaps CachedDnsName should only lazily loaded if settings.DEBUG==True. It's not really fair to expect an end user to have to wait for this timeout just because they are the first one to trigger a mail to be sent. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
CachedDnsName - very slow under apache/mod_python ...
Howdy! Emails were taking 15s to send each. Upon investigation it came down to CachedDnsName in django.core.mail. Specifically, the socket.getfqdn() call. Also, it *always* happened, not just on startup. So it seems the call was timing out and the cache wasn't effective. The strange part is, it works fine in a dev environment or from the production command line, but under apache/mod-python the killer time delay kicks in. Any idea what could be different here? Cheers, Sandy --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Tests fail on redirects when admin urls enabled
I recently enabled the admin module on a project I am working on, and some (formerly) passing tests began erroring when testing redirects. Here is the exception traceback from a failing test: Traceback (most recent call last): File "E:\dev\seo\src\seo\sm\tests.py", line 135, in test_seeking_CitiesRedirect response = self.client.get('/singles/New York/New York/') File "e:\dev\django\django\test\client.py", line 200, in get return self.request(**r) File "e:\dev\django\django\core\handlers\base.py", line 77, in get_response response = callback(request, *callback_args, **callback_kwargs) File "E:\dev\seo\src\seo\sm\views.py", line 170, in seeking 'seek_slug': seek_name})) File "e:\dev\django\django\core\urlresolvers.py", line 282, in reverse return '/' + get_resolver(urlconf).reverse(viewname, *args, **kwargs) File "e:\dev\django\django\core\urlresolvers.py", line 267, in reverse if lookup_view in self.reverse_dict: File "e:\dev\django\django\core\urlresolvers.py", line 207, in _get_reverse_dict for key, value in pattern.reverse_dict.iteritems(): File "e:\dev\django\django\core\urlresolvers.py", line 210, in _get_reverse_dict self._reverse_dict[pattern.callback] = (pattern,) File "e:\dev\django\django\core\urlresolvers.py", line 170, in _get_callback self._callback = get_callable(self._callback_str) File "e:\dev\django\django\utils\functional.py", line 16, in wrapper result = func(*args) File "e:\dev\django\django\core\urlresolvers.py", line 44, in get_callable lookup_view = getattr(__import__(mod_name, {}, {}, ['']), func_name) File "e:\dev\django\django\contrib\admin\views\doc.py", line 291, in 'AutoField' : _('Integer'), TypeError: 'str' object is not callable This is occurring wherever I test a redirect. If I comment out the admin line in urls.py, the errors disappear. I am on the latest development version to date (5541). Any insight or help would be greatly appreciated! Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: multiple databases
Ben Ford is working on merging in changes from the trunk in with the branch... at this time neither he or myself ( I had planned on doing this but found he was farther ahead of me ) have commit permissions to the project... but hopefully if he gets finished with it..and we can test it out... someone will give him permissions to commit. On Jun 25, 3:19 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 6/25/07, grassoalvaro <[EMAIL PROTECTED]> wrote: > > > > > Anyone? That was greate idea but i see that last update was long time > > ago... i need multiple databases in my project so if anyone know > > anything about this (maybe own solutions in this area?) please inform > > me. > > No one is working on it 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 -~--~~~~--~~--~--~---
Re: database error instead of 400
On 6/25/07, Francis Lavoie <[EMAIL PROTECTED]> wrote: > > I have a problem with my 400.html when I put the site in production > (another server). > > Both desktop and server are running ubuntu 7.04. > The Desktop use the builtin webserver and the server is running apache with > mod_python > > On my localhost with debug = True and debug = False, everything is working > as expected. But when I sync the code with the production web server and I > corrected the static path, the server cannot handle 400 error and throw a > database error instead. (I don't use the database, I just have it configured > for future use with the default django services) > > The apache user has read/write permission on the database file. > > here is the error : > > [ ugly traceback snipped] > > File > "/var/lib/python-support/python2.5/django/db/backends/sqlite3/base.py", > line 45, in cursor > detect_types=Database.PARSE_DECLTYPES | Database.PARSE_COLNAMES) > > OperationalError: unable to open database file > Could be related to this: http://code.djangoproject.com/wiki/NewbieMistakes#DjangosaysUnabletoOpenDatabaseFilewhenusingSQLite3 Regards, -- Ramiro Morales --~--~-~--~~~---~--~~ 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: Newforms, MultiSelect, "Hold Down Control" message.
On Jun 25, 1:03 pm, larry <[EMAIL PROTECTED]> wrote: > I've derived a new version of the CheckboxSelectMultiple widget. > Unfortunately, just like its parent, it prints a message "Hold down > "Control", or "Command" on a Mac, to select more than one." on each > field. This instruction, which I assume is coming from an ancestor > class, is not appropriate for checkbox multiples. > > Any hint on how I can suppress it in my descendant? The string you're referring to is appended to the help_text of a ManyToManyField in django.db.models.fields.related. It's not being set by newforms, merely inherited. You also wouldn't be seeing it if you were using CheckboxSelectMultiple, only if the normal HTML select widget were being used. The only case that I'm aware of where this comes up is using the form_for_* shortcuts. To remove the string, one option is to define your own form class. For example: class MyForm(Form): categories = ModelMultipleChoiceField(Category.objects.all()) If you wish to continue using the form_for_* shortcuts, you'll need to modify the form class before instantiating it. This may be a little uglier, but something like: klass = form_for_model(MyModel) klass.base_fields['categories'].help_text = '' would do the trick, with the caveat that any other help text the model field may have specified gets erased too. Matt --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
database error instead of 400
I have a problem with my 400.html when I put the site in production (another server). Both desktop and server are running ubuntu 7.04. The Desktop use the builtin webserver and the server is running apache with mod_python On my localhost with debug = True and debug = False, everything is working as expected. But when I sync the code with the production web server and I corrected the static path, the server cannot handle 400 error and throw a database error instead. (I don't use the database, I just have it configured for future use with the default django services) The apache user has read/write permission on the database file. here is the error : Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/var/lib/python-support/python2.5/django/core/handlers/modpython.py", line 163, in handler return ModPythonHandler()(req) File "/var/lib/python-support/python2.5/django/core/handlers/modpython.py", line 136, in __call__ response = self.get_response(req.uri, request) File "/var/lib/python-support/python2.5/django/core/handlers/base.py", line 95, in get_response return callback(request, **param_dict) File "/var/lib/python-support/python2.5/django/views/defaults.py", line 79, in page_not_found return http.HttpResponseNotFound(t.render(RequestContext(request, {'request_path': request.path}))) File "/var/lib/python-support/python2.5/django/template/context.py", line 97, in __init__ self.update(processor(request)) File "/var/lib/python-support/python2.5/django/core/context_processors.py", line 18, in auth 'user': request.user, File "/var/lib/python-support/python2.5/django/contrib/auth/middleware.py", line 5, in __get__ request._cached_user = get_user(request) File "/var/lib/python-support/python2.5/django/contrib/auth/__init__.py", line 71, in get_user user_id = request.session[SESSION_KEY] File "/var/lib/python-support/python2.5/django/contrib/sessions/middleware.py", line 18, in __getitem__ return self._session[key] File "/var/lib/python-support/python2.5/django/contrib/sessions/middleware.py", line 56, in _get_session expire_date__gt=datetime.datetime.now()) File "/var/lib/python-support/python2.5/django/db/models/manager.py", line 67, in get return self.get_query_set().get(*args, **kwargs) File "/var/lib/python-support/python2.5/django/db/models/query.py", line 211, in get obj_list = list(clone) File "/var/lib/python-support/python2.5/django/db/models/query.py", line 103, in __iter__ return iter(self._get_data()) File "/var/lib/python-support/python2.5/django/db/models/query.py", line 430, in _get_data self._result_cache = list(self.iterator()) File "/var/lib/python-support/python2.5/django/db/models/query.py", line 170, in iterator cursor = connection.cursor() File "/var/lib/python-support/python2.5/django/db/backends/sqlite3/base.py", line 45, in cursor detect_types=Database.PARSE_DECLTYPES | Database.PARSE_COLNAMES) OperationalError: unable to open database file --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Forms and formating error messages
Hi, I was trying to change the way in which the errors are presented in a form. I tried to put them in: {{field.label}}:{{field}}{% if field.field.required %}*{%endif%}{%if field.errors%}{{field.errors}}{%endif%} but I still get them formatted as an and I would like the errors to appear as simple text.. I tried these instructions in this page: http://code.djangoproject.com/wiki/TemplatedForm But I can't seem to make it work.. I have this error on my models.py: Exception Value: name 'TemplatedForm' is not defined I understand that I have to import something, I just don't know how to import it... And by the way, this thing described on the web-page I spoke about is for this purpose right? Changing the appearance of the errors? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to translate this SQL (nearest 20) into Django?
On 6/25/07, Tim Tsai <[EMAIL PROTECTED]> wrote: ... > sqlite> select position_payrate, position_payrate - 2 as diff, > abs(position_payrate - 2) as adiff from positions order by adiff asc > limit 20; > 2|0|0 ... http://www.djangoproject.com/documentation/db-api/#extra-select-none-where-none-params-none-tables-none positions.objects.extra(select={'diff':'position_payrate - 2', 'adiff':'abs(position_payrate - 2)'}).order_by('adiff')[:20] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to translate this SQL (nearest 20) into Django?
Given the corresponding query and output, what would be the best way to translate that into Django? I've looked at QuerySet, filter, etc. but can't quite figure out the best way to do this. The idea is to find the nearest 20 rows that matches, of course. The 2 will be passed via URL (i.e. http://mydomain.com/salary/2) to my view, which normally looks something like this using generic views. def by_pay(request, query_id): qs = positions.objects.filter(position_payrate=query_id) return object_list(request, qs) and urls.py looks something like this: (r'^salary/(?P\d+)/$', 'pay.views.by_pay'), I would want to sort the final output by I think a Django filter in the template will be fine for this purpose. Thanks!! Tim sqlite> select position_payrate, position_payrate - 2 as diff, abs(position_payrate - 2) as adiff from positions order by adiff asc limit 20; 2|0|0 2|0|0 19668.74|-331.26|331.26 19392|-608|608 20758|758|758 19200|-800|800 19200|-800|800 20800|800|800 20800|800|800 19095|-905|905 20988|988|988 21000|1000|1000 19000|-1000|1000 19000|-1000|1000 21000|1000|1000 21071|1071|1071 18720|-1280|1280 21300|1300|1300 21308|1308|1308 21320|1320|1320 --~--~-~--~~~---~--~~ 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: Meta class preventing table add
On 2007-06-25 14:10:30 -0600, Charles Wesley <[EMAIL PROTECTED]> said: > > Hello, > > I'm a Django newbie, and I'm trying to set up a model that includes > the following table: > > class Team(models.Model): > school = models.ForeignKey(School, > unique_for_year="season_start_date") > season_start_date = models.DateField() > division = models.ForeignKey(Division) > coach_first = models.CharField("coach's first name", maxlength=50, > blank=True) > coach_last = models.CharField("coach's last name", maxlength=50, > blank=True) > coach_email = models.EmailField("coach's email address", > blank=True) > coach_phone = models.PhoneNumberField("coach's phone", blank=True) > team_picture = models.ImageField(upload_to="team", blank=True) > players = models.ManyToManyField(Player, blank=True) > > class Admin: > pass > > class Meta: > order_with_respect_to = 'school' > > > When trying to add a team in the Django admin interface, I get this > error: > > Traceback (most recent call last): > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in > get_response > 77. response = callback(request, *callback_args, **callback_kwargs) > File "C:\Python25\lib\site-packages\django\contrib\admin\views > \decorators.py" in _checklogin > 55. return view_func(request, *args, **kwargs) > File "C:\Python25\lib\site-packages\django\views\decorators\cache.py" > in _wrapped_view_func > 39. response = view_func(request, *args, **kwargs) > File "C:\Python25\lib\site-packages\django\contrib\admin\views > \main.py" in add_stage > 254. new_object = manipulator.save(new_data) > File "C:\Python25\lib\site-packages\django\db\models\manipulators.py" > in save > 108. new_object.save() > File "C:\Python25\lib\site-packages\django\db\models\base.py" in save > 238. ','.join(placeholders)), db_values) > File "C:\Python25\lib\site-packages\django\db\backends\util.py" in > execute > 12. return self.cursor.execute(sql, params) > File "C:\Python25\lib\site-packages\MySQLdb\cursors.py" in execute > 166. self.errorhandler(self, exc, value) > File "C:\Python25\lib\site-packages\MySQLdb\connections.py" in > defaulterrorhandler > 35. raise errorclass, errorvalue > > OperationalError at /admin/football/team/add/ > (1093, "You can't specify target table 'football_team' for update in > FROM clause") > > > which appears to stem from this SELECT statement: > > "INSERT INTO `football_team` > (`school_id`,`season_start_date`,`division_id`,`coach_first`,`coach_last`,`coach_email`,`coach_phone`,`team_picture`,`_order`) VALUES > > ('2','2005-09-10','2','','','','','',(SELECT COUNT(*) FROM > `football_team` WHERE `school_id` = '2'))" > > > This error disappears if I remove the Meta class. So what am I doing > wrong when I include it? > > Thanks, > charles > > > You are probably using MySQL. It is a known problem and even if that did work, there currently isn't any admin interface to work it yet. That will be a fix of the newforms-admin branch. Tickets: http://code.djangoproject.com/ticket/1760 and http://code.djangoproject.com/ticket/2137 -- Brian Rosner http://www.brosner.com/blog --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
list_filter in newforms-admin doesn't worj
I'm using the newforms-admin branch, and have specified some admin options for a Experiment model like this class ExperimentalDataOptions(admin.ModelAdmin): list_display = ('project_name','experiment_nr','experiment_date','short_title') search_fields = ('experiment_nr','project_name','experiment_date','title') list_filter = ('project_name',) # 'experiment_date','project_name',) if I leaveout the list_filter line it works ok. with list_filter I get the following message AttributeError at /yyy/admin/zb/experimentaldata/ type object 'ModelAdmin' has no attribute 'manager' Request Method: GET Request URL:https://xxx.xxx.xxx.xxx/yyy/admin/zb/experimentaldata/ Exception Type: AttributeError Exception Value:type object 'ModelAdmin' has no attribute 'manager' Exception Location: /usr/lib/python2.3/site-packages/django/contrib/ admin/filterspecs.py in __init__, line 161 Python Executable: /usr/bin/python Python Version: 2.3.4 Any idea how to get this working? thanks, Eiso --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Meta class preventing table add
Hello, I'm a Django newbie, and I'm trying to set up a model that includes the following table: class Team(models.Model): school = models.ForeignKey(School, unique_for_year="season_start_date") season_start_date = models.DateField() division = models.ForeignKey(Division) coach_first = models.CharField("coach's first name", maxlength=50, blank=True) coach_last = models.CharField("coach's last name", maxlength=50, blank=True) coach_email = models.EmailField("coach's email address", blank=True) coach_phone = models.PhoneNumberField("coach's phone", blank=True) team_picture = models.ImageField(upload_to="team", blank=True) players = models.ManyToManyField(Player, blank=True) class Admin: pass class Meta: order_with_respect_to = 'school' When trying to add a team in the Django admin interface, I get this error: Traceback (most recent call last): File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "C:\Python25\lib\site-packages\django\contrib\admin\views \decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "C:\Python25\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func 39. response = view_func(request, *args, **kwargs) File "C:\Python25\lib\site-packages\django\contrib\admin\views \main.py" in add_stage 254. new_object = manipulator.save(new_data) File "C:\Python25\lib\site-packages\django\db\models\manipulators.py" in save 108. new_object.save() File "C:\Python25\lib\site-packages\django\db\models\base.py" in save 238. ','.join(placeholders)), db_values) File "C:\Python25\lib\site-packages\django\db\backends\util.py" in execute 12. return self.cursor.execute(sql, params) File "C:\Python25\lib\site-packages\MySQLdb\cursors.py" in execute 166. self.errorhandler(self, exc, value) File "C:\Python25\lib\site-packages\MySQLdb\connections.py" in defaulterrorhandler 35. raise errorclass, errorvalue OperationalError at /admin/football/team/add/ (1093, "You can't specify target table 'football_team' for update in FROM clause") which appears to stem from this SELECT statement: "INSERT INTO `football_team` (`school_id`,`season_start_date`,`division_id`,`coach_first`,`coach_last`,`coach_email`,`coach_phone`,`team_picture`,`_order`) VALUES ('2','2005-09-10','2','','','','','',(SELECT COUNT(*) FROM `football_team` WHERE `school_id` = '2'))" This error disappears if I remove the Meta class. So what am I doing wrong when I include it? Thanks, charles --~--~-~--~~~---~--~~ 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, MultiSelect, "Hold Down Control" message.
I've derived a new version of the CheckboxSelectMultiple widget. Unfortunately, just like its parent, it prints a message "Hold down "Control", or "Command" on a Mac, to select more than one." on each field. This instruction, which I assume is coming from an ancestor class, is not appropriate for checkbox multiples. Any hint on how I can suppress it in my descendant? --~--~-~--~~~---~--~~ 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 databases
On 6/25/07, grassoalvaro <[EMAIL PROTECTED]> wrote: > > Anyone? That was greate idea but i see that last update was long time > ago... i need multiple databases in my project so if anyone know > anything about this (maybe own solutions in this area?) please inform > me. > No one is working on it 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 -~--~~~~--~~--~--~---
Re: multiple databases
Anyone? That was greate idea but i see that last update was long time ago... i need multiple databases in my project so if anyone know anything about this (maybe own solutions in this area?) please inform me. On Jun 24, 6:14 pm, grassoalvaro <[EMAIL PROTECTED]> wrote: > Is that project dead or maybe still unofficial supported? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Unittests and coverage
Hello, I try to write test together with coverage [1]. This tool could tell me, which lines of code was or wasn't executed and therefore tell, how my tests are (or aren't) "superior". I put initial code for coverage into setUp, and cleanup to tearDown method of Testcase class. Problem is, that setUp and tearDown method are called before/after each particular test in TestCase. I need to find technique, which enable me initiate coverage before any test begin, and cleanup after *all* test was executed. Do you have some advice please? Thank you Regards, Michal [1] http://www.nedbatchelder.com/code/modules/coverage.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ANN: Django-fr.org is out!
On 6/25/07, Jorge Gajon <[EMAIL PROTECTED]> wrote: > > > Se dice "red" Gracias, 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: Apache auth
Sean, On 24 Jun 2007, at 4:13 pm, Sean Mc Allister wrote: What I'm currently using: Server Version: Apache/2.2.3 (Ubuntu) DAV/2 mod_python/3.2.10 Python/2.5.1 Damn! I was hoping it would be drastically newer than what I was using and I could blame old versions of mod_python or something. Here is what I have.. Apache/2.2.3 (Debian) mod_python/3.2.10 Python/2.4.4 So, pretty much the same versions, other than python - would that make a big difference? And one of my apache directives: #full size images PythonPath "['/home/sean/whav'] + sys.path" PythonOption DJANGO_SETTINGS_MODULE whav.settings-sean- apache PythonOption DjangoPermissionName 'whav_db.full_images' PythonAccessHandler whav.modpython::accesshandler_full SetHandler None You were right about the SetHandler thing, it really shouldn't be set to python-program. Ok, using that works a bit better, but I still get Internal Server Errors every so often - nowhere near as much as before, but still every so often, which is a bit annoying with the kind of files I can serving... Any more help / suggestions greatly appreciated. Thanks, Dave -- David Reynolds [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature
Newforms, widgets, adding new fk values on the fly.
The admin site offers the ability, when setting values for FK or MTM fields, to add a value on the fly. I've built a custom descendant of the CheckboxSelectMultiple widget (which displays the check boxes in a table, not a list, and allows a user-defined number of columns). I'd like to extend this with the ability, at runtime, to specify a number of "slots" for new values to add to the support table before saving the main record. I know where in the widget to render out the additional text fields I need (or at least I think I do). I have no idea whatsoever about how and where to hook the code that receives those fields back and take the necessary action. I could handle this in some way specific to my fields and my code, but I'd rather derive something that understands this concept -- whether it's a form class, a field class, or whatever. Any suggestions on just what class or classes need to be extended to handle this are greatly appreciated. -- Larry Lustig --~--~-~--~~~---~--~~ 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: Empty urls.py file and {% url %} tags
On Mon, 2007-06-25 at 21:43 +1000, Malcolm Tredinnick wrote: > On Mon, 2007-06-25 at 10:06 +, Ryan Kanno wrote: > > I know this isn't big (and maybe it's by design), but this didn't > > happen prior to I believe -r 5516. If you have a empty urls.py > > include file in any app within the project, it causes the {% url %} > > tag to not resolve for any app, even an unrelated app view. > > Well, it's not intended behaviour, but I'm not sure the current > behaviour is wrong, either. You're exploiting a very accidental > implementation side-effect. > > Still, we can probably just work around a missing urlpatterns attribute > without too much harm. I'll fix it up soon. Okay, [5538] should return the previous behaviour. Regards, Malcolm -- Why can't you be a non-conformist like everyone else? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Send a filter-pipline output to a template tag
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hey, is it possible, to send a output, generated by a filter pipeline chain to a template tag? I want to split a page's tag, that is already processed by the reStructuredText filter and a link generation filter, in several subtexts to mix it with the page's images. Thanks! Manuel -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (Darwin) iQEVAwUBRoACqzOKNHIOcnYMAQj9PAgAsXDuV+ggJ0yPh8+l8D2enRW/LrMxK+wB fvN1RjCDlO06htexWJcRIttfgjq3yPhXOGbNOnu2GFZ/gRdstofKICOGMPGai0A5 8j8dzhgaK+684A5heTsUlcvgeRacEIYFmqWaLIWi0dKV8JxibbFbARt0YCbQUJF6 znGyfHiNcOR2EGMfmyyNZGzDJz5xX3z68OaaApjbTzDVU7zuubkZYvV6af/AOanO q0hEJ5BmdwjYNTxsT3hEbablu+tWtkHA/RjI93AV1augoIzHFvuEzp6Jx3DtrSf9 9MmMHoYafkERrcqo0q13P07IPdz1QMs4KYPIr0xMCt4XlSBlXXkSiA== =V10Y -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ANN: Django-fr.org is out!
On 6/22/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > > Dice que estas en #django-es en freenode o un otra network? Estoy en > #django-es ahora. > > (Como se dice "network"?) > Se dice "red" Saludos! --~--~-~--~~~---~--~~ 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: newforms view-question
I do agree. helper methods for every special case is not the solution. on the other hand, it´s just not clear sometimes how things could/ should be done. I´d just wish for more "best practice" advice and more complex examples (esp. in the docs). regards, patrick Am 25.06.2007 um 16:51 schrieb Malcolm Tredinnick: > > On Mon, 2007-06-25 at 16:41 +0200, patrick k. wrote: >> thanks malcolm. >> >> get_initial_data should be defined in the form, I think. because the >> form doesn´t necessarily relate to a model, so the model is probably >> the wrong place. >> I´m a bit surprised that this isn´t easier/cleaner with newforms. > > You can't really be surprised that Django doesn't include helper > methods > for every special case. Particularly when writing your own method > takes > four lines of code. There's a limit on how easy something can be, > given > that the model, the field list, the form field names and the mapping > between form fields and model fields are all variables. > > 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?hl=en -~--~~~~--~~--~--~---
Re: Problem with query over relationships and the FOO_set Manager
I tried your second solution and it works fine! Thanks! On Jun 25, 4:51 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > d = Details.objects.filter(creation_date__gte=datetime.date(2007, 06, > > 01)) > > d = d.header_set.filter(code__exact='123', author__exact='dave') > > > but I get an > > AttributeError: 'QuerySet' object has no attribute 'header_set' > > The results (which you store in "d") are a QuerySet which is a > collection of Details. Each Detail within that set has a > header_set property. Thus it would make sense to do something like > >for thing in d: > for header in thing.header_set: >do_something(header) > > Or, if you want the headers, ask for them, not the details: > >since = datetime.date(2007,6,1) >headers = Headers.objects.filter( > code='123', > author='dave', > header__creation_date__gte=since # (*) > ) >for header in headers: > do_something(header) > > The line marked with (*) may be what you're looking for. > > -tim --~--~-~--~~~---~--~~ 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 query over relationships and the FOO_set Manager
Whoops...though I hate responding to my own post, I got things backwards somehow (swapping details and headers). Your Details have the header attribute so you want since = datetime.date(2007,6,1) details = Details.objects.filter( code='123', author='dave', header__creation_date__gte=since ) for detail in details: do_something(detail) -tim --~--~-~--~~~---~--~~ 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 query over relationships and the FOO_set Manager
On 6/25/07, ilDave <[EMAIL PROTECTED]> wrote: > So, I looked in the documentation and I found the 'FOO_set' Manager, > and I tried something like this: > > d = Details.objects.filter(creation_date__gte=datetime.date(2007, 06, > 01)) > d = d.header_set.filter(code__exact='123', author__exact='dave') > > but I get an > AttributeError: 'QuerySet' object has no attribute 'header_set' The ForeignKey is on Detail, pointing at Header, which means that each Detail has only one Header -- hence there is no "header_set" on a Detail object. What you probably want instead is Detail.objects.filter(created_date__gte=datetime.date(2007, 6, 1), header__code__exact='123', header__author__exact='dave') -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms view-question
On Mon, 2007-06-25 at 16:41 +0200, patrick k. wrote: > thanks malcolm. > > get_initial_data should be defined in the form, I think. because the > form doesn´t necessarily relate to a model, so the model is probably > the wrong place. > I´m a bit surprised that this isn´t easier/cleaner with newforms. You can't really be surprised that Django doesn't include helper methods for every special case. Particularly when writing your own method takes four lines of code. There's a limit on how easy something can be, given that the model, the field list, the form field names and the mapping between form fields and model fields are all variables. 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?hl=en -~--~~~~--~~--~--~---
Re: Problem with query over relationships and the FOO_set Manager
> d = Details.objects.filter(creation_date__gte=datetime.date(2007, 06, > 01)) > d = d.header_set.filter(code__exact='123', author__exact='dave') > > but I get an > AttributeError: 'QuerySet' object has no attribute 'header_set' The results (which you store in "d") are a QuerySet which is a collection of Details. Each Detail within that set has a header_set property. Thus it would make sense to do something like for thing in d: for header in thing.header_set: do_something(header) Or, if you want the headers, ask for them, not the details: since = datetime.date(2007,6,1) headers = Headers.objects.filter( code='123', author='dave', header__creation_date__gte=since # (*) ) for header in headers: do_something(header) The line marked with (*) may be what you're looking for. -tim --~--~-~--~~~---~--~~ 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: newforms view-question
thanks malcolm. get_initial_data should be defined in the form, I think. because the form doesn´t necessarily relate to a model, so the model is probably the wrong place. I´m a bit surprised that this isn´t easier/cleaner with newforms. nevertheless, looks a bit better now: def do_save(form, model, fields): for field in fields: setattr(model, field, form.cleaned_data[field]) def get_initial_data(model, fields): return dict([(f, getattr(model, f)) for f in fields]) def chg_userdata(request, user_id): user_data = User.objects.get(pk=request.user.id) user_profile = UserProfile.objects.get(user=request.user) if request.method == 'POST': form = UserProfileForm(request.POST) if form.is_valid(): do_save(form, user_profile, ['sex', 'date_of_birth', 'phone_number', 'place_address', 'place_zip_code', 'place_location', 'place_state']) user_profile.save() do_save(form, user_data, ['first_name', 'last_name']) user_data.save() else: initial_data = get_initial_data(user_profile, ['sex', 'date_of_birth', 'phone_number', 'place_address', 'place_zip_code', 'place_location']) initial_data['place_state'] = user_profile.get_state_id initial_data['first_name'] = user_data.first_name initial_data['last_name'] = user_data.last_name form = UserProfileForm(initial=initial_data) return render_to_response('site/user/form_userdata.html', { 'form': form, }, context_instance=RequestContext(request)) thanks again, patrick Am 25.06.2007 um 16:07 schrieb Malcolm Tredinnick: > > Hi Patrick, > > On Mon, 2007-06-25 at 15:50 +0200, patrickk wrote: >> here´s my view (I think the form-class is not so important for my >> question): >> >> if request.method == 'POST': >> form = UserProfileForm(request.POST) >> if form.is_valid(): >> # SAVING >> user_profile.sex = form.cleaned_data['sex'] >> user_profile.date_of_birth = form.cleaned_data >> ['date_of_birth'] >> user_profile.phone_number = form.cleaned_data >> ['phone_number'] >> user_profile.place_address = form.cleaned_data >> ['place_address'] >> user_profile.place_zip_code = form.cleaned_data >> ['place_zip_code'] >> user_profile.place_location = form.cleaned_data >> ['place_location'] >> if form.cleaned_data['place_state']: >> user_profile.place_state_id = int(form.cleaned_data >> ['place_state']) >> else: >> user_profile.place_state_id = "" >> user_profile.save() >> user_data.first_name = form.cleaned_data['first_name'] >> user_data.last_name = form.cleaned_data['last_name'] >> user_data.save() >> else: >> # INITIAL_DATA >> initial_data = {'sex': user_profile.sex, >> 'first_name': user_data.first_name, >> 'last_name': user_data.last_name, >> 'date_of_birth': user_profile.date_of_birth, >> 'phone_number': user_profile.phone_number, >> 'place_address': user_profile.place_address, >> 'place_zip_code': user_profile.place_zip_code, >> 'place_location': user_profile.place_location, >> 'place_state': user_profile.get_state_id, >> } >> form = UserProfileForm(initial=initial_data) >> >> problem is: I´d like to clean this view by eliminating SAVING and >> INITIAL_DATA, > > Good design question. You're right, there should be a way to make this > easier. You could define methods like get_initial_data on your > model, as > you suggest. However, the drawbacks are that it will be a bit > repetitive > if you have to do this for many models and it doesn't play nicely with > models from other applications (e.g. a model from Django's core) that > you can't really edit. > > Another approach is to write a couple of functions that take a list of > fields and a model instance. For example (untested code): > > def do_save(form, model, fields): >for field in fields: > setattr(model, field, form.cleaned_data[field]) > > def get_initial_data(model, fields): >return dict([(f, getattr(model, f)) for f in fields]) > > If you were always going to be working with *all* the fields on the > model, you could even leave out the 'fields' parameter and get that > dynamically by iterating through model._meta.fields, but that is a > little more fiddly -- you might need to leave out auto_pk fields and > stuff like that. > > Regards, > Malcolm > > -- > I don't have a solution, but I admire your problem. > http://www.pointy-stick.com/blog/ > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this
Problem with query over relationships and the FOO_set Manager
In my app I have two models like this: class Header(models.Model): code = models.CharField() author = models.CharField() class Detail(models.Model) header = models.ForeignKey(Header) creation_date = models.DateTime() I need to find all the Header objects with a certain code, a certain author and with details created after a certain date. So, I looked in the documentation and I found the 'FOO_set' Manager, and I tried something like this: d = Details.objects.filter(creation_date__gte=datetime.date(2007, 06, 01)) d = d.header_set.filter(code__exact='123', author__exact='dave') but I get an AttributeError: 'QuerySet' object has no attribute 'header_set' What am I making wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: looking for calender and a message board
I'm using a hacked-up version of myghtyboard for http://gretschpages.com/forum. I had a pretty workable calendar app at one point but killed it off. Wasn't that complex. On Jun 24, 3:40 am, "Justin Lilly" <[EMAIL PROTECTED]> wrote: > errr.. sorry. misclicked. You can find the source under the "agenda" folder > of: > > http://justinlilly.no-ip.org/svn/trunk/gtd/ > > If you need anything regarding it, let me know! > -justin > > On 6/24/07, Justin Lilly <[EMAIL PROTECTED]> wrote: > > > > > > > I implemented a decent calendar that accomplishes what I need. > > >http://justinlilly.no-ip.org:8001/calendar/ -- small view > >http://justinlilly.no-ip.org:8002/calendar/ -- large view (CSS in > > progress) > > > If you want to see the code, you can find it at: > > > On 6/24/07, Carl Karsten <[EMAIL PROTECTED]> wrote: > > > > [EMAIL PROTECTED] wrote: > > > > If by message board you mean a forum, a la VBulletin and the like, > > > > Zyons is the only Django one I know of:http://zyons.com/ > > > > cool - thanks. > > > > > As for calendar, I wasn't able to find an existing generic calendar > > > > app, and have been working on rolling my own for my project. I'd > > > > share, but it is most definitely not going to be worthy of sharing > > > > because I am a novice at Django and Python. The code I'm using to > > > > display the calendar came from djangosnippets.org. > > > > Put it up onhttp://code.google.comand get some help :) > > > > did you see the Zyons Event Calendar? looking pretty cool... > > > > Carl K > > > > > On Jun 23, 1:37 pm, Carl Karsten < [EMAIL PROTECTED]> wrote: > > > >> I am going to build a site that needs a calender and a message board, > > > plus some > > > >> specialized things that will 'integrate' with those two features. So > > > it would > > > >> be good if the whole site used the same glue. > > > > >> Anyone have any suggestions? > > > > >> Carl K > > > -- > > Justin Lilly > > University of South Carolina > > -- > Justin Lilly > University of South Carolina --~--~-~--~~~---~--~~ 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: newforms view-question
Hi Patrick, On Mon, 2007-06-25 at 15:50 +0200, patrickk wrote: > here´s my view (I think the form-class is not so important for my > question): > > if request.method == 'POST': > form = UserProfileForm(request.POST) > if form.is_valid(): > # SAVING > user_profile.sex = form.cleaned_data['sex'] > user_profile.date_of_birth = form.cleaned_data > ['date_of_birth'] > user_profile.phone_number = form.cleaned_data > ['phone_number'] > user_profile.place_address = form.cleaned_data > ['place_address'] > user_profile.place_zip_code = form.cleaned_data > ['place_zip_code'] > user_profile.place_location = form.cleaned_data > ['place_location'] > if form.cleaned_data['place_state']: > user_profile.place_state_id = int(form.cleaned_data > ['place_state']) > else: > user_profile.place_state_id = "" > user_profile.save() > user_data.first_name = form.cleaned_data['first_name'] > user_data.last_name = form.cleaned_data['last_name'] > user_data.save() > else: > # INITIAL_DATA > initial_data = {'sex': user_profile.sex, > 'first_name': user_data.first_name, > 'last_name': user_data.last_name, > 'date_of_birth': user_profile.date_of_birth, > 'phone_number': user_profile.phone_number, > 'place_address': user_profile.place_address, > 'place_zip_code': user_profile.place_zip_code, > 'place_location': user_profile.place_location, > 'place_state': user_profile.get_state_id, > } > form = UserProfileForm(initial=initial_data) > > problem is: I´d like to clean this view by eliminating SAVING and > INITIAL_DATA, Good design question. You're right, there should be a way to make this easier. You could define methods like get_initial_data on your model, as you suggest. However, the drawbacks are that it will be a bit repetitive if you have to do this for many models and it doesn't play nicely with models from other applications (e.g. a model from Django's core) that you can't really edit. Another approach is to write a couple of functions that take a list of fields and a model instance. For example (untested code): def do_save(form, model, fields): for field in fields: setattr(model, field, form.cleaned_data[field]) def get_initial_data(model, fields): return dict([(f, getattr(model, f)) for f in fields]) If you were always going to be working with *all* the fields on the model, you could even leave out the 'fields' parameter and get that dynamically by iterating through model._meta.fields, but that is a little more fiddly -- you might need to leave out auto_pk fields and stuff like that. Regards, Malcolm -- I don't have a solution, but I admire your problem. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Courage
Living in the Hell my own people allowed the Illuminati to build for me. Courage is a strange thing, sometimes people say you don't have it when you do . Other times absolute fear enables one to change reality by manipulating the matter around them. In my experience, when this happens one has no fear nor, conscious control over the matter manipulation they administer. I have learned in recent years that matter and energy are one in the same, but that's a hole other subject I will not discus at this point. Heaven forbid the allowed for general public science world wake up, It is as if you become one with God or the collective conscious of this reality and are able to effect it's change. People often refer to one in this state as being a Witch or Psychic, when one sees future possibilities, or past that was before their time. I Lawrence Lapadat, have had many of these experiences, and would like to share one very important one with you at this point. I believe I was about 11,or 12 years old, and I was walking home from school one day when I was confronted by a kid named Johnny Bench. He stepped in front of me and asked me if I wanted to fight. I not wanting to show fear, even though I was afraid agreed. He was about my height but way stockier, and quite a bit heavier. I had never really boxed before and my experience with fighting had usually been wrestling, at which I was quite good. My approach to the task at hand was to reach out to get Johnny in a headlock, this had usually been my best result in past wrestling matches. To my surprise , Johnnies response was a good hard punch to my nose. In shock of what I thought at the time was a cruel unfair way of fighting I got upset and went crying home looking for sympathy. My fathers response was even more shocking to me, when he turned on me with anger and stated, well put up your dukes and fight. The next time I saw Johnny I was angry with him and let him, know by ignoring him, but he persisted, so I let him know I was not happy about him punching me. He apologized , and explained he had only done it because he wanted to be friends. He asked me to play with him, so we went over to his house and played. At one point he asked me why I did not like fighting. I explained that I did not mind wrestling,but did not like punching, so he asked me to wrestle with him. He still got the best of me in wrestling, and he was holding me down and not letting me go when I gave up. I can't recall weather he tried to kiss me or what he did but, I do know something sexual was going on. His mother I believe had been watching us, and ran out scolding Johnny. He let me up, and I yelled out in anger, I never want to play with you again, and I don't want to be your friend. Johnny at this point spurted out in a hurt voice, but I love you, you have to be my friend. Johnnies father had come out the side door at this point, and hollered out get in here right now. My next meeting was with Johnnies father, he stopped me one day explaining he was an ex military drill Sargent or something, and that Johnny had killed himself because I would not be friends with him. This made me extremely angry, and I started yelling at him, well it's your fault, you taught him be a fighter. You probably beat him up too. Then he got mad at me too , I don't recall who threatened to kill who first. But I do recall Johnnies dad admitting to beating Johnny, and crying before he ran off. When I looked up a huge creature was standing behind where Johnnies dad had been. You have found your lizard DNA, it stated. I backed off in terror. I do not recall shape shifting in my encounter with Mr Bench although I may have. This entity I would now describe as an inter- dimensional Lizards. As a 11, or 12 year old boy I assumed this must be the Devil I was talking to. They had not approached me with anger but they exuded much power. I recall Mr Romeo had come out to check on my tiff with Mr Bench and had broken the Illuminati mind control lock on me. I remember backing Mr Romeo off with the statement watch out he will kill you. In some form the Lizards had communicated frustration with the interference Dave Romeo had posed on it's communications with me. We had communicated what had happened with Johnny Bench, He asked me about girls , and had told me we are going to breed you. He told me I would have a very hard life, and that my adversary would be very strong and power full and a Mayor. He then told me that I would be very strong too. He warned if I did not back off my fight against chem trails they would have to kill me. I was backed right back up onto the street by now as I had chased Mr Bench down the trail into the woods. The Lizard then slipped as if talking to a second Lizard beside us. he stated oh no we won't be able to kill him he will be some kind of folk hero, we are just going to have to find another way to kill people. From what I understand today the Illuminati
Courage
Living in the Hell my own people allowed the Illuminati to build for me. Courage is a strange thing, sometimes people say you don't have it when you do . Other times absolute fear enables one to change reality by manipulating the matter around them. In my experience, when this happens one has no fear nor, conscious control over the matter manipulation they administer. I have learned in recent years that matter and energy are one in the same, but that's a hole other subject I will not discus at this point. Heaven forbid the allowed for general public science world wake up, It is as if you become one with God or the collective conscious of this reality and are able to effect it's change. People often refer to one in this state as being a Witch or Psychic, when one sees future possibilities, or past that was before their time. I Lawrence Lapadat, have had many of these experiences, and would like to share one very important one with you at this point. I believe I was about 11,or 12 years old, and I was walking home from school one day when I was confronted by a kid named Johnny Bench. He stepped in front of me and asked me if I wanted to fight. I not wanting to show fear, even though I was afraid agreed. He was about my height but way stockier, and quite a bit heavier. I had never really boxed before and my experience with fighting had usually been wrestling, at which I was quite good. My approach to the task at hand was to reach out to get Johnny in a headlock, this had usually been my best result in past wrestling matches. To my surprise , Johnnies response was a good hard punch to my nose. In shock of what I thought at the time was a cruel unfair way of fighting I got upset and went crying home looking for sympathy. My fathers response was even more shocking to me, when he turned on me with anger and stated, well put up your dukes and fight. The next time I saw Johnny I was angry with him and let him, know by ignoring him, but he persisted, so I let him know I was not happy about him punching me. He apologized , and explained he had only done it because he wanted to be friends. He asked me to play with him, so we went over to his house and played. At one point he asked me why I did not like fighting. I explained that I did not mind wrestling,but did not like punching, so he asked me to wrestle with him. He still got the best of me in wrestling, and he was holding me down and not letting me go when I gave up. I can't recall weather he tried to kiss me or what he did but, I do know something sexual was going on. His mother I believe had been watching us, and ran out scolding Johnny. He let me up, and I yelled out in anger, I never want to play with you again, and I don't want to be your friend. Johnny at this point spurted out in a hurt voice, but I love you, you have to be my friend. Johnnies father had come out the side door at this point, and hollered out get in here right now. My next meeting was with Johnnies father, he stopped me one day explaining he was an ex military drill Sargent or something, and that Johnny had killed himself because I would not be friends with him. This made me extremely angry, and I started yelling at him, well it's your fault, you taught him be a fighter. You probably beat him up too. Then he got mad at me too , I don't recall who threatened to kill who first. But I do recall Johnnies dad admitting to beating Johnny, and crying before he ran off. When I looked up a huge creature was standing behind where Johnnies dad had been. You have found your lizard DNA, it stated. I backed off in terror. I do not recall shape shifting in my encounter with Mr Bench although I may have. This entity I would now describe as an inter- dimensional Lizards. As a 11, or 12 year old boy I assumed this must be the Devil I was talking to. They had not approached me with anger but they exuded much power. I recall Mr Romeo had come out to check on my tiff with Mr Bench and had broken the Illuminati mind control lock on me. I remember backing Mr Romeo off with the statement watch out he will kill you. In some form the Lizards had communicated frustration with the interference Dave Romeo had posed on it's communications with me. We had communicated what had happened with Johnny Bench, He asked me about girls , and had told me we are going to breed you. He told me I would have a very hard life, and that my adversary would be very strong and power full and a Mayor. He then told me that I would be very strong too. He warned if I did not back off my fight against chem trails they would have to kill me. I was backed right back up onto the street by now as I had chased Mr Bench down the trail into the woods. The Lizard then slipped as if talking to a second Lizard beside us. he stated oh no we won't be able to kill him he will be some kind of folk hero, we are just going to have to find another way to kill people. From what I understand today the Illuminati
Re: using recaptcha with django's contrib comments module
Hi, Aidas Bendoraitis a écrit : > You can do that by writing a wrapper for the > django.contrib.comments.views.comments.post_free_comment view. It > should take the request as an argument, check the validity of the > captcha, add the additional parameter to the request, call > the post_free_comment passing the request to it, and return its response. that, i had done... > Then you will need the request context processor > "django.core.context_processors.request" to be activated in your > TEMPLATE_CONTEXT_PROCESSORS. You will be able to access the parameter > passed like this: {{ request.custom_parameter }}. but this is precisely the info i was looking for. thanks a bunch! > Maybe this is not the nicest solution in the world, but it works. -- __ Eric St-Jean[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 -~--~~~~--~~--~--~---
Courage
Living in the Hell my own people allowed the Illuminati to build for me. Courage is a strange thing, sometimes people say you don't have it when you do . Other times absolute fear enables one to change reality by manipulating the matter around them. In my experience, when this happens one has no fear nor, conscious control over the matter manipulation they administer. I have learned in recent years that matter and energy are one in the same, but that's a hole other subject I will not discus at this point. Heaven forbid the allowed for general public science world wake up, It is as if you become one with God or the collective conscious of this reality and are able to effect it's change. People often refer to one in this state as being a Witch or Psychic, when one sees future possibilities, or past that was before their time. I Lawrence Lapadat, have had many of these experiences, and would like to share one very important one with you at this point. I believe I was about 11,or 12 years old, and I was walking home from school one day when I was confronted by a kid named Johnny Bench. He stepped in front of me and asked me if I wanted to fight. I not wanting to show fear, even though I was afraid agreed. He was about my height but way stockier, and quite a bit heavier. I had never really boxed before and my experience with fighting had usually been wrestling, at which I was quite good. My approach to the task at hand was to reach out to get Johnny in a headlock, this had usually been my best result in past wrestling matches. To my surprise , Johnnies response was a good hard punch to my nose. In shock of what I thought at the time was a cruel unfair way of fighting I got upset and went crying home looking for sympathy. My fathers response was even more shocking to me, when he turned on me with anger and stated, well put up your dukes and fight. The next time I saw Johnny I was angry with him and let him, know by ignoring him, but he persisted, so I let him know I was not happy about him punching me. He apologized , and explained he had only done it because he wanted to be friends. He asked me to play with him, so we went over to his house and played. At one point he asked me why I did not like fighting. I explained that I did not mind wrestling,but did not like punching, so he asked me to wrestle with him. He still got the best of me in wrestling, and he was holding me down and not letting me go when I gave up. I can't recall weather he tried to kiss me or what he did but, I do know something sexual was going on. His mother I believe had been watching us, and ran out scolding Johnny. He let me up, and I yelled out in anger, I never want to play with you again, and I don't want to be your friend. Johnny at this point spurted out in a hurt voice, but I love you, you have to be my friend. Johnnies father had come out the side door at this point, and hollered out get in here right now. My next meeting was with Johnnies father, he stopped me one day explaining he was an ex military drill Sargent or something, and that Johnny had killed himself because I would not be friends with him. This made me extremely angry, and I started yelling at him, well it's your fault, you taught him be a fighter. You probably beat him up too. Then he got mad at me too , I don't recall who threatened to kill who first. But I do recall Johnnies dad admitting to beating Johnny, and crying before he ran off. When I looked up a huge creature was standing behind where Johnnies dad had been. You have found your lizard DNA, it stated. I backed off in terror. I do not recall shape shifting in my encounter with Mr Bench although I may have. This entity I would now describe as an inter- dimensional Lizards. As a 11, or 12 year old boy I assumed this must be the Devil I was talking to. They had not approached me with anger but they exuded much power. I recall Mr Romeo had come out to check on my tiff with Mr Bench and had broken the Illuminati mind control lock on me. I remember backing Mr Romeo off with the statement watch out he will kill you. In some form the Lizards had communicated frustration with the interference Dave Romeo had posed on it's communications with me. We had communicated what had happened with Johnny Bench, He asked me about girls , and had told me we are going to breed you. He told me I would have a very hard life, and that my adversary would be very strong and power full and a Mayor. He then told me that I would be very strong too. He warned if I did not back off my fight against chem trails they would have to kill me. I was backed right back up onto the street by now as I had chased Mr Bench down the trail into the woods. The Lizard then slipped as if talking to a second Lizard beside us. he stated oh no we won't be able to kill him he will be some kind of folk hero, we are just going to have to find another way to kill people. From what I understand today the Illuminati
newforms view-question
here´s my view (I think the form-class is not so important for my question): if request.method == 'POST': form = UserProfileForm(request.POST) if form.is_valid(): # SAVING user_profile.sex = form.cleaned_data['sex'] user_profile.date_of_birth = form.cleaned_data ['date_of_birth'] user_profile.phone_number = form.cleaned_data ['phone_number'] user_profile.place_address = form.cleaned_data ['place_address'] user_profile.place_zip_code = form.cleaned_data ['place_zip_code'] user_profile.place_location = form.cleaned_data ['place_location'] if form.cleaned_data['place_state']: user_profile.place_state_id = int(form.cleaned_data ['place_state']) else: user_profile.place_state_id = "" user_profile.save() user_data.first_name = form.cleaned_data['first_name'] user_data.last_name = form.cleaned_data['last_name'] user_data.save() else: # INITIAL_DATA initial_data = {'sex': user_profile.sex, 'first_name': user_data.first_name, 'last_name': user_data.last_name, 'date_of_birth': user_profile.date_of_birth, 'phone_number': user_profile.phone_number, 'place_address': user_profile.place_address, 'place_zip_code': user_profile.place_zip_code, 'place_location': user_profile.place_location, 'place_state': user_profile.get_state_id, } form = UserProfileForm(initial=initial_data) problem is: I´d like to clean this view by eliminating SAVING and INITIAL_DATA, so the view should look like this (if that´s possible): if request.method == 'POST': form = UserProfileForm(request.POST) if form.is_valid(): # SAVING do_save() else: # INITIAL_DATA get_initial_data() form = UserProfileForm(initial=initial_data) question is: where to define do_save() and get_initial_data()? do I have to define that in my model and call something like: user_profile.save() or user_profile.get_initial_data()? or can I define these functions within the form? what´s the "right way" to do that? I´ve done some research but all I could find were examples for form_for_model and form_for_instance, which is not what I need. If someone knows a more complex example of using newforms ... please share it. thanks, patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: no newforms.TextField() available?!?!?
On 6/25/07, Jens Diemer <[EMAIL PROTECTED]> wrote: > This works: > mail_text = forms.CharField(widget=forms.Textarea) That's by design. Whether to show an input type="text" or a textarea is a matter of widgets, so you differentiate between them by using different widgets. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Introducing DjangoSites.Org
On 6/25/07, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > wasnt in spam either - seems to have got eaten up somewhere on the > way - I noticed djangosnippets also had this problem at the start ... > maybe you should consult james bennet On average, I get three or four emails bounced back at me every week from people signing up for djangosnippets.org. Their ISPs don't filter into a spam folder -- they just bounce it back saying "I won't accept this". -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Introducing DjangoSites.Org
On 25-Jun-07, at 5:45 AM, Ross Poulton wrote: > On Jun 21, 12:52 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: >> i had registered as 'lawgon' and waited several hours - but no mail. >> Can you check out? > > As you'd noticed, I've verified your account. According to the mail > logs the mail was sent OK - did it get cought by your spam filtering > or similar? wasnt in spam either - seems to have got eaten up somewhere on the way - I noticed djangosnippets also had this problem at the start ... maybe you should consult james bennet -- 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 -~--~~~~--~~--~--~---
no newforms.TextField() available?!?!?
I would like to use the newforms.TextField() to make a html textarea. But i get the error: 'module' object has no attribute 'TextField' I wounder, because in the Docu i find TextField unter field types list: http://www.djangoproject.com/documentation/newforms/#field-types my code: -- from django import newforms as forms class MailForm(forms.Form): ... mail_text = forms.TextField() ... -- This works: mail_text = forms.CharField(widget=forms.Textarea) Note: I used the unicode-branch. -- Mfg. Jens Diemer A django powered CMS: http://www.pylucid.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?hl=en -~--~~~~--~~--~--~---
Re: How to put an asterisk next to the required form fields?
It works!! Thanks again! I don't know what I would do without this Django users group! :D Ana --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to put an asterisk next to the required form fields?
AnaReis wrote: > Well none of the previous solutions works... :( > I tried the "if field.required" and the "if > field.formfield.is_required" (this particular solution probably > doesn't work because I'm using the newforms). > and I put required=True on the required forms... :S > Excuse me I miss somthing :) {% if field.field.required %} * {% endif %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How can I group fields in admin view of edit_inline foreign models?
How can I group fields in admin view of edit_inline foreign models? The fields tuple in admin takes fields; can I specify foreign models which have edit_inline in them? Thanks for your help as always --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
need help to define models.py for a survey app?
Hello Djangonauts, I am creating a new application to support the creation of online poll (survey). The goals for this application is to support both: -a> The creation of the survey performed by the technical writers -b> Store the answers given by the interviewees The first aspect is similar to what is demonstrated in the tutorial so it was relatively easy to come up with a proposal. The part that I find difficult is to represent the second one. It would be great if someone could suggest a (the best) way to store the answers given by each interviewee. So far I am using a "class" called answer but I am not sure that this is the right thing to do. Thank you for your help. Here it is the models I am having so far: ===models.py= from django.db import models import datetime class Survey(models.Model): name = models.CharField(maxlength=20) description= models.CharField(maxlength=200) start_date=models.DateField("Effective from") end_date=models.DateField("Effective to") def __str__(self): return self.name def is_effective(self): if start_date
Re: How to put an asterisk next to the required form fields?
Well none of the previous solutions works... :( I tried the "if field.required" and the "if field.formfield.is_required" (this particular solution probably doesn't work because I'm using the newforms). and I put required=True on the required forms... :S --~--~-~--~~~---~--~~ 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: 'module' object has no attribute 'urlpatterns'
On Mon, 2007-06-25 at 12:51 +0100, Derek Hoy wrote: > Meant to add that this was definitely something in r5516 - it appeared > consistently going between r5515 and r5516. > > sorry haven't had time to poke about at the cause- got a demo of the > project this afternoon :) > If I can help track it down, let me know. Thanks, Derek, but I think I'm happy enough with the solution to leave it. It was something to do with trying to import modules too early in the process, so I've delayed the importing (and caching) until we really need it the first time. If it works, I'm happy with it. Regards, Malcolm -- Why be difficult when, with a little bit of effort, you could be impossible. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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: 'module' object has no attribute 'urlpatterns'
Meant to add that this was definitely something in r5516 - it appeared consistently going between r5515 and r5516. sorry haven't had time to poke about at the cause- got a demo of the project this afternoon :) If I can help track it down, let me know. Derek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'module' object has no attribute 'urlpatterns'
On 6/24/07, brian corrigan <[EMAIL PROTECTED]> wrote: > > Hi Malcom, > > Thanks for getting back to me so quickly. Updatting to r5520 has fixed > my problem. Good work on you fix so :) Fixed here too. I'm on fcgi + lighttpd and was just getting a 500 server error on any URL in the project, including admin. Many thanks Malcolm. Derek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Empty urls.py file and {% url %} tags
On Mon, 2007-06-25 at 10:06 +, Ryan Kanno wrote: > I know this isn't big (and maybe it's by design), but this didn't > happen prior to I believe -r 5516. If you have a empty urls.py > include file in any app within the project, it causes the {% url %} > tag to not resolve for any app, even an unrelated app view. Well, it's not intended behaviour, but I'm not sure the current behaviour is wrong, either. You're exploiting a very accidental implementation side-effect. Still, we can probably just work around a missing urlpatterns attribute without too much harm. I'll fix it up soon. Regards, Malcolm -- Despite the cost of living, have you noticed how popular it remains? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
REAL PLAYER is FREE and is considered the Best,Music Player Available Today !!
Hi There, Real Player Update !! Now Real Player New Version is available for FREE. With Real Player, Transfer music to iPod and other portable media players.. www.chulbul.com/real.htm Have Fun --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
REAL PLAYER is FREE and is considered the Best,Music Player Available Today !!
Hi There, Real Player Update !! Now Real Player New Version is available for FREE. With Real Player, Transfer music to iPod and other portable media players.. www.chulbul.com/real.htm Have Fun --~--~-~--~~~---~--~~ 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: Introducing DjangoSites.Org
Hi, On 6/25/07, wathi <[EMAIL PROTECTED]> wrote: > Hi Kai, > [...] > font-sizes are already relative and i am not going to change anything > for now. as this is not a django related problem or a feature request > for djangosites.org and no one else has complained about this i would > set up a test page with a small change and invite you to have a look > there rather than discussing it here. You don't have to change anything. I just wanted to say that I don't like the design. The site is great though. Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to put an asterisk next to the required form fields?
For the oldforms, it should be like this: {%for field in form%} {{ field.label }} {{ field }}{%if field.formfield.is_required %}*{%endif%} {%endfor%} tag is deprecated. DO NOT use it. Use CSS. Regards, Aidas Bendoraitis aka Archatas On 6/25/07, EL AATIFI Sidi Mohamed <[EMAIL PROTECTED]> wrote: > > AnaReis wrote: > > Hi! > > I have this form where I want to put red asterisks after each required > > field, but I can't find a way to do it... > > This is my template code: > > > > > onSubmit="return" > > > > > {%for field in form%} > > {{field.label}}{{field}}{%if something_goes_here > > %}*{%endif%} > > {%endfor%} > > > > > > > > > > M > You can try this > > > {% if field.required %}* {% endif %} > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: using recaptcha with django's contrib comments module
You can do that by writing a wrapper for the django.contrib.comments.views.comments.post_free_comment view. It should take the request as an argument, check the validity of the captcha, add the additional parameter to the request, call the post_free_comment passing the request to it, and return its response. Then you will need the request context processor "django.core.context_processors.request" to be activated in your TEMPLATE_CONTEXT_PROCESSORS. You will be able to access the parameter passed like this: {{ request.custom_parameter }}. Maybe this is not the nicest solution in the world, but it works. Regards, Aidas Bendoraitis aka Archatas On 6/23/07, Eric St-Jean <[EMAIL PROTECTED]> wrote: > > Hi, > > Short form of my question: i have a custom view which does some work and > then calls django.contrib.comments.views.comments.post_free_comment; > i've customized the templates/comments/free_preview.html, and i would > like my custom view to somehow pass an additional variable to that > template, without having to do the whole form validation and > re-instantiation that post_free_comment does. How? > > Very long form, skip if you understand the short form: > I integrated recaptcha[1] into the django.contrib.comments comment form > of a little blog app that i wrote with django (based on the django > website blog app, actually, but with tagging). > > So i wanted to keep using most of the code from django.contrib.comments > (view, validation, actual posting, ...) while also using recaptcha. > > The hack i came up with to do so with minimal work, was to copy and > customize templates/comments/free_preview.html, incorporating the > recaptcha code into it. > > The django.contrib.comments.views.comments.post_free_comment view does > everything i need (except for the captcha) for both previewing and > posting. It's in the preview that i show the captcha, using the > aforementionned template (no unnecessary requests to the recaptcha > servers that way). But then, if it's the actual comment post (not the > for-previewing post), i need to actually check that the user solved it. > No problem: i redirected the /comments/postfree/ view to a custom view. > If it's the previewing step, or if it's the posting step and the user > solved the captcha it just goes > return post_free_comment(request) > which does the rest of the validation, and posts the comment. > > My small problem is that at that point, i need to pass a simple variable > to free_preview.html, which is the error code that recaptcha sent us > (such as "the user can't read warped text"), so that the captcha on the > refreshed screen will have error text[2] the problem is that to > instantiate that template with its form, FreeComment's post_free_comment > view uses a ton of code, and i had to duplicate a lot of it into my own > view: > > try: > options, target, security_hash = > request.POST['options'], request.POST['target'], request.POST['gonzo'] >except KeyError: > raise Http404, _("One or more of the required fields > wasn't submitted") > content_type_id, object_id = target.split(':') # target is > something like '52:5157' > option_list = options.split(',') > new_data = request.POST.copy() > new_data['content_type_id'] = content_type_id > new_data['object_id'] = object_id > new_data['ip_address'] = request.META['REMOTE_ADDR'] > new_data['is_public'] = IS_PUBLIC in option_list > manipulator = PublicFreeCommentManipulator() > return render_to_response('comments/free_preview.html', { > 'comment': "", > 'comment_form': oldforms.FormWrapper(manipulator, > new_data, None), > 'options': options, > 'target': target, > 'hash': security_hash, > 'recaptcha_error': recatpcha_resp_text[1], > }, context_instance=RequestContext(request)) > > (see http://dpaste.com/hold/12801/ for nicely formatted view) > > all of that only to pass an extra var ('recaptcha_error') to the > template... the rest of that code is verbatim from the default view. > > after all this rambling, my question is quite simple: after having > validated the captcha, if there was an error with it, i'd prefer to just > call django.contrib.comments.views.comments.post_free_comment so that > *it* bothers itself with refreshing the preview form, rendering my > customized template, and so that i don't duplicate the above code. But > how can i pass some value to the template when i'm not the one > instantiating it? Should i add the error text to the session and have > the template somehow retrieve that? Can a custom templatetag have access > to session data? > > It all works; i just want it Pretty, and i'm sure there's a stupid > solution that i'm too newb to see. > > thank you for your kind attention... > > [1]
Re: Attrs in models
If it is by design - it is ok. I thought that I just can't find information *how* to do it. Thanks for your time & effort. On Jun 25, 3:19 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2007-06-24 at 22:49 +, l5x wrote: > > This is a great stuff and I'm really glad that you show me that, but I > > still wonder if it is possible to do sth like that in a model ;-) > > No, it isn't possible and that's by design. Here's the reasoning behind > why we are doing it the way we are: > > In the general case ,tying a particular presentation to the data > representation isn't a flexible procedure and long-term in medium to > large projects, not great design practice either: the person responsible > for creating the form designs has to also edit the code that is part of > the data representation. We try very hard in Django (and are continually > smoothing out places as we go along) to keep independent > responsibilities separate in the code and this includes moving > presentation information out of models. > > We have to make a choice when creating the API here and, as with all > choices, some use-cases might become a little harder (but never > impossible) whilst we are making the common and best-practice cases > easier. In this particular instance, the case where you have a single > presentation style and are always creating forms directly from a single > model requires you to write the field names twice sometimes. That's one > of the trade-offs in the broader design, unfortunately. > > Consequently, you can't drop presentation information into the model > directly. However, you could store a list of that extra information > mapped to field names in a dictionary and then write a helper function > that takes your model and that dictionary and creates a form. So if you > did have a desire to keep the information together, it's possible. You > just can't hijack the Field class definitions to store it, because that > would require changing the API (you could write new classes, one for > each Field that takes the extra information, but at some point the extra > work to support that might become onerous). > > 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?hl=en -~--~~~~--~~--~--~---
Empty urls.py file and {% url %} tags
I know this isn't big (and maybe it's by design), but this didn't happen prior to I believe -r 5516. If you have a empty urls.py include file in any app within the project, it causes the {% url %} tag to not resolve for any app, even an unrelated app view. The exception returned is somewhere near line 205 in urlresolvers.py as this is the trace returned. AttributeError at / 'module' object has no attribute 'urlpatterns' Exception Type: AttributeError Exception Value: 'module' object has no attribute 'urlpatterns' Exception Location: C:\Python23\lib\site-packages\django\core \urlresolvers.py in_get_reverse_dict, line 205 Python Executable: C:\Python23\python.exe Python Version: 2.3.5 Since the empty include doesn't have a urlpatterns, it throws the above error... then proceeds to load the site. I'm not sure if something is being cached or not - but even as the site eventually loads, none of the {% url %} template tags (that used to work prior to the revision) resolve anymore. The obvious work around is to just add the following to urls.py: from django.conf.urls.defaults import * urlpatterns = patterns('') Just wondering if this was intended behavior or not. Thanks, _RK And yeah, I know... empty urls.py files are probably bad to have around anyway. ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to put an asterisk next to the required form fields?
AnaReis wrote: > Hi! > I have this form where I want to put red asterisks after each required > field, but I can't find a way to do it... > This is my template code: > > onSubmit="return" > > > {%for field in form%} > {{field.label}}{{field}}{%if something_goes_here > %}*{%endif%} > {%endfor%} > > > > > M You can try this {% if field.required %}* {% endif %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to put an asterisk next to the required form fields?
Hi! I have this form where I want to put red asterisks after each required field, but I can't find a way to do it... This is my template code: {%for field in form%} {{field.label}}{{field}}{%if something_goes_here %}*{%endif%} {%endfor%} My problem is that I can't find a way to make this work. I thought of building a function named, for example, "is_required" that would receive the fields name and return True or False if the field was required or not, but this is not possible to be done since you can't input parameters into functions in the templates... Is there already a function in the fields called is_required? Is the only possible way to make this work to forget my neat for in the template and replace it by calling every field in the form class?... I really don't know how to do 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?hl=en -~--~~~~--~~--~--~---
Re: Javascript-Django image paths
> I don't mean to offend you, but I think you've misunderstood how the > web works. There's really no difference in the HTTP request of a > human clicking a link and the HTTP request caused by an image tag (or > javascript image.src assignment). I thought that way because I couldn't find any other reason why the path won't work, especially because this is in Django. I've always believed what you said before this problem arose, but you are still correct though. > Please get Firebug (a Firefox extension) and observe the network > traffic caused by your JS and by directly loading the image. FireFox is crashing because of some specific problems I've yet to fix, that's why I'm using IE. Putty is giving me enough traffic. Right now everytime I toggle the checkbox it shows the path "/images/ schematics/..." Here's all the relevant code: function show_img(suf, val) { img = document.getElementById('image_' + val); img.src = '/images/schematics/SKU' + suf + '.jpg'; } (r'^images/schematics/(?P.*)/$', 'django.views.static.serve', {'document_root': '/www/htdocs/gfs_chefrevival/images/schematics'}), I've tried the url with both the "/$" and "$", none works. [25/Jun/2007 02:02:49] "GET /images/schematics/SKUrc.jpg HTTP/1.1" 304 0 If u guys have any great ideas I'll gladly scrap this up and implement yours. THanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Javascript-Django image paths
On Mon, Jun 25, 2007 at 03:43:51AM -, robo wrote: > function show_img(suf, val) { > img = document.getElementById('image_' + val); > img.src = 'images/schematics/SKU' + suf + '.jpg'; ^ put a / here... img.src = '/images/schematics/SKU' + suf + '.jpg'; > } Cheers, -- Brett Parker --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---