Re: "can't adapt" - mod_python, multiple interpreters, psycopg2
> > Problem is possibly with multiple interpreters and psycopg2 again, > > Why do you say that? The thread you refer to above doesn't talk about > mod_python, so do you have any extra evidence that support this claim? There was a bug in psycopg2 with Decimal data type that sometimes caused error like that: unsupported operand type(s) for *: 'Decimal' and 'Decimal' It was discussed on the list: http://groups.google.com/group/django-users/browse_thread/thread/091aa6c088f6c090 Similarly to "can't adapt" it was raised sometimes, after apache was running for few days, etc.. When error appears, restarting apache causes everything to work fine but only for some time and then again, errors are appearing. It was said that Decimal problem is caused by running psycopg2 with multiple interpreters, so thats why I think "can't adapt" might be the same thing. Exactly same place, same data entered in the form and after submit sometimes I get "can't adapt" and sometimes (after apache restart) everything works. Actually I found one thing in my code that shouldn't be there. I have FloatField in model but in ModelForm it is changed (manually in __init__) to DecimalField (in fact subclass that allows to use comma as a decimal separator). I suppose this change from Float to Decimal might be causing problems but it is strange that sometimes this works and sometimes don't. I have no full traceback because I can't reproduce "can't adapt" on demand. I only have last line of traceback that was sent to me by tester. I've already added logging of SQL yesterday but so far it didn't happen again. Also I've turned off debug mode so I'll have traceback e-mailed as soon as it strikes again. Thanks for your answer! -- Maciej Wisniowski --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ViewDoesNotExist admin error.
Hi Chris, you may have a problem with your urls.py - check if you activated the admin site correctly (see http://www.djangoproject.com/documentation/tutorial02/#activate-the-admin-site - check if you have a pattern that catches /admin/ earlier on Do you use django-profiles? If yes: You do not use it properly: - It seems to not be installed correctly as django does not find the views module - "Recommended usage (for profiles/urls.py) is to use a call to ``include()`` in your project's root URLConf to include this URLConf for any URL beginning with '/ profiles/'." Mitja --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding ManyToManyField to Django models
Michael, Your opinion on this makes sense and in the end I will probably just go with the wrapper approach, since it probably won't make that much of a difference anyways. My biggest qualm is that I'm trying to put together a strong foundation for the projects I'm working on and feel like this is not the best, but yes I understand why it's like this. The other option you brought up about pulling the auth code will probably get hairy (as you already pointed out). The ModelInheritance stuff does look interesting! Thanks for the input. Discussing stuff like this always helps define the scope of the tools and how to use them... I'm sure I would've wanted to do something similar at some point in the future with my own models and it always helps to know what the boundaries are (at least for now). Mike. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding ManyToManyField to Django models
On Tue, 2008-03-04 at 13:06 -0800, Michael Irani wrote: > I was wondering if it's possible to add a ManyToManyField onto a > prebuilt Django model such as User... I know that it would look like > this if I were to have created the model myself: > class User(models.Model): > watch = models.ManyToManyField('self', null=True, blank=True) > > I'm unsure how to add features to prebuilt models and wasn't even sure > if that was possible. Probably not such a great idea, since you aren't in control of any updates that might happen to the User model. It's the standard problem that if you change Django's source, that's fine, but then you have to remember to make sure your changes work with any updates we might happen to make to that code (we aren't about to add any new fields or anything, but extra Python code might be added, for example). A better approach would be to create your own many-to-many lookalike structure by creating the intermediate model with foreign keys pointing to User and whatever else you want (I guess also User in your case). That model is entirely under your control and won't require changing Django's source. Regards, Malcolm -- If Barbie is so popular, why do you have to buy her friends? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ViewDoesNotExist admin error.
Hello, Not sure what has happened but I keep getting this error when attempting to login to my admin section. I key in Username and pass and once I press submit django returns this error: Request Method: GET Request URL:http://django.xyz.net/admin/ Exception Type: ViewDoesNotExist Exception Value:Tried views in module profiles. Error was: 'module' object has no attribute 'views' Exception Location: /srv/django-0.96/django/core/urlresolvers.py in _get_callback, line 184 Python Executable: /usr/bin/python Any Ideas as to what is going on here? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Only 3 weeks left for PostgreSQL Conference: East
Hello, There are only three weeks left to register for the PostgreSQL Community Conference: East! The conference is scheduled on March 29th and 30th (a Saturday and Sunday) at the University of Maryland. Come join us as Bruce Momjian and Joshua Drake have a round table open to any PostgreSQL question from the community. If a round table isn't your cup of tea, visit our talks page where you can pick to learn from over 20 experts in the field. http://www.postgresqlconference.org/talks/ To register just point that old fashion web browser over to: http://www.postgresqlconference.org/ All registrations and sponsorships are donations to PostgreSQL via Software in the Public Interest, Inc., a 501(c)3 non-profit corporation. Thanks again to our Community Conference Sponsors: Organizational Sponsor Command Prompt, Inc. http://www.commandprompt.com/ Silver Sponsor EnterpriseDB http://www.enterprisedb.com Talk Sponsors Afilias http://www.afilias.org/ Continuent http://www.continuent.com/ Sun http://www.sun.com/ Truviso http://www.truviso.com/ Xtuple http://www.xtuple.com/ Meal Sponsors OTG http://www.otg-nc.com/ General Sponsor Emma http://www.myemma.com/ Sincerely, Joshua D. Drake -- The PostgreSQL Company since 1997: http://www.commandprompt.com/ PostgreSQL Community Conference: http://www.postgresqlconference.org/ Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate PostgreSQL SPI Liaison | SPI Director | PostgreSQL political pundit signature.asc Description: PGP signature
Re: Adding ManyToManyField to Django models
Michael; Think of it this way: the auth model is just one way to provide authentication into your architecture. It wouldn't make much sense to have too much more information about the person inside of this model. There is an effort to try to be able to extend models, but as far as I know it has been a difficult forge forward because databases don't work that way. The tie to another model is perfectly natural. As I am still thinking about this you wouldn't want to inherit the code anyway. If you want the cleanest implementation of your code you wouldn't want to have 2 different types (or the possibility thereof) of authentication. What I was saying in my first post is that you don't need to use any of the contrib applications. In fact, you can go ahead and look directly into the auth code and try to rewrite it with all the extras that you would like to put into it. I personally think you would be making yourself crazy just to save a table in your database, but if that is your cup of tea... Evert, take a look at the Model Inheritance branch: http://code.djangoproject.com/wiki/ModelInheritance it looks exciting, but a huge undertaking for whoever is working on it. I would be exciting to see and could save a lot of application code really. It definatly doesn't look like it would be ready before 1.0 On Tue, Mar 4, 2008 at 10:21 PM, Michael Irani <[EMAIL PROTECTED]> wrote: > > One thing I dislike about the approach that's being pushed by the > community, which is to have a one-to-one relationship between > auth.User and your own 'Profile' model (or whatever you want to call > it) adding all the functionality and relationships to the user-created > Model is a bit much. I mean yes it's convenient to use auth.User's > prebuilt functionality, but if you're building for the future and want > to start off in the right place, this method kind of starts your code > in an awkward place. The data model with this approach just feels > wrong... The right way to do it is to have two different tables link > to eachother and have the database make the bindings for you. I know > this simplifies the code a lot and that the DB will probably do a good > job with this lookup, but still seems a little awkward to me... > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django WITHOUT apache on windows.
Hi lbolognini, thanks for the link. I was able to configure Django on W2k3 using DjangoCerise (and WITHOUT using apache). Also I m using IIS to serve media. Now since DjangoCerise configuartion uses separate port for separate projects my urls look like, http://192.168.0.17:8088/djprojone/ http://192.168.0.17:8099/djprojtwo/ Can anybody help me in sorting the URL issue. I want to look them like, http://www.domainone.com/djprojone/ http://www.domaintwo.com/djprojtwo/ OR anything which will hide different ports to be visible. > > What about using CherryPy? (never tried myself) > > http://www.xhtml.net/scripts/Django-CherryPy-server-DjangoCerise > > L. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: location of CSS
On Tuesday 04 March 2008 12:38:25 Lewis Bergman wrote: > Where are your templates stored? currently, here TEMPLATE_DIRS = ( '/home/philproj/dirview/httemplates',) but I have copies of dirview.css in that any every other directory I could think of accessible to user phil. And, oh yeah, no slash on the end. That's inconsistent with other settings like MEDIA_ROOT. > > Phillip Watts wrote: > > I can't figure out where to put css files or background images referred > > to by css. I have: > > > > > > and > > MEDIA_ROOT = '/home/phil/philproj/media/' > > > > ls -al /home/phil/philproj/media > > total 12 > > drwxr-xr-x 2 phil phil 4096 2008-03-04 11:57 . > > drwxr-xr-x 7 phil phil 4096 2008-03-04 12:14 .. > > -rw-r--r-- 1 phil phil 96 2008-03-04 11:57 dirview.css > > > > I've tried everything? Help? Thanks > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
Hi, OK, write a small script that runs you python job. Try running the job from the shell: /usr/bin/python -v /path/to/script/update_feeds.py This will list all the import statements, so find your imports that fail in the cron job ... And then your script would be: #!/bin/sh PYTHONPATH= .. export PYTHONPATH /usr/bin/python /path/to/script/update_feeds.py On 4 Mar 2008, at 18:27, [EMAIL PROTECTED] wrote: > > OK, I did what you instructed and checked the log file, which did > contain the system path and the traceback about the "can't import > module...". > > I see the paths specified don't contain the path to the feedparser > module, which explains the error. My question is how do I add this > path in the cron, especially since the script runs from the command > line? > > On Mar 4, 9:02 am, Evert Rol <[EMAIL PROTECTED]> wrote: >>> Well part of the problem is that the script itself works fine. I can >>> run from the command line without a hitch. But when I try to run it >>> via the cron, I get the traceback about the feedparser module. >> >> I believe that, because your PYTHONPATH will be set correctly from >> the >> command line; but possibly not from a default (basic) shell that cron >> uses. >> So, again, try putting those two statements at the top of your >> script, >> -before- the 'import feedparser' statement, and let cron do its job. >> You may need to redirect the output, eg >> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/to/ >> script/update_feeds.log 2>&1 >> to get that output (I'm not sure how you got the error from the cron >> job; through email?) >> >> Check the log file: before the traceback, you should see the result >> of >> 'print sys.path'. Check if that includes the correct directories. >> Top of script (possibly just below the she-bang): >> import sys print sys.path >> >>> Traceback (most recent call last): >>> File "/path/to/script/update_feeds.py", line 10, in ? >>> import feedparser >>> ImportError: No module named feedparser >> >>> And here is the cron: >> >>> export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/ >>> django/ >>> app >>> export DJANGO_SETTINGS_MODULE=myproject.settings >>> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py >> >>> I'm running the cron on my Dreamhost account BTW. >> >> Did you try printing out the sys.path at the top of your >> script, so >> see if the PYTHONPATH is picked up correctly from the cron >> environment >> settings? I'd guess it should, but it may go wrong there (I'm no >> cron >> expert). > > = Andrew Holt Managing Director 4A Solutions Ltd M: +44(0) 7841 340608 P: +44(0)1257 268351 Email: [EMAIL PROTECTED] Illegitimati non su carborundum ! = --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: solving fixture data conflicts
On Wed, Mar 5, 2008 at 1:34 PM, Evan H. Carmi <[EMAIL PROTECTED]> wrote: > > Russell Keith-Magee wrote: > > The only real solution at present is to avoid serializing content > > types whenever possible (i.e., by not dumping the contenttypes > > application). If your fixture already has content types, manually > > delete them from the fixture before loading. > > How can I go about manually deleting the content types? Is there > something I should look for in my file exported with dumpdata? In an XML fixture, you are looking for any object that matches: (for any value of PK). Delete those objects (including all the tags inside the tag pair), and you should be OK. Analogous structures exist for all the other serialization formats. The magic bit is 'model="contenttypes.contenttype" Yours Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: solving fixture data conflicts
Russell Keith-Magee wrote: > The only real solution at present is to avoid serializing content > types whenever possible (i.e., by not dumping the contenttypes > application). If your fixture already has content types, manually > delete them from the fixture before loading. How can I go about manually deleting the content types? Is there something I should look for in my file exported with dumpdata? Evan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Recovering from Postgres errors
When accessing a Postgres database from Django ORM without any explicit transaction management, any database query begins an implicit transaction which ends with the next save(). If the save fails due to a database error (e.g. integrity violation, timeout...) it raises an exception. At this point, any new queries will fail with the error psycopg2.ProgrammingError: current transaction is aborted, commands ignored until end of transaction block Basically the Postgres transaction is dead and has to be rolled back before any new queries can be executed. ISTM the Model.save() method itself could rollback the (implicit) transaction when there is an error, something like try: ... normal save code except DatabaseError: transaction.rollback_unless_managed() raise I have seen a bit of discussion of this in the list archives and Trac but I haven't found any good solutions. Wrapping every save() in a try block similar to the above seems very clumsy, as is wrapping every save() in an explicit transaction block. So, my questions are - how do others deal with this? - what is considered best practice, if anything? - does it make sense to alter Model.save(), or my own model's save(), as indicated above? Thanks, Kent --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: change user admin template
Right where you would expect it to be: Django.Contrib.admin.templates You might want to look in django.contrib.auth.views to see what template is being used. On Tue, Mar 4, 2008 at 11:41 AM, Rufman <[EMAIL PROTECTED]> wrote: > > Hey > > I can't seem to find the template that is displayed when I change a > user (@ www.example.com/example/admin/auth/user/1/). I'm fairly new to > customizing the admin interface, so I might have overlooked > something... > > Stephane > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: location of CSS
> I can't figure out where to put css files or background images > referred to by > css. I have: > > > and > MEDIA_ROOT = '/home/phil/philproj/media/' Don't you need a '/media/' or something before that 'dirview.css'? What is your MEDIA_URL? Since Django normally has the media files (css, images etc) served completely separately, relative paths to media files don't really work. Btw, be careful when starting a new subject by replying to an old thread: you've just hijacked another thread, see http://groups.google.com/group/django-users/browse_thread/thread/92052a98c16509a0?hl=en Better start a new thread/message/question from scratch. > ls -al /home/phil/philproj/media > total 12 > drwxr-xr-x 2 phil phil 4096 2008-03-04 11:57 . > drwxr-xr-x 7 phil phil 4096 2008-03-04 12:14 .. > -rw-r--r-- 1 phil phil 96 2008-03-04 11:57 dirview.css > > I've tried everything? Help? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding ManyToManyField to Django models
One thing I dislike about the approach that's being pushed by the community, which is to have a one-to-one relationship between auth.User and your own 'Profile' model (or whatever you want to call it) adding all the functionality and relationships to the user-created Model is a bit much. I mean yes it's convenient to use auth.User's prebuilt functionality, but if you're building for the future and want to start off in the right place, this method kind of starts your code in an awkward place. The data model with this approach just feels wrong... The right way to do it is to have two different tables link to eachother and have the database make the bindings for you. I know this simplifies the code a lot and that the DB will probably do a good job with this lookup, but still seems a little awkward to me... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding ManyToManyField to Django models
Evert, the situation is that I was trying to use the auth.User as my model and wanted to have it point to itself. Thereby not having my own model at all. I was curious as well about being able to subclass a prebuilt model, but from the reactions I've gotten towards this, it doesn't seem to be an option... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
> OK, I'm getting a different error now: > > Traceback (most recent call last): > File "update_feeds.py", line 58, in ? > update_feeds() > File "update_feeds.py", line 14, in update_feeds > from knoxd.apps.aggregator.models import Feed, FeedItem > ImportError: No module named knoxd.apps.aggregator.models > > I had added the following to my cron: > > export PYTHONPATH=$PYTHONPATH:$HOME/lib/python2.3/site-packages > (the difference between what the web archive shows and what my emails shows, makes it somewhat hard to keep track of which messages you've already seen, and where we exactly are in the problem solving, but here goes anyway): You initially had your PYTHONPATH set differently: export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/django/app which is not the same as above. So which one should it be? What does your regular shell have ('printenv PYTHONPATH')? In the off-chance you've already got my other email, did you try that (with the correct PATH settings, whatever those may be)? Ie, setting the variables on the command line, not in the header of the crontab file. >> OK, I did what you instructed and checked the log file, which did >> contain the system path and the traceback about the "can't import >> module...". >> >> I see the paths specified don't contain the path to the feedparser >> module, which explains the error. My question is how do I add this >> path in the cron, especially since the script runs from the command >> line? >> >> On Mar 4, 9:02 am, Evert Rol <[EMAIL PROTECTED]> wrote: >> Well part of the problem is that the script itself works fine. I can run from the command line without a hitch. But when I try to run it via the cron, I get the traceback about the feedparser module. >> >>> I believe that, because your PYTHONPATH will be set correctly from >>> the >>> command line; but possibly not from a default (basic) shell that >>> cron >>> uses. >>> So, again, try putting those two statements at the top of your >>> script, >>> -before- the 'import feedparser' statement, and let cron do its job. >>> You may need to redirect the output, eg >>> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/ >>> to/ >>> script/update_feeds.log 2>&1 >>> to get that output (I'm not sure how you got the error from the cron >>> job; through email?) >> >>> Check the log file: before the traceback, you should see the >>> result of >>> 'print sys.path'. Check if that includes the correct directories. >> > Top of script (possibly just below the she-bang): >> > import sys > print sys.path >> Traceback (most recent call last): File "/path/to/script/update_feeds.py", line 10, in ? import feedparser ImportError: No module named feedparser >> And here is the cron: >> export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/ django/ app export DJANGO_SETTINGS_MODULE=myproject.settings 1 * * * * /usr/bin/python /path/to/script/update_feeds.py >> I'm running the cron on my Dreamhost account BTW. >> >>> Did you try printing out the sys.path at the top of your >>> script, so >>> see if the PYTHONPATH is picked up correctly from the cron >>> environment >>> settings? I'd guess it should, but it may go wrong there (I'm no >>> cron >>> expert). > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding ManyToManyField to Django models
> I was wondering if it's possible to add a ManyToManyField onto a > prebuilt Django model such as User... I know that it would look like > this if I were to have created the model myself: > class User(models.Model): > watch = models.ManyToManyField('self', null=True, blank=True) > > I'm unsure how to add features to prebuilt models and wasn't even sure > if that was possible. Cannot you use a model with a ForeignKey to whatever prebuilt model you'd like to use? Cf using a home-made user model for authentication that ties into the prebuilt User. I would be curious, though, whether you can actually subclass a prebuilt model; my guess is not, and that it messes up the database tables, but that would be an interesting option otherwise. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Downlaod Free Softwares
Just Click here http://softwares8501.blogspot.com/ All Kind of Softwares are avaliable ** Free ** http://softwares8501.blogspot.com/ * Application Softwares http://softwares8501.blogspot.com/ *** Operating Softwares http://softwares8501.blogspot.com/ ** Best Regareds Sajjad Ahmad --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding ManyToManyField to Django models
The amazing thing about Django contrib is that, in general, it uses the same features as are available to you in your models. So there is no reason that you need to even install the auth system. You could copy the code out of django.contrib.auth and customize it as you see fit. The only thing is that code is tested and really complex and might be doing things that you haven't even thought about, so you might be looking at a project that is more complicated than you really want it to be. The nice thing about auth is that it gives you a built in function to add a profile to a user. This might be the best solution for you. Check out the django book here: http://www.djangobook.com/en/1.0/chapter12/#cn222 On Tue, Mar 4, 2008 at 4:06 PM, Michael Irani <[EMAIL PROTECTED]> wrote: > > I was wondering if it's possible to add a ManyToManyField onto a > prebuilt Django model such as User... I know that it would look like > this if I were to have created the model myself: > class User(models.Model): > watch = models.ManyToManyField('self', null=True, blank=True) > > I'm unsure how to add features to prebuilt models and wasn't even sure > if that was possible. > > Thanks, > Mike. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
problems with url tag
So, my urlconf is urlpatterns = patterns('teleworker.clients.views', (r'create/$', 'create'), (r'modify/(?P\d+)/$', 'modify'), (r'delete/(?P\d+)/$', 'delete'), (r'page/(?P\d+)/(?P\w+)/(?P\w+)/$', 'list'), (r'page/(?P\d+)/$', 'list'), (r'^$', 'list'), ) The list function is def list(request, page=1, orderby='clientid', direction='forward', filter=None): When I try to use the url tag to get a url to this function, it only matches the last line of the urlconf. {% url teleworker.clients.views.list page=1,orderby=clientid,direction=forward %} What am I missing? Thanks, Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
> OK, I did what you instructed and checked the log file, which did > contain the system path and the traceback about the "can't import > module...". Your script did run (you thought it completely failed), but -only- up the 'import feedparser' part. Anything before that ('print sys.path') actually worked fine. Printing the sys.path is often quite useful to debug things like this. > I see the paths specified don't contain the path to the feedparser > module, which explains the error. My question is how do I add this > path in the cron, especially since the script runs from the command > line? Presumably the environment variables you can set in your cron file are limited (to, eg HOME and EMAIL), which is why things don't work. Assuming this cron works the same as other ones I know, you can set the variables on the command line itself; that may work. Try this entry in your cron (and remove the top part with the environment variable settings): 1 * * * * PYTHONPATH=/path/to/python2.3/site-packages:/path/to/django/ app DJANGO_SETTINGS_MODULE=myproject.settings /usr/bin/python /path/ to/script/update_feeds.py > /path/to/script/update_feeds.log 2>1 (in case mailers mess up things: there are no line breaks in that line) The log file part is still there to check if things go wrong, but if it works fine, remove that part ('> /path/to/script/update_feeds.log 2>1') If this seems a bit messy, you can alter the sys.path at the top of your script, and set the DJANGO_SETTINGS_MODULE from there as well: import sys sys.path.extend(['/path/to/python2.3/site-packages', '/path/to/django/ app') import os os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' . . . import feedparser I prefer the first, since then the script itself is more portable (no hardcoded paths etc). I also came across this thread: http://groups.google.com/group/django-users/browse_thread/thread/d77412f3bbbd1d1a/64d567aadbf4b3f9?hl=en=gst=cron#64d567aadbf4b3f9 which uses something slightly different (solution at the bottom). But since this involves settings everything in your .bashrc (including possibly silly greetings like 'echo "How are you today"), that may be a bit overkill. Let me know if it works. >>> Well part of the problem is that the script itself works fine. I can >>> run from the command line without a hitch. But when I try to run it >>> via the cron, I get the traceback about the feedparser module. >> >> I believe that, because your PYTHONPATH will be set correctly from >> the >> command line; but possibly not from a default (basic) shell that cron >> uses. >> So, again, try putting those two statements at the top of your >> script, >> -before- the 'import feedparser' statement, and let cron do its job. >> You may need to redirect the output, eg >> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/to/ >> script/update_feeds.log 2>&1 >> to get that output (I'm not sure how you got the error from the cron >> job; through email?) >> >> Check the log file: before the traceback, you should see the result >> of >> 'print sys.path'. Check if that includes the correct directories. >> Top of script (possibly just below the she-bang): >> import sys print sys.path >> >>> Traceback (most recent call last): >>> File "/path/to/script/update_feeds.py", line 10, in ? >>> import feedparser >>> ImportError: No module named feedparser >> >>> And here is the cron: >> >>> export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/ >>> django/ >>> app >>> export DJANGO_SETTINGS_MODULE=myproject.settings >>> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py >> >>> I'm running the cron on my Dreamhost account BTW. >> >> Did you try printing out the sys.path at the top of your >> script, so >> see if the PYTHONPATH is picked up correctly from the cron >> environment >> settings? I'd guess it should, but it may go wrong there (I'm no >> cron >> expert). > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
On Tue, 2008-03-04 at 09:43 -0800, [EMAIL PROTECTED] wrote: > I'm sorry, but I still don't understand what this will do here. > > The cron can't run the script because it can't import the feedparser > module or the models from my app. So it doesn't matter if I print the > system path. Again, my problem is getting the python script to run > from the cron in the first place. No, the problem is that the Python path is incorrectly set and so you script cannot import the feedparser! You have been receiving help on how to print out what your script thinks the Python path is set to so that you can see that it is mosty likely incorrect and then go about fixing it. You are still at the "debugging what is wrong" phase, not at the "fixing it" phase. Work out what the Python path is set to (by printing it out, for example) and then you can set an environment variable to set it correctly. Malcolm -- I don't have a solution, but I admire your problem. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: reporting queryset-refactor bugs
On Tue, 2008-03-04 at 13:05 -0800, Dan Watson wrote: > I guess this is mostly a question for Malcolm. Do you want people to > start reporting bugs with the queryset-refactor branch, or would you > rather hold off until things are a little more solidified? And is I say "no bug reports" you'll go back and close the bug report you opened yesterday? :-) You might as well report them. Worst case I just close them as a dupe. My policy so far has been that if somebody reports something I already know about haven't gotten to yet, I'll tend to leave it open as the target for dupes. Just please search for duplicates before posting a ticket. If you're going to be an early adopter, save all us some time by spending 5 or 10 or 15 minutes checking to see if your issue already exists in the system. Regards, Malcolm -- Success always occurs in private and failure in full view. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "can't adapt" - mod_python, multiple interpreters, psycopg2
On Tue, 2008-03-04 at 13:14 -0800, Pigletto wrote: > Hi! > > I'm observing that "can't adapt" error appears on my Django powered > site sometimes. After Apache restart everything is OK for few days and > again... can't adapt appears. This is same thing as described there: > http://groups.google.com/group/django-users/browse_frm/thread/b11f8fbcfb25aaa0/ed9376362ac30e41?#ed9376362ac30e41 > > In my case error is in: > /var/www/django/django_sources/app1/test/django/django/db/backends/ > util.py in execute, line 18 > which turns out to be: > return self.cursor.execute(sql, params) > > I have: > 1. django from svn - newforms-admin branch, rev. 7106 (so it contains > patch for unicode problems as described in the linked topic above) > 2. Apache 2 with mod_python and multiple django instances (multiple > python interpreters) > 3. psycopg2 - version from svn that contains patch for Decimal as > described there: http://www.initd.org/tracker/psycopg/ticket/192 > > Problem is possibly with multiple interpreters and psycopg2 again, Why do you say that? The thread you refer to above doesn't talk about mod_python, so do you have any extra evidence that support this claim? What is the code doing before the problem occurs? Any exception includes a traceback and from that you should be able to work out which piece of your code is being executed prior to the problem. The next step is to work out what data is being passed in that is causing the problem and then tracing back where that came from. For example, after looking at a few tracebacks, if it's always triggered by the same spot in your code, you could put in a try...except block to catch this error and log the data you are trying to send to the database backend (log the type of the data as well, since if you see 1.23 you don't know if it's a float or a decimal or a string, often times). The information you've provided doesn't really have enough information to guess at the problem, unless you're really lucky and somebody with the same setup has seen the problem and already been through these debugging steps. Malcolm -- Always try to be modest and be proud of it! http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding ManyToManyField to Django models
Yep here's a good article on it: http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ On Mar 4, 5:36 pm, Michael Irani <[EMAIL PROTECTED]> wrote: > I got some help on IRC and here's the conclusion. There is no way to > add that mapping from auth.User to itself without hacking the django > code, so what needs to happen is that I add a wrapper Model such as > 'Profile' and add the ManyToManyField to 'Profile'. Thereby the > mappings will happen within the 'Profile' models. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding ManyToManyField to Django models
I got some help on IRC and here's the conclusion. There is no way to add that mapping from auth.User to itself without hacking the django code, so what needs to happen is that I add a wrapper Model such as 'Profile' and add the ManyToManyField to 'Profile'. Thereby the mappings will happen within the 'Profile' models. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "can't adapt" - mod_python, multiple interpreters, psycopg2
On Mar 5, 8:14 am, Pigletto <[EMAIL PROTECTED]> wrote: > Hi! > > I'm observing that "can't adapt" error appears on my Django powered > site sometimes. After Apache restart everything is OK for few days and > again... can't adapt appears. This is same thing as described > there:http://groups.google.com/group/django-users/browse_frm/thread/b11f8fb... > > In my case error is in: > /var/www/django/django_sources/app1/test/django/django/db/backends/ > util.py in execute, line 18 > which turns out to be: > return self.cursor.execute(sql, params) > > I have: > 1. django from svn - newforms-admin branch, rev. 7106 (so it contains > patch for unicode problems as described in the linked topic above) > 2. Apache 2 with mod_python and multiple django instances (multiple > python interpreters) > 3. psycopg2 - version from svn that contains patch for Decimal as > described there:http://www.initd.org/tracker/psycopg/ticket/192 > > Problem is possibly with multiple interpreters and psycopg2 again, so, > as I can't find how, where and why this happens, the question is how > can I change my environment to workaround this problem? > > I wonder about removing multiple interpreters issue by: > 1. changing apache to MPM workers mode > or > 2. Using distinct VirtualHost for each application (so I don't have to > set python_interpreter within VirtualHost directive) > > but I'm not sure if any of the above may help? Any ideas? Neither 1 or 2 will help as multiple interpreters will still be used. If it really is some problem with interaction between multiple sub interpreters in the same process, possibly connected with psycopg2, one option may be to use mod_wsgi (www.modwsgi.org) instead and specifically use its daemon mode to delegate each Django instance to run in a separate set of daemon processes. If it is something to do with psycopg2 code not working in secondary sub interpreters, can also with mod_wsgi force each Django instance to run in main interpreter of their respective sets of processes. Alternatively, use a fastcgi, scgi or ajp based hosting solution. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to give a style for "CHOICE FILED" in py file
> group_name=forms.ChoiceField(choices=[("itp","ITP"),("csg", "CSG"), > ("nwg","NWG"),("pcis","PCIS"),("serv","SERV"),("swg","SWG"), > ("wsg","WSG")],required = False) > I WANT TO GIVE A STYLE FOR CHOICE FILED DATA(swg,wsg)... HW CAN I? I'm not sure if I understand what you mean, but maybe you want: group_name.widget.attrs['class']='my_style' -- Maciej Wisniowski --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: mod_wsgi & trailing slashes on urls
On Mar 5, 8:26 am, Matt <[EMAIL PROTECTED]> wrote: > > Also, you aren't mounting your application at the root of the web > > server but a sub URL, this means that you have to use a WSGI wrapper > > around Django entry point and have to include the mount point path in > > the URLs in urls.py. This is documented in [1], but you don't seem to > > use the wrapper in your script file. > > I've been trying to avoid having to modify my url_patterns in a > mounting-specific way, so I opted not to use the workaround from > #2407. It was my understanding that this fix needs to be employed if > you're trying to host multiple Django sites under a single > VirtualHost. With the exception of the TypeError in my original post, > everything works as it should - Django essentially sees a cropped > version of the url in the address bar (i.e. with /my_app/foo removed), > so url_patterns shouldn't care that there's a url prefix. > > Here is my urls.py: > - > urlpatterns = patterns('', > (r'^/?$', > direct_to_template, {'template': 'viewer.html'}), > (r'^upload/?$', views.upload), > > (r'^accounts/login/$',login, > {'template_name': 'login.html'}), > (r'^accounts/logout/$', logout, > {'next_page': 'accounts/login/'}), > > (r'^admin/', > include('django.contrib.admin.urls')), > ) > - > > I don't fully understand the SCRIPT_NAME problem, but I can surmise > why I'm getting the TypeError: mod_wsgi removes the /my_app/foo prefix > from the url in the address bar and feeds the rest to Django - in the > first url_pattern above, that would be an empty string. My guess is > that mod_wsgi is sending it None instead, causing the exception. The string shouldn't ever be pass as None, so must be something else. I believe the reason for the SCRIPT_NAME fiddle is that when you use APIs within Django to construct a full URL, eg., for doing a redirect, or perhaps for referencing static files, it will be wrong without the fiddle. I don't use Django, so don't the specific functions that might be the issue there. From memory I believe the problems show up quite readily if you enable the admin interface. Some embedded URLs get sent back as /admin instead of /my_app/foo/admin. > Simply matching something other than the empty string would avoid this > problem, but if my surmising above is correct, is that a bug in > mod_wsgi? Don't believe so. Graham > Many thanks, > Matt. > > > Hopefully the above helps, but also check out Apache documentation for > > Alias directive. > > On Mar 3, 6:14 pm, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > > > > > On Mar 4, 4:19 am, Matt <[EMAIL PROTECTED]> wrote: > > > > Hello group, > > > > I'm having some problems understanding the URL setup for mod_wsgi. The > > > documentation at [1] is excellent, but all of the examples of the > > > Apache configuration have a trailing slash appended to the Alias. > > > Did you also read: > > > http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines > > > This has other examples including one which shows mounting at sub URL. > > > Also, are you talking about Alias directive used to map your static > > files, or WSGIScriptAlias directive and the Django application URLs > > itself? > > > > In my experience, that means that /my_app/foo results in a 404. All of my > > > url_patterns have an optional trailing slash, so my assumption is that > > > this is an Apache pattern-matching issue. > > > Maybe, maybe not. > > > Also, you aren't mounting your application at the root of the web > > server but a sub URL, this means that you have to use a WSGI wrapper > > around Django entry point and have to include the mount point path in > > the URLs in urls.py. This is documented in [1], but you don't seem to > > use the wrapper in your script file. > > > > Even worse, when I browse to /my_app/foo/, I get a TypeError. Here's > > > the traceback: > > > > - > > > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in > > > get_response > > > 73. callback, callback_args, callback_kwargs = > > > resolver.resolve(request.path) > > > > Exception Type: TypeError at > > > Exception Value: 'NoneType' object is not iterable > > > - > > > > I get the best results by removing the trailing slash from the Apache > > > configuration. Then, the page loads correctly at /my_app/foo/, but I > > > get the same TypeError at /my_app/foo (without the slash). > > > Post urls.py file as that is where this problem most likely lies. > > > > Config files are below. The platform is Windows with 0.97-pre-SVN-7190 > > > and Apache 2.2.6. > > > > httpd.conf: > > > - > > > Alias /my_app/foo/media "d:/www/media/foo/" > > > Recommended that you use: > > > Alias /my_app/foo/media/ "d:/www/media/foo/" > > > ie., trailing slash on LHS required. That way if someone tries to > > access '/my_app/foo/media' they will get 404. See: > > >
ANN: updater.py v0.5.0 -- Django project evolution utility
updater.py is a utility for applying and removing an ordered sequence of updates to a Django project: - Creates update skeletons. - Records and tracks update application/removal. - Provides some useful helper objects and functions. An update is typically used to evolve the database schema (preserving existing data) and is normally applied as part of a project codebase upgrade. Documentation and download here: http://www.methods.co.nz/django/updater.html Cheers, Stuart -- Stuart Rackham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: mod_wsgi & trailing slashes on urls
Hi Graham, Thanks for the useful reply. You're right, I skipped the general configuration instructions and jumped straight to the Django specific ones, which don't have examples for mounting at a sub-URL. It does very clearly say on the general page that the trailing slash should be omitted in that case - sorry for that. > Recommended that you use: > > Alias /my_app/foo/media/ "d:/www/media/foo/" > > ie., trailing slash on LHS required. That way if someone tries to > access '/my_app/foo/media' they will get 404. See: > > http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias Honestly, I think I prefer it without the trailing slash. That way, with indexing enabled you get a directory listing (as you do for any subdirectories below media), and a 403 otherwise. > Also, you aren't mounting your application at the root of the web > server but a sub URL, this means that you have to use a WSGI wrapper > around Django entry point and have to include the mount point path in > the URLs in urls.py. This is documented in [1], but you don't seem to > use the wrapper in your script file. I've been trying to avoid having to modify my url_patterns in a mounting-specific way, so I opted not to use the workaround from #2407. It was my understanding that this fix needs to be employed if you're trying to host multiple Django sites under a single VirtualHost. With the exception of the TypeError in my original post, everything works as it should - Django essentially sees a cropped version of the url in the address bar (i.e. with /my_app/foo removed), so url_patterns shouldn't care that there's a url prefix. Here is my urls.py: - urlpatterns = patterns('', (r'^/?$', direct_to_template, {'template': 'viewer.html'}), (r'^upload/?$', views.upload), (r'^accounts/login/$',login, {'template_name': 'login.html'}), (r'^accounts/logout/$', logout, {'next_page': 'accounts/login/'}), (r'^admin/', include('django.contrib.admin.urls')), ) - I don't fully understand the SCRIPT_NAME problem, but I can surmise why I'm getting the TypeError: mod_wsgi removes the /my_app/foo prefix from the url in the address bar and feeds the rest to Django - in the first url_pattern above, that would be an empty string. My guess is that mod_wsgi is sending it None instead, causing the exception. Simply matching something other than the empty string would avoid this problem, but if my surmising above is correct, is that a bug in mod_wsgi? Many thanks, Matt. > Hopefully the above helps, but also check out Apache documentation for > Alias directive. On Mar 3, 6:14 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Mar 4, 4:19 am, Matt <[EMAIL PROTECTED]> wrote: > > > Hello group, > > > I'm having some problems understanding the URL setup for mod_wsgi. The > > documentation at [1] is excellent, but all of the examples of the > > Apache configuration have a trailing slash appended to the Alias. > > Did you also read: > > http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines > > This has other examples including one which shows mounting at sub URL. > > Also, are you talking about Alias directive used to map your static > files, or WSGIScriptAlias directive and the Django application URLs > itself? > > > In my experience, that means that /my_app/foo results in a 404. All of my > > url_patterns have an optional trailing slash, so my assumption is that > > this is an Apache pattern-matching issue. > > Maybe, maybe not. > > Also, you aren't mounting your application at the root of the web > server but a sub URL, this means that you have to use a WSGI wrapper > around Django entry point and have to include the mount point path in > the URLs in urls.py. This is documented in [1], but you don't seem to > use the wrapper in your script file. > > > > > Even worse, when I browse to /my_app/foo/, I get a TypeError. Here's > > the traceback: > > > - > > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in > > get_response > > 73. callback, callback_args, callback_kwargs = > > resolver.resolve(request.path) > > > Exception Type: TypeError at > > Exception Value: 'NoneType' object is not iterable > > - > > > I get the best results by removing the trailing slash from the Apache > > configuration. Then, the page loads correctly at /my_app/foo/, but I > > get the same TypeError at /my_app/foo (without the slash). > > Post urls.py file as that is where this problem most likely lies. > > > Config files are below. The platform is Windows with 0.97-pre-SVN-7190 > > and Apache 2.2.6. > > > httpd.conf: > > - > > Alias /my_app/foo/media "d:/www/media/foo/" > > Recommended that you use: > > Alias /my_app/foo/media/ "d:/www/media/foo/" > > ie., trailing slash on LHS required. That way if someone tries to > access '/my_app/foo/media' they will get 404. See: > > http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias >
"can't adapt" - mod_python, multiple interpreters, psycopg2
Hi! I'm observing that "can't adapt" error appears on my Django powered site sometimes. After Apache restart everything is OK for few days and again... can't adapt appears. This is same thing as described there: http://groups.google.com/group/django-users/browse_frm/thread/b11f8fbcfb25aaa0/ed9376362ac30e41?#ed9376362ac30e41 In my case error is in: /var/www/django/django_sources/app1/test/django/django/db/backends/ util.py in execute, line 18 which turns out to be: return self.cursor.execute(sql, params) I have: 1. django from svn - newforms-admin branch, rev. 7106 (so it contains patch for unicode problems as described in the linked topic above) 2. Apache 2 with mod_python and multiple django instances (multiple python interpreters) 3. psycopg2 - version from svn that contains patch for Decimal as described there: http://www.initd.org/tracker/psycopg/ticket/192 Problem is possibly with multiple interpreters and psycopg2 again, so, as I can't find how, where and why this happens, the question is how can I change my environment to workaround this problem? I wonder about removing multiple interpreters issue by: 1. changing apache to MPM workers mode or 2. Using distinct VirtualHost for each application (so I don't have to set python_interpreter within VirtualHost directive) but I'm not sure if any of the above may help? Any ideas? -- Maciej Wisniowski --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Adding ManyToManyField to Django models
I was wondering if it's possible to add a ManyToManyField onto a prebuilt Django model such as User... I know that it would look like this if I were to have created the model myself: class User(models.Model): watch = models.ManyToManyField('self', null=True, blank=True) I'm unsure how to add features to prebuilt models and wasn't even sure if that was possible. Thanks, Mike. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
reporting queryset-refactor bugs
I guess this is mostly a question for Malcolm. Do you want people to start reporting bugs with the queryset-refactor branch, or would you rather hold off until things are a little more solidified? Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
OK, I'm getting a different error now: Traceback (most recent call last): File "update_feeds.py", line 58, in ? update_feeds() File "update_feeds.py", line 14, in update_feeds from knoxd.apps.aggregator.models import Feed, FeedItem ImportError: No module named knoxd.apps.aggregator.models I had added the following to my cron: export PYTHONPATH=$PYTHONPATH:$HOME/lib/python2.3/site-packages I'm assuming this solved the previous traceback issue.(?) On Mar 4, 1:27 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > OK, I did what you instructed and checked the log file, which did > contain the system path and the traceback about the "can't import > module...". > > I see the paths specified don't contain the path to the feedparser > module, which explains the error. My question is how do I add this > path in the cron, especially since the script runs from the command > line? > > On Mar 4, 9:02 am, Evert Rol <[EMAIL PROTECTED]> wrote: > > > > Well part of the problem is that the script itself works fine. I can > > > run from the command line without a hitch. But when I try to run it > > > via the cron, I get the traceback about the feedparser module. > > > I believe that, because your PYTHONPATH will be set correctly from the > > command line; but possibly not from a default (basic) shell that cron > > uses. > > So, again, try putting those two statements at the top of your script, > > -before- the 'import feedparser' statement, and let cron do its job. > > You may need to redirect the output, eg > > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/to/ > > script/update_feeds.log 2>&1 > > to get that output (I'm not sure how you got the error from the cron > > job; through email?) > > > Check the log file: before the traceback, you should see the result of > > 'print sys.path'. Check if that includes the correct directories. > > > >> Top of script (possibly just below the she-bang): > > > >> import sys > > >> print sys.path > > > > Traceback (most recent call last): > > > File "/path/to/script/update_feeds.py", line 10, in ? > > > import feedparser > > > ImportError: No module named feedparser > > > > And here is the cron: > > > > export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/ > > > django/ > > > app > > > export DJANGO_SETTINGS_MODULE=myproject.settings > > > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > > > > I'm running the cron on my Dreamhost account BTW. > > > Did you try printing out the sys.path at the top of your script, so > > see if the PYTHONPATH is picked up correctly from the cron > > environment > > settings? I'd guess it should, but it may go wrong there (I'm no > > cron > > expert). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
sync flickr to my django blog
hello group, First of all I would like to thank this community for helping me in solve my doubts regarding django. And here I am again with another one. I am creating my blog using django and I want to integrate my flickr with my blog. I am using the code from here. http://www.djangosnippets.org/snippets/299/ i have created an app 'photos' in apps folder. I have a flickr model from the snippet above. Also I have flickrupdate.py(which uses flickrlib.py) which is also in the snippet stated above. Now can anyone help me whats the next step to sync my flickr profile with my blog. In admin panel the photos app is showing up with all the fields...But all the fields should be populated from flickr... .Am I right? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: location of CSS
Where are your templates stored? Phillip Watts wrote: > I can't figure out where to put css files or background images referred to by > css. I have: > > > and > MEDIA_ROOT = '/home/phil/philproj/media/' > > ls -al /home/phil/philproj/media > total 12 > drwxr-xr-x 2 phil phil 4096 2008-03-04 11:57 . > drwxr-xr-x 7 phil phil 4096 2008-03-04 12:14 .. > -rw-r--r-- 1 phil phil 96 2008-03-04 11:57 dirview.css > > I've tried everything? Help? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle invalid environment variables
Richard, What versions of Oracle, cx_Oracle, and Django are you using? Apparently, this can be caused by an invalid NLS_LANG environment variable setting or an invalid NLS value in an ALTER SESSION statement. The Oracle backend automatically sets the NLS_LANG environment variable to ".UTF8" and issues an ALTER SESSION query to set the NLS_TIMESTAMP_FORMAT and NLS_DATE_FORMAT parameters. Both of these can be found in django/db/backends/oracle/base.py. I can see no problems with them, but you might try using the same settings in sqlplus to see if you can reproduce the issue there. You might also try asking your question on the cx_Oracle mailing list. Somebody there may have better insight into your problem. Hope that helps, Ian Kelly On Mar 4, 1:45 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hello Django Users, > > Althought this is probably not a specific django error, i hope someone > can point me in the right direction. > I developed a application on a development server where everything > works just fine. > > server specs ( development server ): > - Linux version 2.6.9-22.0.2.ELsmp ([EMAIL PROTECTED] > bc1-6.build.redhat.com) > - Intel Xeon 3 ghz > > When we migrated the application to the production server > > server specs: > - Linux version 2.6.9-55.ELsmp ([EMAIL PROTECTED] > bc2-14.build.redhat.com) > - Intel Xeon 2.7 ghz > > We got the following Oracle error: > ORA-12705: Cannot access NLS data files or invalid environment > specified > > I googled on this error and it says there might be a issue with > deleting sessions. This error occurs random so i really don't know > where to look. > > any help would be appreciated. > > regards, > > Richard Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
location of CSS
I can't figure out where to put css files or background images referred to by css. I have: and MEDIA_ROOT = '/home/phil/philproj/media/' ls -al /home/phil/philproj/media total 12 drwxr-xr-x 2 phil phil 4096 2008-03-04 11:57 . drwxr-xr-x 7 phil phil 4096 2008-03-04 12:14 .. -rw-r--r-- 1 phil phil 96 2008-03-04 11:57 dirview.css I've tried everything? Help? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
OK, I did what you instructed and checked the log file, which did contain the system path and the traceback about the "can't import module...". I see the paths specified don't contain the path to the feedparser module, which explains the error. My question is how do I add this path in the cron, especially since the script runs from the command line? On Mar 4, 9:02 am, Evert Rol <[EMAIL PROTECTED]> wrote: > > Well part of the problem is that the script itself works fine. I can > > run from the command line without a hitch. But when I try to run it > > via the cron, I get the traceback about the feedparser module. > > I believe that, because your PYTHONPATH will be set correctly from the > command line; but possibly not from a default (basic) shell that cron > uses. > So, again, try putting those two statements at the top of your script, > -before- the 'import feedparser' statement, and let cron do its job. > You may need to redirect the output, eg > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/to/ > script/update_feeds.log 2>&1 > to get that output (I'm not sure how you got the error from the cron > job; through email?) > > Check the log file: before the traceback, you should see the result of > 'print sys.path'. Check if that includes the correct directories. > > >> Top of script (possibly just below the she-bang): > > >> import sys > >> print sys.path > > > Traceback (most recent call last): > > File "/path/to/script/update_feeds.py", line 10, in ? > > import feedparser > > ImportError: No module named feedparser > > > And here is the cron: > > > export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/ > > django/ > > app > > export DJANGO_SETTINGS_MODULE=myproject.settings > > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > > > I'm running the cron on my Dreamhost account BTW. > > Did you try printing out the sys.path at the top of your script, so > see if the PYTHONPATH is picked up correctly from the cron > environment > settings? I'd guess it should, but it may go wrong there (I'm no > cron > expert). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
> Well part of the problem is that the script itself works fine. I can > run from the command line without a hitch. But when I try to run it > via the cron, I get the traceback about the feedparser module. I believe that, because your PYTHONPATH will be set correctly from the command line; but possibly not from a default (basic) shell that cron uses. So, again, try putting those two statements at the top of your script, -before- the 'import feedparser' statement, and let cron do its job. You may need to redirect the output, eg 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/to/ script/update_feeds.log 2>&1 to get that output (I'm not sure how you got the error from the cron job; through email?) Check the log file: before the traceback, you should see the result of 'print sys.path'. Check if that includes the correct directories. >> Top of script (possibly just below the she-bang): >> >> import sys >> print sys.path >> > Traceback (most recent call last): > File "/path/to/script/update_feeds.py", line 10, in ? > import feedparser > ImportError: No module named feedparser >> > And here is the cron: >> > export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/ > django/ > app > export DJANGO_SETTINGS_MODULE=myproject.settings > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py >> > I'm running the cron on my Dreamhost account BTW. >> Did you try printing out the sys.path at the top of your script, so see if the PYTHONPATH is picked up correctly from the cron environment settings? I'd guess it should, but it may go wrong there (I'm no cron expert). > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "for key, value" in 0.96
Thank you very much everybody. I suspect that was a trunk's functionality. I solved it using a list of tuples. Thanks again. On 26 feb, 00:02, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2008-02-25 at 10:21 -0800, Jose Jiménez wrote: > > Hello everybody, > > > i'm developing an application with the lates stable release of django > > (0.96). > > In the trunk version, i can do "for key, value in variable", but in > > the 0.96 version i take an error: > > > 'for' statements with five words should end in 'reversed': for key, > > value in variable > > > How can i access to the key and the value of all elements of a > > dictionary? If i do: for a in variable, a is the key, but i can't > > access its value. > > So you are talking about the "for" template tag here, not Python code > (best to be clear about that). It also sounds like your "variable" is a > dictionary from your use of the words "key" and "value". Working on > those assumptions: > > {% for value in variable.items %} > {{ value.0 }} is the key > {{ value.1 }} is the value > {% endfor %} > > Here, variable.items returns a tuple and you can access the items in a > tuple via value.0 and value.1. > > Malcolm > > -- > Why can't you be a non-conformist like everyone > else?http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
Hopefully, it will print the path before the import statement fails, and also log the error message that cron generates to a log. So it does matter if you print the sys.path, because that could tell you that the location of your feedparser module isn't on that path. I don't know about dreamhost, but is your cron running as a different user than you? If so, that could explain why you can run the command from the shell when you login vs. running it as cron. Derek On Mar 4, 12:43 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm sorry, but I still don't understand what this will do here. > > The cron can't run the script because it can't import the feedparser > module or the models from my app. So it doesn't matter if I print the > system path. Again, my problem is getting the python script to run > from the cron in the first place. > > On Mar 4, 11:55 am, Evert Rol <[EMAIL PROTECTED]> wrote: > > > > I'm not sure where to print the path. Do I add that to the > > > update_feeds.py? Or does this go in the cron itself? > > > > If I add it to the script, and then run the script from the command > > > line, it prints what's on my python path and then runs the script as > > > normal. > > > > But that's never been the issue. The cron is what's throwing the > > > error. > > > You're not reading: I wrote: > > > " > > Top of script (possibly just below the she-bang): > > import sys > > print sys.path > > > " > > > and > > > " > > > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/to/ > > script/update_feeds.log 2>&1 > > > " > > > Then check your update_feeds.log. That gets the output generated from > > update_feeds.py when run from cron. > > > (although I note that the web archive doesn't agree with my sent > > emails; hmm...) > > > >>> Unfortunately, I get the same traceback: > > > >>> Traceback (most recent call last): > > >>> File "update_feeds.py", line 10, in ? > > >>> import feedparser > > >>> ImportError: No module named feedparser > > > >> Again: did you print the sys.path? > > > >> The 'cd' is not going to work, unless your modules are relative to > > >> the /path/to/script/ > > > >> I may have a solution, but I first want to know if it's a path > > >> problem. > > > >>> Any idea how to import the module within the cron? > > > >>> On Mar 4, 9:07 am, Jonas Christian <[EMAIL PROTECTED]> wrote: > > I ran into problems like that using cron and instead of trying to > > locate the real error in the paths (we were about to go > > live ...), I > > simple changed the cron line to read: > > > 1 * * * * cd /path/to/script; /usr/bin/python update_feeds.py > > > Why don't you try that and see if it helps... > > > Jonas > > > On 4 Mrz., 14:02, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> > > wrote: > > > > Well part of the problem is that the script itself works fine. I > > > can > > > run from the command line without a hitch. But when I try to run > > > it > > > via the cron, I get the traceback about the feedparser module. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: revert database migration
Thank you... for the help I started using the django evolution its fine... On Mar 4, 3:24 am, "Ramiro Morales" <[EMAIL PROTECTED]> wrote: > On Tue, Mar 4, 2008 at 2:58 AM, stranger <[EMAIL PROTECTED]> wrote: > > After searching this group archive i didnot find much regarding my question > > Really? > > http://groups.google.com/group/django-users/search?hl=en=migrations... > > There is a difference between searching the archives to find the answer > and searching it trying to find the answer one expects :) > > On Tue, Mar 4, 2008 at 3:04 AM, stranger <[EMAIL PROTECTED]> wrote: > > It is very sad that django donot track models. I migrated myself from > > Rails. In rails there is migration where we can make changes to models > > and sync with database. hope django will find a solution. > > http://www.djangoproject.com/documentation/faq/#if-i-make-changes-to-... > > Take a loo to third party efforts in this regard: > > http://code.google.com/p/deseb/http://code.google.com/p/django-evolution/http://www.aswmc.com/dbmigration/http://code.google.com/p/django-schemaevolution/ > > -- > Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
I'm sorry, but I still don't understand what this will do here. The cron can't run the script because it can't import the feedparser module or the models from my app. So it doesn't matter if I print the system path. Again, my problem is getting the python script to run from the cron in the first place. On Mar 4, 11:55 am, Evert Rol <[EMAIL PROTECTED]> wrote: > > I'm not sure where to print the path. Do I add that to the > > update_feeds.py? Or does this go in the cron itself? > > > If I add it to the script, and then run the script from the command > > line, it prints what's on my python path and then runs the script as > > normal. > > > But that's never been the issue. The cron is what's throwing the > > error. > > You're not reading: I wrote: > > " > Top of script (possibly just below the she-bang): > import sys > print sys.path > > " > > and > > " > > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/to/ > script/update_feeds.log 2>&1 > > " > > Then check your update_feeds.log. That gets the output generated from > update_feeds.py when run from cron. > > (although I note that the web archive doesn't agree with my sent > emails; hmm...) > > >>> Unfortunately, I get the same traceback: > > >>> Traceback (most recent call last): > >>> File "update_feeds.py", line 10, in ? > >>> import feedparser > >>> ImportError: No module named feedparser > > >> Again: did you print the sys.path? > > >> The 'cd' is not going to work, unless your modules are relative to > >> the /path/to/script/ > > >> I may have a solution, but I first want to know if it's a path > >> problem. > > >>> Any idea how to import the module within the cron? > > >>> On Mar 4, 9:07 am, Jonas Christian <[EMAIL PROTECTED]> wrote: > I ran into problems like that using cron and instead of trying to > locate the real error in the paths (we were about to go > live ...), I > simple changed the cron line to read: > > 1 * * * * cd /path/to/script; /usr/bin/python update_feeds.py > > Why don't you try that and see if it helps... > > Jonas > > On 4 Mrz., 14:02, "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> > wrote: > > > Well part of the problem is that the script itself works fine. I > > can > > run from the command line without a hitch. But when I try to run > > it > > via the cron, I get the traceback about the feedparser module. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting file selected for upload to survive validation.
At 1:31 AM +1100 3/5/08, Malcolm Tredinnick wrote: >On Tue, 2008-03-04 at 08:58 -0500, Ray Cote wrote: >> I have file uploads working using newforms. >> >> However, if I run into validation errors on the form (say a mandatory >> field is not filled), then when the form re-displays for the user, >> the file they previously selected is no longer selected. > >This is normal browser behaviour: they don't redisplay any file >specified in file upload widgets to avoid phishing-style attacks. So >Django doesn't bother sending it through. > >If you search in the archives, I seem to remember some people came up >with ways to pass the filename back in any case for manual display if >you want that, but it still won't be submitted as part of them form. > >Regards, >Malcolm Thanks for the pointer (and the note that this is expected behavior). --Ray -- Raymond Cote Appropriate Solutions, Inc. PO Box 458 ~ Peterborough, NH 03458-0458 Phone: 603.924.6079 ~ Fax: 603.924.8668 rgacote(at)AppropriateSolutions.com www.AppropriateSolutions.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: edit_inline in ModelForms
hi michael, sorry for not finding the needed information and thanks a lot for the link! regards. tom On 4 Mrz., 14:31, Michael <[EMAIL PROTECTED]> wrote: > This question in various forms was asked 3 times in the last 24 hours. > Check this > outhttp://collingrady.com/2008/02/18/editing-multiple-objects-in-django-... > > On Tue, Mar 4, 2008 at 4:11 AM, tom <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I've been looking and searching for the last days to find out how i > > could fix that, but I don't get around. I did read the newforms-admin > > fieldset.py stuff, also the edit_inline_stacked.html template, but I > > still don't figure it out. > > > What i would like to do is, to have 2 Models within one form. > > > The model is: > > #-- > > -- > > class Album(models.Model): > > artist = models.ForeignKey(PortalUser) > > title = models.CharField(max_length=100) > > slug = models.SlugField(prepopulate_from=("artist", "title")) > > genre = models.ManyToManyField(Genre, > > filter_interface=models.HORIZONTAL) > > def __unicode__(self): > > return self.title > > > class Admin: > > list_display = ('title', 'rating_stars', 'artist', > > 'release_date') > > list_filter = ('label', 'release_date') > > ordering = ('-release_date',) > > search_fields = ('title', 'label') > > fields = ( > > (None, {'fields':('title',)}), > > ('Album informatin', {'fields':('cover', 'language', > > 'release_date', 'genre')}), > > ) > > > class Track(models.Model): > > artist = models.ForeignKey(PortalUser) > > title = models.CharField(max_length=100, core=True) > > file = models.FileField(upload_to="/", core=True) > > album = models.ForeignKey(Album, edit_inline=models.TABULAR, > > num_extra_on_change=1, num_in_admin=10) > > > def __unicode__(self): > > return self.title > > > class Admin: > > list_display = ('title', 'album', 'artist') > > search_fields = ('title', 'genre', 'artist') > > list_filter = ('language',) > > #-- > > -- > > > and I use the following form: > > class AlbumForm(forms.ModelForm): > > > class Meta: > > model = Album > > > with this view: > > login_required > > def add_or_edit_album(request, success_url='', > > form_class=AlbumForm, > > template_name='music/album_form.html'): > > > success_url = '/artist/%s' % (request.user.username) > > > if request.method == 'POST': > > > form = form_class(data=request.DATA, files=request.FILES) > > if form.is_valid(): > > album = form.save(commit=False) > > album.artist = request.user > > album.save() > > form.save_m2m() > > return HttpResponseRedirect(success_url) > > else: > > form = form_class() > > return render_to_response(template_name, > > { 'form': form }, > > > context_instance=RequestContext(request)) > > > what happens, when I call the template is, that only the album form > > shows up, but it does not contain the track slots. When I try to call > > the TrackForm (created the same way as the Album Form) I do get a drop- > > down box for the albums. Does someone know a way how to solve this? > > > I use the current svn version from django. > > > Many thanks! > > > Tom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ManyToMany fields in database lookups
Hello, I have a curious problem with a complex filter in 0.96: Merchant.objects.filter(Q(categories_fr__name__icontains=s) | Q(categories_en__name__icontains=s)) this returns an empty queryset even when 's' is in categories_fr. Changing categories_fr__name with an attribute directly in the object has the same effect. It seems that a ManyToMany field with no elements nullifies the entire query. Is this a bug, or am I misunderstanding something? Thank you, Vincent. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: GeoDjango: distance calculation
> For some of our calculations, it is much too slow to use distance_spheroid - > the slight loss in accuracy is worth the enormous gain in speed. I did some performance tests and confirmed your findings. I've created a ticket that includes a patch that changes the default geodetic distance calculation to use `ST_distance_sphere` instead: http://code.djangoproject.com/ticket/6715 My informal tests indicate that calculations are 30-40% faster, with a maximum of 0.25% loss in accuracy. I haven't committed yet because I wanted to solicit comments on the API that enables spheroid calculations. -Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
> I'm not sure where to print the path. Do I add that to the > update_feeds.py? Or does this go in the cron itself? > > If I add it to the script, and then run the script from the command > line, it prints what's on my python path and then runs the script as > normal. > > But that's never been the issue. The cron is what's throwing the > error. You're not reading: I wrote: " Top of script (possibly just below the she-bang): import sys print sys.path " and " 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > /path/to/ script/update_feeds.log 2>&1 " Then check your update_feeds.log. That gets the output generated from update_feeds.py when run from cron. (although I note that the web archive doesn't agree with my sent emails; hmm...) >>> Unfortunately, I get the same traceback: >> >>> Traceback (most recent call last): >>> File "update_feeds.py", line 10, in ? >>> import feedparser >>> ImportError: No module named feedparser >> >> Again: did you print the sys.path? >> >> The 'cd' is not going to work, unless your modules are relative to >> the /path/to/script/ >> >> I may have a solution, but I first want to know if it's a path >> problem. >> >>> Any idea how to import the module within the cron? >> >>> On Mar 4, 9:07 am, Jonas Christian <[EMAIL PROTECTED]> wrote: I ran into problems like that using cron and instead of trying to locate the real error in the paths (we were about to go live ...), I simple changed the cron line to read: >> 1 * * * * cd /path/to/script; /usr/bin/python update_feeds.py >> Why don't you try that and see if it helps... >> Jonas >> On 4 Mrz., 14:02, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >> > Well part of the problem is that the script itself works fine. I > can > run from the command line without a hitch. But when I try to run > it > via the cron, I get the traceback about the feedparser module. > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blocktrans getting erratic
On Tue, 2008-03-04 at 08:23 -0800, Jonas Christian wrote: > Malcolm, you're a saviour! > > That would explain why I didn't find anything in the Django > documentation. I should have read up on gettext instead. I keep meaning to add something to the docs about that. It bites translators every now and again, but it's one of those things that, once you know it, is kind of obvious. Malcolm -- Success always occurs in private and failure in full view. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
change user admin template
Hey I can't seem to find the template that is displayed when I change a user (@ www.example.com/example/admin/auth/user/1/). I'm fairly new to customizing the admin interface, so I might have overlooked something... Stephane --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sxsw anyone?
We just put up a (django) version of our Q site just for questions about and during SXSW. You can ask specific SXSW questions there--you might get some great answers. http://sxsw.fluther.com Ben Fluther.com On Mar 3, 7:40 am, "Peter Baumgartner" <[EMAIL PROTECTED]> wrote: > Anyone here going to SXSW? It'll be my first trip this year and anyone > that wants to meet up or impart some wisdom on me regarding the event > would be great. > > -- > Pete --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blocktrans getting erratic
Malcolm, you're a saviour! That would explain why I didn't find anything in the Django documentation. I should have read up on gettext instead. Three cheers, Jonas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToMany fields in database lookups
On Tue, 2008-03-04 at 07:28 -0800, Vincent Foley wrote: > Hello, > > I have a curious problem with a complex filter in 0.96: > > Merchant.objects.filter(Q(categories_fr__name__icontains=s) | > Q(categories_en__name__icontains=s)) > > this returns an empty queryset even when 's' is in categories_fr. > Changing categories_fr__name with an attribute directly in the object > has the same effect. It seems that a ManyToMany field with no > elements nullifies the entire query. > > Is this a bug, or am I misunderstanding something? There are a few issues with many-to-many fields and empty results like this. The whole area has been given an overhaul in the queryset-refactor branch and so should be fixed on trunk soon-ish. In the meantime, just select the two halves individually and merge them in Python. Malcolm -- If it walks out of your refrigerator, LET IT GO!! http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blocktrans getting erratic
On Tue, 2008-03-04 at 08:04 -0800, Jonas Christian wrote: > Hi Malcolm: > > > Are you sure you haven't inadvertently introduced newlines into the > > strings here? Can show us what the corresponding lines in the PO file > > look like (include the comments before the msgid bit as well). > > This is what the PO file looks like: > > #: templates/host.html:14 > #, fuzzy, python-format > msgid "This is the count: %(xyz)s" > msgstr "Das ist die Anzahl: %(xyz)s" As suspected! That's why I asked for the comments. :-) "Fuzzy" messages for not make it into the translation. They are not considered to be translated correctly, but they are not deleted, since they are likely to be "almost correct" and just need a small update. Part of normal translator operations is to search out any "fuzzy" messages and verify that they are either still correct (just delete the fuzzy comment, but do not delete the python-format bit) or update them and then remove the "fuzzy". This isn't anything special to Django, by the way. It's the way gettext-backed i18n support operates. Regards, Malcolm -- Quantum mechanics: the dreams stuff is made of. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Getting file selected for upload to survive validation.
On Tue, 2008-03-04 at 08:58 -0500, Ray Cote wrote: > I have file uploads working using newforms. > > However, if I run into validation errors on the form (say a mandatory > field is not filled), then when the form re-displays for the user, > the file they previously selected is no longer selected. This is normal browser behaviour: they don't redisplay any file specified in file upload widgets to avoid phishing-style attacks. So Django doesn't bother sending it through. If you search in the archives, I seem to remember some people came up with ways to pass the filename back in any case for manual display if you want that, but it still won't be submitted as part of them form. Regards, Malcolm -- Telepath required. You know where to apply... http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Flatpages
You were right about the 404.html template being required. And I found this ticket to help back up my problem: http://code.djangoproject.com/ticket/3335 It's a won't fix issue, but they put a comment in the code that was suppose to alert me that I needed the template, but I totally missed it, so that solution sort of failed me. Oh well, I'm sure most other people would have caught it. The strange thing is that I updated both servers to the trunk (0.97- pre-SVN-7193), and only one of them required the 404 template when DEBUG was set to False. So I'm guessing that it might be something external to Django, since my deployments on both boxes were almost identical. Both running on Apache with mod_python, and running all the same apps and very similar settings. Strange bug. On Mar 3, 5:19 pm, Michael <[EMAIL PROTECTED]> wrote: > In your templates folder create a 404.html file. This should solve > your problems. I read that there needs to be a 404.html and 500.html > file somewhere but can't find the link to point you to it. > > On Mon, Mar 3, 2008 at 3:20 PM, Lewis Bergman <[EMAIL PROTECTED]> wrote: > > > If the configs are nearly identical, do a diff and see what *is* the > > difference between the two? Are the two running the same django versions? > > > bfrederi wrote: > > > I am using flatpages on a production box, and whenever I don't set > > > DEBUG to True in the settings.py file, the middleware won't redirect > > > to my flatpages for some reason. It gives me a 'TemplateDoesNotExist: > > > 404.html' error message. > > > > It works perfectly fine on another box, and the setup for both boxes > > > are nearly identical. I can't figure out why one works, and the other > > > doesn't. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
Do you have a link to more information about Django-cron? How do I go about using this? On Mar 4, 10:34 am, "Dj Gilcrease" <[EMAIL PROTECTED]> wrote: > On Tue, Mar 4, 2008 at 4:55 AM, [EMAIL PROTECTED] > > <[EMAIL PROTECTED]> wrote: > > > I'm trying to use a cron job to run a python script that updates feeds > > on an aggregator site I'm building. But I'm getting trackback errors > > telling me it can't import the module feedparser. Here's the error: > > > Traceback (most recent call last): > > File "/path/to/script/update_feeds.py", line 10, in ? > > import feedparser > > ImportError: No module named feedparser > > You can try using django-cron, which is a django app that can run > tasks on a specified schedule and since it runs from within the django > web framework it does not have the environment and path issues that > setting up an actual cron job does --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blocktrans getting erratic
Hi Malcolm: > Are you sure you haven't inadvertently introduced newlines into the > strings here? Can show us what the corresponding lines in the PO file > look like (include the comments before the msgid bit as well). This is what the PO file looks like: #: templates/host.html:14 #, fuzzy, python-format msgid "This is the count: %(xyz)s" msgstr "Das ist die Anzahl: %(xyz)s" > I'm assuming by "not working" you mean the string is being displayed in > English rather than, say, German. You're not saying the string doesn't > display at all, right? Correct. As I said, at first it does display in German. Once I add another variable it goes back to English and stays there. I have a feeling it boils down to either my mistake or something in the creation of the PO file. I don't know enough about gettext to dive into debugging, sadly. > My bet is that the last problems are human error, but I'd like to > understand them to see if we can bullet-proof this a bit more. Thank you for your effort, Jonas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
I'm not sure where to print the path. Do I add that to the update_feeds.py? Or does this go in the cron itself? If I add it to the script, and then run the script from the command line, it prints what's on my python path and then runs the script as normal. But that's never been the issue. The cron is what's throwing the error. On Mar 4, 10:07 am, Evert Rol <[EMAIL PROTECTED]> wrote: > > Unfortunately, I get the same traceback: > > > Traceback (most recent call last): > > File "update_feeds.py", line 10, in ? > > import feedparser > > ImportError: No module named feedparser > > Again: did you print the sys.path? > > The 'cd' is not going to work, unless your modules are relative to > the /path/to/script/ > > I may have a solution, but I first want to know if it's a path problem. > > > Any idea how to import the module within the cron? > > > On Mar 4, 9:07 am, Jonas Christian <[EMAIL PROTECTED]> wrote: > >> I ran into problems like that using cron and instead of trying to > >> locate the real error in the paths (we were about to go live ...), I > >> simple changed the cron line to read: > > >> 1 * * * * cd /path/to/script; /usr/bin/python update_feeds.py > > >> Why don't you try that and see if it helps... > > >> Jonas > > >> On 4 Mrz., 14:02, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > >> wrote: > > >>> Well part of the problem is that the script itself works fine. I can > >>> run from the command line without a hitch. But when I try to run it > >>> via the cron, I get the traceback about the feedparser module. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
On Tue, Mar 4, 2008 at 4:55 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I'm trying to use a cron job to run a python script that updates feeds > on an aggregator site I'm building. But I'm getting trackback errors > telling me it can't import the module feedparser. Here's the error: > > Traceback (most recent call last): > File "/path/to/script/update_feeds.py", line 10, in ? >import feedparser > ImportError: No module named feedparser You can try using django-cron, which is a django app that can run tasks on a specified schedule and since it runs from within the django web framework it does not have the environment and path issues that setting up an actual cron job does --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
> Unfortunately, I get the same traceback: > > Traceback (most recent call last): > File "update_feeds.py", line 10, in ? > import feedparser > ImportError: No module named feedparser Again: did you print the sys.path? The 'cd' is not going to work, unless your modules are relative to the /path/to/script/ I may have a solution, but I first want to know if it's a path problem. > Any idea how to import the module within the cron? > > > On Mar 4, 9:07 am, Jonas Christian <[EMAIL PROTECTED]> wrote: >> I ran into problems like that using cron and instead of trying to >> locate the real error in the paths (we were about to go live ...), I >> simple changed the cron line to read: >> >> 1 * * * * cd /path/to/script; /usr/bin/python update_feeds.py >> >> Why don't you try that and see if it helps... >> >> Jonas >> >> On 4 Mrz., 14:02, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> >> wrote: >> >>> Well part of the problem is that the script itself works fine. I can >>> run from the command line without a hitch. But when I try to run it >>> via the cron, I get the traceback about the feedparser module. > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
Unfortunately, I get the same traceback: Traceback (most recent call last): File "update_feeds.py", line 10, in ? import feedparser ImportError: No module named feedparser Any idea how to import the module within the cron? On Mar 4, 9:07 am, Jonas Christian <[EMAIL PROTECTED]> wrote: > I ran into problems like that using cron and instead of trying to > locate the real error in the paths (we were about to go live ...), I > simple changed the cron line to read: > > 1 * * * * cd /path/to/script; /usr/bin/python update_feeds.py > > Why don't you try that and see if it helps... > > Jonas > > On 4 Mrz., 14:02, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > Well part of the problem is that the script itself works fine. I can > > run from the command line without a hitch. But when I try to run it > > via the cron, I get the traceback about the feedparser module. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blocktrans getting erratic
On Tue, 2008-03-04 at 02:31 -0800, Jonas Christian wrote: > Hi everybody, > > I really enjoy writing applications in Django but I ran into something > very strange while doing my first internationalized app. I'm using the > newforms-admin branch, revision 7192. All translations work fine, > except in these cases: > > When I mark a string that spans multiple lines to be translated with > {% blocktrans %}, make-messages.py shows the string and compile- > messages.py works fine but the translation simply does not appear in > the output. This does not work: > > {% blocktrans %} > This is a test string > {% endblocktrans %} > > This, however, does: > > {% blocktrans %}This is a test string{% endblocktrans %} This one's just a silly restriction in blocktrans. We'll fix it one day. > > I found this - possibly related - bug, but it has been closed as > "worksforme": http://code.djangoproject.com/ticket/4535 > > This would be easy to work around, though. I'd just put everything in > one line. What's worse is the behaviour when using bound variables: > > {% blocktrans with item.count as xyz %}This is the count: {{ xyz }} > {% endblocktrans %} > > This works at first. When I add another variable, it stops working: > > {% blocktrans with item.count as xyz and item.name as abc %}This is > {{ abc }}'s count: {{ xyz }}{% endblocktrans %} > > It appars in the .po file just fine but again, the translated string > does not appear in the output. And the final straw: when I go back to > > {% blocktrans with item.count as xyz %}This is the count: {{ xyz }} > {% endblocktrans %} > > it doesn't work anymore! Does anyone have any idea what might cause > this behaviour? Are you sure you haven't inadvertently introduced newlines into the strings here? Can show us what the corresponding lines in the PO file look like (include the comments before the msgid bit as well). I'm assuming by "not working" you mean the string is being displayed in English rather than, say, German. You're not saying the string doesn't display at all, right? My bet is that the last problems are human error, but I'd like to understand them to see if we can bullet-proof this a bit more. Malcolm -- Depression is merely anger without enthusiasm. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Access cycle var in template - gentle hack
What I meant was that you could use the catch tag to avoid having to use html comments to hide it. (: It's still just as much of a hack, of course, but not quite as visible after rendering. On Feb 28, 3:51 am, itpaul <[EMAIL PROTECTED]> wrote: > ok. like this? > > {% for p in post_list %} > > blah... > > {% endfor %} > {{ caughtvar }} <-- contains nothing > > also tried like this: > > {% cycle 'red' 'blue' as bgcolor %}{% catch as caughtvar %}{% cycle > bgcolor %}{% endcatch %} > > and like this: > > {% catch as caughtvar %}{% cycle 'red' 'blue' as bgcolor %}{% endcatch > %} > > but alas nothing worked :( > > is this what you meant or I am i missing something? > > On Feb 27, 9:43 pm, JeremySandell<[EMAIL PROTECTED]> wrote: > > > Unless I've misunderstood what you're trying to do, this tag should do > > what you're needing: > > >http://code.djangoproject.com/wiki/CatchTag > > > Hope this helps! > > > On Feb 27, 2:01 pm, itpaul <[EMAIL PROTECTED]> wrote: > > > > Big headache. Cycles "context" var seems to be available only in the > > > loop its declared in. I need access to it in a template tag thats > > > outside the loop. (There's some waffle about being "nesting safe" > > > somewhere. Really...) > > > > Ive hacked about a bit and worked out that if I declare the > > > variable(s) to be used by cycle *before* the loop (you need a custom > > > tag to set context variables for this > > > -http://code.djangoproject.com/ticket/1322 > > > ), I can get at them inside and back out the other end... > > > > with one major caveat... > > > > I have to access it ( {% cycle bgcolor %} ) again before it will stick > > > the variable back in the context. Sadly, by doing this, you have to > > > print the value out. > > > > hack complete > > > > before i finished writing this post i realised i could just use html > > > comments to hide it: > > > > > > > > I'm posting anyway in case anybody finds it useful and in the hope > > > that someone knows how to avoid this ugliness. > > > > [mumble]...nesting safe...[/mumble] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Getting file selected for upload to survive validation.
I have file uploads working using newforms. However, if I run into validation errors on the form (say a mandatory field is not filled), then when the form re-displays for the user, the file they previously selected is no longer selected. I've been reading through a variety of file upload suggestions, but I've not found anything specifically targeting this problem. Any suggestions as to what I'm not doing is appreciated. Here's what my (simplified) model/view/template looks like: Model: class Note(models.Model): category = models.ForeignKey(Category) title = models.CharField(max_length=80, unique=False) article = models.FileField(upload_to='articles/%Y_%m/', null=True, blank=True) View: def add(request): NoteFormClass = forms.models.form_for_model(Note) if request.POST: form = NoteFormClass(request.POST, request.FILES) if form.is_valid(): form.save() return HttpResponseRedirect('/') else: form = NoteFormClass() response = render_to_response('notes/add.html', { 'form': form, }) return response Template: {{form.category.label}}*:{{form.category.errors}}{{cat_combo|safe}} {{form.title.label}}*:{{form.title.errors}}{{form.title}} Article File:{{form.article.errors}}{{form.article}}{{form.article_file}} -- Raymond Cote Appropriate Solutions, Inc. PO Box 458 ~ Peterborough, NH 03458-0458 Phone: 603.924.6079 ~ Fax: 603.924.8668 rgacote(at)AppropriateSolutions.com www.AppropriateSolutions.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
I ran into problems like that using cron and instead of trying to locate the real error in the paths (we were about to go live ...), I simple changed the cron line to read: 1 * * * * cd /path/to/script; /usr/bin/python update_feeds.py Why don't you try that and see if it helps... Jonas On 4 Mrz., 14:02, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Well part of the problem is that the script itself works fine. I can > run from the command line without a hitch. But when I try to run it > via the cron, I get the traceback about the feedparser module. > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: edit_inline in ModelForms
This question in various forms was asked 3 times in the last 24 hours. Check this out http://collingrady.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/ On Tue, Mar 4, 2008 at 4:11 AM, tom <[EMAIL PROTECTED]> wrote: > > Hi, > > I've been looking and searching for the last days to find out how i > could fix that, but I don't get around. I did read the newforms-admin > fieldset.py stuff, also the edit_inline_stacked.html template, but I > still don't figure it out. > > What i would like to do is, to have 2 Models within one form. > > The model is: > > # > class Album(models.Model): > artist = models.ForeignKey(PortalUser) > title = models.CharField(max_length=100) > slug = models.SlugField(prepopulate_from=("artist", "title")) > genre = models.ManyToManyField(Genre, > filter_interface=models.HORIZONTAL) > def __unicode__(self): > return self.title > > class Admin: > list_display = ('title', 'rating_stars', 'artist', > 'release_date') > list_filter= ('label', 'release_date') > ordering = ('-release_date',) > search_fields = ('title', 'label') > fields = ( > (None, {'fields':('title',)}), > ('Album informatin', {'fields':('cover', 'language', > 'release_date', 'genre')}), > ) > > class Track(models.Model): > artist = models.ForeignKey(PortalUser) > title = models.CharField(max_length=100, core=True) > file = models.FileField(upload_to="/", core=True) > album = models.ForeignKey(Album, edit_inline=models.TABULAR, > num_extra_on_change=1, num_in_admin=10) > > def __unicode__(self): > return self.title > > class Admin: > list_display = ('title', 'album', 'artist') > search_fields = ('title', 'genre', 'artist') > list_filter = ('language',) > > # > > and I use the following form: > class AlbumForm(forms.ModelForm): > > class Meta: > model = Album > > with this view: > login_required > def add_or_edit_album(request, success_url='', > form_class=AlbumForm, > template_name='music/album_form.html'): > > success_url = '/artist/%s' % (request.user.username) > > if request.method == 'POST': > > form = form_class(data=request.DATA, files=request.FILES) > if form.is_valid(): > album = form.save(commit=False) > album.artist = request.user > album.save() > form.save_m2m() > return HttpResponseRedirect(success_url) > else: > form = form_class() > return render_to_response(template_name, > { 'form': form }, > > context_instance=RequestContext(request)) > > what happens, when I call the template is, that only the album form > shows up, but it does not contain the track slots. When I try to call > the TrackForm (created the same way as the Album Form) I do get a drop- > down box for the albums. Does someone know a way how to solve this? > > I use the current svn version from django. > > Many thanks! > > Tom > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: data import
On 4 Бер, 13:33, "Ben Ford" <[EMAIL PROTECTED]> wrote: > How about setting a default value on all of the database tables the you are > specifying in the dict that you're doing the update with? Hi, Ben, those values can't be set as default value for the table column. Each model may have not only one import source, and values from my dict - are foreign key values, and may differ from one source to another. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
Well part of the problem is that the script itself works fine. I can run from the command line without a hitch. But when I try to run it via the cron, I get the traceback about the feedparser module. On Mar 4, 7:36 am, Evert Rol <[EMAIL PROTECTED]> wrote: > > No, I haven't tried that. How would I go about citing that? > > Top of script (possibly just below the she-bang): > > import sys > print sys.path > > >>> Traceback (most recent call last): > >>> File "/path/to/script/update_feeds.py", line 10, in ? > >>> import feedparser > >>> ImportError: No module named feedparser > > >>> And here is the cron: > > >>> export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/django/ > >>> app > >>> export DJANGO_SETTINGS_MODULE=myproject.settings > >>> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > > >>> I'm running the cron on my Dreamhost account BTW. > > >> Did you try printing out the sys.path at the top of your script, so > >> see if the PYTHONPATH is picked up correctly from the cron > >> environment > >> settings? I'd guess it should, but it may go wrong there (I'm no cron > >> expert). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
> No, I haven't tried that. How would I go about citing that? Top of script (possibly just below the she-bang): import sys print sys.path >>> Traceback (most recent call last): >>> File "/path/to/script/update_feeds.py", line 10, in ? >>> import feedparser >>> ImportError: No module named feedparser >> >>> And here is the cron: >> >>> export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/django/ >>> app >>> export DJANGO_SETTINGS_MODULE=myproject.settings >>> 1 * * * * /usr/bin/python /path/to/script/update_feeds.py >> >>> I'm running the cron on my Dreamhost account BTW. >> >> Did you try printing out the sys.path at the top of your script, so >> see if the PYTHONPATH is picked up correctly from the cron >> environment >> settings? I'd guess it should, but it may go wrong there (I'm no cron >> expert). > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
No, I haven't tried that. How would I go about citing that? On Mar 4, 7:22 am, Evert Rol <[EMAIL PROTECTED]> wrote: > > Traceback (most recent call last): > > File "/path/to/script/update_feeds.py", line 10, in ? > > import feedparser > > ImportError: No module named feedparser > > > And here is the cron: > > > export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/django/app > > export DJANGO_SETTINGS_MODULE=myproject.settings > > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > > > I'm running the cron on my Dreamhost account BTW. > > Did you try printing out the sys.path at the top of your script, so > see if the PYTHONPATH is picked up correctly from the cron environment > settings? I'd guess it should, but it may go wrong there (I'm no cron > expert). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Maximum number of objects in admin interface
Question for all: how change lists (in admin interface) behave when you have couple of thousands objects? What was the maximum number of object did you have in change lists? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems using cron to run a python script
> > Traceback (most recent call last): > File "/path/to/script/update_feeds.py", line 10, in ? > import feedparser > ImportError: No module named feedparser > > And here is the cron: > > export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/django/app > export DJANGO_SETTINGS_MODULE=myproject.settings > 1 * * * * /usr/bin/python /path/to/script/update_feeds.py > > I'm running the cron on my Dreamhost account BTW. Did you try printing out the sys.path at the top of your script, so see if the PYTHONPATH is picked up correctly from the cron environment settings? I'd guess it should, but it may go wrong there (I'm no cron expert). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problems using cron to run a python script
I'm trying to use a cron job to run a python script that updates feeds on an aggregator site I'm building. But I'm getting trackback errors telling me it can't import the module feedparser. Here's the error: Traceback (most recent call last): File "/path/to/script/update_feeds.py", line 10, in ? import feedparser ImportError: No module named feedparser And here is the cron: export PYTHONPATH=/path/to/python2.3/site-packages:/path/to/django/app export DJANGO_SETTINGS_MODULE=myproject.settings 1 * * * * /usr/bin/python /path/to/script/update_feeds.py I'm running the cron on my Dreamhost account BTW. Any suggestions on what I'm doing wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: data import
How about setting a default value on all of the database tables the you are specifying in the dict that you're doing the update with? On 04/03/2008, sector119 <[EMAIL PROTECTED]> wrote: > > > Hi ALL! > > I need to import data in CSV format into my models everyday ~ 500.000 > rows. But my CSV files are uncomplite, I have to append some data to > every row. > > I use something like this to import data into my model: > for d in csv.DictReader(...): > d.update(my_data) > MyModel.objects.create(**d) > > But I don't want to invent a bisycle and want to do this in django > way, may be it'll be better to create intermediate XML fixtures and > then load them using manage.py loaddata ? But if I do so, I do my work > twise. And it takes much more time... load data from XML is very slow, > it takes 14 minutes to import 85.000 rows. > > What you can recomend in my case? > > Thanks! > > > -- Regards, Ben Ford [EMAIL PROTECTED] +447792598685 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: revert database migration
On Tue, Mar 4, 2008 at 2:58 AM, stranger <[EMAIL PROTECTED]> wrote: > After searching this group archive i didnot find much regarding my question Really? http://groups.google.com/group/django-users/search?hl=en=migrations=0=d=en; There is a difference between searching the archives to find the answer and searching it trying to find the answer one expects :) On Tue, Mar 4, 2008 at 3:04 AM, stranger <[EMAIL PROTECTED]> wrote: > It is very sad that django donot track models. I migrated myself from > Rails. In rails there is migration where we can make changes to models > and sync with database. hope django will find a solution. > http://www.djangoproject.com/documentation/faq/#if-i-make-changes-to-a-model-how-do-i-update-the-database Take a loo to third party efforts in this regard: http://code.google.com/p/deseb/ http://code.google.com/p/django-evolution/ http://www.aswmc.com/dbmigration/ http://code.google.com/p/django-schemaevolution/ -- Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Subscribe
--~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
data import
Hi ALL! I need to import data in CSV format into my models everyday ~ 500.000 rows. But my CSV files are uncomplite, I have to append some data to every row. I use something like this to import data into my model: for d in csv.DictReader(...): d.update(my_data) MyModel.objects.create(**d) But I don't want to invent a bisycle and want to do this in django way, may be it'll be better to create intermediate XML fixtures and then load them using manage.py loaddata ? But if I do so, I do my work twise. And it takes much more time... load data from XML is very slow, it takes 14 minutes to import 85.000 rows. What you can recomend in my case? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Earn money from Google.com
Google.com is not only a search engine but also does webadvertising through websites and blogs.Lakhs of common people are earnings hundreds of dollars through online advertising. For more details visit http://www.googlepromisesyou.blogspot.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Optimizing code for a query
> I need to optimize some code related to django db api. > Imagine a model like this: > > class Languages( models.Model ): >name = models.CharField( max_length=255 ) >... > > class Object ( models.Model ): >name = models.CharField( max_length=255 ) >languages = models.ManyToManyField( Languages, radio_admin=True ) > > I need to create a form to search Objects: > def my_view(request): >... >if request.POST: >form = MyForm( request.POST ) >if form.is_valid(): >data = form.cleaned_data >objects = Object.objects.all() >if data['name']: >objects = objects.filter( name__icontains = > data['name'] ) >if data['languages']: >(1) >... > > I need to search an Object with name ILIKE %name% and with the > languages specified in the form. data['languages'] looks like: > [ u'1',u'2' ] the IDs of each language. > > I needs some help with the code that should be placed in (1). > I thought: > > for language in languages: >objects = Object.filter( languages__id = language) Have a look at 'in' filtering: http://www.djangoproject.com/documentation/db-api/#in Maybe that can help you out. The code above is certainly not going to work, because you try on the model, not the results returned from the managaer. Besides, you'd be filtering in an 'AND' combination, not 'OR' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin Site Searching
On Mar 3, 1:41 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2008-03-02 at 10:03 -0800, Lee Connell wrote: > > I have configured my django admin site to allow searching. My > > question is when a user logs in and chooses the table they wish to > > make changes to, it automatically queries ALL data and then gives the > > ability to search. Is there an option to default to NOT grabbing ALL > > data and allowing the user to enter search criteria? This would save > > load time on larger databases. > > No, there is not. If you took the plunge and switched to newforms-admin then you can override the changelist_view method in your ModelAdmin class. You'll need to replicate some of the behaviour of ChangeList from django.contrib.admin.main. Basically you'll want to check for search terms and hand off to the super method if any exist. If not then create a blank ChangeList and render as usual. Regards, Felix --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Blocktrans getting erratic
Hi everybody, I really enjoy writing applications in Django but I ran into something very strange while doing my first internationalized app. I'm using the newforms-admin branch, revision 7192. All translations work fine, except in these cases: When I mark a string that spans multiple lines to be translated with {% blocktrans %}, make-messages.py shows the string and compile- messages.py works fine but the translation simply does not appear in the output. This does not work: {% blocktrans %} This is a test string {% endblocktrans %} This, however, does: {% blocktrans %}This is a test string{% endblocktrans %} I found this - possibly related - bug, but it has been closed as "worksforme": http://code.djangoproject.com/ticket/4535 This would be easy to work around, though. I'd just put everything in one line. What's worse is the behaviour when using bound variables: {% blocktrans with item.count as xyz %}This is the count: {{ xyz }} {% endblocktrans %} This works at first. When I add another variable, it stops working: {% blocktrans with item.count as xyz and item.name as abc %}This is {{ abc }}'s count: {{ xyz }}{% endblocktrans %} It appars in the .po file just fine but again, the translated string does not appear in the output. And the final straw: when I go back to {% blocktrans with item.count as xyz %}This is the count: {{ xyz }} {% endblocktrans %} it doesn't work anymore! Does anyone have any idea what might cause this behaviour? After every change to the template I run make-messages.py -a then after redoing the .po file I do compile-messages.py and then restart the test server. I'd be very grateful for any pointers, I'm running my head against the wall here. It's probably something simple that I overlooked... but I tried it about a million times. Cheers, Jonas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Optimizing code for a query
This code: for language in languages: objects = Object.filter( languages__id = language) doesn't work, so I'd be happy to receive some suggestions. Thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
new generation of LG LCD
Play wide Play LG! http://www.golyofogo.extra.hu/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Optimizing code for a query
Hi, I need to optimize some code related to django db api. Imagine a model like this: class Languages( models.Model ): name = models.CharField( max_length=255 ) ... class Object ( models.Model ): name = models.CharField( max_length=255 ) languages = models.ManyToManyField( Languages, radio_admin=True ) I need to create a form to search Objects: def my_view(request): ... if request.POST: form = MyForm( request.POST ) if form.is_valid(): data = form.cleaned_data objects = Object.objects.all() if data['name']: objects = objects.filter( name__icontains = data['name'] ) if data['languages']: (1) ... I need to search an Object with name ILIKE %name% and with the languages specified in the form. data['languages'] looks like: [ u'1',u'2' ] the IDs of each language. I needs some help with the code that should be placed in (1). I thought: for language in languages: objects = Object.filter( languages__id = language) Is this code good or there is a better solution? Thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: solving fixture data conflicts
On Tue, Mar 4, 2008 at 3:59 PM, Evan H. Carmi <[EMAIL PROTECTED]> wrote: > > Hi, > > I am trying to loaddata from a file, bmdata.xml and getting an error: > Problem installing fixture 'bmdata.xml': duplicate key violates unique > constraint "django_content_type_app_label_key" > > I understand that there is a conflict in the fixture data. However, I > don't know how to solve it. I only ran syncdb before loaddata, and did > not create any content. Hi Evan, The catch is that you _did_ create content - you just don't know that you did because it happens in the background. When you run syncdb, various triggers are fired that stimulate the creation of certain initial data. Of particular interest in this case are the content types. Each model you have in your project generates a content type so that the models can be referred to in a generic manner by other parts of Django. There isn't really any way to control the content types that are allocated. As a result, if you change the applications that are installed, or the order in which they are installed, the content types can change. If you generate a fixture on an old database, modify the installed apps, re-synchronize your database, then load your fixture, the old content types can potentially cause a conflict - the error you are seeing is one such potential problem. The only real solution at present is to avoid serializing content types whenever possible (i.e., by not dumping the contenttypes application). If your fixture already has content types, manually delete them from the fixture before loading. This is a known crusty area associated with fixtures. Unfortunately, it isn't a trivial problem to fix. Suggestions on how to improve this aspect of Django are most welcome. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
18+
ONLY FOR ADULTS: http://href.hu/x/4vm4 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
edit_inline in ModelForms
Hi, I've been looking and searching for the last days to find out how i could fix that, but I don't get around. I did read the newforms-admin fieldset.py stuff, also the edit_inline_stacked.html template, but I still don't figure it out. What i would like to do is, to have 2 Models within one form. The model is: # class Album(models.Model): artist = models.ForeignKey(PortalUser) title = models.CharField(max_length=100) slug = models.SlugField(prepopulate_from=("artist", "title")) genre = models.ManyToManyField(Genre, filter_interface=models.HORIZONTAL) def __unicode__(self): return self.title class Admin: list_display = ('title', 'rating_stars', 'artist', 'release_date') list_filter= ('label', 'release_date') ordering = ('-release_date',) search_fields = ('title', 'label') fields = ( (None, {'fields':('title',)}), ('Album informatin', {'fields':('cover', 'language', 'release_date', 'genre')}), ) class Track(models.Model): artist = models.ForeignKey(PortalUser) title = models.CharField(max_length=100, core=True) file = models.FileField(upload_to="/", core=True) album = models.ForeignKey(Album, edit_inline=models.TABULAR, num_extra_on_change=1, num_in_admin=10) def __unicode__(self): return self.title class Admin: list_display = ('title', 'album', 'artist') search_fields = ('title', 'genre', 'artist') list_filter = ('language',) # and I use the following form: class AlbumForm(forms.ModelForm): class Meta: model = Album with this view: login_required def add_or_edit_album(request, success_url='', form_class=AlbumForm, template_name='music/album_form.html'): success_url = '/artist/%s' % (request.user.username) if request.method == 'POST': form = form_class(data=request.DATA, files=request.FILES) if form.is_valid(): album = form.save(commit=False) album.artist = request.user album.save() form.save_m2m() return HttpResponseRedirect(success_url) else: form = form_class() return render_to_response(template_name, { 'form': form }, context_instance=RequestContext(request)) what happens, when I call the template is, that only the album form shows up, but it does not contain the track slots. When I try to call the TrackForm (created the same way as the Album Form) I do get a drop- down box for the albums. Does someone know a way how to solve this? I use the current svn version from django. Many thanks! Tom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django-dataplot 0.5
I just released a new version of my django-based plotting framework to http://sf.net/projects/django-dataplot. Here's one example of making a plot in an app that tracks goals in a series of soccer games: from dataplot import plotmodels as models class Player(models.Model): name=models.CharField(max_length=100) goals_per_game=models.FloatField() win_percent=models.FloatField() MANAGER_DATAPLOTS=[ (R.SquareScatter,{'get_plot_args':{ 'x':'goals_per_game', 'y':'win_percent', 'ann':'name', 'main':"Does scoring a lot of goals make you win?" }})] Django-dataplot takes care of the rest so you can just put this in your template: {{player.objects.SquareScatter.to_html}} and a scatterplot image will show up on the web page, representing each player as a point labeled by name, with average goals_per_game on the x axis and win_percent on the y axis. So you can use the plot to easily tell if high scoring means high likelihood of winning. There are many other examples, and the system is quite extensible, so I hope it will be able to help out some people in the community. I would appreciate anyone who is interested in making plots/graphs on Django-backed websites to download django-dataplot from sourceforge and email me back with feedback and suggestions. Thanks for your time! Sincerely, Toby Dylan Hocking http://www.ocf.berkeley.edu/~tdhock --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Oracle invalid environment variables
Hello Django Users, Althought this is probably not a specific django error, i hope someone can point me in the right direction. I developed a application on a development server where everything works just fine. server specs ( development server ): - Linux version 2.6.9-22.0.2.ELsmp ([EMAIL PROTECTED] bc1-6.build.redhat.com) - Intel Xeon 3 ghz When we migrated the application to the production server server specs: - Linux version 2.6.9-55.ELsmp ([EMAIL PROTECTED] bc2-14.build.redhat.com) - Intel Xeon 2.7 ghz We got the following Oracle error: ORA-12705: Cannot access NLS data files or invalid environment specified I googled on this error and it says there might be a issue with deleting sessions. This error occurs random so i really don't know where to look. any help would be appreciated. regards, Richard Mendes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to give a style for "CHOICE FILED" in py file
class cust_search(forms.Form): customer_name= forms.CharField(max_length = 255, required = False) product_id= forms.CharField(max_length = 1, required = False) date1=forms.DateField(widget=forms.TextInput(attrs={'class':"vDateField"}),required = False) date2=forms.DateField(widget=forms.TextInput(attrs={'class':"vDateField"}),required = False) group_name=forms.ChoiceField(choices=[("itp","ITP"),("csg", "CSG"), ("nwg","NWG"),("pcis","PCIS"),("serv","SERV"),("swg","SWG"), ("wsg","WSG")],required = False) I WANT TO GIVE A STYLE FOR CHOICE FILED DATA(swg,wsg)... HW CAN I? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Movies
Best movies you ever wanted to see. http://playwide.extra.hu/ Download free --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---