Re: Can't get django comments to pick up alternate form
> Do you have django.contrib.comments > coming before your own app in INSTALLED_APPS, by any chance? Yes I did! Thanks for the hint. I put my own app first, and now it's finding it just fine! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Can't get django comments to pick up alternate form
On Jan 25, 2009, at 1:54 PM, Theme Park Photo, LLC wrote: > > Also from reading the source, I don't see any mechanism by which it > would pick up form.html from any other than the three directories > enumerated there. Am I really supposed to edit and setup.py install > the django framework to change the comments template? The three directories in the template_search_list there are meant to refer to directories in the templates folder of YOUR project, not the django contrib comments installation. This definitely works under normal circumstances, so something else must be going wrong. I don't know how to get a list of template directories except by inducing an error, say by temporarily misnaming the comments templates directory within the django installation. Do you have django.contrib.comments coming before your own app in INSTALLED_APPS, by any chance? E > > > On Jan 24, 5:13 pm, "Theme Park Photo, LLC"wrote: >> The documentation for render_comment_form hints that you can override >> the default template by puttingcomments/form.html with your own form >> in your templates directory. >> >> No matter what I do, it won't pick up my alternate form. >> >> Is there anyway to see the actual directoriesdjangois checking for >> this template? > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Can't get django comments to pick up alternate form
Also from reading the source, I don't see any mechanism by which it would pick up form.html from any other than the three directories enumerated there. Am I really supposed to edit and setup.py install the django framework to change the comments template? On Jan 24, 5:13 pm, "Theme Park Photo, LLC"wrote: > The documentation for render_comment_form hints that you can override > the default template by puttingcomments/form.html with your own form > in your templates directory. > > No matter what I do, it won't pick up my alternate form. > > Is there anyway to see the actual directoriesdjangois checking for > this template? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sqlite3 problems setting up
On Jan 25, 6:04 pm, Steve Holdenwrote: > > When you install something by running > > python setup.py install > > it gets installed into the python that is used to run setup.py. It looks > like you had /usr/local/bin on your path when you installed django, but > not when you installed PIL and pysqlite2 (or maybe you just hadn't > installed Python 2.6 at that stage). > > Either way, one version of Python won't see packages installed in another. Yes, I think this is happening - very frustrating! I just wanted to update python - Whenever I try install modules now though (e.g. sudo aptitude install python-imaging), it doesn't install them in the new folder - why oh why I just found this site http://jaredforsyth.com/content/install-python-26-ubuntu that explains how to have an automatic install - which I did, but now my python path has got my other python 2.6 installation location. (I now have one under /usr/lib/ and another under /usr/local/lib) I've googled and googled and have not found out how you remove it properly (If I were to remove it, I'd just delete the whole folder) I don't know how to set my python path to point to the new python 2.6 folder either. All in all, I'd rather just revert back to python 2.5 problem is that I don't know how to do that either!!! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sqlite3 problems setting up
DragonSlayre wrote: > Just doing some exploring - noticing that: > > * /usr/lib/python2.5/site-packages has a pysqlite2 folder as well as a > PIL folder > * /usr/local/lib/python2.6/site-packages has just django in it > > I'm not sure how the whole site-packages things work, or why python > 2.5 is in /usr/lib/ and python 2.6 is in /usr/local/lib/ ? Sounds like Python 2.5 came with your Unix/Linux distro, and you have added 2.6 by installing from source - by default it installs with --prefix=/usr/local, I believe. When you install something by running python setup.py install it gets installed into the python that is used to run setup.py. It looks like you had /usr/local/bin on your path when you installed django, but not when you installed PIL and pysqlite2 (or maybe you just hadn't installed Python 2.6 at that stage). Either way, one version of Python won't see packages installed in another. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sqlite3 problems setting up
Just doing some exploring - noticing that: * /usr/lib/python2.5/site-packages has a pysqlite2 folder as well as a PIL folder * /usr/local/lib/python2.6/site-packages has just django in it I'm not sure how the whole site-packages things work, or why python 2.5 is in /usr/lib/ and python 2.6 is in /usr/local/lib/ ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Queryset unexpectedly turning into list
Ah, ok thanks for the explanation :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Iterating over jwplayers
I have a simple page with not much css and just trying to iterate over some videos and get them all to display on the same page. They seems to be stacking on top of eachother rather than each having it's own space. This is not really a Django issue but I'm wondering if anyone has had a similar issue and could share some insight. Thanks, {% block video %} The Video Block {% for video in videos %} The player will show in this paragraph var s1 = new SWFObject('{{MED}}/player.swf','player','400','300','9'); s1.addParam('allowfullscreen','true'); s1.addParam('allowscriptaccess','always'); s1.addParam('flashvars','file={{MED}}/{{video.file}}'); s1.write('preview'); {% endfor %} {% endblock %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sqlite3 problems setting up
Importing sqlite3 fails as well (if I type this into a python shell) import sqlite3 Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.6/sqlite3/__init__.py", line 24, in from dbapi2 import * File "/usr/local/lib/python2.6/sqlite3/dbapi2.py", line 27, in from _sqlite3 import * ImportError: No module named _sqlite3 sqlite3 is definitely installed, as I made a database and tested it out --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sqlite3 problems setting up
This is my path currently: ['', '/usr/local/lib/python26.zip', '/usr/local/lib/python2.6', '/usr/ local/lib/python2.6/plat-linux2', '/usr/local/lib/python2.6/lib-tk', '/ usr/local/lib/python2.6/lib-old', '/usr/local/lib/python2.6/lib- dynload', '/usr/local/lib/python2.6/site-packages'] On Jan 25, 3:22 pm, DragonSlayrewrote: > I've just done a fresh install of python 2.6 and django 1.0.2, and > sqlite3 in ubuntu, and I've cloned my repository, and tried python > manage.py runserver, but then I get this error: > > File "/usr/local/lib/python2.6/site-packages/django/db/backends/ > sqlite3/base.py", line 27, in > raise ImproperlyConfigured, "Error loading %s module: %s" % > (module, exc) > django.core.exceptions.ImproperlyConfigured: Error loading sqlite3 > module: No module named _sqlite3 > > The only thing I can think of is that maybe what it's looking for > isn't on the python path or something - I just commented out the DB in > the settings, and it complained about the PIL module (I installed this > prior to installing django). > > I'm not exactly sure what's going on, any help would be appreciated :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
sqlite3 problems setting up
I've just done a fresh install of python 2.6 and django 1.0.2, and sqlite3 in ubuntu, and I've cloned my repository, and tried python manage.py runserver, but then I get this error: File "/usr/local/lib/python2.6/site-packages/django/db/backends/ sqlite3/base.py", line 27, in raise ImproperlyConfigured, "Error loading %s module: %s" % (module, exc) django.core.exceptions.ImproperlyConfigured: Error loading sqlite3 module: No module named _sqlite3 The only thing I can think of is that maybe what it's looking for isn't on the python path or something - I just commented out the DB in the settings, and it complained about the PIL module (I installed this prior to installing django). I'm not exactly sure what's going on, any help would be appreciated :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multithreaded development server
On Jan 25, 11:08 am, Almadwrote: > Hello, > > is there a way to run development server multithreaded, so it can > handle recurring requests? Just use Apache/mod_wsgi instead as described in: http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html Use daemon mode with that recipe for automatic restarting on changes. Configure daemon processes to have multiple threads and if necessary multiple processes. That way you can also test multi process configuration properly. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Datetime and apache log files show wrong timezone
On Jan 25, 2:27 am, simongwrote: > On Jan 24, 2:30 pm, Graham Dumpleton > wrote: > > > > > On Jan 24, 8:46 pm, simong wrote: > > > > My apologies in advance if this isn't a direct django issue but I > > > can't work out where the problem is coming from. > > > > My server's system time runs Centos 5 and is set to Europe/London: > > > > -bash-3.2$ date > > > Sat Jan 24 12:26:14 GMT 2009 > > > -bash-3.2$ date -u > > > Sat Jan 24 12:26:17 UTC 2009 > > > -bash-3.2$ /sbin/hwclock --show > > > Sat 24 Jan 2009 12:31:34 PM GMT -0.984663 seconds > > > > /etc/sysconfig/clock is set thusly: > > > > ZONE="Europe/London" > > > UTC=true > > > ARC=false > > > > My django application timezone is set to 'Europe/London': > > > > TIME_ZONE = 'Europe/London' > > > > The application creates a datestamp to log when an order has been > > > requested using datetime.datetime.now() but it and the apache logs are > > > still using EST, which was what the machine was set to on build (no > > > idea why, it's based in Germany): > > > > xxx.xxx.xxx.xxx - - [24/Jan/2009:07:16:19 -0500] "GET /media/images/ > > > bground_bottom_right.png HTTP/1.1" 200 116555 > > > "http://www.popfood.co.uk/media/css/common.css; "Mozilla/5.0 (Macintosh; > > > U; > > > Intel Mac OS X 10.5; en-US; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5 > > > Ubiquity/0.1.5" > > > > The server has a Plesk control panel which provides a editable > > > configuration file for the domain called vhost.conf which should > > > override anything in the Plesk-generated config files, so I have > > > added > > > SetEnv TZ Europe/London to that and restarted apache to no effect. > > > That will not do anything as it only modified process environment > > variables for CGI script processes execed from Apache. > > > If you are seeing the wrong timzone from what you are setting, it is > > most likely because you are running multiple applications in same > > Apache instance and each is wanting to use a different timezone. These > > could be multiple Django instances, or even PHP applications. > > > Short answer is you can't run multiple applications in same Apache > > which have different timezone requirements. > > > Graham > > For your information SetEnv does work in mod_python. It is referred to > in the djangoproject documentation for setting up a server using > mod_python > here:http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#howt... I am talking about Apache/mod_python alone, where my statement is correct. That SetEnv does that for Django is a hack and works because Django mod_python adapter updates os.environ from mod_python req.subprocess_env. That it does this is quite evil because it actually affects the whole process environment variable set and not that for just that specific Django instance of URL subset as bounded by any Location directive in Apache. If you have multiple Django instances, use SetEnv can cross pollute the process environment variables seen by each, which in some circumstances can cause problems. It will also infect process environment variables as seen by PHP applications if running in same Apache instance. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-smtpd allows you to handle email messages just like Django processes HTTP requests
Wow, very cool. How will this integrate on a production server? is this a true Mailto: link or something else. I mean it doesn't look like a real SMTP engine. I love the idea though! J On Jan 24, 8:29 am, nsidewrote: > Hello, > > I just started a new project that basically allows you to write email > handlers in Django. It could be used in a user-registration > application where the user could reply to the email instead of > clicking on a URL. > I drafted a quick documentation > athttp://code.google.com/p/django-smtpd/wiki/GettingStarted > It shows the basic design of the lib and I'm looking for comments/ > suggestions/use cases if that's of interest to anyone on this list. > Note that this is still in "hacking" phase so don't consider using > this in a production system. > > Thanks! > Denis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multithreaded development server
Some threads on here have used CherryPy's django Plug-in and it's a full server too. You only need to account for Admin files via some well know workings. J On Jan 24, 4:08 pm, Almadwrote: > Hello, > > is there a way to run development server multithreaded, so it can > handle recurring requests? > > Thanks, > > Almad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django-OAuth Issue
Hello David sorry for the late response. I think that I found a minor bug with django-oauth. So I tried Malcolm Tredinnick's recommendation and used the client oauth library found here: http://oauth.googlecode.com/svn/code/python/oauth/example/client.py I filled in the variables as so: SERVER = 'xyz.example.com' PORT = 8080 REQUEST_TOKEN_URL = '/oauth/request_token/' ACCESS_TOKEN_URL = '/oauth/access_token/' AUTHORIZATION_URL = '/oauth/authorize/' CONSUMER_KEY = '2x2pbQGzaWmZSUAQ' CONSUMER_SECRET = '4mzNQfxVPmCrzrQL' then making a simple call to get the request_token as so: client = SimpleOAuthClient(SERVER, PORT, REQUEST_TOKEN_URL, ACCESS_TOKEN_URL, AUTHORIZATION_URL) consumer = oauth.OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET) signature_method_plaintext = oauth.OAuthSignatureMethod_PLAINTEXT() signature_method_hmac_sha1 = oauth.OAuthSignatureMethod_HMAC_SHA1() oauth_request = oauth.OAuthRequest.from_consumer_and_token(consumer, http_url=client.request_token_url) oauth_request.sign_request(signature_method_hmac_sha1, consumer, None) token = client.fetch_request_token(oauth_request) When passing in signature_method_plaintext everything seems to work well since there is no signature to build. When I would use signature_method_hmac_sha1, I would receive an error stating that no oauth token was generated. WHAT I FOUND: When building the signature on the client, it looks like so: vRSS7EtrCln5IBKT7AMtbMjOHt4= Next when rebuilding the signature on the server, I receive a different signature: FQk6YWEuCQRyIhnx0F0ujSfU4LQ= Here is what the oauth request string looks like: >From Client: GET&%2Foauth%2Frequest_token%2F_consumer_key%3D2x2pbQGzaWmZSUAQ %26oauth_nonce%3D26799452%26oauth_signature_method%3DHMAC- SHA1%26oauth_timestamp%3D1232760676%26oauth_version%3D1.0 >From Server GET%3A%2F%2Fxyz.example.com%3A8080%2Foauth%2Frequest_token %2F_consumer_key%3D2x2pbQGzaWmZSUAQ%26oauth_nonce %3D26799452%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp %3D1232760676%26oauth_version%3D1.0 As you can see, the client did not pass in the absolute_uri but the server did so when the server built it's signature it did not match with the client's signature. So the solution that I came up with was this: In jango-oauth/oauth_provider/utils.py on line 13 where it says: request.build_absolute_uri() I changed it to: request.path_info and all seems to work. What are your thoughts and is this the best solution? Also the error messages returned were not very verbose. It would be nice if the errors received were more verbose but this may be an issue with the oauth client library that I used not handling error in a better fasion. Here is an example error that I would receive in relation to a failed signature: Traceback (most recent call last): File "test.py", line 65, in token = client.fetch_request_token(oauth_request) File "test.py", line 34, in fetch_request_token return oauth.OAuthToken.from_string(response.read()) File "/some/location/disk/oauth.py", line 70, in from_string key = params['oauth_token'][0] KeyError: 'oauth_token' Thanks for your response. On Jan 19, 3:58 pm, David Larletwrote: > Chris, > > It seems that oauth_token argument is missing from your response. Do > you still have errors with your code? > > Do not hesitate to contact me directly if that's the case, I do not > want to spam this mailing-list with custom apps support. > > Regards, > David > > Le 14 janv. 09 à 05:49, Chris a écrit : > > > > > Well I plugged in my variables into the example client and it still > > seems to break on the same segment: > > token = client.fetch_request_token(oauth_request) > > > I am using code from this repository to handle the server sided > > portion: > >http://code.larlet.fr/django-oauth/ > > Perhaps there is an issue with this library. I will look into this. > > > example documentation: > >http://code.larlet.fr/doc/django-oauth-provider.html > > This example seems to do things slightly different. > > > Chris > > > On Jan 13, 7:29 pm, Malcolm Tredinnick > > wrote: > >> On Tue, 2009-01-13 at 18:54 -0800, Chris wrote: > >>> Hello, > > >>> I have been using django-oauth and am getting the below error using > >>> this codehttp://dpaste.com/108808/ > > >>> I get this when running the dpaste code in the python shell. > >>> Traceback (most recent call last): > >>> File "", line 1, in > >>> File "", line 7, in get_unauthorised_request_token > >>> File "/usr/lib/python2.5/site-packages/oauth.py", line 70, in > >>> from_string > >>> key = params['oauth_token'][0] > >>> KeyError: 'oauth_token' > > >>> so when I make a request to /oauth/request_token/, it initializes > >>> the > >>> oauth classes and methods using: > >>> oauth_server, oauth_request = initialize_server_request(request) > > >>> next, this call which seems to be where it breaks: > >>> token = oauth_server.fetch_request_token(oauth_request) > > >>> so the
Can't get django comments to pick up alternate form
The documentation for render_comment_form hints that you can override the default template by putting comments/form.html with your own form in your templates directory. No matter what I do, it won't pick up my alternate form. Is there anyway to see the actual directories django is checking for this template? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multithreaded development server
On Jan 24, 7:08 pm, Almadwrote: > Hello, > > is there a way to run development server multithreaded, so it can > handle recurring requests? > > Thanks, > > Almad Yes, there's a patch attached to http://code.djangoproject.com/ticket/3357 that will enable multi-threading in the dev server. Unfortunately, it's likely never to get adopted by Django, since the lead devs don't want to deal with the maintenance overhead it would entail. Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multithreaded development server
Hello, is there a way to run development server multithreaded, so it can handle recurring requests? Thanks, Almad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding a slug
On Sun, Jan 25, 2009 at 2:14 AM, Adi Siekerwrote: > > Hi, > > as far as I know loaddata doesn't use the ORM to insert the data. Incorrect. loaddata does use the ORM, but it uses raw save mode, which disables custom save methods. Raw save mode also disables any database field pre-handling, such as the auto_update_now triggers on a date field. > So things like signals and overloaded save methods don't work when > using loaddata. This point is correct. Custom save methods aren't activated as part of the loaddata process. Yours Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Queryset unexpectedly turning into list
All magic happens in line: if(queryset):#check if query returned somethin To perform this check QuerySet is evaluated and makes query to DB and stores result in list. After that QuerySet slice operation make real slice on underlying cache and of cource return list. On Sun, Jan 25, 2009 at 1:26 AM, mb0...@googlemail.com < mb0...@googlemail.com> wrote: > > Hi, > > please have a look at: http://dpaste.com/112603/ > > Can someone tell me why the sliced queryset suddenly turns into a > list? > I'm still new to Python/Django so I can't tell if it is a bug... but > it sure cost me some time because in my eyes it was something complete > out of the blue. > > Django version 1.0.2 > Python 2.5.2 > > Kind regards, > Martin > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Queryset unexpectedly turning into list
On Sat, Jan 24, 2009 at 8:26 PM, mb0...@googlemail.comwrote: > > Hi, > > please have a look at: http://dpaste.com/112603/ > > Can someone tell me why the sliced queryset suddenly turns into a > list? > I'm still new to Python/Django so I can't tell if it is a bug... but > it sure cost me some time because in my eyes it was something complete > out of the blue. > > Django version 1.0.2 > Python 2.5.2 > What DB backend are you using?. -- 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Queryset unexpectedly turning into list
Hi, please have a look at: http://dpaste.com/112603/ Can someone tell me why the sliced queryset suddenly turns into a list? I'm still new to Python/Django so I can't tell if it is a bug... but it sure cost me some time because in my eyes it was something complete out of the blue. Django version 1.0.2 Python 2.5.2 Kind regards, Martin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Customize form fields after instantiation
Hello all, I'd like an easy way to customize one or more form fields after being instantiated by a ModelForm. I didn't find anything close in the docs so I came up with the following: from django.forms import ModelForm class CustomModelForm(ModelForm): # a mapping of field names to attr./value dicts field2attrs = {} def __init__(self, *args, **kwargs): super(CustomModelForm, self).__init__(*args, **kwargs) for name,attrs in self.field2attrs.iteritems(): field = self.fields[name] for attr,val in attrs.iteritems(): setattr(field,attr,val) # usage === class QnAForm(CustomModelForm): field2attrs = { 'question': dict(widget=TextInput(attrs={'size':100})), 'answer': dict(required=False), } class Meta: model = models.QnA Is there a better way to do it ? If not, I think it might be useful enough to be added in the base ModelForm. George --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Use _meta.fields to return the datatype
Thanks!!! It was exactly what I was looking for :-). On Jan 24, 3:20 am, Steve Holdenwrote: > dj wrote: > > On Jan 23, 10:12 pm, dj wrote: > > >> Hello All, > > >> I am a Django novice, and I recently discovered the _meta methods for > >> use with models. > >> Using _meta.fields to return the field names in a model instance, the > >> current value of an instance (getattr()) and set the value (setattr > >> ()). > > >> I was wondering if anyone knows how to use _meta.fields to return the > >> datatype for a field in a model ? > > >> Your assistance is greatly appreciated :-). > > > It would appear there is method called get_internal_type() that maybe > > what I am looking for. > > The method is in django.db.models.Field. But I am unable to find > > anything that would tell > > me how to use the function to return the data type for a field in a > > model. > > > m=Org() > > > for field in m._meta.fields[1:]: > > fields.append(str(field.name)) > > get_internal_type(field.name) - is this the correct way to call > > the method ? > > [But he top-posted, so I moved his stuff down below the question]. > > A bit of fiddling about with the interpreter in a manage.py shell > session reveals all: > > In [11]: from django.db.models import Field > > In [12]: f = Field() > > In [13]: f.get_internal_type() > Out[13]: 'Field' > > In [14]: from django.db.models import IntegerField > > In [15]: i = IntegerField() > > In [16]: i.get_internal_type() > Out[16]: 'IntegerField' > > And, of course, there's always > > In [17]: help(i.get_internal_type) > > which tells you: > """ > Help on method get_internal_type in module django.db.models.fields: > > get_internal_type(self) method of django.db.models.fields.IntegerField > instance > """ > > Not terrifically helpful, but at least the signature tells you no > arguments are required ... > > regards > Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with contenttype/renaming of an app
look in auth_permission I would just rename them by hand or by sql http://crucial-systems.com On Sat, Jan 24, 2009 at 8:19 PM, Benjamin Buchwrote: > > Hi, > > during development, I messed around with an app name. > First it was called 'body copies' (no native speaker!), then I renamed > it to 'stanza', which I liked better. > No problem there: As there was no data in the db, I deleted the tables > and created them again, with other names. > > Then I deployed the project. > I transfered the data via manage.py dumpdata/loaddata. > Still no problems when I'm logged in as admin. > > But: > When I create a new user group and want to give permissions, there's > still 'body copy' instead of 'stanza'. > ('bodyopies | body copy | Can add static content' and so on...) > > If I give the bodycopy permissions and log in as a user with those > permissions, I'm not able to edit 'stanza'. > The 'stanza'-area won't even show up in the admin panel, neither does > 'bodycopies'. > > I took a look at the database, and in the table 'django_content_type' > I found some entries refering to 'bodycopies': > > id |name | app_label | model > ---+---++--- > 09 | body copy | bodycopies | bodycopy > > I renamed them to the according 'stanza' labels. > After that, in the group permissions on the group page 'stanza' showed > up instead of 'bodycopies', > but I still was not able to edit 'stanza' as non-admin-user. > > Any ideas? > > Benjamin > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
RELEASED: django-batchimport 0.2
Hi Folks, I've updated the django-batchimport project to version 0.2. This new version allows for easy import of relationship data (many-to-many, for example) for previously imported data -- even if your original data doesn't have unique IDs. There's also the new ability to override field values (say, using some property in the session or on the user's profile, for example) and several convenience methods... http://code.google.com/p/django-batchimport/ Take a look. Let me know if you have any problems. Best, Keyton django-batchimport: This application can be added to any django project to give it batch import capability via uploaded Microsoft Excel file (or other formats saved as XLS). This allows for someone with a spreadsheet of, say, users to easily upload it and add it all at once. While batch importing in django is easy to do via fixtures, this reusable app is aimed at being for non-developer end users of your web application. The process by which this app does it's work is completely dynamic, inspecting both the spreadsheet and the django models dynamically at runtime. No prior knowledge of either the model into which the user is importing or the spreadsheet uploaded is required. The only prerequisite is John Machin's xlrd library (http:// www.lexicon.net/sjmachin/xlrd.htm), python 2.5+, and django 1.0+. See the website for full details and please drop me a note on the django-batchimport-users group if you have questions or comments. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need help with models
Do you use a custom Model Manager or something similar to make it optimal? I'm using this approach now but it needs to make a query for every element, which is not very efficient. I'd be happy if one of the django "brains" tell us how could we do this. Thank you. On 24 ene, 21:07, Klesswrote: > I also was looking for a solution for it and I found that the most > optimal is the first approach --at least for me--. > > You have a normal table with data entered into a language by default, > and then it's used another one to translating the text fields from > that main table. > > The difference with yours is that I use: > > lang = models.ForeignKey('Language') > > On 24 ene, 17:41, Adrián Ribao wrote: > > > Hello everybody, > > > I need to create dinamic content in several models. I have 3 > > approaches: > > > approach 1: > > > class News(models.Model): > > date = ... > > visible = ... > > text = models.CharField(max_length=255) > > > class NewsTrans(models.Model): > > news = models.ForeignKey(News) > > lang = models.CharField(max_length=5, choices=settings.LANGUAGES) > > text = models.CharField(max_length=255) > > > approach 2: > > class News(models.Model): > > lang = models.CharField(max_length=5, choices=settings.LANGUAGES) > > date = ... > > visible = ... > > text = models.CharField(max_length=255) > > > approcah 3: > > class NewsBase(): > > date = ... > > visible = ... > > > class News(NewsBase): > > lang = models.CharField(max_length=5, choices=settings.LANGUAGES) > > text = models.CharField(max_length=255) > > > (Any other approaches are welcome.) > > > The one I like the least is the second one. > > > I really need help here, please tell me how to implement translations > > in ddbb in the most efficient way. > > > Thank you. > > > P.S. I hope Django can manage this problem, hopefully in 1.3! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need help with models
I also was looking for a solution for it and I found that the most optimal is the first approach --at least for me--. You have a normal table with data entered into a language by default, and then it's used another one to translating the text fields from that main table. The difference with yours is that I use: lang = models.ForeignKey('Language') On 24 ene, 17:41, Adrián Ribaowrote: > Hello everybody, > > I need to create dinamic content in several models. I have 3 > approaches: > > approach 1: > > class News(models.Model): > date = ... > visible = ... > text = models.CharField(max_length=255) > > class NewsTrans(models.Model): > news = models.ForeignKey(News) > lang = models.CharField(max_length=5, choices=settings.LANGUAGES) > text = models.CharField(max_length=255) > > approach 2: > class News(models.Model): > lang = models.CharField(max_length=5, choices=settings.LANGUAGES) > date = ... > visible = ... > text = models.CharField(max_length=255) > > approcah 3: > class NewsBase(): > date = ... > visible = ... > > class News(NewsBase): > lang = models.CharField(max_length=5, choices=settings.LANGUAGES) > text = models.CharField(max_length=255) > > (Any other approaches are welcome.) > > The one I like the least is the second one. > > I really need help here, please tell me how to implement translations > in ddbb in the most efficient way. > > Thank you. > > P.S. I hope Django can manage this problem, hopefully in 1.3! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: InternalError and transactions
On Jan 24, 11:41 am, Karen Traceywrote: > Just a note -- what you are describing is unique URLs per-user. You > confused me a bit with how you phrased it as duplicate URLs are allowed by > what you have specified, so long as they are associated with different > users. Right. Sorry for the confusion. > You left out the form definition. I'm guessing it's a ModelForm? Also I'm > guessing you excluded the user from the form? Note if it is a ModelForm, > and all the fields involved in unique_together were in fact included in it, > then the form validation would do the unique check for you, and you wouldn't > have to worry about the save causing a database error, assuming you could > guarantee no other save was made that might invalidate the unique check done > by is_valid() before the committing save() ran. But if you exclude one of > the fields or can't guarantee a duplicate entry hasn't been inserted between > the validation check and the committing save, then you do need to deal with > the potential database error. For full disclosure, here's my LinkForm: class LinkForm(ModelForm): class Meta: model = Link exclude = ('user',) def __init__(self, request, *args, **kwargs): super(LinkForm, self).__init__(*args, **kwargs) self.request = request self.fields['category'].queryset = Category.objects.filter (user=request.user).order_by('name') Based on what you describe above, it sounds preferable to let Django handle the unique_together on is_valid(), but I don't think I can do that since I need to attach the user to the form later since I don't know it until the request comes in. So I'm stuck with having to do my own error checking, correct? > So...if you can't call transaction.rollback() because the code is not under > transaction management, ensure it is under transaction management whenever > you might need to call transaction.rollback(). Probably easiest to just > wrap it in commit_on_success: > > http://docs.djangoproject.com/en/dev/topics/db/transactions/#django-d... > > Alternatively you could use the lower-level connection rollback routine and > bypass the django.db.transaction layer, but I think it's cleaner to stick > with the higher level routines. OK. I added commit_on_success to wrap the view and am now able to rollback on IntegrityError. Thanks, Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: InternalError and transactions
On Sat, Jan 24, 2009 at 12:52 PM, Rob Hudsonwrote: > > I'm a bit at a loss as to where to go from here... > > I have simple Link and Category models. My Link model is essentially: > user_id, category (FK), name, URL. I have a Meta unique_together on > (user, url) so no duplicate URLs get entered. I'm testing this by > trying to purposefully enter a duplicate URL. > Just a note -- what you are describing is unique URLs per-user. You confused me a bit with how you phrased it as duplicate URLs are allowed by what you have specified, so long as they are associated with different users. > > At first my code threw an IntegrityError so I'm trying to catch that. > Here's my create view: > > def create(request): > >errors = {} > >if request.method == 'POST': >form = LinkForm(request, request.POST) >if form.is_valid(): >link = form.save(commit=False) >link.user = request.user You left out the form definition. I'm guessing it's a ModelForm? Also I'm guessing you excluded the user from the form? Note if it is a ModelForm, and all the fields involved in unique_together were in fact included in it, then the form validation would do the unique check for you, and you wouldn't have to worry about the save causing a database error, assuming you could guarantee no other save was made that might invalidate the unique check done by is_valid() before the committing save() ran. But if you exclude one of the fields or can't guarantee a duplicate entry hasn't been inserted between the validation check and the committing save, then you do need to deal with the potential database error. >try: >link.save() >except IntegrityError: >errors['Duplicate URL'] = 'That URL is already a > link.' >else: >return HttpResponseRedirect(reverse('links_index')) >else: >form = LinkForm(request) > >return render_to_response( >'links/link_form.html', { >'form': form, >'errors': errors, >}, >context_instance=RequestContext(request) >) > > But I get an InternalError. Trackback below: > > [snip] > Exception Type: InternalError at /links/create/ > Exception Value: current transaction is aborted, commands ignored > until end of transaction block > Anytime you catch a DB exception and try to proceed, at least under PostgreSQL, you'll see this error from whatever the next command sent to the DB is. > Since this looked like a transaction issue I tried adding a > transaction.rollback() to my IntegrityError except clause but that > threw its own error that it wasn't in transaction management. > So...if you can't call transaction.rollback() because the code is not under transaction management, ensure it is under transaction management whenever you might need to call transaction.rollback(). Probably easiest to just wrap it in commit_on_success: http://docs.djangoproject.com/en/dev/topics/db/transactions/#django-db-transaction-commit-on-success Alternatively you could use the lower-level connection rollback routine and bypass the django.db.transaction layer, but I think it's cleaner to stick with the higher level routines. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem with contenttype/renaming of an app
Hi, during development, I messed around with an app name. First it was called 'body copies' (no native speaker!), then I renamed it to 'stanza', which I liked better. No problem there: As there was no data in the db, I deleted the tables and created them again, with other names. Then I deployed the project. I transfered the data via manage.py dumpdata/loaddata. Still no problems when I'm logged in as admin. But: When I create a new user group and want to give permissions, there's still 'body copy' instead of 'stanza'. ('bodyopies | body copy | Can add static content' and so on...) If I give the bodycopy permissions and log in as a user with those permissions, I'm not able to edit 'stanza'. The 'stanza'-area won't even show up in the admin panel, neither does 'bodycopies'. I took a look at the database, and in the table 'django_content_type' I found some entries refering to 'bodycopies': id |name | app_label | model ---+---++--- 09 | body copy | bodycopies | bodycopy I renamed them to the according 'stanza' labels. After that, in the group permissions on the group page 'stanza' showed up instead of 'bodycopies', but I still was not able to edit 'stanza' as non-admin-user. Any ideas? Benjamin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Formset for user-specific data
Greetings, In a Web app, users can create categories for their data. Categories are stored in a model as (PK, user, name, description). I want users to be able to edit categories that belong to them using a formset. To display a subset of the fields is simple, I just use the queryset parameter. How do I make sure users can only edit their own categories? So far I’m using a hack to this effect: post = dict(request.POST.items()) for i in range(int(post["form-TOTAL_FORMS"])): if post["form-%d-name" % i] != "": post["form-%d-user" % i] = request.user.pk with a check that the IDs mentioned actually belong to the current user’s category. Of course, the actual fields could have been anything, not just categories and users. In general, I want the formset to operate on a subset of the table, making sure all operations are within that subset, and that fields not editable by users (the “user” field in my case) are correctly populated for newly created records. How does one do that in Django? -- TIA Roman. smime.p7s Description: S/MIME cryptographic signature
Re: Where can i get a wiki formatting widget?
On Jan 24, 10:23 am, Brian Nealwrote: > On Jan 24, 9:44 am, Gath wrote: > > > Guys > > > Where can i get a wiki formatting widget for django? > > > I have enough notes fields in my models and i would want a nice wiki > > widget for entering data! > > > Paul > > I'm using the markItUp! javascript editor to enter Markdown syntax, it > is very nice and it can also be configured to do wiki syntax: > > http://markitup.jaysalvat.com/home/ > > Best, > BN Of course you'll need some software on the server side that translates the wiki markup to HTML. I'm not familiar with that part. But there is great Textile and Markdown support in Django. See: http://docs.djangoproject.com/en/dev/ref/contrib/#markup Best, BN --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple static media roots?
OK thanks and yes it does but that's half the story. I haven't made myself very clear. The ImageField still tries to append /media/ to the image upload_to path rather than /uploads/ which would retrieve them from the dynamic media root rather than the application media. My point was how do I get these 2 things to work together serving multiple media directories and FileFields? The only way I can see is to have uploads under media which I don't really want. I can't see a way in the docs to tell file field which media root it belongs to. > > Er, yes it does. For example: > (r'^site_media/(?P.*)$', 'django.views.static.serve', > {'document_root': '/path/to/media'}), > (r'^uploads/(?P.*)$', 'django.views.static.serve', > {'document_root': '/path/to/uploads'}), > > In both cases, /path/to/whatever can be anywhere you like, and you can > have as many as you want. > > Seehttp://docs.djangoproject.com/en/dev/howto/static-files/ > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
InternalError and transactions
I'm a bit at a loss as to where to go from here... I have simple Link and Category models. My Link model is essentially: user_id, category (FK), name, URL. I have a Meta unique_together on (user, url) so no duplicate URLs get entered. I'm testing this by trying to purposefully enter a duplicate URL. At first my code threw an IntegrityError so I'm trying to catch that. Here's my create view: def create(request): errors = {} if request.method == 'POST': form = LinkForm(request, request.POST) if form.is_valid(): link = form.save(commit=False) link.user = request.user try: link.save() except IntegrityError: errors['Duplicate URL'] = 'That URL is already a link.' else: return HttpResponseRedirect(reverse('links_index')) else: form = LinkForm(request) return render_to_response( 'links/link_form.html', { 'form': form, 'errors': errors, }, context_instance=RequestContext(request) ) But I get an InternalError. Trackback below: Environment: Request Method: POST Request URL: http://localhost:8000/links/create/ Django Version: 1.1 pre-alpha Python Version: 2.5.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'private_apps.links', 'django_extensions'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'private_apps.middleware.RequireLoginMiddleware') Traceback: File "/Users/rob/django/django-trunk/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/Users/rob/git/private_apps/private_apps/../private_apps/links/ views.py" in create 61. context_instance=RequestContext(request) File "/Users/rob/django/django-trunk/django/template/context.py" in __init__ 105. self.update(processor(request)) File "/Users/rob/django/django-trunk/django/core/ context_processors.py" in auth 27. 'messages': user.get_and_delete_messages(), File "/Users/rob/django/django-trunk/django/contrib/auth/models.py" in get_and_delete_messages 262. for m in self.message_set.all(): File "/Users/rob/django/django-trunk/django/db/models/query.py" in _result_iter 186. self._fill_cache() File "/Users/rob/django/django-trunk/django/db/models/query.py" in _fill_cache 667. self._result_cache.append(self._iter.next ()) File "/Users/rob/django/django-trunk/django/db/models/query.py" in iterator 281. for row in self.query.results_iter(): File "/Users/rob/django/django-trunk/django/db/models/sql/query.py" in results_iter 238. for rows in self.execute_sql(MULTI): File "/Users/rob/django/django-trunk/django/db/models/sql/query.py" in execute_sql 1935. cursor.execute(sql, params) File "/Users/rob/django/django-trunk/django/db/backends/util.py" in execute 19. return self.cursor.execute(sql, params) Exception Type: InternalError at /links/create/ Exception Value: current transaction is aborted, commands ignored until end of transaction block Since this looked like a transaction issue I tried adding a transaction.rollback() to my IntegrityError except clause but that threw its own error that it wasn't in transaction management. Side note: I'm curious if the IntegrityError might be worth putting in the metaclass to add to the base model class, so one doesn't need to import it specifically, they could use `except Link.IntegrityError`? Thanks, Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Import Fixtures per test
Yeah this is true, that would work. Thanks, Vitaly Babiy On Sat, Jan 24, 2009 at 12:38 PM, Alex Koshelevwrote: > Extract this test to its own TestCase with needed fixtures. > > > On Sat, Jan 24, 2009 at 8:15 PM, Vitaly Babiy wrote: > >> Is there a way to specify which fixtures I want to import per test? >> >> Vitaly Babiy >> >> >> > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Need help with models
Hello everybody, I need to create dinamic content in several models. I have 3 approaches: approach 1: class News(models.Model): date = ... visible = ... text = models.CharField(max_length=255) class NewsTrans(models.Model): news = models.ForeignKey(News) lang = models.CharField(max_length=5, choices=settings.LANGUAGES) text = models.CharField(max_length=255) approach 2: class News(models.Model): lang = models.CharField(max_length=5, choices=settings.LANGUAGES) date = ... visible = ... text = models.CharField(max_length=255) approcah 3: class NewsBase(): date = ... visible = ... class News(NewsBase): lang = models.CharField(max_length=5, choices=settings.LANGUAGES) text = models.CharField(max_length=255) (Any other approaches are welcome.) The one I like the least is the second one. I really need help here, please tell me how to implement translations in ddbb in the most efficient way. Thank you. P.S. I hope Django can manage this problem, hopefully in 1.3! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Import Fixtures per test
Extract this test to its own TestCase with needed fixtures. On Sat, Jan 24, 2009 at 8:15 PM, Vitaly Babiywrote: > Is there a way to specify which fixtures I want to import per test? > > Vitaly Babiy > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Last-Modified headers and render_to_response
Just now you can store response object for a while and don't return it immediately. When set needed headers response = render_to_response("foobar.html") response["Last-Modified"] = "some value" return response On Sat, Jan 24, 2009 at 8:24 PM, Viktor Nagywrote: > Hi, > > I would like to provide proper Last-Modified headers, but in general my > code uses the render_to_response shortcut. As far as I understand the code, > even though I can add a **kwargs argument to render_to_response, it won't > get added to my response object. > > Is there an easy way to still achieve what I would like to without touching > the core code? Is there any chance that a patch that adds this funcionality > would be accepted? > > My implementation would be to extend the render_to_response code, so that > before returning the HttpResponse object, we get over an optionally passed > kwargs['headers'] dictionary, and add all of its elements to the > HttpResponse object. > > How would you achieve this? > > V > -- > Viktor Nagy - http://viktornagy.com > PhD student > Toulouse School of Economics > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Last-Modified headers and render_to_response
Hi, I would like to provide proper Last-Modified headers, but in general my code uses the render_to_response shortcut. As far as I understand the code, even though I can add a **kwargs argument to render_to_response, it won't get added to my response object. Is there an easy way to still achieve what I would like to without touching the core code? Is there any chance that a patch that adds this funcionality would be accepted? My implementation would be to extend the render_to_response code, so that before returning the HttpResponse object, we get over an optionally passed kwargs['headers'] dictionary, and add all of its elements to the HttpResponse object. How would you achieve this? V -- Viktor Nagy - http://viktornagy.com PhD student Toulouse School of Economics --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Import Fixtures per test
Is there a way to specify which fixtures I want to import per test? Vitaly Babiy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding a slug
Hi, as far as I know loaddata doesn't use the ORM to insert the data. So things like signals and overloaded save methods don't work when using loaddata. adi On 24.01.2009, at 17:48, Kless wrote: > > > > On 24 ene, 15:51, Daniel Roseman> wrote: >> Are you saying that the slug is not being created when you reload >> your >> previously dumped data via ./manage.py loaddata? This is expected >> behaviour. > Yes, that's it. > > The slug is succesfully created when a new objects is added but it > doesn't works since ./manage.py loaddata > -- Adi J. Sieker mobile: +49 - 178 - 88 5 88 13 Freelance developer skype: adijsieker SAP-Consultantweb:http://www.sieker.info/profile openbc: https://www.openbc.com/hp/ AdiJoerg_Sieker/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting Logged in User with Test Client
Yes either way would work I was just wondering if there was a more cleaner way of doing so. Vitaly Babiy On Sat, Jan 24, 2009 at 11:47 AM, Masklinnwrote: > > On 24 Jan 2009, at 06:22 , Vbabiy wrote: > > > >def test_showAccountWithZeroTrackers(self): > >self.client.login(username='user', password='test123') > > > > How can I get the user model when I use the client to login in to the > > application? > > > Why not simply use `User.objects.get(username='user')`? > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Automatically Generating Non-Ajax Client-Side Form Validation
See http://code.google.com/p/django-ajax-forms/ I started this project to handle your use case. On Jan 24, 3:52 am, Chriswrote: > Is anyone aware of a simple way to automatically generate non-Ajax > form validation? I've seen some useful posts aboutAjax-form > validation (e.g.http://eikke.com/django-generic-ajax-form-validation/), > but I'd rather not waste bandwidth on validating integers/dates/phone- > numbers/required-fields/etc that can easily be done directly in the > browser. Ideally, once this initial client-side validation passes, > then theAjaxvalidation would be used. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django-smtpd allows you to handle email messages just like Django processes HTTP requests
Hello, I just started a new project that basically allows you to write email handlers in Django. It could be used in a user-registration application where the user could reply to the email instead of clicking on a URL. I drafted a quick documentation at http://code.google.com/p/django-smtpd/wiki/GettingStarted It shows the basic design of the lib and I'm looking for comments/ suggestions/use cases if that's of interest to anyone on this list. Note that this is still in "hacking" phase so don't consider using this in a production system. Thanks! Denis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding a slug
On 24 ene, 15:51, Daniel Rosemanwrote: > Are you saying that the slug is not being created when you reload your > previously dumped data via ./manage.py loaddata? This is expected > behaviour. Yes, that's it. The slug is succesfully created when a new objects is added but it doesn't works since ./manage.py loaddata --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting Logged in User with Test Client
On 24 Jan 2009, at 06:22 , Vbabiy wrote: > >def test_showAccountWithZeroTrackers(self): >self.client.login(username='user', password='test123') > > How can I get the user model when I use the client to login in to the > application? > Why not simply use `User.objects.get(username='user')`? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting Logged in User with Test Client
On Jan 23, 10:22 pm, Vbabiywrote: > How can I get the user model when I use the client to login in to the > application? This method is a little ugly, but it works:: from django.contrib.auth.models import User def test_showAccountWithZeroTrackers(self): self.client.login(username='user', password='test123') user = User.objects.get(id=self.client.session ['_auth_user_id']) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Where can i get a wiki formatting widget?
On Jan 24, 9:44 am, Gathwrote: > Guys > > Where can i get a wiki formatting widget for django? > > I have enough notes fields in my models and i would want a nice wiki > widget for entering data! > > Paul I'm using the markItUp! javascript editor to enter Markdown syntax, it is very nice and it can also be configured to do wiki syntax: http://markitup.jaysalvat.com/home/ Best, BN --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Access to Settings
On Jan 24, 3:28 pm, nosrednak...@gmail.com wrote: > Hello Django Users, > > I am writing an application that needs to do some 'advanced' SQL to update > some tables. I am curious about the best way to lock tables and make the > transaction safe. The solution I wrote for a Quick and dirty is: > > DATABASE_ENGINE = str(settings.__getattr__("DATABASE_ENGINE")) > > if DATABASE_ENGINE == "postgresql": > _lock = "lock table nav_object in share row exclusive mode;" > _unlock = "" > elif DATABASE_ENGINE == "mysql": > _lock = "lock table nav_object WRITE;" > _unlock = "unlock tables;" > > And I append the appropriate strings, but this seems hackish and since I'm > new to both python and Django I am looking for advice. Is there > documentation for using django to lock tables etc... so I don't need to do > this? > > Thank you, > Mark Have you read this part of the documentation? http://docs.djangoproject.com/en/dev/topics/db/transactions/ As far as accessing settings is concerned, don't use __getattr__ - just do settings.DATABASE_ENGINE. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: API mismatch bug with CursorDebugWrapper?
On Jan 23, 7:14 pm, Karen Traceywrote: > Take a look at the implementation of CursorDebugWrapper > __getattr__ in django/db/backends/util.py -- CursorDebugWrapper defers to > the wrapped cursor for anything it itself doesn't implement. Thanks, Karen. You're exactly right. I was coming at it from the other direction and relying too much on the shell. Quandary solved. - whiteinge --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding a slug
On Jan 24, 12:49 pm, Klesswrote: > I want to add a new field --slug-- to tables where any data is being > used in the URL > > I dumped all data, added that new field > -- > slug = models.SlugField(_('slug')) > -- > > And I created a hook to save it. > -- > def save(self): > #if not self.slug: > self.slug = defaultfilters.slugify(self.name) > super(Model, self).save() > -- > > I load all data but slug is not being created. > I also tried with _post_save() hook. > > Any idea to solve this? Are you saying that the slug is not being created when you reload your previously dumped data via ./manage.py loaddata? This is expected behaviour. Luckily it's quite easy to solve. >From the Python shell: for item in Model.objects.all(): item.save() -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple static media roots?
On Jan 24, 2:43 pm, John Bakerwrote: > > write a custom file > > storagehttp://docs.djangoproject.com/en/dev/topics/files/ > > Thanks. However, I know I can store them somewhere else but my problem > is serving them up again in the local development environment. The > django.views.static.serve doesn't take an argument for serving from a > different system directory so its difficult to have 2. Er, yes it does. For example: (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}), (r'^uploads/(?P.*)$', 'django.views.static.serve', {'document_root': '/path/to/uploads'}), In both cases, /path/to/whatever can be anywhere you like, and you can have as many as you want. See http://docs.djangoproject.com/en/dev/howto/static-files/ -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Where can i get a wiki formatting widget?
Guys Where can i get a wiki formatting widget for django? I have enough notes fields in my models and i would want a nice wiki widget for entering data! Paul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Access to Settings
Hello Django Users, I am writing an application that needs to do some 'advanced' SQL to update some tables. I am curious about the best way to lock tables and make the transaction safe. The solution I wrote for a Quick and dirty is: DATABASE_ENGINE = str(settings.__getattr__("DATABASE_ENGINE")) if DATABASE_ENGINE == "postgresql": _lock = "lock table nav_object in share row exclusive mode;" _unlock = "" elif DATABASE_ENGINE == "mysql": _lock = "lock table nav_object WRITE;" _unlock = "unlock tables;" And I append the appropriate strings, but this seems hackish and since I'm new to both python and Django I am looking for advice. Is there documentation for using django to lock tables etc... so I don't need to do this? Thank you, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Datetime and apache log files show wrong timezone
On Jan 24, 2:30 pm, Graham Dumpletonwrote: > On Jan 24, 8:46 pm, simong wrote: > > > > > My apologies in advance if this isn't a direct django issue but I > > can't work out where the problem is coming from. > > > My server's system time runs Centos 5 and is set to Europe/London: > > > -bash-3.2$ date > > Sat Jan 24 12:26:14 GMT 2009 > > -bash-3.2$ date -u > > Sat Jan 24 12:26:17 UTC 2009 > > -bash-3.2$ /sbin/hwclock --show > > Sat 24 Jan 2009 12:31:34 PM GMT -0.984663 seconds > > > /etc/sysconfig/clock is set thusly: > > > ZONE="Europe/London" > > UTC=true > > ARC=false > > > My django application timezone is set to 'Europe/London': > > > TIME_ZONE = 'Europe/London' > > > The application creates a datestamp to log when an order has been > > requested using datetime.datetime.now() but it and the apache logs are > > still using EST, which was what the machine was set to on build (no > > idea why, it's based in Germany): > > > xxx.xxx.xxx.xxx - - [24/Jan/2009:07:16:19 -0500] "GET /media/images/ > > bground_bottom_right.png HTTP/1.1" 200 116555 > > "http://www.popfood.co.uk/media/css/common.css; "Mozilla/5.0 (Macintosh; U; > > Intel Mac OS X 10.5; en-US; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5 > > Ubiquity/0.1.5" > > > The server has a Plesk control panel which provides a editable > > configuration file for the domain called vhost.conf which should > > override anything in the Plesk-generated config files, so I have > > added > > SetEnv TZ Europe/London to that and restarted apache to no effect. > > That will not do anything as it only modified process environment > variables for CGI script processes execed from Apache. > > If you are seeing the wrong timzone from what you are setting, it is > most likely because you are running multiple applications in same > Apache instance and each is wanting to use a different timezone. These > could be multiple Django instances, or even PHP applications. > > Short answer is you can't run multiple applications in same Apache > which have different timezone requirements. > > Graham > For your information SetEnv does work in mod_python. It is referred to in the djangoproject documentation for setting up a server using mod_python here: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#howto-deployment-modpython Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Datetime and apache log files show wrong timezone
On Jan 24, 2:30 pm, Graham Dumpletonwrote: > On Jan 24, 8:46 pm, simong wrote: > > > > > My apologies in advance if this isn't a direct django issue but I > > can't work out where the problem is coming from. > > > My server's system time runs Centos 5 and is set to Europe/London: > > > -bash-3.2$ date > > Sat Jan 24 12:26:14 GMT 2009 > > -bash-3.2$ date -u > > Sat Jan 24 12:26:17 UTC 2009 > > -bash-3.2$ /sbin/hwclock --show > > Sat 24 Jan 2009 12:31:34 PM GMT -0.984663 seconds > > > /etc/sysconfig/clock is set thusly: > > > ZONE="Europe/London" > > UTC=true > > ARC=false > > > My django application timezone is set to 'Europe/London': > > > TIME_ZONE = 'Europe/London' > > > The application creates a datestamp to log when an order has been > > requested using datetime.datetime.now() but it and the apache logs are > > still using EST, which was what the machine was set to on build (no > > idea why, it's based in Germany): > > > xxx.xxx.xxx.xxx - - [24/Jan/2009:07:16:19 -0500] "GET /media/images/ > > bground_bottom_right.png HTTP/1.1" 200 116555 > > "http://www.popfood.co.uk/media/css/common.css; "Mozilla/5.0 (Macintosh; U; > > Intel Mac OS X 10.5; en-US; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5 > > Ubiquity/0.1.5" > > > The server has a Plesk control panel which provides a editable > > configuration file for the domain called vhost.conf which should > > override anything in the Plesk-generated config files, so I have > > added > > SetEnv TZ Europe/London to that and restarted apache to no effect. > > That will not do anything as it only modified process environment > variables for CGI script processes execed from Apache. > > If you are seeing the wrong timzone from what you are setting, it is > most likely because you are running multiple applications in same > Apache instance and each is wanting to use a different timezone. These > could be multiple Django instances, or even PHP applications. > > Short answer is you can't run multiple applications in same Apache > which have different timezone requirements. > > Graham > Nope, there is one other django application running on the server and it's set to Europe/London too. There's nothing else on the machine that uses any scripting. A further search suggests setting a PythonOption for mod_python might work. Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple static media roots?
> write a custom file storagehttp://docs.djangoproject.com/en/dev/topics/files/ Thanks. However, I know I can store them somewhere else but my problem is serving them up again in the local development environment. The django.views.static.serve doesn't take an argument for serving from a different system directory so its difficult to have 2. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Datetime and apache log files show wrong timezone
On Jan 24, 8:46 pm, simongwrote: > My apologies in advance if this isn't a direct django issue but I > can't work out where the problem is coming from. > > My server's system time runs Centos 5 and is set to Europe/London: > > -bash-3.2$ date > Sat Jan 24 12:26:14 GMT 2009 > -bash-3.2$ date -u > Sat Jan 24 12:26:17 UTC 2009 > -bash-3.2$ /sbin/hwclock --show > Sat 24 Jan 2009 12:31:34 PM GMT -0.984663 seconds > > /etc/sysconfig/clock is set thusly: > > ZONE="Europe/London" > UTC=true > ARC=false > > My django application timezone is set to 'Europe/London': > > TIME_ZONE = 'Europe/London' > > The application creates a datestamp to log when an order has been > requested using datetime.datetime.now() but it and the apache logs are > still using EST, which was what the machine was set to on build (no > idea why, it's based in Germany): > > xxx.xxx.xxx.xxx - - [24/Jan/2009:07:16:19 -0500] "GET /media/images/ > bground_bottom_right.png HTTP/1.1" 200 116555 > "http://www.popfood.co.uk/media/css/common.css; "Mozilla/5.0 (Macintosh; U; > Intel Mac OS X 10.5; en-US; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5 > Ubiquity/0.1.5" > > The server has a Plesk control panel which provides a editable > configuration file for the domain called vhost.conf which should > override anything in the Plesk-generated config files, so I have > added > SetEnv TZ Europe/London to that and restarted apache to no effect. That will not do anything as it only modified process environment variables for CGI script processes execed from Apache. If you are seeing the wrong timzone from what you are setting, it is most likely because you are running multiple applications in same Apache instance and each is wanting to use a different timezone. These could be multiple Django instances, or even PHP applications. Short answer is you can't run multiple applications in same Apache which have different timezone requirements. Graham > I built python 2.5.2 by hand on the server as it came with 2.4 so I am > wondering if the timezone is statically set somewhere in either the > python or apache build, but does anyone have any other suggestions > related to django, python or apache as to why I can't override the > timezone setting? > > Thanks > Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple static media roots?
On Saturday 24 Jan 2009 6:59:57 pm John Baker wrote: > I need to separate static media roots into "static" (belonging to > application - css, images etc) and "dynamic" (uploaded by users with > filefields etc). > > The point is that truly "static" media doesn't change and is part of > the deployed code. Dynamic "static" media is uploaded and kept in a > separate directory not within the application code. I have 2 - one is the standard media directory where users upload files and is outside the project directory, the other I call sitemedia which is a directory under the the project directory with three directories under it - css, js and images. This is mapped in apache conf to http://myproject.com/sitemedia/ - and it is referred to as /sitemedia/ in the templates. This sitemedia directory is also under version control as part of the site. -- regards KG http://lawgon.livejournal.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple static media roots?
John Baker wrote: > Any suggestions? write a custom file storage http://docs.djangoproject.com/en/dev/topics/files/ -- ()_() | That said, I didn't actually _test_ my patch. | + (o.o) | That's what users are for! | +---+ 'm m' | (Linus Torvalds) | O | (___) | raffaele at salmaso punto 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multiple static media roots?
I need to separate static media roots into "static" (belonging to application - css, images etc) and "dynamic" (uploaded by users with filefields etc). The point is that truly "static" media doesn't change and is part of the deployed code. Dynamic "static" media is uploaded and kept in a separate directory not within the application code. Is there any way to have 2 media directories in django? Ideally I would like /uploads/ and /media/ but the FileField appends the filename to the MEDIA_URL which in my case would be wrong because it is dynamic media not truly static. I next tried mapping 2 instances of django.views.static.serve, once to /media/uploads/ (this solves FileField problem) and once to /media/ for truly static application media. However, I find that django.views.static.serve doesn't allow a media root only document root to server from. To me it seems poor design to combine application media (belongs to a specific version of application code) with uploaded media (belongs to what is in the database). Any suggestions? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Related Field has invalid lookup error
Ramiro, Thanks very much - I knew I must have been overlooking something. Adding __exact did the trick nicely. Derek On Jan 24, 7:38 am, Ramiro Moraleswrote: > On Sat, Jan 24, 2009 at 2:30 AM, dwil...@gmail.com wrote: > > > I've got an odd-looking error when I try to use a related model's > > field in the ORM. Here's the traceback: > > > [...] > > File "/home/dwillis/lib/python2.5/django/db/models/fields/ > > related.py", line 157, in get_db_prep_lookup > >raise TypeError, "Related Field has invalid lookup: %s" % > > lookup_type > > TypeError: Related Field has invalid lookup: year > > > It's caused by the following query: > > > active_hc = CollegeCoach.objects.select_related().filter > > (jobs__name='Head Coach', end_date__isnull=True, > > collegeyear__year=CURRENT_SEASON).order_by('-start_date') > > Try changing that lookup to > > collegeyear__year__exact=CURRENT_SEASON > > Django has a 'year' lookup for Date (and DateTime?) fields > that in you case is clashing eith the name of one of your field > and is trying to use it, that explains the error you get > (it can't apply it to an integer field). > > Hopefully, adding exact will help in disambiguating your > intentions. > > > > > And here are the models in question: > > > class CollegeYear(models.Model): > >college = models.ForeignKey(College) > >year = models.IntegerField() > >wins = models.IntegerField(default=0) > > -- > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Adding a slug
I want to add a new field --slug-- to tables where any data is being used in the URL I dumped all data, added that new field -- slug = models.SlugField(_('slug')) -- And I created a hook to save it. -- def save(self): #if not self.slug: self.slug = defaultfilters.slugify(self.name) super(Model, self).save() -- I load all data but slug is not being created. I also tried with _post_save() hook. Any idea to solve 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Datetime and apache log files show wrong timezone
My apologies in advance if this isn't a direct django issue but I can't work out where the problem is coming from. My server's system time runs Centos 5 and is set to Europe/London: -bash-3.2$ date Sat Jan 24 12:26:14 GMT 2009 -bash-3.2$ date -u Sat Jan 24 12:26:17 UTC 2009 -bash-3.2$ /sbin/hwclock --show Sat 24 Jan 2009 12:31:34 PM GMT -0.984663 seconds /etc/sysconfig/clock is set thusly: ZONE="Europe/London" UTC=true ARC=false My django application timezone is set to 'Europe/London': TIME_ZONE = 'Europe/London' The application creates a datestamp to log when an order has been requested using datetime.datetime.now() but it and the apache logs are still using EST, which was what the machine was set to on build (no idea why, it's based in Germany): xxx.xxx.xxx.xxx - - [24/Jan/2009:07:16:19 -0500] "GET /media/images/ bground_bottom_right.png HTTP/1.1" 200 116555 "http:// www.popfood.co.uk/media/css/common.css" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5 Ubiquity/0.1.5" The server has a Plesk control panel which provides a editable configuration file for the domain called vhost.conf which should override anything in the Plesk-generated config files, so I have added SetEnv TZ Europe/London to that and restarted apache to no effect. I built python 2.5.2 by hand on the server as it came with 2.4 so I am wondering if the timezone is statically set somewhere in either the python or apache build, but does anyone have any other suggestions related to django, python or apache as to why I can't override the timezone setting? Thanks Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Related Field has invalid lookup error
On Sat, Jan 24, 2009 at 2:30 AM, dwil...@gmail.comwrote: > > I've got an odd-looking error when I try to use a related model's > field in the ORM. Here's the traceback: > > [...] > File "/home/dwillis/lib/python2.5/django/db/models/fields/ > related.py", line 157, in get_db_prep_lookup >raise TypeError, "Related Field has invalid lookup: %s" % > lookup_type > TypeError: Related Field has invalid lookup: year > > It's caused by the following query: > > active_hc = CollegeCoach.objects.select_related().filter > (jobs__name='Head Coach', end_date__isnull=True, > collegeyear__year=CURRENT_SEASON).order_by('-start_date') Try changing that lookup to collegeyear__year__exact=CURRENT_SEASON Django has a 'year' lookup for Date (and DateTime?) fields that in you case is clashing eith the name of one of your field and is trying to use it, that explains the error you get (it can't apply it to an integer field). Hopefully, adding exact will help in disambiguating your intentions. > > And here are the models in question: > > class CollegeYear(models.Model): >college = models.ForeignKey(College) >year = models.IntegerField() >wins = models.IntegerField(default=0) -- 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using dinamically created tables
I guess I would still recommend that you not get too fancy. Your data rate is 50 plants, 8000 records each, for a total of 400k records per day. I have a MySQL table that added 500k records in the last 24 hours, and it's fine. It's just an ordinary Innodb table, with no special optimizations. At these data rates, at least in our environment, the challenges lie elsewhere (nginx throughput, Django throughput, etc). Our datrabase has a handful of tables in the 60-million-row neighborhood, and the db as a whole manages almost 80Gb of data. Are you sure you have a problem to solve here? Relational databases really are quite good at what they do, it's unusual cases where you have to help them with partitioning and the like. --Ned. Alessandro Ronchi wrote: > One simple solution for my problem is table partitioning. Both MySQL > and PosgreSQL can handle that. > On PGSQL I can create a master table for my model and one partition > for every value of a master key. It should be great. > > Do you think it's possible to handle a child table creation (also with > a PGSQL command without ORM) on a save of a model? The query and > inserts should be transparent, and so I could use django for > everything. > > > > > -- Ned Batchelder, http://nedbatchelder.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using dinamically created tables
One simple solution for my problem is table partitioning. Both MySQL and PosgreSQL can handle that. On PGSQL I can create a master table for my model and one partition for every value of a master key. It should be great. Do you think it's possible to handle a child table creation (also with a PGSQL command without ORM) on a save of a model? The query and inserts should be transparent, and so I could use django for everything. -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.com Sviluppo Software e Sistemi Open Source Sede: Via Poggiali 2/bis, 47100 Forlì (FC) Tel.: +39 0543 798985 - Fax: +39 0543 579928 Rispetta l'ambiente: se non ti è necessario, non stampare questa mail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Use _meta.fields to return the datatype
dj wrote: > On Jan 23, 10:12 pm, djwrote: > >> Hello All, >> >> I am a Django novice, and I recently discovered the _meta methods for >> use with models. >> Using _meta.fields to return the field names in a model instance, the >> current value of an instance (getattr()) and set the value (setattr >> ()). >> >> I was wondering if anyone knows how to use _meta.fields to return the >> datatype for a field in a model ? >> >> Your assistance is greatly appreciated :-). >> > It would appear there is method called get_internal_type() that maybe > what I am looking for. > The method is in django.db.models.Field. But I am unable to find > anything that would tell > me how to use the function to return the data type for a field in a > model. > > m=Org() > > for field in m._meta.fields[1:]: >fields.append(str(field.name)) >get_internal_type(field.name) - is this the correct way to call > the method ? > [But he top-posted, so I moved his stuff down below the question]. A bit of fiddling about with the interpreter in a manage.py shell session reveals all: In [11]: from django.db.models import Field In [12]: f = Field() In [13]: f.get_internal_type() Out[13]: 'Field' In [14]: from django.db.models import IntegerField In [15]: i = IntegerField() In [16]: i.get_internal_type() Out[16]: 'IntegerField' And, of course, there's always In [17]: help(i.get_internal_type) which tells you: """ Help on method get_internal_type in module django.db.models.fields: get_internal_type(self) method of django.db.models.fields.IntegerField instance """ Not terrifically helpful, but at least the signature tells you no arguments are required ... regards Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---