Re: Caching template fragments without specifying expiration time
Be aware that the way the cache key is constructed changed a bit. I'm also invalidating template fragments when models used for rendering changed, and found this while randomly reading changesets: It used to be: fragment_name:additional:arguments:seperated:by:colons Now it is: template.cache.fragment_name.args where args is md5 (additional:arguments:seperated:by:colons) http://code.djangoproject.com/changeset?new=django%2Ftrunk%2Fdjango%2Ftemplatetags%2Fcache.py%4011068&old=django%2Ftrunk%2Fdjango%2Ftemplatetags%2Fcache.py%408533 On Aug 2, 10:25 am, Nick Fishman wrote: > I was wondering if it's possible to not specify the expiration time when > using the {% cache %} tag to cache template fragments. With the low-level > API, cache entries will expire after a timeout configured in CACHE_BACKEND. > Is it possible to use the same default when caching template fragments? > > In particular, I'd like to use model signals to invalidate cache entries. > That way, entries won't be invalidated after an arbitrary time period, but > rather when they're actually invalid. Nathaniel Whiteinge wrote on > 2008-12-03 that the {% cache %} tag creates entries with keys > "fragment_name:additional:arguments:seperated:by:colons", so this seems > possible. > > Any thoughts? > > Nick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Retrieving the values from query set
Hi Daniel ,Malcom Thanks for the reply That exactly was the solution I wanted On Mon, Aug 3, 2009 at 11:47 AM, Daniel Roseman wrote: > > On Aug 3, 7:03 am, Subramanyam Vemu wrote: > > Hi Malcom > > > > The values_list() returns a list of tuples whereas I am looking for a > simple > > list of the values > > > From the link Malcolm so helpfully provided: > > "If you only pass in a single field, you can also pass in the `flat` > parameter. If True, this will mean the returned results are single > values, rather than one-tuples." > > In other words, that's exactly what you want. > -- > DR. > > > -- Regards Subramanyam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Retrieving the values from query set
On Aug 3, 7:03 am, Subramanyam Vemu wrote: > Hi Malcom > > The values_list() returns a list of tuples whereas I am looking for a simple > list of the values > >From the link Malcolm so helpfully provided: "If you only pass in a single field, you can also pass in the `flat` parameter. If True, this will mean the returned results are single values, rather than one-tuples." In other words, that's exactly what you want. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Retrieving the values from query set
Hi Malcom The values_list() returns a list of tuples whereas I am looking for a simple list of the values On Mon, Aug 3, 2009 at 10:48 AM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > > On Sun, 2009-08-02 at 21:59 -0700, bvemu wrote: > [...] > > Is there a django way of retrieving only the values as a list and not > > the fieldname > > Have a look at the values_list() method. That does what you are after. > > > http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list-fields > > Regards, > Malcolm > > > > > -- Regards Subramanyam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Caching template fragments without specifying expiration time
On Mon, 2009-08-03 at 01:00 -0400, Nick Fishman wrote: > > and suggests otherwise). It might not be too difficult to add support > > for an optional timeout, although the error checking requires a lot of > > care. > > I think that's the main problem. Since arguments to {% cache %} aren't > named, it doesn't seem possible to differentiate {% cache 500 key1 > key2 %} from {% cache user.id key1 key2 %}. In the first case, 500 > represents a timeout. In the second case, user.id might resolve to 500 > and represent a _key_ rather than a timeout. I'm not sure of an > elegant way to deal with this. Right. I hadn't thought of (ab)using it like that to just cache a random variable (why not do it in the view in that case?!). It's more intended for caching rendered template fragments and I thought you'd be able to tell when the first thing was a number it's a timeout and when it's a string it's a template fragment. > I'll probably stick with setting a large constant in a > context_processor and using that as the "effectively expire never" > time. I'd have to use a similar trick when using the low-level cache > API, anyway. Or you could do it the easy way and spend three minutes writing a template tag that uses the default cache value. Remember, you are *encouraged* to write your own template tags to scratch itches. You already have an example to work from. :) 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Retrieving the values from query set
On Sun, 2009-08-02 at 21:59 -0700, bvemu wrote: [...] > Is there a django way of retrieving only the values as a list and not > the fieldname Have a look at the values_list() method. That does what you are after. http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list-fields 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Caching template fragments without specifying expiration time
> and suggests otherwise). It might not be too difficult to add support > for an optional timeout, although the error checking requires a lot of > care. I think that's the main problem. Since arguments to {% cache %} aren't named, it doesn't seem possible to differentiate {% cache 500 key1 key2 %} from {% cache user.id key1 key2 %}. In the first case, 500 represents a timeout. In the second case, user.id might resolve to 500 and represent a _key_ rather than a timeout. I'm not sure of an elegant way to deal with this. I'll probably stick with setting a large constant in a context_processor and using that as the "effectively expire never" time. I'd have to use a similar trick when using the low-level cache API, anyway. Thanks, Nick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Retrieving the values from query set
Hi In my project I want to store an integer as the username To randomly allocate a new username I need the list of available usernames (integer type list) I tried the following ways user_list=[] user_list=list(User.objects.values('username').order_by('username')) and when I try to print the values of list , it actually represents a string like ('fieldname':'value') >>> fun(user_list) {'username': u'1'} {'username': u'103'} {'username': u'11'} {'username': u'121'} {'username': u'13'} {'username': u'13421'} {'username': u'1342323221'} {'username': u'1342333661'} {'username': u'134563661'} Is there a django way of retrieving only the values as a list and not the fieldname Thanks in advance Subramanyam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: locking up development server
On Sun, Aug 2, 2009 at 9:24 PM, Russell Keith-Magee wrote: > > On Mon, Aug 3, 2009 at 12:01 PM, Rusty Greer wrote: >> >> i added a column to one of my tables in my db. i added the column in >> the model definition, then i went into mysql and added the column with >> what i think is the appropriate alter table command. >> the command i used was: >> alter table db_game add column player_info_url varchar(200) not null; >> >> the code in the model is this: >> player_info_url = models.URLField(blank=True) >> >> i am now able to update that table no problem from mysql. the new >> field shows up just fine in the admin. i can edit other tables via >> the admin, however, if i change the table i modified in the admin (not >> just the new field), the development server seems to lock up. after i >> restart it, all is fine until i edit that same table again. > > I'm going to guess that the URL you are storing in player_info_url is > being served by your development server. > > If this is the case, you are hitting the limitations of the > single-threaded development server. By default, URLFields validate > that the URL they store is alive (i.e. returns a HTTP 200). This > requires opening a connection to the server to establish the status > code of the request. However, the development server is single > threaded, and is already serving the admin page - which means that the > inner validation request can't be served. > > There are at least four possible solutions here. > > 1. Test using a multi-threaded server - either a full blown > apache/mod_wsgi deployment, or a lightweight fcgi container. > > 2. Disable validation on the URLField. If you set set > validation=False, Django won't try to validate the URL, so you won't > get the inner request that causes the lockup. You can do this either > as a temporary thing during testing, or as a permanent change, > depending you your needs. > > 3. Don't use self-links for testing purposes. If you need to use self > links, then you get 'multithreaded lite' by running two instances of > the dev server - one on port 8000 and one on port 8001; use 8001 to > run your tests, but submit URLs from port 8000. Again, depending on > your usage, this could be fiddly, but it is a relatively simple way > around the problem. > > 4. Close your eyes, hold your nose, and think of England :-) This > problem won't exist on the production server - it's an artefact of the > development server. > > Yours > Russ Magee %-) > > BINGO, you got it. single threaded test server and the admin validation locked it up. i had just figured it out. a little more testing and i pointed the URL at cnn.com and it worked. thanks for all the workarounds. rusty --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: locking up development server
On Mon, Aug 3, 2009 at 12:01 PM, Rusty Greer wrote: > > i added a column to one of my tables in my db. i added the column in > the model definition, then i went into mysql and added the column with > what i think is the appropriate alter table command. > the command i used was: > alter table db_game add column player_info_url varchar(200) not null; > > the code in the model is this: > player_info_url = models.URLField(blank=True) > > i am now able to update that table no problem from mysql. the new > field shows up just fine in the admin. i can edit other tables via > the admin, however, if i change the table i modified in the admin (not > just the new field), the development server seems to lock up. after i > restart it, all is fine until i edit that same table again. I'm going to guess that the URL you are storing in player_info_url is being served by your development server. If this is the case, you are hitting the limitations of the single-threaded development server. By default, URLFields validate that the URL they store is alive (i.e. returns a HTTP 200). This requires opening a connection to the server to establish the status code of the request. However, the development server is single threaded, and is already serving the admin page - which means that the inner validation request can't be served. There are at least four possible solutions here. 1. Test using a multi-threaded server - either a full blown apache/mod_wsgi deployment, or a lightweight fcgi container. 2. Disable validation on the URLField. If you set set validation=False, Django won't try to validate the URL, so you won't get the inner request that causes the lockup. You can do this either as a temporary thing during testing, or as a permanent change, depending you your needs. 3. Don't use self-links for testing purposes. If you need to use self links, then you get 'multithreaded lite' by running two instances of the dev server - one on port 8000 and one on port 8001; use 8001 to run your tests, but submit URLs from port 8000. Again, depending on your usage, this could be fiddly, but it is a relatively simple way around the problem. 4. Close your eyes, hold your nose, and think of England :-) This problem won't exist on the production server - it's an artefact of the development server. Yours Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: locking up development server
On Sun, 2009-08-02 at 21:01 -0700, Rusty Greer wrote: > i added a column to one of my tables in my db. i added the column in > the model definition, then i went into mysql and added the column with > what i think is the appropriate alter table command. > the command i used was: > alter table db_game add column player_info_url varchar(200) not null; > > the code in the model is this: > player_info_url = models.URLField(blank=True) > > i am now able to update that table no problem from mysql. the new > field shows up just fine in the admin. i can edit other tables via > the admin, however, if i change the table i modified in the admin (not > just the new field), the development server seems to lock up. after i > restart it, all is fine until i edit that same table again. Locking up is a rare and unusual symptom. There's one intermediate test you haven't done (you've tried direct db editing and end-to-end through the web browser): can you query and edit the records via the interactive prompt? Another thing I would try is creating a copy of your settings file then modifying it to point to a database with a different name and trying a fresh install (so you aren't blowing away your current database). Then see if the problem reoccurs. You can also compare the sql from the two if there are differences in behaviour. > > i am not too concerned about the development server, i can nuke my db > and restart with that and i am sure the problem will go away. > however, when i go try to make the same change on my production > server, i don't want to have the same problems with it. any ideas > what i could have possibly done wrong? or how to fix it? will i have > the same problem with apache/wsgi on my production server. > > by the way i am running 1.0.2-final and mysql One important piece of debugging would be to upgrade to 1.0.3 as soon as you can, since there are about 6 months worth of bug fixes in there. I can't think of anything that's been added in the 1.0.X branch that would change this (the whole behaviour sounds *very * odd), but it wouldn't hurt to rule that out. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
locking up development server
i added a column to one of my tables in my db. i added the column in the model definition, then i went into mysql and added the column with what i think is the appropriate alter table command. the command i used was: alter table db_game add column player_info_url varchar(200) not null; the code in the model is this: player_info_url = models.URLField(blank=True) i am now able to update that table no problem from mysql. the new field shows up just fine in the admin. i can edit other tables via the admin, however, if i change the table i modified in the admin (not just the new field), the development server seems to lock up. after i restart it, all is fine until i edit that same table again. i am not too concerned about the development server, i can nuke my db and restart with that and i am sure the problem will go away. however, when i go try to make the same change on my production server, i don't want to have the same problems with it. any ideas what i could have possibly done wrong? or how to fix it? will i have the same problem with apache/wsgi on my production server. by the way i am running 1.0.2-final and mysql thanks in advance, any help is appreciated, rusty --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using email instead of username in extended "User" model?
On Sun, 2009-08-02 at 20:21 -0700, Dana wrote: > Oops i mean username, not password. > > Im not clear on how I can get this to override the django login > functionality. Im reading more up on custom auth backends but Ill > admit it's a little confusing. You write a custom authentication function that compares the username and password supplied by the user in the login form against the email address and password fields in the User model -- fetch the User instance(s) matching the email address and then use the check_password() method on the User instance to see if it's valid. It should only a couple of lines of code in the skeleton code described here: http://docs.djangoproject.com/en/dev/topics/auth/#writing-an-authentication-backend 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: HELP! pysqlite2 FTS3 and datetime not returning datetime
On Sun, Aug 2, 2009 at 7:06 PM, Carol Hatcher wrote: > > Hi, > > I'm using Django 1.0 and 1.1, pysqlite2 (latest version), sqlite3 > (latest version) and FTS3 (latest > version). > I'm creating some Django models where I recreate the database tables > as virtual tables using > FTS3 so that we can do full text search. > Some of the fields in the tables are datetime fields. > We preload the database tables by reading datafiles, building the > appropriate Django models > and saving them using the the models.save() method. > The datetime fields go into the database as datetime objects but > they come back out (called with objects.get(pk=)) as unicode > strings. > Integer and string data go in and come out fine. > I don't see the database adapter/converter invoked. ( I put a print > statement into the code) > > If I don't recreate the tables as virtual tables using FTS3, > everything works fine. > I see the database adapter/converter invoked. > > Does anyone know what might be going wrong here? > >From a little research on the virtual tables used by sqlite's full-text support, I'm wondering if these tables support maintaining the type information that the Python interface uses for the converter functions. Specifically on this page: http://www.sqlite.org/cvstrac/wiki?p=FtsUsage it states that, for the CREATE VIRTUAL TABLE, "Any additional information, including constraints and type information, is ignored." Also, "The set of columns which can be referenced are exactly those enumerated in the create statement, all of which will appear to be of type TEXT". If all of the columns appear to be of type TEXT to clients accessing the tables, I do not think the client (Python interface) will have the information it needs to know when to invoke the registered converter functions. To test this, I'd try a program similar to the sample one here: http://docs.python.org/library/sqlite3.html#converting-sqlite-values-to-custom-python-types only modified to use fts3 virtual tables as you are. I believe Django is relying on method #1 (using declared types) to cause the converter functions to be called. If that sample does not work for the fts3 virtual tables than I think that would explain why Django's registered converter functions are not being called for these tables. If method #1 does work for the sample program on virtual fts tables, then it's not clear to me why Django's converters aren't being called, unless you dropped the type information during creation of the virtual tables. If method #1 does not work, but #2 (using column names) does, that would be interesting to know. It might point to a way Django could alter its sqlite sql to support getting converters called for these tables, but I have no idea how feasible such a change would be. Someone with more ORM/backend experience would have to give an opinion on that. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using email instead of username in extended "User" model?
Oops i mean username, not password. Im not clear on how I can get this to override the django login functionality. Im reading more up on custom auth backends but Ill admit it's a little confusing. Anyone have a finished example of how I can get Django to use email to login (either by making email the username field or some other method), I learn best by example. Cheers, D On Aug 2, 7:33 pm, Dana wrote: > Tried using that but seems to not do what I need. I couldn't get an > email address to save as a password and I am not willing to modify > Django or hack my database to do it just yet. > > On Aug 2, 9:21 am, Darek wrote: > > > tips&tricks: Email addresses for user > > name:http://www.djangosnippets.org/snippets/74/ > > > On Aug 2, 5:38 pm,Dana wrote: > > > > Hello All, > > > > I am looking to create a user model that extends the Auth "User" > > > model, like how James Bennett outlines in his article "Extending the > > > User Model" [1] by creating a FK to the "User" model and everything is > > > going fine other than one issue. > > > > I would like to make "email" become the unique field and not need > > > "username" when creating user accounts. Now, I don't mind using > > > username for the Django admin, but for my own user section on the > > > front end I want people creating accounts/logging in using an email. I > > > am wondering if there is any clear way of doing this without having to > > > roll my own auth app? > > > > I played with the idea of having my "save()" function create a random > > > username when saving but that is obviously an ugly solution. Is there > > > an easier way to do this that I am overlooking? > > > > Thanks for all your time! > > >DanaW > > > > [1]http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django newbie deployment question
Thanks prabhu, Your answer is bang on target. Thanks :). On Aug 2, 4:43 am, prabhu S wrote: > Your apache server would run as www user. Where as you have saved your > project in /root with root as the owner. To do this properly, do not > save your django project in /root. Have it somewhere like /var/www and > make "www" as the owner. Also fix execute permissions. > > chmod -R 700 should do. Or try 744 > > On Aug 1, 11:36 am, Ankur Gupta wrote: > > > Hello folks, > > > I have facing the same problem mentioned in the stackoverflow question > > here > > (http://stackoverflow.com/questions/962533/django-modpython-error-impo... > > ). The solution doesn't seem to work > > > Problem description The app runs fine using django internal server > > however when I use apache + mod_python I get the below error > > > File "/usr/local/lib/python2.6/dist-packages/django/conf/init.py", > > line 75, in init raise ImportError, "Could not import settings > > '%s' (Is it on sys.path? Does it have syntax errors?): %s" % > > (self.SETTINGS_MODULE, e) > > > ImportError: Could not import settings 'settings' (Is it on sys.path? > > Does it have syntax errors?): No module named settings > > > Here is the needed information > > > 1) Project directory: /root/djangoprojects/mysite > > > 2) directory listing of /root/djangoprojects/mysite ls -ltr total 28 - > > rw-r--r-- 1 root root 546 Aug 1 08:34 manage.py -rw-r--r-- 1 root root > > 0 Aug 1 08:34 init.py -rw-r--r-- 1 root root 136 Aug 1 08:35 init.pyc - > > rw-r--r-- 1 root root 2773 Aug 1 08:39 settings.py -rw-r--r-- 1 root > > root 1660 Aug 1 08:53 settings.pyc drwxr-xr-x 2 root root 4096 Aug 1 > > 09:04 polls -rw-r--r-- 1 root root 581 Aug 1 10:06 urls.py -rw-r--r-- > > 1 root root 314 Aug 1 10:07 urls.pyc > > > 3) App directory : /root/djangoprojects/mysite/polls > > > 4) directory listing of /root/djangoprojects/mysite/polls ls -ltr > > total 20 -rw-r--r-- 1 root root 514 Aug 1 08:53 tests.py -rw-r--r-- 1 > > root root 57 Aug 1 08:53 models.py -rw-r--r-- 1 root root 0 Aug 1 > > 08:53 init.py -rw-r--r-- 1 root root 128 Aug 1 09:02 views.py -rw-r-- > > r-- 1 root root 375 Aug 1 09:04 views.pyc -rw-r--r-- 1 root root 132 > > Aug 1 09:04 init.pyc > > > 5) Anywhere in the filesystem running import django in python > > interpreter works fine > > > 6) content of httpd.conf > > > SetHandler python-program PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE settings PythonOption django.root / > > mysite PythonPath "['/root/djangoprojects/', '/root/djangoprojects/ > > mysite','/root/djangoprojects/mysite/polls', '/var/www'] + sys.path" > > PythonDebug On > > > 7) PYTHONPATH variable is set to > > > echo $PYTHONPATH /root/djangoprojects/mysite > > > 8) DJANGO_SETTINGS_MODULE is set to echo $DJANGO_SETTINGS_MODULE > > mysite.settings > > > 9) content of sys.path is > > > import sys > > > sys.path ['', '/root/djangoprojects/mysite', '/usr/lib/ > > python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib- > > tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/ > > usr/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist- > > packages'] > > > How do I add settings location to sys.path such that it persistent > > across sessions ? > > > I have read umpteen no of post with people having the same issue it > > and I have tried a lot completely beats me as to what I need to do. > > > Looking for some help. > > > Thanks in advance Ankur Gupta --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: need help with model design and table relationship
On Sun, 2009-08-02 at 14:08 -0700, Unnamed_Hero wrote: > I have a table with a list of corporations; each corp has a field with > it unique number. > There is a table, filled with people, each record contains a field > with a corp's unique field (where each person works) > > Task: when displaying info about corporation, also fetch info about > people working at. > > Also there are several tables with such relationship with a corp > table. > > So, it seems to be a many-to-many relationship. > > there is come code > > class c12b (models.Model): > id = models.AutoField (primary_key=True) > A15 = models.CharField ('Телетайп', max_length=20, blank= True) > A17 = models.CharField ('Телекс', max_length=20, blank= True) > A19 = models.CharField ('Факс', max_length=40, blank= True) > A34 = models.CharField ('Код промышленности',max_length=5, > blank=True) > A29 = models.CharField ('E-mail', max_length=50, blank=True) > A30 = models.CharField ('Сайт', max_length=40, blank= True) > A3 = models.CharField ( 'ИНН',max_length=10, blank=True) > A21 = models.CharField ('Реквизиты банка' ,max_length=255, > blank=True) > A22 = models.CharField ('Код ОКПО', max_length=8, blank=True ) > #CORP INIQUE KEY > #here I've tried to create a related field > boss = models.ManyToManyField (Dolgnost, db_column="A22", > through='bosses_table') > class Meta: > db_table='C12B' > > class bosses_table (models.Model): > c12b = models.ForeignKey (c12b, to_field="A22") I'm surprised Django didn't raise a validation error here, since c12b.A22 is required to be a unique field in order to be the target of a to_field parameter and you haven't marked it as unique in the above model. > dolgnost = models.ForeignKey (Dolgnost, > to_field="A22",unique=False) > > > #in view.py > ... > result = c12b.objects.filter(A34__exact ="02100") > return render_to_response ("prkp/lista.html", { >"result":result, > ... > #template > {% for i in result %} > > {% for b in i.boss.all %} > {{ b.U1 }} > {% endfor %} > {{ i.boss.U1 }} > > Finally I've got an exeption > Caught an exception while rendering:relation "search_bosses_table" > doesn't exist I would start by removing as many variables from the debugging situation as possible. In particular, instead of debugging this through the template system, use an interactive shell. Work out the exist record in "result" that is causing the problem so that you can narrow things down to the exact piece(s) of data that are causing the problem. There doesn't seem to be anything immediately wrong with your models, although I would put some effort into naming the fields more descriptively ("A34" is hardly easy to debug when it pops up in a traceback). I would also simply make A22 the primary key of the c12b model (and probably the boss model as well, if it's similar) so that you don't even need the intermediate table and can just use a normal ManyToManyField. Generally, if you are using "through" on a ManyToManyField, it would be because the intermediate table contains more than just the two linking fields. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Caching template fragments without specifying expiration time
On Sun, 2009-08-02 at 04:25 -0400, Nick Fishman wrote: > I was wondering if it's possible to not specify the expiration time > when using the {% cache %} tag to cache template fragments. With the > low-level API, cache entries will expire after a timeout configured in > CACHE_BACKEND. Is it possible to use the same default when caching > template fragments? > > In particular, I'd like to use model signals to invalidate cache > entries. That way, entries won't be invalidated after an arbitrary > time period, but rather when they're actually invalid. Nathaniel > Whiteinge wrote on 2008-12-03 that the {% cache %} tag creates entries > with keys "fragment_name:additional:arguments:seperated:by:colons", so > this seems possible. The "cache" template tag always requires a timeout (although the docstring on the function in django.templatetags.cache.do_cache() lies and suggests otherwise). It might not be too difficult to add support for an optional timeout, although the error checking requires a lot of care. So you might want to have a swing at adding this support and open an enhancement ticket with a patch in Trac if you get that far. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template and substitute
On Sat, 2009-08-01 at 19:29 -0700, David wrote: > Hi, > > When I tested sql of MySQL in Python interactive shell, I got an > error of "not enough arguments for format string". I checked the > arguments however I could not find anything wrong. > > Can anybody give me a clue? > > Thanks so much. > > > >>> sql = Template('select dimension1 ,adddate(current_date,-1),current_date, > >>> ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = > >>> adddate(current_date,-1) then ifnull($ss_1,0) end),0) as \'PreviousDay\', > >>> ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = > >>> current_date then ifnull($ss_2,0) end),0) as \'Today\' from > >>> message_alert where dataset_id = $ss_3 and dimension1 in ($ss_4) and > >>> hour(creation_date) = hour(now())-1 group by dimension1 having > >>> (ifnull(sum(case when date_format(creation_date,\'%Y-%m-%d\') = > >>> current_date then ifnull($ss_5,0) end),0) / ifnull(sum(case when > >>> date_format(creation_date,\'%Y-%m-%d\') = adddate(current_date,-1) then > >>> ifnull($ss_6,0) end),0)) $ss_7 $ss_8') > > >>> > >>> sql = sql.substitute(ss_1='metric1', ss_2='metric1', ss_3=2, > >>> ss_4='557796,558069,558230', ss_5='metric1', ss_6='metric1', ss_7='>=', > >>> ss_8=0.05) You seem to be trying to create raw SQL using Django's template system. Please don't do that. It's like trying to use a shovel to hammer in a nail, but less effective. You are also using something other than Django's templating system since django.templates.Template does not have a substitute() method. And Python format markers in strings are things start with "%", not "$", so "ss_1" and friends aren't variables in the string. If you are trying to create raw SQL, write it out as a string and pass the parameters in to the execute() call. Do not substitute them into the string first, since that is the easiest way to introduce SQL injection attacks. If you need more information about how to use cursor.execute(), have a read of PEP 249. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: using the stable api
On Sat, 2009-08-01 at 19:59 +, Faheem Mitha wrote: > Hi Malcolm, > > Thanks for the helpful reply. > > On Sat, 01 Aug 2009 12:24:29 +1000, Malcolm Tredinnick > wrote: > > > On Fri, 2009-07-31 at 11:42 -0400, Faheem Mitha wrote: [...] > >> 3) Get the sessionid. I had to change request.COOKIES['sessionid'] > >> to request.COOKIES[settings.SESSION_COOKIE_NAME] > > > The default value of settings.SESSION_COOKIE_NAME has always (and > > remains) "sessionid". However, it's a little more portable to use > > the latter form (request.COOKIES[settings.SESSION_COOKIE_NAME) in > > your applications, since then they are usable no matter what the > > setting happens to be. A Django application writer is not > > necessarily in control of the settings that will be used when the > > application is installed. > > To summarize, I've changed settings.SESSION_COOKIE_NAME from their > default value, so this breaks request.COOKIES['sessionid'], and in > this case, using request.COOKIES[settings.SESSION_COOKIE_NAME) is > preferable, because it will work no matter what the value of > settings.SESSION_COOKIE_NAME happens to be. Is that a correct summary? Correct. 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 'str' object is not callable
Try to configure url from (r'^(?P[-\w]+)/$', 'coltrane_category_detail'), to (r'^(?P[-\w]+)/$', coltrane_category_detail), But before that, you need to import this function Or give a whole path to the view like (r'^(?P[-\w]+)/$', 'pack_xxx.mod_xxx.coltrane_category_detail'), On Mon, Aug 3, 2009 at 2:00 AM, Dolph wrote: > > hey guys, > > New to django and I'm just working through James Bennett's practical > django projects book, 2nd ed. I'm trying to get the categories section > working in the blog and I'm getting the above error. I've read through > some of the previous posts to try to figure it out, but I can't seem > to figure it out. > > error: > > /usr/lib/python2.5/site-packages/django/core/handlers/base.py in > get_response, line 86 > > categories.py in urls directory: > > from django.conf.urls.defaults import * > > from coltrane.models import Category > > urlpatterns = patterns('', >(r'^$','django.views.generic.list_detail.object_list', >{ 'queryset': Category.objects.all() }), >(r'^(?P[-\w]+)/$', 'coltrane_category_detail'), > ) > > here's my view in coltrane: > > from django.shortcuts import get_object_or_404 > from coltrane.models import Category > from django.views.generic.list_detail import object_list > > def category_detail(request, slug): >category = get_object_or_404(Category, slug=slug) >return object_list(request, queryset=category.entry_set.all(), >extra_context={ 'category': category }) > > the category list works ok and the get_absolute_url is rendering the > correct link, but when I click on the link or attempt to get specific > category details, i.e. "http://127.0.0.1:8000/weblog/categories/ > programming/", I get the above error. > > thanks. > > Eric > > > > -- === Regards Ronghui Yu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using email instead of username in extended "User" model?
Tried using that but seems to not do what I need. I couldn't get an email address to save as a password and I am not willing to modify Django or hack my database to do it just yet. On Aug 2, 9:21 am, Darek wrote: > tips&tricks: Email addresses for user > name:http://www.djangosnippets.org/snippets/74/ > > On Aug 2, 5:38 pm,Dana wrote: > > > Hello All, > > > I am looking to create a user model that extends the Auth "User" > > model, like how James Bennett outlines in his article "Extending the > > User Model" [1] by creating a FK to the "User" model and everything is > > going fine other than one issue. > > > I would like to make "email" become the unique field and not need > > "username" when creating user accounts. Now, I don't mind using > > username for the Django admin, but for my own user section on the > > front end I want people creating accounts/logging in using an email. I > > am wondering if there is any clear way of doing this without having to > > roll my own auth app? > > > I played with the idea of having my "save()" function create a random > > username when saving but that is obviously an ugly solution. Is there > > an easier way to do this that I am overlooking? > > > Thanks for all your time! > >DanaW > > > [1]http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: mysqldb help! Can't connect to MySQL server error...
On Sun, Aug 2, 2009 at 9:16 PM, mdsmoker wrote: > > when running python manage.py syncdb I got the following errors... > > C:\DJANGO~1\mysite>python manage.py syncdb > Traceback (most recent call last): > [snip] super(Connection, self).__init__(*args, **kwargs2) > _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL > server on 'lo > calhost' (10061)") > 10061 is Winsock connection refused. There is no program listening on the port/host you are trying to connect to. > > I have mysqldb 1.2.2 installed w/out errors. I think I'm just missing > something pretty simple. If it helps, this is what my settings.py > looks like... > > DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', > 'postgresql', 'mysql', 'sqlite3' or 'oracle'. > DATABASE_NAME = 'mysitedb' # Or path to database file if > using sqlite3. > DATABASE_USER = 'root' # Not used with sqlite3. > DATABASE_PASSWORD = 'blue33' # Not used with sqlite3. > DATABASE_HOST = '' # Set to empty string for localhost. > Not used with sqlite3. > DATABASE_PORT = '3036' # Set to empty string for default. > Not used with sqlite3. > Why have you specified port 3036? The default MySQL port is 3306, so unless you have configured your server to use this other port, that DATABASE_PORT setting explains the failure to connect. Assuming you have not specially configured your MySQL server to listen on a non-standard port, it's best to just leave DATABASE_PORT empty and let the default one be used automatically. Karen > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using email instead of username in extended "User" model?
Modification of Django code is not really a path I want to take, I'd prefer a cleaner approach, but thanks for the suggestion! On Aug 2, 11:39 am, cootetom wrote: > Another option you have is to modify the User model directly in the > django source code. > > You will need to edit: > django.contrib.auth.models.User > django.contrib.auth.forms.UserCreationForm > django.contrib.auth.forms.AuthenticationForm > > Find the username field and use the forms.EmailField instead. > > On Aug 2, 4:56 pm, David Koblas wrote: > > > Just to add my $0.02 cents to this, I too would like a better way to > > extend django.contrib.auth.models.User than the current approach. The > > two biggest "problems" that I have are: > > > * Everything depends on django.contrib.auth.models.User -- which means > > that while you could swap out your authenticator you still basically > > have to go and rip apart everybody's applications to support your user > > object. > > * To the above point, it also means that to construct your own User > > object means you can't use contrib.admin since it depends on the User > > object. > > > What would be really nice is to have something like: > > django.auth.interface.User > > > Which in turn would instantiate something from settings.USER_MODEL > > (default contrib.auth.modes) this might mean you could subsume > > AUTH_PROFILE_MODULE into the USER_INSTANCE for most developers. Up shot > > is that I can now still use public applications and the admin system, > > but now somebody can just create a "facebook.models.User" class that > > mirrors using facebook as the authenticator and get everything for free... > > > --koblas > > >Danawrote: > > > Hello All, > > > > I am looking to create a user model that extends the Auth "User" > > > model, like how James Bennett outlines in his article "Extending the > > > User Model" [1] by creating a FK to the "User" model and everything is > > > going fine other than one issue. > > > > I would like to make "email" become the unique field and not need > > > "username" when creating user accounts. Now, I don't mind using > > > username for the Django admin, but for my own user section on the > > > front end I want people creating accounts/logging in using an email. I > > > am wondering if there is any clear way of doing this without having to > > > roll my own auth app? > > > > I played with the idea of having my "save()" function create a random > > > username when saving but that is obviously an ugly solution. Is there > > > an easier way to do this that I am overlooking? > > > > Thanks for all your time! > > >DanaW > > > > [1]http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Passing an object between views
And that's it? I guess I've always been afraid of the session due to working on web apps with non-traditional architecture (A web app built entirely in PL/SQL, for example). Thanks for the help. On Aug 2, 9:13 pm, Steve Schwarz wrote: > On Sun, Aug 2, 2009 at 6:58 PM, Jon Renaut wrote: > > > I would like to use a form to collect a billing address, pass this > > address to a new form where I collect credit card info, and then pass > > the whole thing to the credit card processor. The only thing I want > > to save to the database is a shipping address. Is there a best > > practice for doing this? > > Hi, > You might take a look at storing the information in the user's server-side > session when the first form is submitted and then accessing it from the > second > form:http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-htt... > Best Regards, > Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
mysqldb help! Can't connect to MySQL server error...
when running python manage.py syncdb I got the following errors... C:\DJANGO~1\mysite>python manage.py syncdb Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "c:\django-trunk\django\core\management\__init__.py", line 362, in execut e_manager utility.execute() File "c:\django-trunk\django\core\management\__init__.py", line 303, in execut e self.fetch_command(subcommand).run_from_argv(self.argv) File "c:\django-trunk\django\core\management\base.py", line 195, in run_from_a rgv self.execute(*args, **options.__dict__) File "c:\django-trunk\django\core\management\base.py", line 221, in execute self.validate() File "c:\django-trunk\django\core\management\base.py", line 249, in validate num_errors = get_validation_errors(s, app) File "c:\django-trunk\django\core\management\validation.py", line 67, in get_v alidation_errors connection.validation.validate_field(e, opts, f) File "c:\django-trunk\django\db\backends\mysql\validation.py", line 15, in val idate_field db_version = connection.get_server_version() File "c:\django-trunk\django\db\backends\mysql\base.py", line 297, in get_serv er_version self.cursor() File "c:\django-trunk\django\db\backends\__init__.py", line 81, in cursor cursor = self._cursor() File "c:\django-trunk\django\db\backends\mysql\base.py", line 281, in _cursor self.connection = Database.connect(**kwargs) File "C:\Python25\lib\site-packages\MySQLdb\__init__.py", line 74, in Connect return Connection(*args, **kwargs) File "C:\Python25\lib\site-packages\MySQLdb\connections.py", line 170, in __in it__ super(Connection, self).__init__(*args, **kwargs2) _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'lo calhost' (10061)") I have mysqldb 1.2.2 installed w/out errors. I think I'm just missing something pretty simple. If it helps, this is what my settings.py looks like... DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = 'mysitedb' # Or path to database file if using sqlite3. DATABASE_USER = 'root' # Not used with sqlite3. DATABASE_PASSWORD = 'blue33' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '3036' # Set to empty string for default. Not used with sqlite3. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Passing an object between views
On Sun, Aug 2, 2009 at 6:58 PM, Jon Renaut wrote: > > I would like to use a form to collect a billing address, pass this > address to a new form where I collect credit card info, and then pass > the whole thing to the credit card processor. The only thing I want > to save to the database is a shipping address. Is there a best > practice for doing this? Hi, You might take a look at storing the information in the user's server-side session when the first form is submitted and then accessing it from the second form: http://docs.djangoproject.com/en/dev/topics/http/sessions/#topics-http-sessions Best Regards, Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using email instead of username in extended "User" model?
On Sun, Aug 2, 2009 at 11:56 PM, David Koblas wrote: > > Just to add my $0.02 cents to this, I too would like a better way to > extend django.contrib.auth.models.User than the current approach. The > two biggest "problems" that I have are: > > * Everything depends on django.contrib.auth.models.User -- which means > that while you could swap out your authenticator you still basically > have to go and rip apart everybody's applications to support your user > object. > * To the above point, it also means that to construct your own User > object means you can't use contrib.admin since it depends on the User > object. > > What would be really nice is to have something like: > django.auth.interface.User > > Which in turn would instantiate something from settings.USER_MODEL > (default contrib.auth.modes) this might mean you could subsume > AUTH_PROFILE_MODULE into the USER_INSTANCE for most developers. Up shot > is that I can now still use public applications and the admin system, > but now somebody can just create a "facebook.models.User" class that > mirrors using facebook as the authenticator and get everything for free... You aren't the first person to suggest this, and it's something I'm interested in looking at in the v1.2 timeframe. This is a very common question, and one for which Django needs to have a clear and well documented solution. Ticket #3011 has one solution; I'm not completely convinced that the patch on that ticket is the whole solution, though. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Passing an object between views
I would like to use a form to collect a billing address, pass this address to a new form where I collect credit card info, and then pass the whole thing to the credit card processor. The only thing I want to save to the database is a shipping address. Is there a best practice for doing this? Below is pseudo-code for what I'm trying to do: def getAddress(request): if get: show form if post: validate form save if shipping address send to getCCInfo def getCCInfo(request, billingAddress): if get: show form if post: validate form send form results and billingAddress to cc processor redirect to success/fail Any help would be much appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Applications as components
On Sun, Aug 2, 2009 at 10:26 PM, Torsten Bronger wrote: > > Hallöchen! > > My first Django project was a single application. Probably most of > you started this way, with only some other applications shipped with > Django installed on the same site, too. > > However, I now prepare my second Django application which will be > used together with the first one. For me, this is no problem. But > I wonder how to write an application which can be easily integrated > by others into their eco system. > > For example, get_profile() can only be connected with one model per > site. But every application may have its own UserDetails, so > get_profile must actually be considered harmful, unless you know for > sure that your application will never be used somewhere else. Then don't use get_profile(). A User profile is, by definition (and implementation) unique for a given user. If you don't have a unique class or a unique profile, then you don't have a User Profile - you have a model with a foreign key on User. And that's fine. my_user.get_profile() is, at best, a convenience - and not really a big one, either. Beyond the caching benefits (which you can get through other channels if you really need them), it isn't really any better than AppProfile.objects.get(user=my_user). > http://code.djangoproject.com/ticket/3011 has the same problem, > namely that only one application can extend the global > datastructures. #3011 is a separate issue to this, and one that I can sympathize with (or at least, one that I would like to stop being a FAQ). Even if #3011 is fixed, I would imagine that individual apps would continue to have tables that contain app-specific profile data. > I think that patching an application so that it doesn't login > handling anymore (because another app does already) is okay, but for > example substituting all get_profile calls is actually unnecessary. > What do you think? You shouldn't need to patch an application so that it does (or doesn't) do login handling. You should have an application that handles logins, and 2+ separate applications that are appropriately decorated to ensure that users are logged in. This is the essence of re-usable applications. If you have built an application that does authentication/login _and_ something else, then your first port of call is to separate this into two applications. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: howto change FileField value in model.save() ?
Hi, You are on the right track. In your save() method you can change the field values for a FileField object, then save it. See the documentation on overriding model methods for more details. You routine would look something like this: def save(self, force_insert=False, force_update=False): files.upload_to = 'secret_uploads' super(Seed, self).save(force_insert, force_update) # Call the "real" save() method. return Hope this helps, Carol Hatcher On Jul 31, 9:58 pm, Shuge Lee wrote: > Take a look here > > http://dpaste.com/73953/ > > or following > > # in models.py > > class Seed(models.Model): > name = models.CharField(max_length=128) > > UPLOAD_ROOT = 'uploads' > files = models.FileField(upload_to=UPLOAD_ROOT, blank=True, > null=True) > source = models.CharField(max_length=256, blank=True, null=True) > > def save(self, force_insert=False, force_update=False): > # I want to change self.files here > # how to do it ? > > Thanks for reply. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
app __init.py__ question
Hi all, I have both a project and an app I just created (using django-admin). I modified the __init.py__ file in the app to execute a print statement on import. But it gets executed twice when I start the development server. Oddly, it doesn't happen when I set USE_I18N = False in the settings file. I'm new to python and django, so I'm not sure what to make of this behavior. Is is normal? My understanding of python is that I would expect the print statement to only execute once, but perhaps I don't understand. Any help in understanding greatly appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
HELP! pysqlite2 FTS3 and datetime not returning datetime
Hi, I'm using Django 1.0 and 1.1, pysqlite2 (latest version), sqlite3 (latest version) and FTS3 (latest version). I'm creating some Django models where I recreate the database tables as virtual tables using FTS3 so that we can do full text search. Some of the fields in the tables are datetime fields. We preload the database tables by reading datafiles, building the appropriate Django models and saving them using the the models.save() method. The datetime fields go into the database as datetime objects but they come back out (called with objects.get(pk=)) as unicode strings. Integer and string data go in and come out fine. I don't see the database adapter/converter invoked. ( I put a print statement into the code) If I don't recreate the tables as virtual tables using FTS3, everything works fine. I see the database adapter/converter invoked. Does anyone know what might be going wrong here? Thanks in advance, Carol Hatcher --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django RSS Feeds with adsense
2009/7/9 Juanjux (Google) : > > I don't know the answer to your specific question but you could make a > feedburner RSS from it. Then you can insert adsense for feeds on it > with just a click on adsense settings (it's all integrated.) I'm using feedburner but with another account. I cannot move the feed because I've a lot of members who have subscribed the feed by email. So my only chance is to add the adsense code to django feeds, but I don't know how because it pass the code to a safe filter and that disable my script. -- Alessandro Ronchi SOASI Sviluppo Software e Sistemi Open Source http://www.soasi.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: psycopyg setup error: no build_ext
From that bash interaction I can assume you are running os x. The absolutely easiest way to install postgresql and psycopg2 on os x is with postgresplus. These links may help if you decide to go down that path: http://www.enterprisedb.com/products/postgres_plus/overview.do http://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/ Matt Hampel wrote: > Setting the pg_config path got me to the next stage of errors, which > is a step forward. Thanks! > > Now I get a permission denied error without any more information or > context. > Any suggestions? > > What I tried: > > matth:psycopg2-2.0.11 matth$ python setup.py build > running build > running build_py > running build_ext > error: Permission denied > matth:psycopg2-2.0.11 matth$ sudo python setup.py build > Password: > running build > running build_py > running build_ext > error: Permission denied > > > > On Jul 19, 12:20 am, walty wrote: > >> thx, it solves my problem (psycopg2-2.0.11 on OSX) right away :) >> >> just drop a few more words: >> if installed the postgresql 8.4 using mac binary, the line of >> configuration (inside setup.cfg) should be: >> pg_config=/Library/PostgreSQL/8.4/bin/pg_config >> >> On Jul 7, 6:17 am, Justin Johnson wrote: >> >> >>> I corrected the build_ext error and successfully built/installed by >>> adding the full path to pg_config in setup.cfg. >>> >>> On Jun 23, 10:19 am, Chris Haynes wrote: >>> Using what I believe is the latest version of psycopyg, I get: 509 ~/Desktop/psycopg2-2.0.9$ python setup.py build running build running build_py creating build creating build/lib.macosx-10.3-fat-2.6 creating build/lib.macosx-10.3-fat-2.6/psycopg2 copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 runningbuild_ext error: No such file or directory and easy_install doesn't work either (seems like the same problem): 510 ~/Desktop/psycopg2-2.0.9$ easy_install . Processing . Running setup.py -q bdist_egg --dist-dir /Users/home/Desktop/ psycopg2-2.0.9/egg-dist-tmp-mYsMSq error: Setup script exited with error: No such file or directory > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django on Hostmonster shared hosting
On Aug 2, 8:10 pm, Tim wrote: > Hello > > I have been trying to get Django working with Hostmonster.com shared > webhosting with FCGI. > > From what I gather from the HM forums, this is possible, but I've been > hitting some issues. > > I've installed Python 2.6.2 in my home directory, and by all accounts, > its working. > > I've downloaded Django from SVN (revision 11375) > > If I create a project, and an app, I can run it by > > >> ~/local/bin/python manage.py runserver > > This gives me a server running at 127.0.0.1:8000 .. which I can get > to if I telnet locally (lynx is b0rked, dunno why, not really part of > this problem here). > > Configure the FCGI app, and .htaccess, as described > athttp://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#runnin... > and elaborated on > athttp://www.hostmonsterforum.com/showpost.php?p=15030&postcount=4, > I can get it to generate an internal exception. > > Run the fgci script at a shell, and I get: > timat...@host280:~/public_html/django$ ./mysite.fcgi > WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! > WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! > WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! > WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! > Traceback (most recent call last): > File "/home2/timatlee/local/lib/python2.6/site-packages/ > flup-1.0.3.dev_20090716-py2.6.egg/flup/server/fcgi_base.py", line 558, > in run > protocolStatus, appStatus = self.server.handler(self) > File "/home2/timatlee/local/lib/python2.6/site-packages/ > flup-1.0.3.dev_20090716-py2.6.egg/flup/server/fcgi_base.py", line > 1118, in handler > result = self.application(environ, start_response) > File "/home2/timatlee/djtrunk/django/core/handlers/wsgi.py", line > 230, in __call__ > self.load_middleware() > File "/home2/timatlee/djtrunk/django/core/handlers/base.py", line > 33, in load_middleware > for middleware_path in settings.MIDDLEWARE_CLASSES: > File "/home2/timatlee/djtrunk/django/utils/functional.py", line 269, > in __getattr__ > self._setup() > File "/home2/timatlee/djtrunk/django/conf/__init__.py", line 40, in > _setup > self._wrapped = Settings(settings_module) > File "/home2/timatlee/djtrunk/django/conf/__init__.py", line 75, in > __init__ > raise ImportError, "Could not import settings '%s' (Is it on > sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, > e) > ImportError: Could not import settings 'myproject.settings' (Is it on > sys.path? Does it have syntax errors?): No module named > myproject.settings > > .. which is to say, it fails just the same as if I went to the > website. > > mysite.fcgi looks like: > #!/home2/timatlee/local/bin/python > import sys, os > > # Add a custom Python path. > # sys.path.insert(0, "/home/user/python") > sys.path.insert(0, "/home2/timatlee/local/bin/python") > sys.path.insert(0, "/home2/timatlee/local/lib/python2.6/site-packages/ > flup-1.0.3.dev_20090716-py2.6.egg") > sys.path.insert(0, "/home2/timatlee/local/lib/python2.6") > sys.path.insert(0, "/home2/timatlee/djcode") > sys.path.insert(0, "/home2/timatlee/djcode/mysite") > sys.path.insert(0, "/home2/timatlee/djtrunk") > > # Switch to the directory of your project. (Optional.) > os.chdir("/home2/timatlee/djcode/mysite") > > # Set the DJANGO_SETTINGS_MODULE environment variable. > os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings" > > from django.core.servers.fastcgi import runfastcgi > runfastcgi(method="threaded", daemonize="false") > > myproject.settings exists in /home2/timatlee/djcode/mysite, which from > what I can tell is on the path. > > If I set os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings" > to be the absolute path of the file, I get the following as an error: > ImportError: Could not import settings '/home2/timatlee/djcode/mysite/ > myproject.settings' (Is it on sys.path? Does it have syntax errors?): > Import by filename is not supported. > > So if I truncate myproject.settings, I see no change. If I make > myproject.settings a copy of settings.py (which is what I thought this > file was supposed to be), I'm at where I am right now. > > I'm sure it's something plainly obvious, but I've overlooked... > > Any help would be appreciated. > > Thanks! Maybe a silly question, but you keep talking about 'myproject.settings' - do you mean this is what you've called the file? That won't work at all. The settings should be called settings.py, you don't need to copy/rename it. In the documentation, 'myproject.settings' refers to the settings.py file in the myproject module/directory. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this
Re: psycopyg setup error: no build_ext
Setting the pg_config path got me to the next stage of errors, which is a step forward. Thanks! Now I get a permission denied error without any more information or context. Any suggestions? What I tried: matth:psycopg2-2.0.11 matth$ python setup.py build running build running build_py running build_ext error: Permission denied matth:psycopg2-2.0.11 matth$ sudo python setup.py build Password: running build running build_py running build_ext error: Permission denied On Jul 19, 12:20 am, walty wrote: > thx, it solves my problem (psycopg2-2.0.11 on OSX) right away :) > > just drop a few more words: > if installed the postgresql 8.4 using mac binary, the line of > configuration (inside setup.cfg) should be: > pg_config=/Library/PostgreSQL/8.4/bin/pg_config > > On Jul 7, 6:17 am, Justin Johnson wrote: > > > I corrected the build_ext error and successfully built/installed by > > adding the full path to pg_config in setup.cfg. > > > On Jun 23, 10:19 am, Chris Haynes wrote: > > > > Using what I believe is the latest version of psycopyg, I get: > > > > 509 ~/Desktop/psycopg2-2.0.9$ python setup.py build > > > running build > > > running build_py > > > creating build > > > creating build/lib.macosx-10.3-fat-2.6 > > > creating build/lib.macosx-10.3-fat-2.6/psycopg2 > > > copying lib/__init__.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 > > > copying lib/errorcodes.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 > > > copying lib/extensions.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 > > > copying lib/extras.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 > > > copying lib/pool.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 > > > copying lib/psycopg1.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 > > > copying lib/tz.py -> build/lib.macosx-10.3-fat-2.6/psycopg2 > > > runningbuild_ext > > > error: No such file or directory > > > > and easy_install doesn't work either (seems like the same problem): > > > > 510 ~/Desktop/psycopg2-2.0.9$ easy_install . > > > Processing . > > > Running setup.py -q bdist_egg --dist-dir /Users/home/Desktop/ > > > psycopg2-2.0.9/egg-dist-tmp-mYsMSq > > > error: Setup script exited with error: No such file or directory --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
newbie tutorial part 1 startproject doesn't create folder and appropriate files
I'm using django 1.1, python 2.5, and windows and i'm brand-spanking new to this. i installed django w/out a problem. python is in my windows path and if i type import django after running python i don't get any errors so I'm assuming it is installed correctly. after i run django-admin.py startproject mysite i don't get any errors and i also don't get any results :( no new folder or project files were created. any suggestions? i can't believe i can't get through the very first step in the tutorial! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
need help with model design and table relationship
I have a table with a list of corporations; each corp has a field with it unique number. There is a table, filled with people, each record contains a field with a corp's unique field (where each person works) Task: when displaying info about corporation, also fetch info about people working at. Also there are several tables with such relationship with a corp table. So, it seems to be a many-to-many relationship. there is come code class c12b (models.Model): id = models.AutoField (primary_key=True) A15 = models.CharField ('Телетайп', max_length=20, blank= True) A17 = models.CharField ('Телекс', max_length=20, blank= True) A19 = models.CharField ('Факс', max_length=40, blank= True) A34 = models.CharField ('Код промышленности',max_length=5, blank=True) A29 = models.CharField ('E-mail', max_length=50, blank=True) A30 = models.CharField ('Сайт', max_length=40, blank= True) A3 = models.CharField ( 'ИНН',max_length=10, blank=True) A21 = models.CharField ('Реквизиты банка' ,max_length=255, blank=True) A22 = models.CharField ('Код ОКПО', max_length=8, blank=True ) #CORP INIQUE KEY #here I've tried to create a related field boss = models.ManyToManyField (Dolgnost, db_column="A22", through='bosses_table') class Meta: db_table='C12B' class bosses_table (models.Model): c12b = models.ForeignKey (c12b, to_field="A22") dolgnost = models.ForeignKey (Dolgnost, to_field="A22",unique=False) #in view.py ... result = c12b.objects.filter(A34__exact ="02100") return render_to_response ("prkp/lista.html", { "result":result, ... #template {% for i in result %} {% for b in i.boss.all %} {{ b.U1 }} {% endfor %} {{ i.boss.U1 }} Finally I've got an exeption Caught an exception while rendering:relation "search_bosses_table" doesn't exist syncdb says psycop2.ProgrammingError: there is no unique constaint mathing given keys for reference table "C12B" Please, show me a right way (I'm thinking of creating my manager with a raw sql for this) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django-tel new features
Hi everyone, django-tel is an app that helps you make "click-to-call" URLs in your mobile web apps. More details are on its github page: http://github.com/hilomath/django-tel/tree/master Since its initial announcement here a few weeks ago, a template tag named "telify" has been added. telify will find all phone numbers in a block of text and transform them into "tel:" hyperlinks. So your template can include something like this: {{{ {% load tel %} {% telify %}Call 800-555-1212 to get your free gift today! (Not 866-555-1212, that is something else entirely.){% endtelify %} }}} ...which will finally produce an HTML response like this: {{{ Call 800-555-1212 today! (Not 866-555-1212, that is something else entirely.) }}} I have not tagged any version yet. But what's up there now will be very close to the official 1.0 version to be released soon. License is GPL version 3. Hope you find this of value. Please let me know of any comments, bug reports or feature requests. Cheers, Aaron -- Aaron Maxwell Hilomath - Mobile Web Development http://hilomath.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: subclassed ModelForms initial values behavior changed from 1.1beta to 1.1
It looks like the change happened between rev. 10189 & 10190: 10189 displays the value, 10190 doesn't. Unfortunately, I don't think I can give you a completely unbiased answer as to what behavior I think is more correct, because of history and personal use :) With that out on the table, though, it seems to me that if you are using a model form, and you're initializing it with a model instance, and that model instance has a current value for a field on your form, the form ought to get initialized with that value, regardless of whether or not you plan on eventually saving the field in the database or not. If you're going to display it, it ought to reflect what's currently in the database. I think I've read some stuff about eventually making 'read only' forms, or marking fields on a form as 'read only', which seems like it could tie into this somehow, eventually, maybe. If you agree with that, though, then currently both ModelForms & ModelFormsets initialization is broken, because neither fills in the values. - D On Aug 2, 6:24 am, Russell Keith-Magee wrote: > On Sun, Aug 2, 2009 at 12:58 PM, David Haas wrote: > > > Ramiro: > > > I've set up some models / forms / formsets which demonstrate the > > change here: > > >http://dpaste.de/YhrI/ > > > My initial report wasn't correct - the change in behavior is only seen > > when initalizing ModelFormSets . . . the ModelForm behavior is > > unchanged. With a formset, the value use to get initialized; now it > > doesn't. With a form, the value has never gotten initialized. > > > I think 1.1 & 1.0.3 have the same behavior (no initialization in > > formsets); and SVN 10132 (1.1 beta) & 1.0.2 have the same behavior > > (initialization in formsets). > > Hi David, > > Thanks for this report. I'll have to dig a bit deeper to see exactly > what is going on here. If you want to help out, working out which > changeset between 10132 (beta 1) and 11365 (1.1 final) introduced this > discrepancy would be extremely helpful. > > I'd also be interested to hear which behaviour - history and personal > uses notwithstanding - you think is correct. On first inspection, I'm > not completely convinced that the 'new' behaviour is actually > incorrect - or, at least, that there might be a larger bug lurking > here with regard to the interpretation of inherited Meta.field > arguments. However, this is entirely based on first impressions, late > at night, with a mild headache, so I could be completely off base. > > Yours > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template links when Django not domain root
Thanks. I'm not trying to jump the solution. I'm not the server admin and I have to wait until the weekend is over to get that information from them and I will definitely post it. I was simply asking a question. Trying to come up with a template contexts SITE_URL property isn't an out of bounds question, most templating engines use something like this and just asking the question isnt' a hack. It's just a question. On Aug 1, 6:54 pm, Graham Dumpleton wrote: > Hacks which embed knowledge of the mount point in the application > generally indicate that you are doing something wrong in your > configuration. > > Stop trying to jump to solutions when hasn't even been determined what > you are doing wrong. > > As suggested, post the mod_wsgi configuration you are using so can > confirm that for starters, that that isn't the problem. > > Graham > > On Aug 2, 3:40 am, Streamweaver wrote: > > > Thanks for the great replies here. > > > It seems from this there might be less repetition if I can just put a > > SITE_URL attribute in my settings.py file and then make that available > > to the template without having to go through the view. Is this > > possible or easy? Custom template filter perhaps but these seem > > pretty complicated and more intended to work like decorators than just > > pushing variables to the template. Hmmm, not sure. > > > On Jul 31, 1:42 pm, Adam Yee wrote: > > > > On Jul 30, 7:29 pm, Graham Dumpleton > > > wrote: > > > > > If you are using mod_wsgi then you definitely do not need > > > > FORCE_SCRIPT_NAME as mod_wsgi does the correct think in respect of > > > > setting up SCRIPT_NAME/PATH_INFO. The only time it might not be right > > > > with mod_wsgi is if you used WSGIScriptAliasMatch to map the > > > > application and you didn't set up the directive properly. This can > > > > happen because how you set up pattern and target for that directive > > > > will control how SCRIPT_NAME is calculated. WSGIScriptAliasMatch > > > > should only be used if absolutely required. > > > > > So, post how you configured mod_wsgi to mount your application just to > > > > eliminate that as possibility. Verify that FORCE_SCRIPT_NAME isn't set > > > > in settings.py or if it is that it is set to None. > > > > > Someone with more Django knowledge would then need to tell you if you > > > > are specifying urls.py correctly, whether any other settings you need > > > > to check and whether how URL references are generated are correct. All > > > > I can tell you is that if mod_wsgi is set up properly, you should > > > > never need FORCE_SCRIPT_NAME with mod_wsgi. > > > > > You may need to explain better what is meant by 'This is causing all > > > > my template links to break'. Ie., what errors are you getting, what > > > > are the URLs it is generating and what they should be etc. > > > > > Graham > > > > > On Jul 31, 12:09 pm, Streamweaver wrote: > > > > > > I'm not actually using {% url %} at this time. I am setup for > > > > > mod_wsgi and don't know how to go about configuring links in the > > > > > templates when the sites root is on a subdirectory. There isn't much > > > > > in the way of examples on FORCE_SCRIPT_NAME I can find and I'm not > > > > > really an apache admin so I'm a bit out of my depth here. > > > > > > Is this the avenue I should be pursuing or is there some way to set > > > > > this up better. the url filter seems to violate DRY methodology. > > > > > > Thanks again. > > > > > > On Jul 30, 9:52 pm, Graham Dumpleton > > > > > wrote: > > > > > > > Using FORCE_SCRIPT_NAME is only appropriate for certain WSGI hosting > > > > > > mechanisms. Using it may simply hide the fact that the OPs > > > > > > application > > > > > > code is wrong to begin with. > > > > > > > OP should indicate how they are hosting their application for real > > > > > > site. Ie., mod_python, mod_wsgi, fastcgi or other. > > > > > > > Graham > > > > Graham is right about needing to mount your site correctly. Post your > > > Apache config athttp://groups.google.com/group/modwsgi?hl=enandthey > > > can help with that. I've not had to use FORCE_SCRIPT_NAME when using > > > mod_wsgi. What I found that works is passing the script_name in each > > > view context. This is violating DRY, but I haven't worried about that > > > too much. This is a way to make apps portable. If you still need or > > > want to use the {% url %} tag, you just need to preceed it by a > > > {{ script_name }} (I'm mostly sure, correct me if wrong). You can > > > give script_name to your context with request.META['SCRIPT_NAME'] if > > > it exists. > > > > hope this helps, > > > Adam > > > > > > > On Jul 31, 6:04 am, Alex Koshelev wrote: > > > > > > > > If you are using `{% url %}` template tag or `reverse` function > > > > > > > you can set > > > > > > > FORCE_SCRIPT_NAME [1] settings variable specified for your > > > > > > > deployment > > > > > > > project root. Or working with right web-server in front of django > > > > > > > pr
Re: Is it possible to combine these two queries?
Thanks Tim. Your reply is quite helpful. On Jul 30, 6:25 pm, Tim Chase wrote: > > al_1 = Alert.objects.filter(creation_date__regex=today).values > > ('dimension1').annotate(Sum('metric1')).order_by('dimension1') > > > and > > > al_2 = Alert.objects.filter(creation_date__regex=yesterday).values > > ('dimension1').annotate(Sum('metric1')).order_by('dimension1') > > > They are almost the same except that al_1 is for today's data and al_2 > > is for yesterday's data. They summarize data in column "metric1" that > > is grouped and ordered by "dimension1". > > > Sample data from al_1: > > > [{'metric1__sum': 0.0, 'dimension1': u'1'}, {'metric1__sum': 14.0, > [snip] > > What I need to do is to find a ratio value for each "dimension1" > > between its today's value and yesterday's value. For example, for > > dimension1 = '110085', I need to find 2758.0 / 2658.0 = 1.04. > > Then I compare this value "1.04" with a threshold and process > > further. > > You can do something like > > >>> map1 = dict((d['dimension1'], d['metric1__sum']) for d in al_1) > >>> map2 = dict((d['dimension1'], d['metric1__sum']) for d in al_2) > >>> ratios = [(dim, metric/map2[dim]) for dim, metric in > map1.iteritems() if map2.get(dim, 0) != 0] > >>> results = [(dim, ratio) for dim, ratio in ratios if ratio >= > threshold] > > It may lose ordering if that is significant (dicts aren't ordered > by default), and skips over those where there are problems (items > don't exist in the opposite map, or the previous value was 0 > making for a divide-by-zero problem). > > Things might change a little depending on what you'd expect on > those edge cases (dim in a1 but not in a2; dim in a2 but not in > a1; a2.metric = 0) > > -tim- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django on Hostmonster shared hosting
Hello I have been trying to get Django working with Hostmonster.com shared webhosting with FCGI. >From what I gather from the HM forums, this is possible, but I've been hitting some issues. I've installed Python 2.6.2 in my home directory, and by all accounts, its working. I've downloaded Django from SVN (revision 11375) If I create a project, and an app, I can run it by >> ~/local/bin/python manage.py runserver This gives me a server running at 127.0.0.1:8000 .. which I can get to if I telnet locally (lynx is b0rked, dunno why, not really part of this problem here). Configure the FCGI app, and .htaccess, as described at http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache and elaborated on at http://www.hostmonsterforum.com/showpost.php?p=15030&postcount=4, I can get it to generate an internal exception. Run the fgci script at a shell, and I get: timat...@host280:~/public_html/django$ ./mysite.fcgi WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! Traceback (most recent call last): File "/home2/timatlee/local/lib/python2.6/site-packages/ flup-1.0.3.dev_20090716-py2.6.egg/flup/server/fcgi_base.py", line 558, in run protocolStatus, appStatus = self.server.handler(self) File "/home2/timatlee/local/lib/python2.6/site-packages/ flup-1.0.3.dev_20090716-py2.6.egg/flup/server/fcgi_base.py", line 1118, in handler result = self.application(environ, start_response) File "/home2/timatlee/djtrunk/django/core/handlers/wsgi.py", line 230, in __call__ self.load_middleware() File "/home2/timatlee/djtrunk/django/core/handlers/base.py", line 33, in load_middleware for middleware_path in settings.MIDDLEWARE_CLASSES: File "/home2/timatlee/djtrunk/django/utils/functional.py", line 269, in __getattr__ self._setup() File "/home2/timatlee/djtrunk/django/conf/__init__.py", line 40, in _setup self._wrapped = Settings(settings_module) File "/home2/timatlee/djtrunk/django/conf/__init__.py", line 75, in __init__ raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) ImportError: Could not import settings 'myproject.settings' (Is it on sys.path? Does it have syntax errors?): No module named myproject.settings .. which is to say, it fails just the same as if I went to the website. mysite.fcgi looks like: #!/home2/timatlee/local/bin/python import sys, os # Add a custom Python path. # sys.path.insert(0, "/home/user/python") sys.path.insert(0, "/home2/timatlee/local/bin/python") sys.path.insert(0, "/home2/timatlee/local/lib/python2.6/site-packages/ flup-1.0.3.dev_20090716-py2.6.egg") sys.path.insert(0, "/home2/timatlee/local/lib/python2.6") sys.path.insert(0, "/home2/timatlee/djcode") sys.path.insert(0, "/home2/timatlee/djcode/mysite") sys.path.insert(0, "/home2/timatlee/djtrunk") # Switch to the directory of your project. (Optional.) os.chdir("/home2/timatlee/djcode/mysite") # Set the DJANGO_SETTINGS_MODULE environment variable. os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings" from django.core.servers.fastcgi import runfastcgi runfastcgi(method="threaded", daemonize="false") myproject.settings exists in /home2/timatlee/djcode/mysite, which from what I can tell is on the path. If I set os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings" to be the absolute path of the file, I get the following as an error: ImportError: Could not import settings '/home2/timatlee/djcode/mysite/ myproject.settings' (Is it on sys.path? Does it have syntax errors?): Import by filename is not supported. So if I truncate myproject.settings, I see no change. If I make myproject.settings a copy of settings.py (which is what I thought this file was supposed to be), I'm at where I am right now. I'm sure it's something plainly obvious, but I've overlooked... Any help would be appreciated. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template Architecture: how to render template using several apps?
On Aug 2, 7:35 am, aleph wrote: > Hi! > > My questions is about "the right way to do it" in Django: I have a > simple message board with two columns: news on the left, the board > itself (input form and messages list) on the right. In fact, this are > two different applications presented in one page. It seems natural to > have a template with on the left and > on the right and some elegant way to direct the output of > corresponding apps into these two placeholders. > > Of course, it can be done with simple AJAX trick, but what confuses me > a lot here is that I can't find a simple server-side way to do it in > Django - only template inheritence and those block which are not what > I need I suppose. > > In general, it seems to me that Django doesn't want you to think about > page as of set of independent rectangular areas with independent > rendering and behaviour (call the components or widgets, whatever) and > it seems very strange because at first this is the common way to think > about it in UI programming (compare with Mason e.g.) and at the second > jango has this beautifull apps concept that maps so great on the idea > of UI components. > > Can you correct me and whats your ideas about it?... > > regardz, > Ilya. On the contrary, Django has excellent support for this - I don't know why your searches failed to turn anything up. The answer of course is to use template tags. The standard reference on this is James Bennett's excellent post: http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-template-tags/ (although it's slightly out of date as there are now some helpful decorators to take away some of the boilerplate code, see the normal documentation). -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using email instead of username in extended "User" model?
Another option you have is to modify the User model directly in the django source code. You will need to edit: django.contrib.auth.models.User django.contrib.auth.forms.UserCreationForm django.contrib.auth.forms.AuthenticationForm Find the username field and use the forms.EmailField instead. On Aug 2, 4:56 pm, David Koblas wrote: > Just to add my $0.02 cents to this, I too would like a better way to > extend django.contrib.auth.models.User than the current approach. The > two biggest "problems" that I have are: > > * Everything depends on django.contrib.auth.models.User -- which means > that while you could swap out your authenticator you still basically > have to go and rip apart everybody's applications to support your user > object. > * To the above point, it also means that to construct your own User > object means you can't use contrib.admin since it depends on the User > object. > > What would be really nice is to have something like: > django.auth.interface.User > > Which in turn would instantiate something from settings.USER_MODEL > (default contrib.auth.modes) this might mean you could subsume > AUTH_PROFILE_MODULE into the USER_INSTANCE for most developers. Up shot > is that I can now still use public applications and the admin system, > but now somebody can just create a "facebook.models.User" class that > mirrors using facebook as the authenticator and get everything for free... > > --koblas > > Dana wrote: > > Hello All, > > > I am looking to create a user model that extends the Auth "User" > > model, like how James Bennett outlines in his article "Extending the > > User Model" [1] by creating a FK to the "User" model and everything is > > going fine other than one issue. > > > I would like to make "email" become the unique field and not need > > "username" when creating user accounts. Now, I don't mind using > > username for the Django admin, but for my own user section on the > > front end I want people creating accounts/logging in using an email. I > > am wondering if there is any clear way of doing this without having to > > roll my own auth app? > > > I played with the idea of having my "save()" function create a random > > username when saving but that is obviously an ugly solution. Is there > > an easier way to do this that I am overlooking? > > > Thanks for all your time! > > Dana W > > > [1]http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
'str' object is not callable
hey guys, New to django and I'm just working through James Bennett's practical django projects book, 2nd ed. I'm trying to get the categories section working in the blog and I'm getting the above error. I've read through some of the previous posts to try to figure it out, but I can't seem to figure it out. error: /usr/lib/python2.5/site-packages/django/core/handlers/base.py in get_response, line 86 categories.py in urls directory: from django.conf.urls.defaults import * from coltrane.models import Category urlpatterns = patterns('', (r'^$','django.views.generic.list_detail.object_list', { 'queryset': Category.objects.all() }), (r'^(?P[-\w]+)/$', 'coltrane_category_detail'), ) here's my view in coltrane: from django.shortcuts import get_object_or_404 from coltrane.models import Category from django.views.generic.list_detail import object_list def category_detail(request, slug): category = get_object_or_404(Category, slug=slug) return object_list(request, queryset=category.entry_set.all(), extra_context={ 'category': category }) the category list works ok and the get_absolute_url is rendering the correct link, but when I click on the link or attempt to get specific category details, i.e. "http://127.0.0.1:8000/weblog/categories/ programming/", I get the above error. thanks. Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Can i add initial admin user?
Hi, Try to use 'southdb' for better management. http://south.aeracode.org/wiki/Tutorial cheers On Aug 1, 9:38 am, Mirat Can Bayrak wrote: > i am playing a lot with my models in my project nowadays. On every change i > am deleting my sqlite3 file and running syncdb again.. its ok but creating a > admin user in every syncdb is booored me. is there any way to give django a > inital user with username : admin, and pass : admin ? > > -- > Mirat Can Bayrak --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using email instead of username in extended "User" model?
tips&tricks: Email addresses for user name: http://www.djangosnippets.org/snippets/74/ On Aug 2, 5:38 pm, Dana wrote: > Hello All, > > I am looking to create a user model that extends the Auth "User" > model, like how James Bennett outlines in his article "Extending the > User Model" [1] by creating a FK to the "User" model and everything is > going fine other than one issue. > > I would like to make "email" become the unique field and not need > "username" when creating user accounts. Now, I don't mind using > username for the Django admin, but for my own user section on the > front end I want people creating accounts/logging in using an email. I > am wondering if there is any clear way of doing this without having to > roll my own auth app? > > I played with the idea of having my "save()" function create a random > username when saving but that is obviously an ugly solution. Is there > an easier way to do this that I am overlooking? > > Thanks for all your time! > Dana W > > [1]http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using email instead of username in extended "User" model?
Just to add my $0.02 cents to this, I too would like a better way to extend django.contrib.auth.models.User than the current approach. The two biggest "problems" that I have are: * Everything depends on django.contrib.auth.models.User -- which means that while you could swap out your authenticator you still basically have to go and rip apart everybody's applications to support your user object. * To the above point, it also means that to construct your own User object means you can't use contrib.admin since it depends on the User object. What would be really nice is to have something like: django.auth.interface.User Which in turn would instantiate something from settings.USER_MODEL (default contrib.auth.modes) this might mean you could subsume AUTH_PROFILE_MODULE into the USER_INSTANCE for most developers. Up shot is that I can now still use public applications and the admin system, but now somebody can just create a "facebook.models.User" class that mirrors using facebook as the authenticator and get everything for free... --koblas Dana wrote: > Hello All, > > I am looking to create a user model that extends the Auth "User" > model, like how James Bennett outlines in his article "Extending the > User Model" [1] by creating a FK to the "User" model and everything is > going fine other than one issue. > > I would like to make "email" become the unique field and not need > "username" when creating user accounts. Now, I don't mind using > username for the Django admin, but for my own user section on the > front end I want people creating accounts/logging in using an email. I > am wondering if there is any clear way of doing this without having to > roll my own auth app? > > I played with the idea of having my "save()" function create a random > username when saving but that is obviously an ugly solution. Is there > an easier way to do this that I am overlooking? > > Thanks for all your time! > Dana W > > [1] http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using email instead of username in extended "User" model?
Hello All, I am looking to create a user model that extends the Auth "User" model, like how James Bennett outlines in his article "Extending the User Model" [1] by creating a FK to the "User" model and everything is going fine other than one issue. I would like to make "email" become the unique field and not need "username" when creating user accounts. Now, I don't mind using username for the Django admin, but for my own user section on the front end I want people creating accounts/logging in using an email. I am wondering if there is any clear way of doing this without having to roll my own auth app? I played with the idea of having my "save()" function create a random username when saving but that is obviously an ugly solution. Is there an easier way to do this that I am overlooking? Thanks for all your time! Dana W [1] http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django formwizard as a context processor?
Has anyone tried to make a FormWizard form (multiple stage form) work across a whole site as a context process? I'm looking at attempting this - have done a context process & a formwizard form, but never tried to 'cross the streams' like this before. In particular, I'll be taking code from forms.py like this: class ComparisonForm1(forms.Form): type_of_cover = forms.ChoiceField(choices=TYPE_CHOICES) smoker = forms.ChoiceField(choices=SMOKE_CHOICES) title = forms.ChoiceField(choices=TITLE_CHOICES) first_name = forms.CharField(max_length=100) surname = forms.CharField(max_length=100) contact_telephone = forms.IntegerField() alternative_telephone = forms.IntegerField(required=False) email_address = forms.EmailField() address_line_one = forms.CharField(max_length=100) postcode = forms.CharField(max_length=100) #Second Form """ class ComparisonForm1(forms.Form): message = forms.CharField(widget=forms.Textarea) """ #Form Wizard to glue the above forms together. See: http://docs.djangoproject.com/en/1.0/ref/contrib/formtools/form-wizard/ from django.http import HttpResponseRedirect from django.contrib.formtools.wizard import FormWizard class CompareWizard(FormWizard): def done(self, request, form_list): # do_something_with_the_form_data(form_list) return HttpResponseRedirect('/compare/thanks/') And migrating to a context pulling an html snippet across the site. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Applications as components
Hallöchen! My first Django project was a single application. Probably most of you started this way, with only some other applications shipped with Django installed on the same site, too. However, I now prepare my second Django application which will be used together with the first one. For me, this is no problem. But I wonder how to write an application which can be easily integrated by others into their eco system. For example, get_profile() can only be connected with one model per site. But every application may have its own UserDetails, so get_profile must actually be considered harmful, unless you know for sure that your application will never be used somewhere else. http://code.djangoproject.com/ticket/3011 has the same problem, namely that only one application can extend the global datastructures. I think that patching an application so that it doesn't login handling anymore (because another app does already) is okay, but for example substituting all get_profile calls is actually unnecessary. What do you think? Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: torsten.bron...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: subclassed ModelForms initial values behavior changed from 1.1beta to 1.1
On Sun, Aug 2, 2009 at 12:58 PM, David Haas wrote: > > Ramiro: > > I've set up some models / forms / formsets which demonstrate the > change here: > > http://dpaste.de/YhrI/ > > My initial report wasn't correct - the change in behavior is only seen > when initalizing ModelFormSets . . . the ModelForm behavior is > unchanged. With a formset, the value use to get initialized; now it > doesn't. With a form, the value has never gotten initialized. > > I think 1.1 & 1.0.3 have the same behavior (no initialization in > formsets); and SVN 10132 (1.1 beta) & 1.0.2 have the same behavior > (initialization in formsets). Hi David, Thanks for this report. I'll have to dig a bit deeper to see exactly what is going on here. If you want to help out, working out which changeset between 10132 (beta 1) and 11365 (1.1 final) introduced this discrepancy would be extremely helpful. I'd also be interested to hear which behaviour - history and personal uses notwithstanding - you think is correct. On first inspection, I'm not completely convinced that the 'new' behaviour is actually incorrect - or, at least, that there might be a larger bug lurking here with regard to the interpretation of inherited Meta.field arguments. However, this is entirely based on first impressions, late at night, with a mild headache, so I could be completely off base. Yours Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Stopping people loging in twice
> The main purpose for this would be to track login collisions > and make sure users aren't sharing log in info. > > If a user has a high number of collisions we can assume they > are sharing their credentials and take the appropriate > actions. There are plenty of legitimate reasons for login collisions: I might be using the site from my desktop machine, walk into the conference room to give a demo of your website on the company laptop, and then walk out the door to a customer site where I access the site from my handheld mobile device. My computer may die (had 4 XP boxes push up daisies this past week in some fashion or another thanks to hardware failure or driver issues, out of ~50 I oversee) before I can log out and I need to use another machine. A user may flip back and forth between browsers which won't share session information. Things may compound if you offer an API -- multiple scripts may run that use the same login (my company has a handful of scripts that all access salesforce.com's API and can collide) So rather than pissing off users by *preventing* it, simply log hinky transactions and if you suspect they are violating your Terms of Service, fall back on your contractual agreement's audit-the-customer clause (if you're so fascistly controlling your users, you do have one, right?). I'm sure they'll love an audit because it's great for customer relations. -tkc --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: URL & DB question
Well it works a treat so big thanks. 2009/8/2 Chris Withers > > Rob B wrote: > > Great I didn't know about that one. I'm curious to what are the > > benefits of doing it that are? > > Less code for you to write and maintain :-) > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting >- http://www.simplistix.co.uk > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: modelform validation errors
Digging in documentation surely helps :) I had to replace {% if pform.non_field_errors %} {{ pform.non_field_errors.as_ul }} {% endif %} with {{ pform.errors }} to see that about field was causing it. I overrid about field with tinymce widget in forms.py and did not set null=True and blank=True there. Alan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: URL & DB question
Rob B wrote: > Great I didn't know about that one. I'm curious to what are the > benefits of doing it that are? Less code for you to write and maintain :-) Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Stopping people loging in twice
The main purpose for this would be to track login collisions and make sure users aren't sharing log in info. If a user has a high number of collisions we can assume they are sharing their credentials and take the appropriate actions. -- Sent from my Palm Pre Tim Chase wrote: > So is there a viable django solution for this problem? To build on what Malcolm was saying, the problem you have is that the only things your server knows are (1) when a user last engaged in a transaction with your server and optionally (2) when a user has intentionally logged out. #2 is nice, but many users don't log out intentionally -- like Malcolm said, they just close the browser or shut down the computer. In theory, you could create your own session backend that tracks the user associated with a session token and last-activity timestamp, and ensure that the user is unique in your session-store. HOWEVER...this creates a world of hurt for pretty much everybody: - Testing on multiple browsers becomes a pain because you need to serialize your tests, or create a user for each browser to step through the processes in parallel. - Users get miffed because you break their expectations of how the web usually works. - You may have to support those miffed users who call to let you know they can't log in, peeving them even further when you tell them "oh, just wait 30 minutes and your session will expire". You might be able to mitigate this by having a JavaScript activity-ping on your page that makes a request every 30 seconds or every minute, and then shortening your timeout window to 5-minutes. However, this peeves the folks that disable JS (such as the FF NoScript plugin) because they now have to perform activity every 5 minutes or else re-login. This also puts notable load on the server (one request per user, every 30-60 seconds, just to update their "hey, I'm still here" timestamp) I'm sure there are other reasons not to do it, but those are what I can come up with before breakfast and in my mind, the list is already pretty convincing against the idea of trying to limit users to a single session. The onlyvalue I could see in this is for some service where you're charging on a per-user-seat licensing scheme. If this is your wish, take a hint from little companies like Salesforce.com -- just do your licensing per-named-user and stop worrying about how many machines they access it from. -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Caching template fragments without specifying expiration time
I was wondering if it's possible to not specify the expiration time when using the {% cache %} tag to cache template fragments. With the low-level API, cache entries will expire after a timeout configured in CACHE_BACKEND. Is it possible to use the same default when caching template fragments? In particular, I'd like to use model signals to invalidate cache entries. That way, entries won't be invalidated after an arbitrary time period, but rather when they're actually invalid. Nathaniel Whiteinge wrote on 2008-12-03 that the {% cache %} tag creates entries with keys "fragment_name:additional:arguments:seperated:by:colons", so this seems possible. Any thoughts? Nick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: URL & DB question
Great I didn't know about that one. I'm curious to what are the benefits of doing it that are? Thanks 2009/8/2 Chris Withers > > Rob B (uk) wrote: > > Solved it by doing this: > > > > def profile_detail(request, name): > > p = get_object_or_404(Profile, name=name) > > return render_to_response('profile_detail.html', {'name': p}) > > How about using the detail generic view: > > from django.views.generic.list_detail import object_detail > > urlpatterns = patterns('', > (r'^(?P[\w\._-]+)/$', > object_detail, > {'queryset':Profile.objects.all()})) > > cheers, > > Chris > > -- > Simplistix - Content Management, Batch Processing & Python Consulting >- http://www.simplistix.co.uk > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: URL & DB question
Rob B (uk) wrote: > Solved it by doing this: > > def profile_detail(request, name): > p = get_object_or_404(Profile, name=name) > return render_to_response('profile_detail.html', {'name': p}) How about using the detail generic view: from django.views.generic.list_detail import object_detail urlpatterns = patterns('', (r'^(?P[\w\._-]+)/$', object_detail, {'queryset':Profile.objects.all()})) cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---