Re: manage.py startapp suggestions
On Wed, 2007-03-21 at 23:36 -0700, [EMAIL PROTECTED] wrote: > > Hmm... if we do it, this feels like something that should be kept > > separate from the standard manage.py; I can certainly see it being an > > immense help to developers who are just starting to work with Django, > > but I can also see more experienced users saying "I just want a blank > > app, without having to answer all these questions at the prompt". > > > > So maybe this could work more as an introductory tool, so that once a > > developers are familiar enough with Django to make the choice, they > > can decide to keep using it or switch to the standard manage.py app > > skeleton. > > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > > correct." > > Why not something like a "python manage.py startapp verbose"? I'm with James on this one: I think it's probably a fairly useful tool to have, but it's not something that's necessarily appropriate for the core manage.py program. The debate isn't about what words to use to invoke it -- it's about whether having that functionality in the code is a good idea. The reasoning is that whilst it's not impossible to add this type of functionality, now we suddenly have a few dozen or a hundred more lines of code that need to be maintained for something that isn't really core functionality. It would be very easy to write a "getting started wizard" that leverages a lot of the stuff already inside manage.py. Have a look at the code there. You can see it splits up most of the functionality into separate functions (there's a command line arg to function mapping towards the bottom of the file that does just that). So a third-party application that wants to create some directories, fill in a bunch of stuff and provide the whole "getting started" framework skeleton doesn't have to replicate any of the existing work. Import django.core.management and call out to that. The extra stuff can then be kept separate and both sides remain maintainable. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Mod_python + MySQLdb won't install ...
I've been having problems on CentOS as well. Then again I tried to upgrade to python 2.4, and the server is 64-bit. I was able to find some RPMs (check http://rpm.pbone.net/index.php3/stat/3/srodzaj/1/search/MySQL-python) -- although with that I had to install some dependencies manually. Anyhow, turns out there's no RPM for 64 bit CentOS with python-2.4 (only 2.3). Also I wasn't able to compile from source, but that may have had more to do with 64-bit than CentOS. Well... good luck :) On Mar 21, 7:58 pm, "Andy Dustman" <[EMAIL PROTECTED]> wrote: > On 3/20/07, dbee <[EMAIL PROTECTED]> wrote: > > > > > > > System: Linux 2.6.9-34.0.1.EL #1 Wed May 24 07:40:56 CDT 2006 i686 > > athlon i386 GNU/Linux > > OS: CentOS > > Python: 2.3.4 > > Mysql: 5.0 > > > I'm having lots of issues trying to get my django server up. It seems > > that mod_python won't work on my system. > > > When I yum install mysql-python, the package installs fine, but I get > > this error whenever I need to import it into my python scope. > > > >>> import MySQLdb > > ImportError: this is MySQLdb version (1, 2, 2, 'final', 0), but _mysql > > is version (1, 0, 0, 'final', 1) > > You have conflicting pieces from different versions, or else this is > due in part to your build failure, when upgrading. > > > When I try to build the source version of MySQLdb from sourceforge, it > > just errors with this non-descript error... > > > error: command 'gcc' failed with exit status 1 > > > I really wasn't expecting it to take so long to get mod_python + > > MySQLdb working. > > > Help > > There is no way MySQLdb-1.0.0 is going to work with MySQL-5.0. The > oldest version that would possibly work is 1.2.0. > > The gcc error you are getting indiciates... well not much, but my > guess is you are missing essential development files. Check the README > and make sure you have everything it says you need to have. You can > also build an RPM package. > -- > Patriotism means to stand by the country. It does > not mean to stand by the president. -- T. Roosevelt > > This message has been scanned for memes and > dangerous content by MindScanner, and is > believed to be unclean. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: manage.py startapp suggestions
> Hmm... if we do it, this feels like something that should be kept > separate from the standard manage.py; I can certainly see it being an > immense help to developers who are just starting to work with Django, > but I can also see more experienced users saying "I just want a blank > app, without having to answer all these questions at the prompt". > > So maybe this could work more as an introductory tool, so that once a > developers are familiar enough with Django to make the choice, they > can decide to keep using it or switch to the standard manage.py app > skeleton. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." Why not something like a "python manage.py startapp verbose"? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: I wish for a "less than" and "greater than" in templates
limodou wrote: > You can also use PyIf tag(written by me) to do that. > http://www.djangosnippets.org/snippets/12/ > And it can support any python expression. So it's more general I think. And it's short and understandable. I like it too. Thanks Mike -- Michael Lake --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: I wish for a "less than" and "greater than" in templates
On 3/22/07, Michael Lake <[EMAIL PROTECTED]> wrote: > > Kenneth Gonsalves wrote: > > > On 22-Mar-07, at 9:25 AM, Michael Lake wrote: > >>>write your own tag - someone has done it, you can see it in this > >>>file: > >>> > >>>http://nrcfosshelpline.in/code/browser/trunk/web/templatetags/ > >>>base_utils.py > >>> > >>>class CompareNode near the end > >> > >>But that link above no longer works. > > > works now - thanks for the heads up on this > Thanks for that Kenneth. > The code there looks like just what I need. > You can also use PyIf tag(written by me) to do that. http://www.djangosnippets.org/snippets/12/ And it can support any python expression. So it's more general I think. -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: I wish for a "less than" and "greater than" in templates
Kenneth Gonsalves wrote: > On 22-Mar-07, at 9:25 AM, Michael Lake wrote: >>>write your own tag - someone has done it, you can see it in this >>>file: >>> >>>http://nrcfosshelpline.in/code/browser/trunk/web/templatetags/ >>>base_utils.py >>> >>>class CompareNode near the end >> >>But that link above no longer works. > works now - thanks for the heads up on this Thanks for that Kenneth. The code there looks like just what I need. Mike -- Michael Lake --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: I wish for a "less than" and "greater than" in templates
On 22-Mar-07, at 9:25 AM, Michael Lake wrote: >> write your own tag - someone has done it, you can see it in this >> file: >> >> http://nrcfosshelpline.in/code/browser/trunk/web/templatetags/ >> base_utils.py >> >> class CompareNode near the end > > But that link above no longer works. works now - thanks for the heads up on this -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Having problems getting contrib.markup to load
[EMAIL PROTECTED] wrote: > Hi Michael, > Have you added "django.contrib.markup" to your INSTALLED_APPS setting? Ah :-) I had placed django.contrib.markup into the MIDDLEWARE_CLASSES instead of the INSTALLED_APPS section in settings.py. I have fixed that and it's now saying the markdown library is not installed which is much much better. I have to get and install that and then I think I should be running fine. Thanks -- Michael Lake --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Having problems getting contrib.markup to load
Hi Michael, Have you added "django.contrib.markup" to your INSTALLED_APPS setting? --Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
I wish for a "less than" and "greater than" in templates
Hi all I'm wishing for a "less than" and "greater than" in templates. The mailing list has this on the matter: On 31-Aug-06 >> Is it possible to make "less than" and "greater than" comparisons in >> templates? >> I was trying to do something similar to this, but without success: >> {% if list|length > max_list_length %} >> Exceeded by {{ list|length - max_list_length }} items >> {% endif %} > > write your own tag - someone has done it, you can see it in this file: > > http://nrcfosshelpline.in/code/browser/trunk/web/templatetags/ > base_utils.py > > class CompareNode near the end But that link above no longer works. Does anyone have some code for this? I looked in Django Snippets and didn't find such a snippet. Mike -- Michael Lake --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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_python + MySQLdb won't install ...
On 3/20/07, dbee <[EMAIL PROTECTED]> wrote: > > System: Linux 2.6.9-34.0.1.EL #1 Wed May 24 07:40:56 CDT 2006 i686 > athlon i386 GNU/Linux > OS: CentOS > Python: 2.3.4 > Mysql: 5.0 > > I'm having lots of issues trying to get my django server up. It seems > that mod_python won't work on my system. > > When I yum install mysql-python, the package installs fine, but I get > this error whenever I need to import it into my python scope. > > >>> import MySQLdb > ImportError: this is MySQLdb version (1, 2, 2, 'final', 0), but _mysql > is version (1, 0, 0, 'final', 1) You have conflicting pieces from different versions, or else this is due in part to your build failure, when upgrading. > When I try to build the source version of MySQLdb from sourceforge, it > just errors with this non-descript error... > > error: command 'gcc' failed with exit status 1 > > I really wasn't expecting it to take so long to get mod_python + > MySQLdb working. > > Help There is no way MySQLdb-1.0.0 is going to work with MySQL-5.0. The oldest version that would possibly work is 1.2.0. The gcc error you are getting indiciates... well not much, but my guess is you are missing essential development files. Check the README and make sure you have everything it says you need to have. You can also build an RPM package. -- Patriotism means to stand by the country. It does not mean to stand by the president. -- T. Roosevelt This message has been scanned for memes and dangerous content by MindScanner, and is believed to be unclean. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Database exception handling please
On 3/21/07, ZebZiggle <[EMAIL PROTECTED]> wrote: > I'm going to have to deal with this, so here's what I'm thinking: some > sort of helper function that will do a filter() but act as a .get() in > that it only returns 1, but in the event more than 1 comes back notify > the admin that the integrity of the database has been compromised. > Alternatively, I may need to research if there is a way to put a > constraint on the database that prevents duplication in the tables and > raises an exception at "insert" time. You could try doing "get_or_create", which looks to see if there's already an object matching the criteria you've handed it, and will not create a new object if one already exists. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: manage.py startapp suggestions
On 3/21/07, Tom Smith <[EMAIL PROTECTED]> wrote: > This is my very crude attempt, which first calls startapp, then does > standard stuff that ALWAYS seem to have to do and ALWAYS forget like: > Add a urls.py for my app... > Add a URL pattern to load static images > Create the folder to host the static images > Put some examples in the views calls and add standard imports > Create all the classes in models.py that I think I'm gonna need (but not > call syncdb yet) > Add __str__ calls to all classes, and Admin classes (it's easier to delete > them than to add them by hand later) > Docstrings, one day I may comment my code. Hmm... if we do it, this feels like something that should be kept separate from the standard manage.py; I can certainly see it being an immense help to developers who are just starting to work with Django, but I can also see more experienced users saying "I just want a blank app, without having to answer all these questions at the prompt". So maybe this could work more as an introductory tool, so that once a developers are familiar enough with Django to make the choice, they can decide to keep using it or switch to the standard manage.py app skeleton. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Database exception handling please
Hey all! I run into a problem related to this discussion. Somehow, someway, I'm getting multiple entries in my data model where I should only ever have one. I suspect it's related to the users hitting the back button or double- clicking a submit button (or something). But it baffles me how it's happening. I even have special code in there to catch duplicate attempts, but they are still getting through. If anyone has any ideas, I'm all ears. The result, however, is everywhere I have Foo.objects.get(field = x), I have to be a paranoid programmer and change them all to Foo.objects.filter(field = x) ... otherwise I get 500 errors in places where it should never happen. I'm going to have to deal with this, so here's what I'm thinking: some sort of helper function that will do a filter() but act as a .get() in that it only returns 1, but in the event more than 1 comes back notify the admin that the integrity of the database has been compromised. Alternatively, I may need to research if there is a way to put a constraint on the database that prevents duplication in the tables and raises an exception at "insert" time. Has anyone else run into this problem? If so, how are you dealing with it? Thx in advance, Sandy --- Play a murder mystery at http://www.MyDarkSecret.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: Development in LAN. URLs of FlatPages. Best Practices?
Ashwoods, I did also some other business-related modifications so it would take me some time to prepare that just for a snippet. That middleware is not worth making it a snippet. I would better suggest you to use the solution by Derek. Regards, Aidas Bendoraitis [aka Archatas] On 3/21/07, ashwoods <[EMAIL PROTECTED]> wrote: > > could you post the code on django snippets? :) > > On Mar 20, 11:35 pm, "Aidas Bendoraitis" <[EMAIL PROTECTED]> > wrote: > > > have you found any solution? > > > > Yes. I wrote my own FlatPage model with it's own middleware. Now the > > URL can be empty and it represents the relative path counting from the > > website root directory. The root directory is "/" on the public site > > and "/someproject/" on the development site. The root directory is set > > in the settings. > > > > > would it be correct to say that the problem would > > > be solved if there was a way to access project settings from inside > > > flatpages? > > > > Not really. You don't define what you mean, saying "from inside > > faltpages" - whether you're talking about models, views, middleware, > > or something else from the flatpages. Anyway, it's enough to write > > your own middleware to override the default control of the flatpages > > (And fortunately it is not hard to do that). > > > > Regards, > > Aidas Bendoraitis [aka Archatas] > > > > > > > > > On Mar 5, 12:44 pm, "Aidas Bendoraitis" <[EMAIL PROTECTED]> > > > wrote: > > > > We are developing a few Django projects. The development versions are > > > > accessible in the local network under some directories of the local > > > > server's IP (i.e.http://1.2.3.4/example/) and the published versions > > > > are accessible under some domains directly (i.e.http://example.com/). > > > > > > If you have a similar situation, how are you dealing with the URLs > > > > ofFlatPages? The problem is that in the development version the URLs are > > > > like /example/about/ and in the published version they are like > > > > /about/. So we need to modify all theflatpageswhen transfer the data > > > > from the development version to the public one. > > > > > > The ideas that came to my mind: > > > > 1. creating my own FlatPage model based on the contributed one which > > > > corresponds to the directory setting in the project settings. > > > > 2. installing a BIND (DNS) server locally so that we didn't have to > > > > put projects under specific directories, but rather under local domain > > > > names (i.e.http://example.local/). > > > > 3. creating some middleware that removes directory name from the > > > > requested URL before URL parsing. > > > > > > What are the best practices for doing that? What do you do in similar > > > > situations? > > > > > > Regards, > > > > Aidas Bendoraitis [aka Archatas] > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Database exception handling please
On Wed, 2007-03-21 at 16:47 -0700, Gerard M wrote: > Hello django community, I have a HUGE problem, and I would like to > know if some of you guys can help me, the problem is: Im accesing a > database and there is a big chance of not finding the item im looking > for, this is the snipplet of code im using and the "solution" that > I've implemented but it doesn't work as it should: Maybe a better way to think about this is to look at the exception as meaning "I can't do what you asked for" -- that's what exceptions in programming are for ;) And look carefully at the difference between "get" and "filter" -- "get" is meant to return one, and exactly one, object, while "filter" is meant to return a sequence representing all the objects which match the conditions. Looking at it this way, we can consider the two cases: > z=Dic.objects.filter(DB_Word=worfromtext).distinct() This means, roughly, "give me a sequence representing all the distinct things which match these criteria". And Django can do that -- it returns an empty sequence, because there are no distinct things which match the criteria. In effect it says in response, "you asked for a sequence containing all these objects, and there aren't any, so here's a sequence containing nothing". > e = Entry.objects.get(id=3) Here you're saying to Django, "I promise you that there is one, exactly one, and *only* one object which matches these criteria. Go and get it for me." And when it raises the exception, Django is saying "I couldn't do what you asked -- there wasn't an object matching that" (or, sometimes, it will tell you there were multiple objects). If you need to use "filter" and check whether it found anything, this is a better method: >>> z=Dic.objects.filter(DB_Word=worfromtext).distinct() >>> if not z.count(): print 'ERROR!' The "count" method will tell you how many objects match the QuerySet, and testing it as a boolean like this will let you easily distinguish between cases where there are some objects and cases where there are none. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Date field wiget for generic views...
I am writing an app that makes heavy use of generic views. I have several forms which include date fields and I want to know how to attach a widget to the field for entering the date (like the one used in the admin site). Am I making sense? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Database exception handling please
On Wed, Mar 21, 2007 at 04:47:35PM -0700, Gerard M wrote: > > Hello django community, I have a HUGE problem, and I would like to > know if some of you guys can help me, the problem is: Im accesing a > database and there is a big chance of not finding the item im looking > for, this is the snipplet of code im using and the "solution" that > I've implemented but it doesn't work as it should: > > from django.core.exceptions import ObjectDoesNotExist > > try: > z=Dic.objects.filter(DB_Word=worfromtext).distinct() > print z > except ObjectDoesNotExist: > print 'ERROR!' Try using Dic.objects.get( ... ) instead of filter( ... ). filter gives you a subset of the table. get gives you a single result. filter doesn't mind giving you an empty result. get assumes you wanted exactly one result, and raises an exception (Dic.DoesNotExist) if the object doesn't exist. Hope this helps. -Forest signature.asc Description: Digital signature
Re: Database exception handling please
On Wed, 2007-03-21 at 16:47 -0700, Gerard M wrote: > Hello django community, I have a HUGE problem, and I would like to > know if some of you guys can help me, the problem is: Im accesing a > database and there is a big chance of not finding the item im looking > for, this is the snipplet of code im using and the "solution" that > I've implemented but it doesn't work as it should: > > from django.core.exceptions import ObjectDoesNotExist > > try: > z=Dic.objects.filter(DB_Word=worfromtext).distinct() > print z > except ObjectDoesNotExist: > print 'ERROR!' > > so the first part works well, if the object (in this case a word) is > in the database I can do something like printing the word in this > case, but if the object is not in the database and the exception is > raised, I cant do anything, for example the 'ERROR!' message wont > show, do you guys have any ideas of what could be wrong? > > I got this piece of code from the Django Database API: > > from django.core.exceptions import ObjectDoesNotExist > try: > e = Entry.objects.get(id=3) > b = Blog.objects.get(id=1) > except ObjectDoesNotExist: > print "Either the entry or blog doesn't exist." The difference between the two examples is that the get() method on a QuerySet return precisely one result. It raises an error if there are zero or multiple results that meet the given restrictions. The filter() method, on the other hand, returns all results matching the filter conditions -- this could be zero or more results. It returns an iterator over these results. So, if you are expecting there to be exactly one result and want an error to be raised in all other cases, use get(). Otherwise use filter() and either convert the results to a list (QuerySets support the iterator protocol, so they aren't lists automatically) or call len() on the result or use count() to determine the number of results. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Database exception handling please
Hello django community, I have a HUGE problem, and I would like to know if some of you guys can help me, the problem is: Im accesing a database and there is a big chance of not finding the item im looking for, this is the snipplet of code im using and the "solution" that I've implemented but it doesn't work as it should: from django.core.exceptions import ObjectDoesNotExist try: z=Dic.objects.filter(DB_Word=worfromtext).distinct() print z except ObjectDoesNotExist: print 'ERROR!' so the first part works well, if the object (in this case a word) is in the database I can do something like printing the word in this case, but if the object is not in the database and the exception is raised, I cant do anything, for example the 'ERROR!' message wont show, do you guys have any ideas of what could be wrong? I got this piece of code from the Django Database API: from django.core.exceptions import ObjectDoesNotExist try: e = Entry.objects.get(id=3) b = Blog.objects.get(id=1) except ObjectDoesNotExist: print "Either the entry or blog doesn't exist." I suppose this example works but I havent tried it, even tho im doing the same, I dont know what am I doing wrong, thanks for your time and help Gerard. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Deploying multiple sites on one computer using SSL
On Wed, 21 Mar 2007 18:19:21 -0400, Dan Goldner <[EMAIL PROTECTED]> wrote: [snip] > > httpd.conf: > > > ServerName projects.mycompany.com > SetHandler python-program > PythonInterpPerDirective On > > # Turn Off for production, On for dev: > PythonAutoReload On > PythonDebug On > > > PythonHandler django.core.handlers.modpython > PythonPath "['/usr/local/projects', '/usr/local/projects/ > project1']+sys.path" > SetEnv DJANGO_SETTINGS_MODULE project1.settings_prod > > > PythonHandler django.core.handlers.modpython > PythonPath "['/usr/local/projects', '/usr/local/projects/ > project2']+sys.path" > SetEnv DJANGO_SETTINGS_MODULE project2.settings_prod > > > SetHandler None > > > [... SSL stuff ...] > > > > Any ideas or pointers to help? > Many Thanks! > I may be off track, but I'd try adding a directive for each static dir: SetHandler None SetHandler None http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Best way to implement user-specific content?
Anyone know of the recommended way to set up user-specific content, where each user (except the admin) would see only his content, regardless of the view being used to access it? Assume that content is associated with users via the threadlocals method (http:// code.djangoproject.com/wiki/CookBookThreadlocalsAndUser). I'm hoping there's a preferred/standard way to set this up, but haven't been able to find it here or in the django docs/code. Thanks, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Suggestions for Django Presentation
On Tue, Mar 20, 2007 at 10:18:19PM -0500, Jeremy Dunck wrote: > How long's the pres? You might just pick some high points and make a > slide at the end with small font and loads of links to all the other > stuff you didn't have time form. ;-) > I've got an hour and a half. I was planning to only hit the high points, then leave references to other things, and maybe mention briefly why they should care. Thanks for the suggestions (this goes to everyone) -- Scott Paul Robertson http://spr.mahonri5.net GnuPG FingerPrint: 09ab 64b5 edc0 903e 93ce edb9 3bcc f8fb dc5d 7601 pgpc2uvIHYpp9.pgp Description: PGP signature
Re: Deploying multiple sites on one computer using SSL
Hello, As noted previously I'm serving two independent, low-traffic django projects off a single virtual host in order to use SSL without a single certificate. Since I want static files to be SSL'd as well, these are served from the same virtual host. This seems to be working, with one mysterious glitch. All the dynamic stuff works fine for both sites. The problem I'm having is that static files from project1 work fine, while static files from project2 return a 404. For example, browsing to https://projects.mycompany.com/project1/static/img/logo.jpg returns the logo, while browsing to https://projects.mycompany.com/project2/static/img/logo.jpg returns a 404. All static files are like this, e.g. the project1 css works but the project2 css has no effect (b/c it's not found). I've checked for asymmetries in the settings, urls, and views between the two projects; they are basically identical except for "project1" vs "project2" in urls etc. I've spent a lot of time with Django and modpython and apache docs and still don't really understand what's going on. directory structure: /usr/local/projects/ /project1 settings.py urls.py views.py /static /css /img /project2 settings.py urls.py views.py /static /css /img httpd.conf: ServerName projects.mycompany.com SetHandler python-program PythonInterpPerDirective On # Turn Off for production, On for dev: PythonAutoReload On PythonDebug On PythonHandler django.core.handlers.modpython PythonPath "['/usr/local/projects', '/usr/local/projects/ project1']+sys.path" SetEnv DJANGO_SETTINGS_MODULE project1.settings_prod PythonHandler django.core.handlers.modpython PythonPath "['/usr/local/projects', '/usr/local/projects/ project2']+sys.path" SetEnv DJANGO_SETTINGS_MODULE project2.settings_prod SetHandler None [... SSL stuff ...] Any ideas or pointers to help? Many 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: Search feature
Another option for search is to use the google co-op thing- look in your google services. If your site is public, then it could be all you need. I've used it on 2 sites and they're non-commercial so I can switch off the ads. It took some time for google's indexing to settle down, but it seems to work fine now. Derek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Deploying multiple sites on one computer using SSL
On Wed, 2007-03-21 at 15:19 -0700, Dan Goldner wrote: > Hello, > > As noted previously I'm serving two independent, low-traffic django > projects off a single virtual host in order to use SSL without a > single certificate. Since I want static files to be SSL'd as well, > these are served from the same virtual host. This seems to be working, > with one mysterious glitch. > All the dynamic stuff works fine for both sites. The problem I'm > having is that static files from project1 work fine, while static > files from project2 return a 404. For example, browsing to > https://projects.mycompany.com/project1/static/img/logo.jpg >returns the logo, while browsing to >https://projects.mycompany.com/project2/static/img/logo.jpg >returns a 404. All static files are like this, e.g. the project1 > css works but the project2 css has no effect (b/c it's not found). > I've checked for asymmetries in the settings, urls, and views between > the two projects; they are basically identical except for "project1" > vs "project2" in urls etc. I've spent a lot of time with Django and > modpython and apache docs and still don't really understand what's > going on. Since you're talking about static files, this shouldn't involve Django at all, because those files will just be being retrieved directly. See if there are any clues in the Apache error logs (what file is it *really* trying to retrieve, for example). Check that permissions are the same on both sets of files. Check to see what happens if you temporarily copy the project1 static files into the project2 location and try to retrieve them: if it works, there is a problem with accessing the project2 files specifically, if it doesn't work, there is a problem with the access path (because the same files behave differently in two different locations). Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
Mary, On 3/21/07, Mary <[EMAIL PROTECTED]> wrote: > > I am using 0.95.1 the latest stable version for Django > --MA You have to be using the development version of django and not the 0.95.1 release as the fix in changeset [3490] wasn't backported to 0.95.1. [3490] http://code.djangoproject.com/changeset/3490 > > On Mar 20, 10:21 pm, "Matthew Flanagan" <[EMAIL PROTECTED]> > wrote: > > On 3/20/07, Mary <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > here is my search.py > > > > > from django.contrib.sites.models import Site > > > > > from stuff.search.helpers import SearchDefinition > > > > > class PageSearch(SearchDefinition): > > > model_module = 'test.Unpublished_Pages' > > > time_order_by = 'time_created' > > > search_fields = ('title', 'text') > > > > > I put it in one of my applications inside the project and i get > > > another error now which is : > > > > > Exception Value:'NoneType' object has no attribute 'objects' > > > Exception Location: /var/www/test/stuff/search/helpers.py in > > > get_id_list, line 32 > > > > > Sorry for all my questions which may be stupid :( > > > Thank you in advance for help > > > > Which version of Django are you using? 0.95.x or trunk? there was a > > problem in 0.95 that caused stuff.search to fail. > > > > > > > > > > > > > On Mar 20, 12:02 pm, "Matthew Flanagan" <[EMAIL PROTECTED]> > > > wrote: > > > > On 3/20/07, Mary <[EMAIL PROTECTED]> wrote: > > > > > > > Hi Mathew > > > > > > > I really appreciate this diff patch it solves all the problem and now > > > > > i am just facing one error in the search.py > > > > > xception Value: No module named helpers > > > > > Exception Location: /var/www/test.net/test/search.py in ?, line 11 > > > > > > > Do u have an idea why this could happened > > > > > > Can you provide test/search.py? > > > > > > > hi Doug > > > > > > > Thanks for the snippets but i really can't understand how it works is > > > > > there any full example that i can see or any documnetation that i can > > > > > read for that > > > > > > > Thank you in advance ; > > > > > Mary Adel > > > > > > > On Mar 19, 11:42 pm, "[EMAIL PROTECTED]" > > > > > <[EMAIL PROTECTED]> wrote: > > > > > > As noted in another thread there is a hack way of adding search to a > > > > > > model detailed on teh django snippits > > > > > > site:http://www.djangosnippets.org/snippets/31/http://www.djangosnippets.o... > > > > > > > > It is no where near as nice nor as comprehensive as the old django > > > > > > stuff abstract search interface, but it does get the job done in a > > > > > > pinch. > > > > > > > > -Doug > > > > > > -- > > > > matthewhttp://wadofstuff.blogspot.com > > > > -- > > matthewhttp://wadofstuff.blogspot.com > > > > > -- matthew http://wadofstuff.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: Development in LAN. URLs of FlatPages. Best Practices?
On Mar 5, 10:44 am, "Aidas Bendoraitis" <[EMAIL PROTECTED]> wrote: ... > 2. installing a BIND (DNS) server locally so that we didn't have to > put projects under specific directories, but rather under local domain > names (i.e.http://example.local/). I just use the hosts file on my development boxes, for example put in something like dev.mydomain.com, point that to your LAN server IP in hosts, and set up a virtual domain on your development server- I'm using lighttpd. Use the local_settings.py trick for anything you need to set up that you don't want on your production setup. I use flatpages for all kinds of stuff, and this setup works well. Derek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Handling a page with multiple areas
Matt, For 'temporary' state which does not need to live beyond an interactive session with a website, I prefer to use a custom cookie with an expiration of 12 hours or less. Many times if it is just a CSS mark of some sort, I will just use 100% javascript to get the job done, as it means I can even cache the page being rendered for an added performance boost. If it is something that needs to move with the user (i.e. they log out, then log back in, or go to a different browser/machine), or cross users, then a Model is the only maintainable way of doing it. I might use the user session cookie, but ultimately it's data in the DB. For really complex applications, I do both. Store the data in a custom cookie, and if there is an associated user, then parse the cookie data and also store it in the Database. If you go this route you need to plan your data management carefully (merging issues for changing cookies). That is how the PyCon scheduling app works. This means I can cache the expensive to render times table, and let javascript to the context highlighting. It also means that you don't need complex AJAX talking back to the server to change state which increases server, bandwidth, and time overhead. http:://us.pycon.org/apps07/schedule/ -Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Handling a page with multiple areas
Thanks. The problem is that I then have to record this for each person, and for each question if I can find a lightweight way of doing this (in terms of my LOC, as well as server activity) that would be better. I thought that perhaps a cookie, which got deleted at the end of the session would be better (doesn't matter as much if they got to remark it next session). Matt Mar 21, 3:54 pm, "akonsu" <[EMAIL PROTECTED]> wrote: > hello, > > unless i misunderstood the question, you need to maintain some state > across multiple requests. if so, this is what the database is for. :-) > make a model that has your "marked" flag. > > konstantin > > On Mar 21, 11:36 am, "MattW" <[EMAIL PROTECTED]> wrote: > > > Dear All, > > > More of a design question than a technical query... > > > I've got a page with multiple 'areas' - some static text, a wiki bit > > and a 'marking' bit (via a form). I'd like to be able to only allow > > people to enter a mark once, after which views of the page should say > > "Thanks for the feedback". > > > The problem I have is that from the 'base' view, if I mark the page, > > and then go back to base view, I can do this (using a simple > > 'marked':True in the context and an {% if marked %} tag in the > > template). But if I then edit the wiki bit, I lose the fact that I've > > also marked the page. > > > I wondered if I could do this by passing the same context around, by > > taking the request from one page and then passing it to the next; this > > would (presumably) preserve the 'marked' bit. I tried this using > > RequestContext, but it all went horribly wrong. So, please: > > > 1: Any better ideas about how to do it > > 2: If the RequestContext idea is right, then could someone outline how > > to do it? > > > Thanks, > > Matt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQLdb version
On 3/21/07, worksology <[EMAIL PROTECTED]> wrote: > > I have the exact same issue, also with Dreamhost. I tried the > "mysql_old" thing, but still got the same error. Malcolm has just checked in a fix. this has saved My_old backend :) Derek --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQLdb version
I'm guessing that the import statement in mysql_old/introspection.py should read: from django.db.backends.mysql_old.base import quote_name rather than: from django.db.backends.mysql.base import quote_name That seems to have worked for me, but probably should be fixed in the source, eh? - Josh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQLdb version
I have the exact same issue, also with Dreamhost. I tried the "mysql_old" thing, but still got the same error. Here's the relevant part of the stack trace: File "/django_src/django/db/backends/mysql_old/introspection.py", line 1, in ? from django.db.backends.mysql.base import quote_name File "/django_src/django/db/backends/mysql/base.py", line 20, in ? raise ImportError, "MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__ ImportError: MySQLdb-1.2.1p2 or newer is required; you have 1.2.1g3 My checkout is up-to-date (Revision 4767). Any help would be awesome. J On Mar 21, 1:51 pm, Michael Radziej <[EMAIL PROTECTED]> wrote: > On Wed, Mar 21, Adam wrote: > > > This causes a problem with DreamHost...I know they're not the best in > > the world, but I get this error now on any sites on their servers. > > Does anyone have a decent solution to get around this? Can I install > > a local copy somehow and make django use it instead of their version? > > Has anyone had luck getting them to update their version? > > If you upgrade Django to the current svn release, you can set the database > engine setting to 'mysql_old' instead of 'mysql'. Then everything should > work again with the old MySQLdb. > > Michael > > -- > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - > Tel +49-911-9352-0 - Fax +49-911-9352-100http://www.noris.de- The > IT-Outsourcing Company > > Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - > Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
manage.py startapp suggestions
I'd love it if someone made an intelligent startapp call for manage.py. At the moment, it looks like Rails... but doesn't DO an awful lot This is my very crude attempt, which first calls startapp, then does standard stuff that ALWAYS seem to have to do and ALWAYS forget like: Add a urls.py for my app... Add a URL pattern to load static images Create the folder to host the static images Put some examples in the views calls and add standard imports Create all the classes in models.py that I think I'm gonna need (but not call syncdb yet) Add __str__ calls to all classes, and Admin classes (it's easier to delete them than to add them by hand later) Docstrings, one day I may comment my code.I deliberately don't want to do any kind of auto-build wizard, because that would end up with code that I couldn't hack, or simply get ridiculously complicated, this is a simple "this is the stuff I get bored, or forget to type every time I start a project".I also don't want this to tell me how I HAVE to do things, but it'd be nice to have some polite suggestions in how to organise my folders, classes, views etc...I think this idea is ok... or.. it works for me... I'd love it if someone could make it a bit fabber...I have made a teensy weensy video so you can laugh at my accent as I try to explain what I'd like startapp to do... my code is also made available for your amusement :-)http://www.youtube.com/watch?v=tXkRpRaHNu0regardstom startapp.py Description: application/applefile #!/usr/bin/env python """This is meant to show how I think startapp should be a bit more helpful with regard to us novice users, adding examples, adding common imports, adding stuff that can be added quicker from the command-line than when coding in python (perhaps) The idea here is that, IF there is a "good" way to do things then let's adopt it but not force it on people. And that it's easier to delete stuff you don't need, than create it from scratch. This file is also meant to be deliberately non-clever, so that it's easy to hack from top to bottom, to work the way you work, rather than the way Ithink you should work... because to be honest I haven't a clue. If someone could make this work properly, I'd be very grateful tom, http://www.theotherblog.com """ import sys, os, traceback def do(cmd): f = os.popen(cmd) result = f.read() f.close() return result.strip() if __name__ == '__main__': app = sys.argv[1] #get enclosing folder name path_to_here = os.getcwd() project = os.getcwd().split("/")[-1] print "Starting app:", app cmd = "python manage.py startapp %s" % app print "doing: ", cmd, "..." os.system(cmd) #DO MODELS f = open("./" + app + "/models.py", 'w') #data = f.read() we could do a search and replace here... START MODELS.PY class_str = ''' # standard import urllib2, urllib, traceback, logging from string import * # django from django.conf import settings from django.db import models,connection, backend from django.core.exceptions import ObjectDoesNotExist # my imports # Create your models here. ''' #ASK ABOUT INDIVIDUAL CLASSES class_name = 'y' classes = [] # A list of classes we define along the way extras = ''' def __str__(self): return repr(self) class Admin: search_fields = [] list_display = ( ) list_filter = [] class Meta: ordering = () ''' while class_name != 'n': print "Would you like to add a class to your model? ClassName or n\r" class_name = raw_input() class_name.strip() if class_name == 'n' or '': print break classes.append(class_name) class_str += "\rclass %s(models.Model):\r" % class_name class_str += '\t""\r' #add attributes attr_name = 'y' while attr_name != 'n': print 'Add an attribute to class "%s"? attribute_name or n' % class_name attr_name = raw_input().strip() if attr_name == 'n' or '': class_str += extras print break print '...of type fk, char, text, int, datetime, url?' attr_type = raw_input().strip() if attr_type == 'fk': # ask which class from classes? class_str += "\t" + attr_name + " = models.ForeignKey(???)\r" elif attr_type == 'char': #ask how long? class_str += "\t" + attr_name + " = models.Charfield(maxlength=200, blank=True)\r" elif attr_type == 'text': class_str += "\t" + attr_name + " = models.TextField(default='', blank=True)\r" elif attr_type == 'int': #ask default? class_str += "\t" + attr_name + " = models.IntegerField(default=0)\r" elif attr_type == 'datetime': class_str += "\t" + attr_name + " = models.DateTimeField(auto_now_add=True, blank=True)\r" class_str += extras print "writing models.py." f.write(class_str ) f.close() ### END MODELS ### START
Re: MySQLdb version
On Wed, Mar 21, Adam wrote: > > This causes a problem with DreamHost...I know they're not the best in > the world, but I get this error now on any sites on their servers. > Does anyone have a decent solution to get around this? Can I install > a local copy somehow and make django use it instead of their version? > Has anyone had luck getting them to update their version? If you upgrade Django to the current svn release, you can set the database engine setting to 'mysql_old' instead of 'mysql'. Then everything should work again with the old MySQLdb. Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: contrib.auth logins "randomly" complaining about cookies being disabled
There is nothing special about that app. The login which is failing is the standard django one (The app just adds code for new account creation, e-mailing the registerant, and enabling the account with a unique key). I believe the problem you are running into is because the page is stale. That is you are using the back button and not reloading the page with the login form fresh. When the page loads a new temporary cookie is set. If that cookie is not present on the login submission, then you get the cookies enabled error. Other parts of the system will delete the cookie if they see it (including logout). So you go to the main page wich has a login form (cookie created) You load a different page with the login form (cookie created, again) You log in (cookie is seen, you are logged in and the cookie is deleted) You log out (cookie doesn't exist, nothing to do) You go 'back' to main page with login (page is not reloaded from the server, so still no cookie) You log-in (no cookie - Error message) If yo reload the page (hold the shift key down on reload), then try again - Works. Also you can run into this problem if you are using the cache middleware. Make sure the session middleware occurs BEFORE the cache middleware, in your middleware list. -Doug On Mar 21, 12:56 pm, "ashwoods" <[EMAIL PROTECTED]> wrote: > have you tried contacting the project maintainer? this is third party > code and unless anybody happens to use it, to answer you they would > have to go through his code. on the wiki page it says: > > >Questions? Problems? > >If you've got a question that isn't covered here or in the comments and > >docstrings in the code, or if you run into a bug, swing on over to this > >app's Google >Code project page and file a new "issue". I'll do my best to > >respond promptly. > > so i would try that first :) > if that doesnt work, i guess i'll have to go through the code ;) > > cheers, > ashley > > On Mar 21, 1:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > Hi! > > > I've recently implementedhttp://code.google.com/p/django-registration/ > > to support user registration and authentication on a project. > > > I've also created a form in a template that extends ALL other > > templates on the site. > > > I'm facing the following problem: > > > If I fire the django development server up and enter my login > > credentials on the site's front page, the login fails with the > > following message: "Your Web browser doesn't appear to have cookies > > enabled. Cookies are required for logging in.". > > > What's weird is that I do have cookies enabled. What's even more weird > > is that ... > > > ... If I try to login AGAIN using the same form on the page that shows > > me this message, I can login just fine. > > > If I then go to the front page and log out, I can login from the front > > page without a problem. BUT if I logout, go to a random location on > > the site, and then back to the front page, I can't login again. > > > The same behavior is present on all pages (~5), except the actual > > login-page. > > > I've tested on both apache with mod_python and using the Django > > development server and on several different client computers. Browsers > > tested: FF 2.0.0.2 and Safari 2.0.0.4. > > > Would greatly appreciate any help! > > > Thanks in anticipation, > > Gustaf Sjöberg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Integrating web services with django
On 3/21/07, Nathan Harmston <[EMAIL PROTECTED]> wrote: ... > The view could return results if the result was retrieved > within a specific time period, else it would return a "work in progress". > Would this kind of thing work? So the "WS client process" and Django both > share the same models and "talk" using the database? Is there any problem > with this that anyone can see? Yeah, when you buy a PDF book from here: http://www.pragmaticprogrammer.com/ They generate the PDF in response, and it sometimes takes a while. They basically issue a ticket, and they email you when the response is completed. I had a task one time that could run a long time, so I had the browser meta-refresh on the job status page until the job was completed. The only problem with that approach is if you have a -lot- of clients, refreshing frequently will put more load on your server. You can either slow down the poll or add servers... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySQLdb version
This causes a problem with DreamHost...I know they're not the best in the world, but I get this error now on any sites on their servers. Does anyone have a decent solution to get around this? Can I install a local copy somehow and make django use it instead of their version? Has anyone had luck getting them to update their version? Adam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Development in LAN. URLs of FlatPages. Best Practices?
could you post the code on django snippets? :) On Mar 20, 11:35 pm, "Aidas Bendoraitis" <[EMAIL PROTECTED]> wrote: > > have you found any solution? > > Yes. I wrote my own FlatPage model with it's own middleware. Now the > URL can be empty and it represents the relative path counting from the > website root directory. The root directory is "/" on the public site > and "/someproject/" on the development site. The root directory is set > in the settings. > > > would it be correct to say that the problem would > > be solved if there was a way to access project settings from inside > > flatpages? > > Not really. You don't define what you mean, saying "from inside > faltpages" - whether you're talking about models, views, middleware, > or something else from the flatpages. Anyway, it's enough to write > your own middleware to override the default control of the flatpages > (And fortunately it is not hard to do that). > > Regards, > Aidas Bendoraitis [aka Archatas] > > > > > On Mar 5, 12:44 pm, "Aidas Bendoraitis" <[EMAIL PROTECTED]> > > wrote: > > > We are developing a few Django projects. The development versions are > > > accessible in the local network under some directories of the local > > > server's IP (i.e.http://1.2.3.4/example/) and the published versions > > > are accessible under some domains directly (i.e.http://example.com/). > > > > If you have a similar situation, how are you dealing with the URLs > > > ofFlatPages? The problem is that in the development version the URLs are > > > like /example/about/ and in the published version they are like > > > /about/. So we need to modify all theflatpageswhen transfer the data > > > from the development version to the public one. > > > > The ideas that came to my mind: > > > 1. creating my own FlatPage model based on the contributed one which > > > corresponds to the directory setting in the project settings. > > > 2. installing a BIND (DNS) server locally so that we didn't have to > > > put projects under specific directories, but rather under local domain > > > names (i.e.http://example.local/). > > > 3. creating some middleware that removes directory name from the > > > requested URL before URL parsing. > > > > What are the best practices for doing that? What do you do in similar > > > situations? > > > > Regards, > > > Aidas Bendoraitis [aka Archatas] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: contrib.auth logins "randomly" complaining about cookies being disabled
have you tried contacting the project maintainer? this is third party code and unless anybody happens to use it, to answer you they would have to go through his code. on the wiki page it says: >Questions? Problems? >If you've got a question that isn't covered here or in the comments and >docstrings in the code, or if you run into a bug, swing on over to this app's >Google >Code project page and file a new "issue". I'll do my best to respond >promptly. so i would try that first :) if that doesnt work, i guess i'll have to go through the code ;) cheers, ashley On Mar 21, 1:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi! > > I've recently implementedhttp://code.google.com/p/django-registration/ > to support user registration and authentication on a project. > > I've also created a form in a template that extends ALL other > templates on the site. > > I'm facing the following problem: > > If I fire the django development server up and enter my login > credentials on the site's front page, the login fails with the > following message: "Your Web browser doesn't appear to have cookies > enabled. Cookies are required for logging in.". > > What's weird is that I do have cookies enabled. What's even more weird > is that ... > > ... If I try to login AGAIN using the same form on the page that shows > me this message, I can login just fine. > > If I then go to the front page and log out, I can login from the front > page without a problem. BUT if I logout, go to a random location on > the site, and then back to the front page, I can't login again. > > The same behavior is present on all pages (~5), except the actual > login-page. > > I've tested on both apache with mod_python and using the Django > development server and on several different client computers. Browsers > tested: FF 2.0.0.2 and Safari 2.0.0.4. > > Would greatly appreciate any help! > > Thanks in anticipation, > Gustaf Sjöberg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Integrating web services with django
is there any reason you want to process the "webservices" on the server side? unless there is any special reason to do this, it looks like kind of redundant and actually that is one of the main reasons to use webservices (decentralized application model). that means you would want to spit out client side code that actually does the processing. there are some situations where you want to "cache" a webservice, so the server would do the service "fetching". both approaches are easily done with django. On Mar 21, 2:04 pm, "Nathan Harmston" <[EMAIL PROTECTED]> wrote: > When I say Web Services, I am including SOAP aswell as REST. So my django > project actually becomes a portal to various web services hosted by external > entities. So is the best way to do it, to have a job model which holds the > various job data and have a process running which runs the web service and > updates the relevant job model so when the user views the "results" view it > appears properly. The view could return results if the result was retrieved > within a specific time period, else it would return a "work in progress". > Would this kind of thing work? So the "WS client process" and Django both > share the same models and "talk" using the database? Is there any problem > with this that anyone can see? > > Would this work? > > Many Thanks in advance, > > Nathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Handling a page with multiple areas
hello, unless i misunderstood the question, you need to maintain some state across multiple requests. if so, this is what the database is for. :-) make a model that has your "marked" flag. konstantin On Mar 21, 11:36 am, "MattW" <[EMAIL PROTECTED]> wrote: > Dear All, > > More of a design question than a technical query... > > I've got a page with multiple 'areas' - some static text, a wiki bit > and a 'marking' bit (via a form). I'd like to be able to only allow > people to enter a mark once, after which views of the page should say > "Thanks for the feedback". > > The problem I have is that from the 'base' view, if I mark the page, > and then go back to base view, I can do this (using a simple > 'marked':True in the context and an {% if marked %} tag in the > template). But if I then edit the wiki bit, I lose the fact that I've > also marked the page. > > I wondered if I could do this by passing the same context around, by > taking the request from one page and then passing it to the next; this > would (presumably) preserve the 'marked' bit. I tried this using > RequestContext, but it all went horribly wrong. So, please: > > 1: Any better ideas about how to do it > 2: If the RequestContext idea is right, then could someone outline how > to do it? > > Thanks, > Matt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'module' object has no attribute 'handler404'
this helped. thanks. i was not importing the default handler. konstantin > > Make sure the module referred to by ROOT_URLCONF has defined 'handler404'. > > This is typically provided via > " > from django.conf.urls.defaults import * > " in the URLConf because urls.defaults.py includes this: > handler404 = 'django.views.defaults.page_not_found' > > -Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Handling a page with multiple areas
Dear All, More of a design question than a technical query... I've got a page with multiple 'areas' - some static text, a wiki bit and a 'marking' bit (via a form). I'd like to be able to only allow people to enter a mark once, after which views of the page should say "Thanks for the feedback". The problem I have is that from the 'base' view, if I mark the page, and then go back to base view, I can do this (using a simple 'marked':True in the context and an {% if marked %} tag in the template). But if I then edit the wiki bit, I lose the fact that I've also marked the page. I wondered if I could do this by passing the same context around, by taking the request from one page and then passing it to the next; this would (presumably) preserve the 'marked' bit. I tried this using RequestContext, but it all went horribly wrong. So, please: 1: Any better ideas about how to do it 2: If the RequestContext idea is right, then could someone outline how to do it? Thanks, Matt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Suggestions for Django Presentation
Filters are unbelievably helpful when you have different people doing markup and development. The 'pluralize' filter, for example (as well as the 'humanize' collection), has saved us developers from having to write templae-side code to figure out if there should be an 's' at the end of a noun. This shouldn't be a programmer's job: it's a presentation issue and should be dealt with by the XHTML authors. Filters lets this happen. The concept is very simple to grasp, easy to demonstrate, and EXTREMELY useful! By the way, good luck with the presentation! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'module' object has no attribute 'handler404'
On 3/21/07, akonsu <[EMAIL PROTECTED]> wrote: > thanks for your reply. the error that i am getting seems to indicate > that it is not 404.html that is the problem. it cannot find the > handler itself, not the template. and i do have this template, but it > does not help :-) I assume you're using the standard RegexURLResolver. (If you're not sure, you are. :)) Make sure the module referred to by ROOT_URLCONF has defined 'handler404'. This is typically provided via " from django.conf.urls.defaults import * " in the URLConf because urls.defaults.py includes this: handler404 = 'django.views.defaults.page_not_found' If that doesn't work, please provide the traceback and the code for your ROOT_URLCONF module so I can help more. -Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Blocking IP with middleware?
On 3/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Looking at my logs, I saw a gazillion requests from 81.208.31.216, > which I believe is a malicious bot. I understand there's a way to use > middleware to block IPs, but could somebody elaborate on that, or > point me in the right direction? Thanks! Let your web server or firewall do this for you; it'll be much more efficient. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'module' object has no attribute 'handler404'
Scott, thanks for your reply. the error that i am getting seems to indicate that it is not 404.html that is the problem. it cannot find the handler itself, not the template. and i do have this template, but it does not help :-) konstantin On Mar 21, 6:46 am, "ScottB" <[EMAIL PROTECTED]> wrote: > Hi konstantin. > > I added a 404.html file to my templates directory (also a 500.html) > and now Django displays them (assuming Debug = False). You can use > the standard template inheritance, etc, so your error pages match the > rest of the site. > > Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Blocking IP with middleware?
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > middleware to block IPs, but could somebody elaborate on that, or > point me in the right direction? Thanks! Better use your local firewall or the webserver in front of Django. Why let an (comparable expensive) application deal with this? Regards, Frank --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Blocking IP with middleware?
On Wed, Mar 21, [EMAIL PROTECTED] wrote: > > Looking at my logs, I saw a gazillion requests from 81.208.31.216, > which I believe is a malicious bot. I understand there's a way to use > middleware to block IPs, but could somebody elaborate on that, or > point me in the right direction? Thanks! Better use Apache or whatever you use for this, it's usually much faster in throwing away requests. I don't know if someone has provided a middleware to do that in Django, but I doubt. Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Blocking IP with middleware?
Check the request.META['REMOTE_ADDR'] in your custom request middleware. If it equals to the one, you want to block, return an error page. Regards, Aidas Bendoraitis [aka Archatas] On 3/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Looking at my logs, I saw a gazillion requests from 81.208.31.216, > which I believe is a malicious bot. I understand there's a way to use > middleware to block IPs, but could somebody elaborate on that, or > point me in the right direction? 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 -~--~~~~--~~--~--~---
Blocking IP with middleware?
Looking at my logs, I saw a gazillion requests from 81.208.31.216, which I believe is a malicious bot. I understand there's a way to use middleware to block IPs, but could somebody elaborate on that, or point me in the right direction? 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: Integrating web services with django
When I say Web Services, I am including SOAP aswell as REST. So my django project actually becomes a portal to various web services hosted by external entities. So is the best way to do it, to have a job model which holds the various job data and have a process running which runs the web service and updates the relevant job model so when the user views the "results" view it appears properly. The view could return results if the result was retrieved within a specific time period, else it would return a "work in progress". Would this kind of thing work? So the "WS client process" and Django both share the same models and "talk" using the database? Is there any problem with this that anyone can see? Would this work? Many Thanks in advance, Nathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: newbie : Django Error Handling
Hi Simon, Thanks for your response! I was more thinking of exceptions raised when something is terribly wrong like mysql being down when you try to do a : Models.objects.all() or maybe also if you try to fetch data filtering with a filter with a wrong data type. ... basically every exceptions that needs to be try: ... except: ... to avoid the app to get screwed :) Cheers Seb [EMAIL PROTECTED] wrote: > Hi Seb :) > > There's no list of exceptions in the docs, but if other people think > it's a good idea, I'll add it as a feature request. > > Anyway, Models.objects.all() will return an empty list ([]) if there's > nothing in the database. Something like > Model.objects.get(pk=somevalue) will raise a Models.DoesNotExist > exception. Which other ones were you stuck on? > > --Simon > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newbie : Django Error Handling
Hi Seb :) There's no list of exceptions in the docs, but if other people think it's a good idea, I'll add it as a feature request. Anyway, Models.objects.all() will return an empty list ([]) if there's nothing in the database. Something like Model.objects.get(pk=somevalue) will raise a Models.DoesNotExist exception. Which other ones were you stuck on? --Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
contrib.auth logins "randomly" complaining about cookies being disabled
Hi! I've recently implemented http://code.google.com/p/django-registration/ to support user registration and authentication on a project. I've also created a form in a template that extends ALL other templates on the site. I'm facing the following problem: If I fire the django development server up and enter my login credentials on the site's front page, the login fails with the following message: "Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.". What's weird is that I do have cookies enabled. What's even more weird is that ... ... If I try to login AGAIN using the same form on the page that shows me this message, I can login just fine. If I then go to the front page and log out, I can login from the front page without a problem. BUT if I logout, go to a random location on the site, and then back to the front page, I can't login again. The same behavior is present on all pages (~5), except the actual login-page. I've tested on both apache with mod_python and using the Django development server and on several different client computers. Browsers tested: FF 2.0.0.2 and Safari 2.0.0.4. Would greatly appreciate any help! Thanks in anticipation, Gustaf Sjöberg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
newbie : Django Error Handling
Hi All, This is my very first POST. I am looking @ django for a quick project i have to set up; and so far i must admit i am quite amazed on how quickly things can be done. One thing bugs me though i could not find anywhere how to handle errors : what are the exceptions thrown by django for instance when u do a Models.object.all(), Is there a list somewhere ? (could not find the exceptions in the API ...) Thanks for your help Seb --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Suggestions for Django Presentation
> Testing is a must have for long term support. Templatetags are great too. > I second this. You might want to include the newly introduced support for Fixtures (XML, JSON, Python and YAML). Regards, Manoj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'module' object has no attribute 'handler404'
Hi konstantin. On Mar 21, 2:38 am, "akonsu" <[EMAIL PROTECTED]> wrote: > i have no handler404 defined in my application, so when a 404 is > raised the server returns internal server error and an error message > saying 'module' object has no attribute 'handler404' is written in to > the log. how to make it use the default 404 view? I added a 404.html file to my templates directory (also a 500.html) and now Django displays them (assuming Debug = False). You can use the standard template inheritance, etc, so your error pages match the rest of the site. Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem importing models in custom data import scripts
Hi Nathan. On Mar 21, 12:37 am, "Nathan Harmston" <[EMAIL PROTECTED]> wrote: > My Project is called pynomics and the app alignments. > ~/pynomics/alignments/models.py > > so in my "Parser.py", I try to import the models file > from pynomics.alignments.models import * > > but I get the following error when I try to run it: > Traceback (most recent call last): > File "Parser.py", line 1, in ? > from pynomics.pyalignments.models import Interval > ImportError: No module named pynomics.pyalignments.models Python can't find the pynomics module to import because it is not in the search path. A simple workaround would be to add the path that contains pynomics (i.e. your home directory) to sys.path in your Parser.py. import sys sys.path.append("/home/nathan/") You can also add the path to a PYTHONPATH environment variable or put a symlink to pynomics in your site-packages directory (which is somewhere like /usr/lib/python2.4/site-packages). > However the import seems to work when I import it in views.py. Yeah, Django sets it up in the path for you if you do manage.py runserver. The next error you'll probably get is about DJANGO_SETTINGS_MODULE not being set. This means the Django framework doesn't know where to find the settings for database connection, etc. Again in your Parser.py script, try: import os os.environ['DJANGO_SETTINGS_MODULE'] = 'pynomics.settings' Sorry if I'm a bit vague - I'm new to Python and this is just what I've figured out. Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: New Forms/Newbie Question
Hi Jim. On Mar 19, 8:41 pm, "JimR" <[EMAIL PROTECTED]> wrote: > how do I retrieve/store the correct key/id for the > attribute information? I generate a drop-down with the valid > selections "home," "mobile," etc.) and then want to store it's > associated id ... > FORM: > class RegistrationForm(forms.Form): > ... > phone_type = forms.ChoiceField(choices=[(c.description, > c.name) for c in TelecommuncationType.objects.all()]) There might be a better way, but this is what I did in a similar situation: I had a MultipleChoiceField with CheckboxSelectMultiple widget so users select one or more checkboxes, in my case to specify areas of a site. The choices parameter is a list of (area.id, area.name) set like: # populate choices within form self.fields['areas'].choices = [(area.id, area.name) for area in site.areas.all()] Once the form is submitted and validated, I access clean_data['areas'] to get a list of the ids of all the selected areas. To get the objects for these ids I use in_bulk (because there are potentially several of them). # populate invitation object within form invitation.areas = self.site.areas.in_bulk(self.clean_data['areas']) So for your RegistrationForm, perhaps the choices for phone_type would be (c.id, c.name). Then you can set the type of a TelecommunicationsNumber from a completed form with something like: tele_num.type = TelecommunicationsType.objects.get(pk=form.clean_data['phone_type']) Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: SESSION_EXPIRE
On Mar 19, 6:00 pm, "tyman26" <[EMAIL PROTECTED]> wrote: > Where do I set the 'SESSION_EXPIRE_AT_BROWSER_CLOSE = True'? I added > this to the "settings" file and sync'd the database, but when I close > the browser the session still stays intact. Do I have to add this > when the session is created? When the session is created, a cookie is set in the user's browser. If SESSION_EXPIRE_AT_BROWSER_CLOSE is False (the default), the cookie is set to expire in two weeks. If it is True, the cookie does not have an expiry date and so will not be saved by the browser when it closes. It sounds like you have an unexpired cookie in your browser for a session that was created before you changed the setting. Delete the cookie in your browser and try again. Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Suggestions for Django Presentation
2007/3/21, Scott Paul Robertson <[EMAIL PROTECTED]>: > I'm giving a presentation on Django to two local Linux Users Groups in > the next month. I don't want to rehash the tutorial; I'd rather spend > time showing off why Django is cool and how to do interesting things > with it. Currently I want to talk about: > - Authenticate framework > - Generic views > - Template language > - Newforms > > I'm looking for suggestions of more features to emphasize/show-off. So > what does everyone think? What features make Django such a great > framework? Testing is a must have for long term support. Templatetags are great too. Good luck, David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Changing the database - attribute errors
I was using the same shell. I also tried shutting down the server, rebooting the machine and opening everything up again to see if that would make any difference but it did not. However, then a few hours later - it started to work again. I still don't fully understand the reason. I can only assume that my path was somehow faulty. However, that doesn't fully explain why Django was using my model file perfectly ok in some instances (such as in the Admin and in the DB), but not in the shell or through my views. MerMer On Mar 20, 12:04 pm, "Ramiro Morales" <[EMAIL PROTECTED]> wrote: > On 3/20/07, Merric Mercer <[EMAIL PROTECTED]> wrote: > > > > > > > Another observation after more investigation. > > > I decided to do the following:- > > > 1. Drop the table (again) from the DB. > > 2. Alter the Model in Django. This time I deleted one of the original > > fields named "rrp". > > > Then:- > > > 1. I re-ran syncdb. This confirmed the creating of a new table in the db > > 2. I checked the db and the admin - again both of these showed up > > correctly with all the fields from my Model. > > 3. In the shell I then tried to run a query set on the table. I got > > the following error > > > " OperationError: (1054, "unknown column 'promotions_product.rrp' in > > field list)" > > > This was the field that I deleted from the model. > > > This is making me conclude that django is using two versions of the > > information in my Models. The updated version is being used to > > correctly update the database and the admin - but the older version is > > being used to run the query sets. > > Are you opening a new Python shell (with the myproject.promotions import) > after any of your model/database modifications or have been > maintaining the same shell session open from before you started > these mods?. > > Regards, > > -- > Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple file upload crashes dev server
> OK, I'm impressed. :-) > > Nice job thinking through all the things it might be and thinking of > horses, not zebras. > > Malcolm A happy confluence of unrelated events should get the credit tho: work frustration turning into determination to be useful to someone and discovering my new Dell has the nerve to beep at me even with the volume muted :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms and output of required fields
Hi Rubic, On Mar 20, 5:18 pm, "Rubic" <[EMAIL PROTECTED]> wrote: > On Mar 20, 4:27 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > I have explained the technique with example code here: > >http://code.djangoproject.com/wiki/TemplatedForm > > Very nice, Alex. You might consider adding this code > to the djangosnippets.org site. Done :) http://www.djangosnippets.org/snippets/121/ > FWIW, you can replace > the first 4 lines in output_via_template with a single > assignment: > > bound_fields = [BoundField(self, field, name) for name, field > in self.fields.items()] Thanks! This worked well. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
I am using 0.95.1 the latest stable version for Django --MA On Mar 20, 10:21 pm, "Matthew Flanagan" <[EMAIL PROTECTED]> wrote: > On 3/20/07, Mary <[EMAIL PROTECTED]> wrote: > > > > > > > here is my search.py > > > from django.contrib.sites.models import Site > > > from stuff.search.helpers import SearchDefinition > > > class PageSearch(SearchDefinition): > > model_module = 'test.Unpublished_Pages' > > time_order_by = 'time_created' > > search_fields = ('title', 'text') > > > I put it in one of my applications inside the project and i get > > another error now which is : > > > Exception Value:'NoneType' object has no attribute 'objects' > > Exception Location: /var/www/test/stuff/search/helpers.py in > > get_id_list, line 32 > > > Sorry for all my questions which may be stupid :( > > Thank you in advance for help > > Which version of Django are you using? 0.95.x or trunk? there was a > problem in 0.95 that caused stuff.search to fail. > > > > > > > On Mar 20, 12:02 pm, "Matthew Flanagan" <[EMAIL PROTECTED]> > > wrote: > > > On 3/20/07, Mary <[EMAIL PROTECTED]> wrote: > > > > > Hi Mathew > > > > > I really appreciate this diff patch it solves all the problem and now > > > > i am just facing one error in the search.py > > > > xception Value: No module named helpers > > > > Exception Location: /var/www/test.net/test/search.py in ?, line 11 > > > > > Do u have an idea why this could happened > > > > Can you provide test/search.py? > > > > > hi Doug > > > > > Thanks for the snippets but i really can't understand how it works is > > > > there any full example that i can see or any documnetation that i can > > > > read for that > > > > > Thank you in advance ; > > > > Mary Adel > > > > > On Mar 19, 11:42 pm, "[EMAIL PROTECTED]" > > > > <[EMAIL PROTECTED]> wrote: > > > > > As noted in another thread there is a hack way of adding search to a > > > > > model detailed on teh django snippits > > > > > site:http://www.djangosnippets.org/snippets/31/http://www.djangosnippets.o... > > > > > > It is no where near as nice nor as comprehensive as the old django > > > > > stuff abstract search interface, but it does get the job done in a > > > > > pinch. > > > > > > -Doug > > > > -- > > > matthewhttp://wadofstuff.blogspot.com > > -- > matthewhttp://wadofstuff.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 -~--~~~~--~~--~--~---