Re: File upload progress bar for Django?
On Oct 20, 2008, at 12:22 PM, M Godshall wrote: > Is anyone familiar with a django or python tutorial that shows how > to implement > some kind of file upload progress bar? Ideally I'd like to use > jquery, but I'm open to anything at this point. Any links or code > examples would be greatly appreciated. I couldn't find any tutorials, but it's come up on this list before: http://groups.google.com/group/django-users/search?group=django-users&q=progress+bar And there are a couple of good examples on djangosnippets.org: http://djangosnippets.org/snippets/678 http://djangosnippets.org/snippets/679 Unfortunately they're not accessible at the moment. Since it keeps coming up, I put together a demo app showing how the pieces fit together. It also shows how you could use nginx and its mod_uploadprogress instead, to avoid tying up your Django processes with slow uploads. http://www.fairviewcomputing.com/blog/2008/10/21/ajax-upload-progress-bars-jquery-django-nginx/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: File upload progress bar for Django?
On Oct 20, 2008, at 12:22 PM, M Godshall wrote: > Is anyone familiar with a django or python tutorial that shows how > to implement > some kind of file upload progress bar? Ideally I'd like to use > jquery, but I'm open to anything at this point. Any links or code > examples would be greatly appreciated. I couldn't find any tutorials, but it's come up on this list before: http://groups.google.com/group/django-users/search?group=django-users&q=progress+bar And there are a couple of good examples on djangosnippets.org: http://djangosnippets.org/snippets/678 http://djangosnippets.org/snippets/679 Unfortunately they're not accessible at the moment. Since it keeps coming up, I put together a demo app showing how the pieces fit together. It also shows how you could use nginx and its mod_uploadprogress instead, to avoid tying up your Django processes with slow uploads. http://www.fairviewcomputing.com/blog/2008/10/21/ajax-upload-progress-bars-jquery-django-nginx/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom upload handlers: Potential multi threading, session, etc issues. Take a look!
On Oct 20, 2008, at 8:11 AM, truebosko wrote: > What is happening: The custom upload handler works, data is being > sent, the session is being set WITHIN the handler but when I call the > function from Javascript to fetch the progress (or even from a simple > manual GET) it does not return anything because it does not recognize > the session > > What I found though, is that the view that is being called from JS > will finally have access to the session variable after the upload is > complete which in this case makes it totally useless since I'm trying > to track the progress and not just show them "Uploading ..." [...] > So that's where I stand now at this. The progress view just cant get > the request.session variable. It shows up, eventually but not when I > need it. I figure I might be doing something silly but I don't know > anymore Yes, I think you are. :^) The session is saved at the end of the request. That's why your progress report view doesn't see anything until the upload completes. You could explicitly save the session every chunk and batter your database, but the cache is a better place for this. John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: inlineformset_factory KeyError after updating
On Jan 6, 2009, at 4:18 AM, Alistair Marshall wrote: > When creating a new feed unit the system works fine. However if you go > and edit an existing feed unit, an error gets thrown when saving the > form. The problem is this bit in main_form.html, around line 37: {% ifnotequal field.label "Id" %} {{ field }} {% endifnotequal %} The omitted ID is causing your KeyError; leave it in the form. John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Question about ornery nginx reverse proxy in front of apache mod_wsgi
On Sep 25, 2008, at 9:23 PM, Prairie Dogg wrote: > I'm trying to set up a new server to host several existing django > sites. The stack is: > > Ubuntu Hardy Heron > Apache 2.2 MPM Worker w/ mod_wsgi (for dynamic content) > Nginx (for static files) > > I'm migrating away from mod_python. The django apps run correctly > under apache mod_wsgi - I've tested this by running the sites under > Apache directly on port 80, everything works swimmingly. > > Then, I put up an nginx instance to reverse proxy the dynamic content > and serve static files directly. nginx serves the static files > correctly, but the dynamic content hangs indefinitely, eventually > throwing a 504 timeout error to the browser and leaving this message > in the nginx error log: > > 2008/09/26 00:38:05 [error] 3544#0: *10 upstream timed out (110: > Connection timed out) while connecting to upstream, client: > 198.28.57.218, server: mysite.com, URL: "/whatever/53/", upstream: > "http://127.0.0.1:8080/whatever/53/";, host: "mysite.com" > > I'm using the exact same nginx virtualhost config as I did under > mod_python. Am I wrong to assume that this should Just Work™? Has > anyone else experienced this problem when moving from mod_python to > mod_wsgi? Any suggestions on what might be going wrong here? I'm running the same stack with no problems. The only difference I could see in our configurations was that I'm using mod_wsgi in daemon mode. I'm using mod_wsgi 2.3 and nginx 0.6.32; which do you have? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Storage of files in database
On Oct 7, 2008, at 8:29 AM, Mariana Romão wrote: > Hi, > I'm new in the group and in the use of Dajngo too. > I'm developing an application that needs storage files ".py" in > database (and maybe other types of files). I thought Django did this > "automatically" when I define the field in the model as FileField, > but I realized that what does is put in database a column as a > varchar. > > What I need do for that the database storage the file? Create other > table or other column manually? If all you're doing is serving those files, don't put them in the database. There are more efficient ways to do that, even if you require authentication or other special handling. If you're doing something more interesting with them, then two approaches spring to mind. You could look into writing a custom Storage implementation to save them into the database (see http://docs.djangoproject.com/en/dev/ref/files/storage/) , or you could just add a FileField to your form instead of your model, and in the form's save method, read the file contents into a TextField on your 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Figuring out prefork v. worker
On Oct 16, 2008, at 4:14 PM, Doug Van Horn wrote: > I was just wondering if anyone else had been through this cycle? My > testing showed I didn't have any issues with mod_wsgi/prefork leaking > info across apps, but maybe someone else has? > > I'm pretty much thinking I shouldn't have bothered with all this fancy > worker and wsgi stuff and just stuck with the prefork/mod_python > configuration. After all, I'm running business applications, not > social networking sites. Yeah, actually I had the same problem with timezones in embedded mode, and some other weird problems with psycopg2, too. Daemon mode fixed all of them, and my experience bears out what Graham said: this setup handles more load than prefork with fewer processes and less memory, and the footprint's more predictable. There are other benefits, like the ability to run different sites as different users, but that was my main concern. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Cannot serve static files
No matter what i do i can't get my css to load. 100% Frustrated with Django. My index page loads when i request http://127.0.0.1:8000/ but it is not styled. Django dev server returns 404 in console for "GET / css/styles.css HTTP/1.1" In my base template i have: In my urls.py I have: urlpatterns = patterns('', (r'^$', 'proj.app.views.index'), (r'^admin/(.*)', admin.site.root), (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), ) In my settings.py i have (among other things): import os SETTINGS_FILE_FOLDER = os.path.dirname(__file__) MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media') MEDIA_URL = 'http://127.0.0.1:8000/media/' ADMIN_MEDIA_PREFIX = 'adminmedia' my directory structure in windows is: c:\dev -\proj __init__.py manage.py settings.py urls.py -\app -__init__.py -admin.py -models.py -views.py -\adminmedia -\media -\css -styles.css -\images -\templates -base.html -index.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Cannot serve static files
Thanks but no change. On Jan 22, 11:02 am, Dj Gilcrease wrote: > change > > to > > > Dj Gilcrease > OpenRPG Developer > ~~http://www.openrpg.com > > On Thu, Jan 22, 2009 at 8:53 AM, john wrote: > > > No matter what i do i can't get my css to load. 100% Frustrated with > > Django. My index page loads when i requesthttp://127.0.0.1:8000/but > > it is not styled. Django dev server returns 404 in console for "GET / > > css/styles.css HTTP/1.1" > > > In my base template i have: > > > > > In my urls.py I have: > > urlpatterns = patterns('', > > (r'^$', 'proj.app.views.index'), > > (r'^admin/(.*)', admin.site.root), > > (r'^media/(?P.*)$', 'django.views.static.serve', > > {'document_root': settings.MEDIA_ROOT}), > > ) > > > In my settings.py i have (among other things): > > import os > > SETTINGS_FILE_FOLDER = os.path.dirname(__file__) > > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media') > > MEDIA_URL = 'http://127.0.0.1:8000/media/' > > ADMIN_MEDIA_PREFIX = 'adminmedia' > > > my directory structure in windows is: > > > c:\dev > > -\proj > > __init__.py > > manage.py > > settings.py > > urls.py > > -\app > > -__init__.py > > -admin.py > > -models.py > > -views.py > > -\adminmedia > > -\media > > -\css > > -styles.css > > -\images > > -\templates > > -base.html > > -index.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Cannot serve static files
Thanks but no change. On Jan 22, 11:30 am, Puneet Madaan wrote: > beside href="{MEDIA_URL}css/styles.css"> > you need to correct settings.py to > > SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__)) > > > > On Thu, Jan 22, 2009 at 5:26 PM, john wrote: > > > Thanks but no change. > > > On Jan 22, 11:02 am, Dj Gilcrease wrote: > > > change > > > > > > to > > > > > > > Dj Gilcrease > > > OpenRPG Developer > > > ~~http://www.openrpg.com > > > > On Thu, Jan 22, 2009 at 8:53 AM, john wrote: > > > > > No matter what i do i can't get my css to load. 100% Frustrated with > > > > Django. My index page loads when i requesthttp://127.0.0.1:8000/but > > > > it is not styled. Django dev server returns 404 in console for "GET / > > > > css/styles.css HTTP/1.1" > > > > > In my base template i have: > > > > > > > > > In my urls.py I have: > > > > urlpatterns = patterns('', > > > > (r'^$', 'proj.app.views.index'), > > > > (r'^admin/(.*)', admin.site.root), > > > > (r'^media/(?P.*)$', 'django.views.static.serve', > > > > {'document_root': settings.MEDIA_ROOT}), > > > > ) > > > > > In my settings.py i have (among other things): > > > > import os > > > > SETTINGS_FILE_FOLDER = os.path.dirname(__file__) > > > > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media') > > > > MEDIA_URL = 'http://127.0.0.1:8000/media/' > > > > ADMIN_MEDIA_PREFIX = 'adminmedia' > > > > > my directory structure in windows is: > > > > > c:\dev > > > > -\proj > > > > __init__.py > > > > manage.py > > > > settings.py > > > > urls.py > > > > -\app > > > > -__init__.py > > > > -admin.py > > > > -models.py > > > > -views.py > > > > -\adminmedia > > > > -\media > > > > -\css > > > > -styles.css > > > > -\images > > > > -\templates > > > > -base.html > > > > -index.html > > -- > If you spin an oriental man, does he become disoriented? > (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu > > is der net süß » ε(●̮̮̃•̃)з > -PM --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Cannot serve static files
ah ok. good catch. My MEDIA_ROOT = C:\dev\proj. But my media directory is actually in my app directory, one directory down. I fixed MEDIA_ROOT to equal C:\dev\proj\app and still not having any luck. my use of -\ in directory structure example is just to indicate a folder in directory tree. Let me clarify: C:\dev\proj is project directory C:\dev\proj\app is application directory. Under this i have 'adminmedia', 'media' and 'templates' directories. So static files are here: C:\dev\proj\app\media. css file is here: C:\dev\proj\app\media\css\styles.css settings file is here: C:\dev\proj\settings.py like i said i now have MEDIA_ROOT set to C:\dev\proj\app, but still not working. In template i was told to use . MEDIA_URL not MEDIA_ROOT regardless, do i have to pass context for MEDIA_URL in view so template knows what it is?? is that the problem? Thanks for helping, btw. Much appreciated. On Jan 22, 11:57 am, Puneet Madaan wrote: > well at my side it works well on both *nix and windoof platforms... here is > what I use on my projects... > > settings.py > -- > import platform > import os > > PROJECT_DIR = os.path.dirname( os.path.abspath(__file__)) > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static') > --- > > urls.py > - > from django.conf.urls.defaults import * > from django.contrib import admin > from django.conf import settings > > urlpatterns = patterns('', > #urls for your project > (r'^static/(?P.*)$', 'django.views.static.serve', > {'document_root': settings.MEDIA_ROOT}), > ) > > where i use a directory named 'static' residing in same folder, where i have > my settings.py can you please place 'print MEDIA_ROOT' inside your > settings.py and check the terminal the path is spilts out ? because your '-' > convention before '-\media' is sort confusing, and its missing before > manage.py and settings.py is media folder residing really in the same > directory where settings.py ? > > c:\dev > > > > > -\proj > > __init__.py > > manage.py > > settings.py > > urls.py > > -\app > > -__init__.py > > -admin.py > > -models.py > > -views.py > > -\adminmedia > > -\media > > -\css > > -styles.css > > -\images > > -\templates > > -base.html > > -index.html > > if 'print MEDIA_ROOT' spilts out a path different from your media folder, > then you know where is the problem .. > > Greetings, > Puneet > > > > On Thu, Jan 22, 2009 at 5:40 PM, john wrote: > > > Thanks but no change. > > > On Jan 22, 11:30 am, Puneet Madaan wrote: > > > beside > href="{MEDIA_URL}css/styles.css"> > > > you need to correct settings.py to > > > > SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__)) > > > > On Thu, Jan 22, 2009 at 5:26 PM, john wrote: > > > > > Thanks but no change. > > > > > On Jan 22, 11:02 am, Dj Gilcrease wrote: > > > > > change > > > > > > > > > > to > > > > > > href="{MEDIA_URL}css/styles.css"> > > > > > > Dj Gilcrease > > > > > OpenRPG Developer > > > > > ~~http://www.openrpg.com > > > > > > On Thu, Jan 22, 2009 at 8:53 AM, john > > wrote: > > > > > > > No matter what i do i can't get my css to load. 100% Frustrated > > with > > > > > > Django. My index page loads when i requesthttp:// > > 127.0.0.1:8000/but > > > > > > it is not styled. Django dev server returns 404 in console for "GET > > / > > > > > > css/styles.css HTTP/1.1" > > > > > > > In my base template i have: > > > > > > > > > > > > > In my urls.py I have: > > > > > > urlpatterns = patterns('', > > > > > > (r'^$', 'proj.app.views.index'), > > > > > > (r'^admin/(.*)', admin.site.root), > > > > > > (r'^media/(?P.*)$', 'django.views.static.serve', > > > > > > {'document_root': settings.MEDIA_ROOT}), > > > > > > ) > > > > > > > In my settings.py i have (among other things): > > > > > > import os > > > > > > SETTINGS_FILE_FOLDER = os.path.dirname(
Re: Cannot serve static files
Ok finally got it. David Zhou above, earlier mentioned adding static file directory to css link (ie, ) but when i did that it didn't work. I must have had something wrong somewhere else. Anyway, i made some more changes after reading info here: http://stackoverflow.com/questions/446026/django-how-do-you-serve-media-stylesheets-and-link-to-them-within-templates So given above directory structure i have this working now with the following: settings.py MEDIA_ROOT = 'c:/dev/proj/app/media/' (i changed from 'c:\dev\proj\app \media\' not sure if it mattered) MEDIA_URL = '/media/' ADMIN_MEDIA_PREFIX = '/adminmedia/' from what i gather, media and admin_media can't be the same directory urls.py (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), base.html template What a effin hassle this has been. Django needs inprovement here. Nothing wrong with building a recommended directory structure and/or publishing better instructions on this. This type of thing is very different for people coming from standard page style development. Dir structure and url routing seem to be built into most MVC systems (at least the ones i looked into before django). On Jan 22, 12:32 pm, john wrote: > ah ok. good catch. My MEDIA_ROOT = C:\dev\proj. But my media directory > is actually in my app directory, one directory down. I fixed > MEDIA_ROOT to equal C:\dev\proj\app and still not having any luck. my > use of -\ in directory structure example is just to indicate a folder > in directory tree. Let me clarify: > > C:\dev\proj is project directory > C:\dev\proj\app is application directory. Under this i have > 'adminmedia', 'media' and 'templates' directories. So static files are > here: C:\dev\proj\app\media. > css file is here: C:\dev\proj\app\media\css\styles.css > settings file is here: C:\dev\proj\settings.py > > like i said i now have MEDIA_ROOT set to C:\dev\proj\app, but still > not working. In template i was told to use type="text/css" href="{{MEDIA_URL}}css/styles.css">. > > MEDIA_URL not MEDIA_ROOT > > regardless, do i have to pass context for MEDIA_URL in view so > template knows what it is?? is that the problem? > > Thanks for helping, btw. Much appreciated. > > On Jan 22, 11:57 am, Puneet Madaan wrote: > > > well at my side it works well on both *nix and windoof platforms... here is > > what I use on my projects... > > > settings.py > > -- > > import platform > > import os > > > PROJECT_DIR = os.path.dirname( os.path.abspath(__file__)) > > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static') > > --- > > > urls.py > > - > > from django.conf.urls.defaults import * > > from django.contrib import admin > > from django.conf import settings > > > urlpatterns = patterns('', > > #urls for your project > > (r'^static/(?P.*)$', 'django.views.static.serve', > > {'document_root': settings.MEDIA_ROOT}), > > ) > > > > where i use a directory named 'static' residing in same folder, where i have > > my settings.py can you please place 'print MEDIA_ROOT' inside your > > settings.py and check the terminal the path is spilts out ? because your '-' > > convention before '-\media' is sort confusing, and its missing before > > manage.py and settings.py is media folder residing really in the same > > directory where settings.py ? > > > c:\dev > > > > -\proj > > > __init__.py > > > manage.py > > > settings.py > > > urls.py > > > -\app > > > -__init__.py > > > -admin.py > > > -models.py > > > -views.py > > > -\adminmedia > > > -\media > > > -\css > > > -styles.css > > > -\images > > > -\templates > > > -base.html > > > -index.html > > > if 'print MEDIA_ROOT' spilts out a path different from your media folder, > > then you know where is the problem .. > > > Greetings, > > Puneet > > > On Thu, Jan 22, 2009 at 5:40 PM, john wrote: > > > > Thanks but no change. > > > > On Jan 22, 11:30 am, Puneet Madaan wrote: > > > > beside > > href="{MEDIA_URL}css/styles.css"> > > > > you need to correct settings.py to > > > > > SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__
Django nube
I am trying to follow the Django | Writing your first Django ap part 1 tutorial. When I get to the python manage.py syncdb command I get the following: Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/usr/lib/python2.5/site-packages/django/core/management/ __init__.py", line 340, in execute_manager utility.execute() File "/usr/lib/python2.5/site-packages/django/core/management/ __init__.py", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 192, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 219, in execute output = self.handle(*args, **options) File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 348, in handle return self.handle_noargs(**options) File "/usr/lib/python2.5/site-packages/django/core/management/ commands/syncdb.py", line 51, in handle_noargs cursor = connection.cursor() File "/usr/lib/python2.5/site-packages/django/db/backends/ __init__.py", line 56, in cursor cursor = self._cursor(settings) File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/ base.py", line 139, in _cursor raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the settings module before using the database." django.core.exceptions.ImproperlyConfigured: Please fill out DATABASE_NAME in the settings module before using the database. j...@john-laptop:~/Django/mysite$ python manage.py syncdb Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/usr/lib/python2.5/site-packages/django/core/management/ __init__.py", line 340, in execute_manager utility.execute() File "/usr/lib/python2.5/site-packages/django/core/management/ __init__.py", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 192, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 219, in execute output = self.handle(*args, **options) File "/usr/lib/python2.5/site-packages/django/core/management/ base.py", line 348, in handle return self.handle_noargs(**options) File "/usr/lib/python2.5/site-packages/django/core/management/ commands/syncdb.py", line 51, in handle_noargs cursor = connection.cursor() File "/usr/lib/python2.5/site-packages/django/db/backends/ __init__.py", line 56, in cursor cursor = self._cursor(settings) File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/ base.py", line 139, in _cursor raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the settings module before using the database." django.core.exceptions.ImproperlyConfigured: Please fill out DATABASE_NAME in the settings module before using the database. Here is how my settings. py file is settup. ADMINS = ( # ('Your Name', 'your_em...@domain.com'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = '' # Or path to database file if using sqlite3. DATABASE_USER = '' # Not used with sqlite3. DATABASE_PASSWORD = '' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # although not all choices may be available on all operating systems. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = 'Am My understanding is, that because I am using sqlite it will automatically create a database file when I run the syncdb command. I had a slightly different experience with Turbogears. My thought is that my sqlite is not set up correctly, but I don't even know where to start looking. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 nube
WOW!!! That was painfully obvious. As I said newbe...to python, django, and programming. Hopefully my questions will get more interesting soon! Thanks On Feb 26, 3:29 am, Karen Tracey wrote: > On Thu, Feb 26, 2009 at 2:41 AM, john wrote: > > > I am trying to follow the Django | Writing your first Django ap part 1 > > tutorial. When I get to the python manage.py syncdb command I get the > > following: > > > Traceback (most recent call last): > > [snip] > > raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the > > settings module before using the database." > > django.core.exceptions.ImproperlyConfigured: Please fill out > > DATABASE_NAME in the settings module before using the database. > > > Here is how my settings. py file is settup. > > > ADMINS = ( > > # ('Your Name', 'your_em...@domain.com'), > > ) > > > MANAGERS = ADMINS > > > DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', > > 'postgresql', 'mysql', 'sqlite3' or 'oracle'. > > DATABASE_NAME = '' # Or path to database file if using > > sqlite3. > > You need to decide on a name and fill on in here. (Note the comments don't > say "Not used with sqlite3" for this one, as they do for the following > ones. The DATABASE_NAME is required for sqlite3. > > > > > DATABASE_USER = '' # Not used with sqlite3. > > DATABASE_PASSWORD = '' # Not used with sqlite3. > > DATABASE_HOST = '' # Set to empty string for localhost. > > Not used with sqlite3. > > DATABASE_PORT = '' # Set to empty string for default. Not > > used with sqlite3. > > > [snip] > > My understanding is, that because I am using sqlite it will > > automatically create a database file when I run the syncdb command. I > > had a slightly different experience with Turbogears. > > Yes, it will be created automatically. So if the file you specify in > DATABASE_NAME does not exist, it will be created. You still have to specify > a name for it, though, as described here: > > http://docs.djangoproject.com/en/dev/intro/tutorial01/#database-setup > > 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: Django nube
Or perhaps they will remain trivial for a while. I added the name as such: DATABASE_NAME = '/Django/mysite/mysite_data.db' {I have tried w/ ~, w/o leading /, with /john/Djan..., and w/ john/ Dja...} My project looks like this: j...@john-laptop:~/Django/mysite$ ls -l total 24 -rw-r--r-- 1 john john0 2009-02-25 22:48 __init__.py -rw-r--r-- 1 john john 133 2009-02-25 23:09 __init__.pyc -rw-r--r-- 1 john john 546 2009-02-25 22:48 manage.py -rw-r--r-- 1 john john 2805 2009-02-26 05:03 settings.py -rw-r--r-- 1 john john 1699 2009-02-26 05:03 settings.pyc -rw-r--r-- 1 john john 537 2009-02-25 22:48 urls.py -rw-r--r-- 1 john john 233 2009-02-25 23:11 urls.pyc j...@john-laptop:~/Django/mysite$ Now I am getting: File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/ base.py", line 145, in _cursor self.connection = Database.connect(**kwargs) sqlite3.OperationalError: unable to open database file On Feb 26, 4:19 am, john wrote: > WOW!!! That was painfully obvious. As I said newbe...to python, > django, and programming. Hopefully my questions will get more > interesting soon! > > Thanks > > On Feb 26, 3:29 am, Karen Tracey wrote: > > > On Thu, Feb 26, 2009 at 2:41 AM, john wrote: > > > > I am trying to follow the Django | Writing your first Django ap part 1 > > > tutorial. When I get to the python manage.py syncdb command I get the > > > following: > > > > Traceback (most recent call last): > > > [snip] > > > raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the > > > settings module before using the database." > > > django.core.exceptions.ImproperlyConfigured: Please fill out > > > DATABASE_NAME in the settings module before using the database. > > > > Here is how my settings. py file is settup. > > > > ADMINS = ( > > > # ('Your Name', 'your_em...@domain.com'), > > > ) > > > > MANAGERS = ADMINS > > > > DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', > > > 'postgresql', 'mysql', 'sqlite3' or 'oracle'. > > > DATABASE_NAME = '' # Or path to database file if using > > > sqlite3. > > > You need to decide on a name and fill on in here. (Note the comments don't > > say "Not used with sqlite3" for this one, as they do for the following > > ones. The DATABASE_NAME is required for sqlite3. > > > > DATABASE_USER = '' # Not used with sqlite3. > > > DATABASE_PASSWORD = '' # Not used with sqlite3. > > > DATABASE_HOST = '' # Set to empty string for localhost. > > > Not used with sqlite3. > > > DATABASE_PORT = '' # Set to empty string for default. Not > > > used with sqlite3. > > > > [snip] > > > My understanding is, that because I am using sqlite it will > > > automatically create a database file when I run the syncdb command. I > > > had a slightly different experience with Turbogears. > > > Yes, it will be created automatically. So if the file you specify in > > DATABASE_NAME does not exist, it will be created. You still have to specify > > a name for it, though, as described here: > > >http://docs.djangoproject.com/en/dev/intro/tutorial01/#database-setup > > > 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: Raw HTTP request processing?
> Isn't it just > request.raw_post_data Thanks and I suspected it was that but hoped there might be a little example somewhere as the docs don't say much only this: HttpRequest.raw_post_data The raw HTTP POST data. This is only useful for advanced processing. Use POST instead. As I am going to be dealing with potentially very large streams in and out, I need it to access the streams rather than a variable stored in memory. Any examples of doing this that you know about? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: json serialization error on arrays
When I have arrays of 100,000+ the performance of lists gets unacceptable in standard c python. That's why arrays exist in python! After doing research and testing, I have decided to rebuild the project in java with embedded jython. For some bizarre reason jython performance increases with large datasets in memory where standard c python plunges (From what I hear its that the GC strategy doesn't scale). I also can't use django at having to read and convert everything in memory etc is going to be too bad a hit. Shame, as I like django but it won't do for this project as there are many assumptions that don't fit my requirements - I would have to hack it to death to get what I want and that is a waste of time. Everything is going to have to be stream based (conversions happening on the fly) and use efficient use of memory internally for arrays etc. I now will be using jetty, servlets, jython as I can optimise everything easily for huge data sets. There is a maximum permissible time lag for each request. On 25 Aug, 21:38, Peter Bengtsson wrote: > what's wrong with turning it into a list? If you gzip it it won't be > that big. > > On Aug 25, 5:16 pm, John Baker wrote: > > > I need to json serialize some very large objects which include large > > arrays. How can I do this in django? The arrays will be very big and > > heavily processed before so need to use efficient array storage. > > > Testing with arrays I get.. > > > TypeError at /zeros/ > > > array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) is not JSON > > serializable > > > What would you recommend I do to support arrays? > > > Thanks in advance, > > John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Raw HTTP request processing?
Thanks but it seems that in this example (if I have understood correctly) it loads the entire request into memory. I need to convert stuff on the fly using streams on both input and output as both may be huge. I have a number of stages of transformation and it wouldn't take very many requests to bring the machine to a grinding halt if everything is being done in memory at each stage. I have decided to do it in java with jetty, servlets and embedding jython (which bizarrely for large datasets seems to be more efficient, standard c python perfomance plunges after certain in memory data sizes - I believe its the GC strategy not scaling well from what I have heard). On 25 Aug, 21:41, Peter Bengtsson wrote: > Here's an example:http://www.djangosnippets.org/snippets/1322/ > > On Aug 25, 5:43 pm, John wrote: > > > > Isn't it just > > > request.raw_post_data > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Searching disparate databases
I would have your internal model how you like for the best application design and then write cron scripts that import into your main db from the other disparate format databases. Have a field in your internal model so you know the original source of each entry. Reimport when the third party DBs dumps change modified date. Have something in the file names (a prefix or suffix) so you know which script to run for each. Thats my idea without knowing more about what you are doing.. John On Jun 8, 11:05 am, Amit Sethi wrote: > Hi all , > I am trying to develop a web app that searches products on some > local stores and give the price.Now I can obviously have a format for stores > to feed my database but rather than that .What I want is that the local > stores be able to dump their database/feeds on my Server . It would make > adding a store a breeze . But the problem is that these databases / feeds > might be very different . The datamodels might be very different . So how do > I integrate such databases. I just need to extract the product and its price > from a store. > -- > A-M-I-T S|S --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Switching backend database on the fly?
One more requirement.. 4. The application must be self contained i.e contain its own django installation (which has the quick start web server) and sqlite db module. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
problem with syncing sqlite3.6.22
When I run python manage.py syncdb I get the following error. I left the name field blank expecting Django to fill in the file name. Am I miss understanding the Name section of the intro? "NAME -- The name of your database. If you're using SQLite, the database will be a file on your computer; in that case, NAME should be the full absolute path, including filename, of that file. If the file doesn't exist, it will automatically be created when you synchronize the database for the first time (see below)." I am running Django in a virtualenv and am using Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/home/john/Django/lib/python2.6/site-packages/django/core/ management/__init__.py", line 438, in execute_manager utility.execute() File "/home/john/Django/lib/python2.6/site-packages/django/core/ management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/john/Django/lib/python2.6/site-packages/django/core/ management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/home/john/Django/lib/python2.6/site-packages/django/core/ management/base.py", line 218, in execute output = self.handle(*args, **options) File "/home/john/Django/lib/python2.6/site-packages/django/core/ management/base.py", line 347, in handle return self.handle_noargs(**options) File "/home/john/Django/lib/python2.6/site-packages/django/core/ management/commands/syncdb.py", line 52, in handle_noargs cursor = connection.cursor() File "/home/john/Django/lib/python2.6/site-packages/django/db/ backends/__init__.py", line 75, in cursor cursor = self._cursor() File "/home/john/Django/lib/python2.6/site-packages/django/db/ backends/sqlite3/base.py", line 168, in _cursor raise ImproperlyConfigured("Please fill out the database NAME in the settings module before using the database.") django.core.exceptions.ImproperlyConfigured: Please fill out the database NAME in the settings module before using the database. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: problem with syncing sqlite3.6.22
Thank you for the quick reply. Seems to have worked! On Jul 19, 7:59 pm, Ben Atkin wrote: > I think you misunderstood the part where it said "If the file doesn't exist, > it will automatically be created". It says "file", not "filename". A file > name or path must be given. The file *at the path* doesn't need to exist, > but the path needs to be specified. > > The quickest way to get started is to change it to something like > "dev.sqlite3" and re-run it. > > Ben > > On Mon, Jul 19, 2010 at 6:53 PM, john wrote: > > When I run python manage.py syncdb I get the following error. I left > > the name field blank expecting Django to fill in the file name. Am I > > miss understanding the Name section of the intro? > > > "NAME -- The name of your database. If you're using SQLite, the > > database will be a file on your computer; in that case, NAME should be > > the full absolute path, including filename, of that file. If the file > > doesn't exist, it will automatically be created when you synchronize > > the database for the first time (see below)." > > > I am running Django in a virtualenv and am using > > Traceback (most recent call last): > > File "manage.py", line 11, in > > execute_manager(settings) > > File "/home/john/Django/lib/python2.6/site-packages/django/core/ > > management/__init__.py", line 438, in execute_manager > > utility.execute() > > File "/home/john/Django/lib/python2.6/site-packages/django/core/ > > management/__init__.py", line 379, in execute > > self.fetch_command(subcommand).run_from_argv(self.argv) > > File "/home/john/Django/lib/python2.6/site-packages/django/core/ > > management/base.py", line 191, in run_from_argv > > self.execute(*args, **options.__dict__) > > File "/home/john/Django/lib/python2.6/site-packages/django/core/ > > management/base.py", line 218, in execute > > output = self.handle(*args, **options) > > File "/home/john/Django/lib/python2.6/site-packages/django/core/ > > management/base.py", line 347, in handle > > return self.handle_noargs(**options) > > File "/home/john/Django/lib/python2.6/site-packages/django/core/ > > management/commands/syncdb.py", line 52, in handle_noargs > > cursor = connection.cursor() > > File "/home/john/Django/lib/python2.6/site-packages/django/db/ > > backends/__init__.py", line 75, in cursor > > cursor = self._cursor() > > File "/home/john/Django/lib/python2.6/site-packages/django/db/ > > backends/sqlite3/base.py", line 168, in _cursor > > raise ImproperlyConfigured("Please fill out the database NAME in > > the settings module before using the database.") > > django.core.exceptions.ImproperlyConfigured: Please fill out the > > database NAME in the settings module before using the database. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@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. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
setting up datebase
Hi all, I am following the django book. I am to the point of setting up my datebase. It instructs me to enter the command: python manage.py sqlall. When I do I get no output, and no errors. It just returns me to the >>>. python manage.py validate returned 0 errors found. I also tried the syndb command. It returned "No fixtures found." Since I am not getting any error I am at a loss. Any direction 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-us...@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.
setting up datebase
Hi all, I am following the django book. I am to the point of setting up my datebase. It instructs me to enter the command: python manage.py sqlall. When I do I get no output, and no errors. It just returns me to the >>>. python manage.py validate returned 0 errors found. I also tried the syndb command. It returned "No fixtures found." Since I am not getting any error I am at a loss. Any direction 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-us...@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.
No fixtures found
I got the message 'No fixtures found' when I ran the python manage.py syncdb command. I am working in sqlite3 which seems to be working as evidenced by the fact that if I type sqlite in a terminal I get the sqlite>. The first time I got the following output, followed by the aforementioned message. Subsequent syncdb's just return the message. Creating table django_admin_log Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating table auth_message Creating table django_content_type Creating table django_session ... Installing index for admin.LogEntry model Installing index for auth.Permission model Installing index for auth.Group_permissions model Installing index for auth.User_user_permissions model Installing index for auth.User_groups model Installing index for auth.Message model No fixtures found. The trace back is as follows. Request URL: http://127.0.0.1:8000/time/plus/1/ Django Version: 1.2.1 Python Version: 2.6.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'mysite.books'] Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.common.CommonMiddleware') Traceback: File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/core/handlers/base.py" in get_response 91. request.path_info) File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/core/urlresolvers.py" in resolve 214. for pattern in self.url_patterns: File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/core/urlresolvers.py" in _get_url_patterns 243. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/core/urlresolvers.py" in _get_urlconf_module 238. self._urlconf_module = import_module(self.urlconf_name) File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/utils/importlib.py" in import_module 35. __import__(name) File "/home/john/mysite/../mysite/urls.py" in 21.(r'^admin/', include(admin.site.urls)), Exception Type: NameError at /time/plus/1/ Exception Value: name 'admin' is not defined -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
No fixtures found
I got the message 'No fixtures found' when I ran the python manage.py syncdb command. I am working in sqlite3 which seems to be working as evidenced by the fact that if I type sqlite in a terminal I get the sqlite>. The first time I got the following output, followed by the aforementioned message. Subsequent syncdb's just return the message. Creating table django_admin_log Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating table auth_message Creating table django_content_type Creating table django_session ... Installing index for admin.LogEntry model Installing index for auth.Permission model Installing index for auth.Group_permissions model Installing index for auth.User_user_permissions model Installing index for auth.User_groups model Installing index for auth.Message model No fixtures found. The Traceback is: Environment: Request Method: GET Request URL: http://127.0.0.1:8000/admin Django Version: 1.2.1 Python Version: 2.6.4 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'mysite.books'] Installed Middleware: ('django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware') Traceback: File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/core/handlers/base.py" in get_response 80. response = middleware_method(request) File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/contrib/auth/middleware.py" in process_request 15. assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." Exception Type: AssertionError at /admin Exception Value: The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'. My MIDDLEWARE_CLASSES is as follows. MIDDLEWARE_CLASSES = ( ... 'django.contrib.auth.middleware.AuthenticationMiddleware', ... 'django.contrib.sessins.middleware.SessionsMiddleware', ... 'django.middleware.common.CommonMiddleware', ... ) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: No fixtures found
Oh, I guess it just look concerning. I'll keep working on the tutorial and see what happens. Thanks! On Jul 25, 2:51 pm, n3ph wrote: > Am 25.07.2010 21:36, schrieb Daniel Roseman: > > > On Jul 25, 8:11 pm, john wrote: > >> I got the message 'No fixtures found' when I ran the python manage.py > >> syncdb command. I am working in sqlite3 which seems to be working as > >> evidenced by the fact that if I type sqlite in a terminal I get the > >> sqlite>. > > >> The first time I got the following output, followed by the > >> aforementioned message. Subsequent syncdb's just return the > >> message. > > So what's the problem with that? Have you in fact defined any > > fixtures? Do you need any? > > -- > > DR. > > Right, this isn't really a problem.. unless you need and had defined > some fixtures... if not - don't care about -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: No fixtures found
I still don't see why I am getting the error messages: Traceback: File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/core/handlers/base.py" in get_response 80. response = middleware_method(request) File "/home/john/Django/lib/python2.6/site-packages/Django-1.2.1- py2.6.egg/django/contrib/auth/middleware.py" in process_request 15. assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." Exception Type: AssertionError at /admin Exception Value: The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'. My MIDDLEWARE_CLASSES is as follows. MIDDLEWARE_CLASSES = ( ... 'django.contrib.auth.middleware.AuthenticationMiddleware', ... 'django.contrib.sessins.middleware.SessionsMiddleware', ... 'django.middleware.common.CommonMiddleware', ... ) when I try and run my app. The traceback says I need to edit my middleware classes, but the requested modual is already in the middleware_classes. On Jul 25, 2:51 pm, n3ph wrote: > Am 25.07.2010 21:36, schrieb Daniel Roseman: > > > On Jul 25, 8:11 pm, john wrote: > >> I got the message 'No fixtures found' when I ran the python manage.py > >> syncdb command. I am working in sqlite3 which seems to be working as > >> evidenced by the fact that if I type sqlite in a terminal I get the > >> sqlite>. > > >> The first time I got the following output, followed by the > >> aforementioned message. Subsequent syncdb's just return the > >> message. > > So what's the problem with that? Have you in fact defined any > > fixtures? Do you need any? > > -- > > DR. > > Right, this isn't really a problem.. unless you need and had defined > some fixtures... if not - don't care about -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Custom Admin Form for ManyToMany, missing Green Plus Sign?
Hi, I just had fun creating a new Custom Admin Form to sort a ManyToMany field by ABC order (why isnt it in ABC order by default on the "def __unicode__" item?) It works great, but now the Green Plus Sign to add more items to the list is missing, where did it go? I guess its not enabled by default? Does anyone know where I can search on this more, and/or what this Green Plus Sign is called? Is this just an extra command that needs to be entered or do I have to reinvent the wheel to get this back to working? thanks! This is the Green Plus Sign im looking for (even though this is for a ForeignKey field): http://docs.djangoproject.com/en/dev/_images/admin10.png My code if you want to take a look (sorry that a lot of it has to be redacted): # more xyz/admin.py from abc.xyz.models import Items,Stuff from django.contrib import admin from django import forms class StuffForm(forms.ModelForm): item=forms.ModelMultipleChoiceField(queryset=Items.objects.order_by('item')) class Meta: model=Stuff class StuffAdmin(admin.ModelAdmin): exclude=('items',) form=StuffForm admin.site.register(Stuff, StuffAdmin) # more xyz/models.py class Items(models.Model): item=models.CharField(max_length=100) def __unicode__(self): return self.item class Stuff(models.Model): items=models.ManyToManyField(Items) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Custom Admin Form for ManyToMany, missing Green Plus Sign?
Maybe I didnt fully explain the issue, and it seems that Google added a couple of extra lines to the code above. Ive got an app with 2 Model classes. The first one describes a product (the Item model above). The second one (the Stuff model above), along with other data references the Product via a ManyToMany key. The basic default Admin settings, which work correctly, allow the addition of new Products via the Green Plus Sign and a Pop-up Window. Everything works fine. However when adding new Products, the Admin interface sorts the ManyToMany field by ID, instead of a much more intelligible Product Name. Lots of Products, too hard to find a particular one in the list. Thus I wrote up a Custom Admin Form to sort these Products in the ManyToMany field. This works great, the Products are sorted in ABC order. But, with this Custom Admin Form, the ability to Add another Product via the Little Green Plus Sign has been removed, the Plus Sign just isnt there, and therefore cannot spawn the Pop-up Window to add another Product to the Items model DB table. It seems that this should be an easy fix, but I cant find any docs that dont involve reinventing the wheel. Yes, the Items model data can be accessed through another part of the Admin interface, but I think the purpose of the Green Plus Sign was to alleviate this extra step. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
i18n Reverse URL Unit Test Error
I have encountered a Unit Test error while using a reverse url lookup for i18n. All is running fine in the development environment. Issues only occur during testing. It appears to possibly be an issue with shared contexts between contrib.auth and views.i18n. Template Code Unit Test Output == ERROR: test_confirm_complete (django.contrib.auth.tests.views.PasswordResetTest) -- Traceback (most recent call last): File "/home/john.chase/trunk/lib/CloudTest.py", line 249, in tag_aware_case_run testMethod() File "/usr/lib/python2.4/site-packages/django/contrib/auth/tests/ views.py", line 117, in test_confirm_complete response = self.client.get(path) File "/usr/lib/python2.4/site-packages/django/test/client.py", line 281, in get response = self.request(**r) File "/usr/lib/python2.4/site-packages/django/core/handlers/ base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/auth/ views.py", line 141, in password_reset_confirm return render_to_response(template_name, context_instance=context_instance) File "/usr/lib/python2.4/site-packages/django/shortcuts/ __init__.py", line 20, in render_to_response return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) File "/usr/lib/python2.4/site-packages/django/template/loader.py", line 108, in render_to_string return t.render(context_instance) File "/usr/lib/python2.4/site-packages/django/test/utils.py", line 29, in instrumented_test_render return self.nodelist.render(context) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 779, in render bits.append(self.render_node(node, context)) File "/usr/lib/python2.4/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/python2.4/site-packages/django/template/ loader_tags.py", line 97, in render return compiled_parent.render(context) File "/usr/lib/python2.4/site-packages/django/test/utils.py", line 29, in instrumented_test_render return self.nodelist.render(context) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 779, in render bits.append(self.render_node(node, context)) File "/usr/lib/python2.4/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/python2.4/site-packages/django/template/ loader_tags.py", line 97, in render return compiled_parent.render(context) File "/usr/lib/python2.4/site-packages/django/test/utils.py", line 29, in instrumented_test_render return self.nodelist.render(context) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 779, in render bits.append(self.render_node(node, context)) File "/usr/lib/python2.4/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/python2.4/site-packages/django/template/ loader_tags.py", line 24, in render result = self.nodelist.render(context) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 779, in render bits.append(self.render_node(node, context)) File "/usr/lib/python2.4/site-packages/django/template/debug.py", line 81, in render_node raise wrapped TemplateSyntaxError: Caught an exception while rendering: Reverse for 'django.views.i18n.javascript_catalog' with arguments '()' and keyword arguments '{}' not found. Original Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/python2.4/site-packages/django/template/ defaulttags.py", line 382, in render raise e NoReverseMatch: Reverse for 'django.views.i18n.javascript_catalog' with arguments '()' and keyword arguments '{}' not found. == ERROR: test_confirm_different_passwords (django.contrib.auth.tests.views.PasswordResetTest) -- Traceback (most recent call last): File "/home/john.chase/trunk/lib/CloudTest.py", line 249, in tag_aware_case_run testMethod() File "/usr/lib/python2.4/site-packages/django/contrib/auth/tests/ views.py", line 123, in test_confirm_different_passwords response = self.client.post(path, {'new_password1': 'anewpassword', File "/usr/lib/python2.4/site-packages/django/test/client.py", line 313, in post response = self.request(**r) File "/usr/lib/python2.4/site-packages/django/core/handlers/ base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/auth/ views.py", line 141,
Re: i18n Reverse URL Unit Test Error
These are the additions to urls.py js_info_dict = { 'packages': ('cui.translations',), } urlpatterns += patterns('', (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), ) Cheers, John On Mar 23, 6:10 pm, Rolando Espinoza La Fuente wrote: > On Tue, Mar 23, 2010 at 6:38 PM, John wrote: > > I have encountered a Unit Test error while using a reverse url lookup > > for i18n. All is running fine in the development environment. Issues > > only occur during testing. It appears to possibly be an issue with > > shared contexts between contrib.auth and views.i18n. > > How looks your urls.py? > > You should have something like: > > (r'^jsi18n/$', 'django.views.i18n.javascript_catalog'), > > Regards, > > Rolando -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Error when doing the tutorial
Hello all, I am new to django and am doing the tutorial and when I run the command below I get the following error. Does anyone know how to solve this? E:\temp_dj_site\mysite>python manage.py syncdb Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "E:\Python26\lib\site-packages\django\core\management \__init__.py", line 362, in execute_manager utility.execute() File "E:\Python26\lib\site-packages\django\core\management \__init__.py", line 303, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "E:\Python26\lib\site-packages\django\core\management\base.py", line 195, in run_from_argv self.execute(*args, **options.__dict__) File "E:\Python26\lib\site-packages\django\core\management\base.py", line 221, in execute self.validate() File "E:\Python26\lib\site-packages\django\core\management\base.py", line 249, in validate num_errors = get_validation_errors(s, app) File "E:\Python26\lib\site-packages\django\core\management \validation.py", lin e 22, in get_validation_errors from django.db import models, connection File "E:\Python26\lib\site-packages\django\db\__init__.py", line 41, in backend = load_backend(settings.DATABASE_ENGINE) File "E:\Python26\lib\site-packages\django\db\__init__.py", line 17, in load_b ackend return import_module('.base', 'django.db.backends.%s' % backend_name) File "E:\Python26\lib\site-packages\django\utils\importlib.py", line 35, in im port_module __import__(name) File "E:\Python26\lib\site-packages\django\db\backends\mysql \base.py", line 13 , in raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo dule named MySQLdb E:\temp_dj_site\mysite> -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
ForeignKey('self') field displays primary key in list_filter
Hi guys, In a model I have the line: base_lot = models.ForeignKey('self', blank=True, null=True, related_name='base') In the admin, when I set list_filter to 'base_lot', it displays the primary key of the record it is related to instead of what the __str__ model function returns. Is this normal for a self referential foreignkey? I tried using a foreign key that pointed to another model, and the list_filter displayed what that models __str__ function returns, so i'm wondering whether it's just a self referential thing. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ForeignKey('self') field displays primary key in list_filter
Nevermind, I deleted and syncdb'd the models and what i expected showed up On Jul 23, 3:28 pm, John <[EMAIL PROTECTED]> wrote: > Hi guys, > > In a model I have the line: > > base_lot = models.ForeignKey('self', blank=True, null=True, > related_name='base') > > In the admin, when I set list_filter to 'base_lot', it displays the > primary key of the record it is related to instead of what the __str__ > model function returns. Is this normal for a self referential > foreignkey? I tried using a foreign key that pointed to another > model, and the list_filter displayed what that models __str__ function > returns, so i'm wondering whether it's just a self referential thing. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
tsearch2 problems in postgres?
SELECT *, rank(ts_vec, to_tsquery('default', 'lc & 11(')) FROM us WHERE ts_vec @@ to_tsquery('default', 'lc & 11(') LIMIT 9 OFFSET 0 this query gives an error in tsearch2 saying syntax error any idea on how 2 strip the non safe tsearch stuff before feeding it to sql this is from a web search interface? psycopg2.ProgrammingError at /search -> if i give inpu as lc !! ( is there a list of characters that need to stripped out before doing @@ in tsearch2 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
startproject errors with Ubuntu
On Ubuntu Feisty (7.04) I upgraded python2.5 via synaptic. I download the django 0.96 tarball, extracted into usr/local then installed with "sudo python setup.py install" The django files seem to be correctly installed under python2.5/site-packages and I can do "python" => python 2.5 ">>> import django >>>django.VERSION " and I get the correct django version (0.96). I created a symlink at /usr/local/bin to the django django-admin.py file under python2.5. If I go to my home directory and try to create a new project I get a syntax error pointing at the end of startproject. If I try " >>> /usr/lib/... django-admin.py startproject myproject" I get a permission denied error. Something seems wrong here. Any ideas ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: startproject errors with Ubuntu
On Aug 5, 6:43 am, "Jason Ribeiro" <[EMAIL PROTECTED]> wrote: > The 'python-django' package in ubuntu's universe "just works" for me > and 0.96 is in the feisty-backports repository. Why not try that? > > Jason > > On 8/5/07, James Bennett <[EMAIL PROTECTED]> wrote: > > > > > On 8/5/07, john <[EMAIL PROTECTED]> wrote: > > > I created a symlink at /usr/local/bin to the django django-admin.py > > > file under python2.5. If I go to my home directory and try to create > > > a new project I get a syntax error pointing at the end of > > > startproject. If I try " >>> /usr/lib/... django-admin.py > > > startproject myproject" I get a permission denied error. Something > > > seems wrong here. Any ideas ? > > > Go to the directory where django-admin.py is located, and do the following: > > > sudo chmod +x django-admin.py > > > Then try it again. Or, alternatively, use > > > python /path/to/django/bin/django-admin.py startproject someprojectname > > > to bypass the need for the executable bit. > Okay, I attached the backports repository and reinstalled both python2.5 and django - again running version it shows okay. But it appears the Ubuntu packaging is messed up - first there is a /usr/lib/ python-django/bin folder that links to /usr/lib/python2.5/site- packages/django/bin okay but there are duplicate files listed under in each /bin folder and there are no execute permissions for the /bin programs in the python2.5 path. Duplicate files with differing permissions ? So I still get a syntax error trying to run startproject, pointing either at the end of startproject or the end of the project name (depending whether I run it at command line or under python). I have seen other messages with the similar problem on google search without answers - something is apparently wrong and needs to be fixed. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: startproject errors with Ubuntu
On Aug 5, 8:24 pm, ocgstyles <[EMAIL PROTECTED]> wrote: > django-admin.py is a python script that should be ran at the command > line: > > $ django-admin startproject myproject > > ..should work fine. > thks - the tutorial shows the .py extension and that was giving the error. So, can we get the tutorial changed to reflect this ? Also it would be helpful for the tutorial to have a paragraph with the steps of changing the database settings and running the startapp Also I still think something might be wrong with the ubuntu packaging - I don't understand why the same django files (under /django/bin) should be in 3 locations: /usr/lib/python-django/, /usr/lib/ python2.5/site-packages/, and /usr/share/python-support/python- django/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: startproject errors with Ubuntu
On Aug 5, 10:46 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 8/5/07, john <[EMAIL PROTECTED]> wrote: > > > thks - the tutorial shows the .py extension and that was giving the > > error. > > The file's name is 'django-admin.py', not 'django-admin', and the > tutorial is correct; the problem was that you did not have the > executable bit set on django-admin.py, and so you did not have > permission to execute that file from the command line. Okay, but who is the Ubuntu package manager contact for django? - how can we get the packaging straightened out so new people to django don't face the same problem I did. As I mentioned before, it seems the packaging can be improved. > On 8/5/07, john <[EMAIL PROTECTED]> wrote: > Also I still think something might be wrong with the ubuntu packaging > - I don't understand why the same django files (under /django/bin) > should be in 3 locations: /usr/lib/python-django/, /usr/lib/ > python2.5/site-packages/, and /usr/share/python-support/python- > django/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: startproject errors with Ubuntu
On Aug 6, 9:48 am, Brett Parker <[EMAIL PROTECTED]> wrote: > On Mon, Aug 06, 2007 at 06:07:16AM -0700, john wrote: > > > On Aug 5, 10:46 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > > > On 8/5/07, john <[EMAIL PROTECTED]> wrote: > > > > > thks - the tutorial shows the .py extension and that was giving the > > > > error. > > > > The file's name is 'django-admin.py', not 'django-admin', and the > > > tutorial is correct; the problem was that you did not have the > > > executable bit set on django-admin.py, and so you did not have > > > permission to execute that file from the command line. > > > Okay, but who is the Ubuntu package manager contact for django? - > > how can we get the packaging straightened out so new people to django > > don't face the same problem I did. As I mentioned before, it seems > > the packaging can be improved. > > Err, it's not an "official" ubuntu package, it's a compile of the debian > package you can find that with a simple "apt-cache show > python-django". Bugs, apparently, should be mailed to > "[EMAIL PROTECTED]", I'm in the "Original-Maintainer" field. > > The packaging just uses python support - there's nothing clever going on > there - the only thing we (me and raphael, my sponsor for that package) > do is rename django-admin.py to django-admin and drop it in /usr/bin for > convienience. (Oh, and change /usr/bin/env python -> /usr/bin/python, > modify the bash completion to deal with django-admin. > > If you've got any suggestions for the packaging, I'm willing to listen! just as suggestions: 1) the /django/bin/ files are in 3 locations (perhaps because I loaded from respository and from tarball) - the 3 locations are: a) /usr/lib//python2.5/site-packages/ b) /usr/lib/python-django/.. (the folder is symlinked but all the files are still underneath) c) /usr/share/python-support/. if there's a good reason for them to be in all 3 places fine, just is confusing 2) whether ".py" or not to be ".py" doesn't really matter - just an explanation on the tutorial for debian/ubuntu users will help avoid the constant frustration I had trying to get it to run (and to avoid future support msgs on the same issue). thks for the support - I am now exploring Django and seeing if it can convert me from rails. john --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: [Q] Django with modpython in Ubuntu
It would appear to Be a problem with your cookie.py File.In order for me to help you further I will need To see The source of said file John Menerick Sent from my iPhone On Aug 9, 2007, at 9:03 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED] > wrote: > > Dear all, > > I have a problem using mod_python with Django (v 0.95) under apache2 > in Ubunu. > I followed all the steps described in the online documentation, but it > did not work. > The followins is how I set up the httpd.conf and error message I got. > > httpd.conf: > DirectoryIndex index.php index.html index.htm > AcceptPathInfo on > > >SetHandler python-program >PythonHandler django.core.handlers.modpython >SetEnv DJANGO_SETTINGS_MODULE mysite.settings >PythonDebug On >PythonPath "['/home/yjlee/Worx/Django/Projects'] + sys.path" > > > I created a project with "django-admin.py startproject mysite" at "/ > home/yjlee/Worx/Django/Projects" directory. > > When I pointed my web browser to "http://edtech.soe.ku.edu/mysite/"; > I got the following error messages: > Mod_python error: "PythonHandler django.core.handlers.modpython" > > Traceback (most recent call last): > > File "/usr/lib/python2.5/site-packages/mod_python/apache.py", line > 299, in HandlerDispatch >result = object(req) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > modpython.py", line 163, in handler >return ModPythonHandler()(req) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > modpython.py", line 136, in __call__ >response = self.get_response(req.uri, request) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > base.py", line 59, in get_response >response = middleware_method(request) > > File "/var/lib/python-support/python2.5/django/contrib/sessions/ > middleware.py", line 69, in process_request >request.session = > SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME, > None)) > > File "/var/lib/python-support/python2.5/django/core/handlers/ > modpython.py", line 59, in _get_cookies >self._cookies = > http.parse_cookie(self._req.headers_in.get('cookie', '')) > > File "/var/lib/python-support/python2.5/django/http/__init__.py", > line 150, in parse_cookie >c.load(cookie) > > File "Cookie.py", line 619, in load >self.__ParseString(rawdata) > > File "Cookie.py", line 650, in __ParseString >self.__set(K, rval, cval) > > File "Cookie.py", line 572, in __set >M.set(key, real_value, coded_value) > > File "Cookie.py", line 451, in set >raise CookieError("Illegal key value: %s" % key) > > CookieError: Illegal key value: hide:inst11 > > Can anyone help me solve this problem? > > Thanks in advance. > > Young-Jin Lee > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
error with Admin
I am just working on my first project. I successfully created a couple of models but get the following error when I poin the browser at /admin/ Any ideas ? thks. Running on Ubuntu Feisty w/ .96 backport. TemplateDoesNotExist at /admin/ admin/login.html Request Method: GET Request URL:http://127.0.0.1:8000/admin/ Exception Type: TemplateDoesNotExist Exception Value:admin/login.html Exception Location: /usr/lib/python2.5/site-packages/django/template/ loader.py in find_template_source, line 72 Template-loader postmortem Django tried loading these templates, in this order: * Using loader django.template.loaders.filesystem.load_template_source: * Using loader django.template.loaders.app_directories.load_template_source: Traceback (innermost last) Switch to copy-and-paste view * /usr/lib/python2.5/site-packages/django/core/handlers/base.py in get_response 70. # Apply view middleware 71. for middleware_method in self._view_middleware: 72. response = middleware_method(request, callback, callback_args, callback_kwargs) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: error with Admin
On Aug 13, 6:58 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > Do you have "django.contrib.admin" in INSTALLED_APPS? yes > Are the templates actually present in django/contrib/admin/ > templates/ ? there is a directory /usr/lib/python2.5/site-packages/django/contrib/ admin/templatetags/... "templatetags" but no "templates" - is this right ? > > Are the permissions on that directory and every directory above it > such that the webserver can read them? yes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: error with Admin
On Aug 13, 8:28 pm, Empty <[EMAIL PROTECTED]> wrote: > On 8/13/07, john <[EMAIL PROTECTED]> wrote: > > > > Are the templates actually present in django/contrib/admin/ > > > templates/ ? > > > there is a directory /usr/lib/python2.5/site-packages/django/contrib/ > > admin/templatetags/... > > > "templatetags" but no "templates" - is this right ? > > You should have a templates directory in that location. Sounds like > something might be wacky with your install. > there is a template folder under /django/template as well as /django/ templatetags but under /django/contrib/admin there is only the template tags. If this is not right there must be a problem with the Ubuntu Feisty packaging since that is what I installed. I will remove the django package, clean out any django folders and reload. Something is wrong - shouldn't be this hard. Could it be some sort of tab problem with "Installed Apps" ? I think having to edit the "Installed Apps" setting is not only cumbersome but can lead to additional errors - is there a better way ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: error with Admin
On Aug 13, 11:30 pm, Collin Grady <[EMAIL PROTECTED]> wrote: > Your problem is completely unrelated to INSTALLED_APPS, if your django/ > contrib/admin/templates dir is missing. Okay, thks. It appears the Feisty django 0.96 backport is broken. Using synaptic, I removed django, then had to remove the django folder under python2.5 manually, then reinstalled - it only installs the symlinked portion /usr/lib/python-django and does not install any of the django libs under python2.5.I guess I will try to do manually from the tarball. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
0.96 tarball is corrupt
I've downloaded the tarball several times - each time the archiver shows it as corrupt (other tarballs work fine). Using Ubuntu Feisty. (and the Feisty backport package is broken as well). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 0.96 tarball is corrupt
On Aug 14, 1:29 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > I've downloaded the tarball several times - each time the archiver > > shows it as corrupt (other tarballs work fine). Using Ubuntu Feisty. > > (and the Feisty backport package is broken as well). > > Given the multiple responses that the tarball seems fine (tested > on WinXP, OS X, FreeBSD, Ubuntu Dapper, and I tested it on > OpenBSD), I suspect the problem is on your machine. What are you > using to investigate its contents? > > From a command-line, you can try > >bash$ wgethttp://www.djangoproject.com/download/0.96/tarball/ >bash$ tar tvfz Django-0.96.tar.gz thks. wget worked just fine. Clicking on download link does not (as it downloads it cannot calc filesize, indicates mistaking file type). Could it be a problem with the download link operation with Firefox? Or maybe the forces are just telling me to stay with rails :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Can Django be run on 1and1 ?
Can Django be run on a mainstream web hosting company like 1and1.com or does it require a hosting company that specially offers django ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Can Django be run on 1and1 ?
On Aug 25, 7:07 am, Amirouche <[EMAIL PROTECTED]> wrote: > As a general advice don't run anything on 1and1.com ; ) > Unless you want to state a specific good reason, don't make comments like this - we have been using 1and1 for email and static type web hosting for a long time with excellent reliability and low cost. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: deleting a foreign key object deletes all related items
> advisor.delete() I expect should just delete the advisor object and > change p2.advisor and p4.advisor to None but advisor.delete() deletes > p2 and p4. This is the expected behavior, and it's behavior that's required to maintain referential integrity in the database. The docs mention it at http://www.djangoproject.com/documentation/db-api/#deleting-objects : "When Django deletes an object, it emulates the behavior of the SQL constraint ON DELETE CASCADE - in other words, any objects which had foreign keys pointing at the object to be deleted will be deleted along with it." > Is there no way to have an optional relationship to a > foreignobject. Ofcourse I can find all related objects for advisor, > disconnect them from advisor and then delete the advisor. This is exactly what you'll have to do. Maybe something like this (untested): for p in Person.objects.filter(advisor=advisor): p.advisor = None p.save() advisor.delete() You could also override Person's delete() method to make this the default behavior. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Model.py not creating MYSQL tables.
I've created a forms application. After running syncdb without any errors I thought database connection with MYSQL was working. Django tables have been created. After I entered http://localhost:8000/contacts I get the following error. ProgrammingError at /contacts/ (1146, "Table 'iansfree.contacts_contact' doesn't exist") Request Method: GET Request URL:http://localhost:8000/contacts/ Exception Type: ProgrammingError Exception Value:(1146, "Table 'iansfree.contacts_contact' doesn't exist") Exception Location: C:\Python25\lib\site-packages\MySQLdb \connections.py in defaulterrorhandler, line 35 It seems that model.py(below) isn't working. from django.db import models # Create your models here. class Contact(models.Model): name = models.CharField(maxlength=200) phone = models.CharField(maxlength=200) Would anyone know why the table Contact isn't being created in MySQL? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model.py not creating MYSQL tables.
Thanks. That works. Now I'm only getting partial form (NAME AND PHONE INBOX BOX IS DISPLAYED) with a bunch of html code. The html code isn't being rendered properly. Any ideas Contacts Name: Phone: (NAME AND PHONE BOX IS HERE) On Sep 4, 3:51 pm, John <[EMAIL PROTECTED]> wrote: > I've created a forms application. After running syncdb without any > errors I thought database connection with MYSQL was working. Django > tables have been created. > > After I entered http://localhost:8000/contactsI get the following > error. > > ProgrammingError at /contacts/ > (1146, "Table 'iansfree.contacts_contact' doesn't exist") > Request Method: GET > Request URL:http://localhost:8000/contacts/ > Exception Type: ProgrammingError > Exception Value:(1146, "Table 'iansfree.contacts_contact' doesn't > exist") > Exception Location: C:\Python25\lib\site-packages\MySQLdb > \connections.py in defaulterrorhandler, line 35 > > It seems that model.py(below) isn't working. > > from django.db import models > > # Create your models here. > class Contact(models.Model): > name = models.CharField(maxlength=200) > phone = models.CharField(maxlength=200) > > Would anyone know why the table Contact isn't being created in MySQL? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model.py not creating MYSQL tables.
Thanks. That works. Now I'm only getting partial form (NAME AND PHONE INBOX BOX IS DISPLAYED) with a bunch of html code. The html code isn't being rendered properly.The submit button isn't being displayed Any ideas? Contacts Name: Phone: (NAME AND PHONE BOX IS HERE) On Sep 4, 3:58 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 9/4/07, John <[EMAIL PROTECTED]> wrote: > > > > > I've created a forms application. After running syncdb without any > > errors I thought database connection with MYSQL was working. Django > > tables have been created. > > Ensure that your contacts app is listed in INSTALLED_APPS. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model.py not creating MYSQL tables.
The template, view, and form are in dpaste 18690 [Template] 19181 [View] 19183 [Form] I'm using the django contact form On Sep 4, 6:25 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 9/4/07, John <[EMAIL PROTECTED]> wrote: > > > > > Thanks. That works. > > > Now I'm only getting partial form (NAME AND PHONE INBOX BOX IS > > DISPLAYED) with a bunch of html code. The html code > > isn't being rendered properly.The submit button isn't being displayed > > You'll have to show your form, view, and template for me to help with that. > > Use dpaste.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Sending SMS messages
Let me try and answer your questions. Do you need to receive SMS? If you need to receive SMS, you will need to host your own GSM device or modem so that people can send you SMS. If not, you can just use internet SMS gateways like clickatell to do the work, and post to them by HTTP, XML or email. The cost is about 6-8 cents per SMS. There are cheaper services, but not always reliable. If you need to host your own GSM device, you can use software like [url]http://www.kannel.org[/url] (GPL Open Source) or [url]http://www.visualgsm.com[/url]. Regards, SMS Gateway Expert http://www.visualtron.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Sending SMS messages
can you share some other service names, not necessarily cheaper but with a decent api like clickatell has? >>> clickatell is the best for price and reliability Regards, SMS Gateway Expert http://www.visualtron.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Basic ModelForm operation question
If you have code like this using a form that subclasses ModelForm: if request.method == 'POST': form = MyModelForm(request.POST, instance=some_instance) form.is_valid(): form.save() Does MyModelForm first fill it's fields with data from some_instance, and then override with the data that is in request.POST? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
CPOSC 2008 is looking for Django presentations
Hi, I'm with the Central PA Linux User Group (CPLUG) and a few of us are organizing a small, open source conference to be held this fall in Harrisburg, PA (USA). It would be cool to have a Django presentation (or two), so I wanted to extend an invite to those on the django-discuss list. If you or someone you know would like to speak at the conference, please see the details below. Don't be shy! :) Thanks, John *** Call for Participation *** CPOSC, the Central PA Open Source Conference, is a one-day, multi- track, low-cost conference about all things open source: software, programming, operating systems, community and more. It will take place on Sunday, October 19th at the ITT Tech campus in Harrisburg, PA. You can read more about the conference at http://cposc.org We are looking for interesting speakers and talks. Instructions on how to submit abstracts can be found here: http://www.cposc.org/speakers/call-for-participation The submission deadline is July 11, 2008. Accepted speakers will be notified no later than July 25, 2008. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
accessing dictionary elements in opening tag of django template for loop
Hello Django Users, I'm having trouble accessing dictionary elements within a nested for loop. here are some code snippets: # here is the python code that sets up the page class DocumentPage(webapp.RequestHandler): def get(self): # get a list of documents from google app engine datastore documents = Document.all().order('-date') # for every document, get it's associated taglist and stick that in a dictionary tag_dict = {} for document in documents: tag_dict[document.uid] = DocumentTag.all().filter('docid =',document.uid) template_values = { 'documents': documents, 'tag_dict': tag_dict } path = os.path.join(os.path.dirname(__file__), 'document.html') self.response.out.write(template.render(path, template_values)) # so far so good, but then I try to iterate over the documents and their associated tags in a template # here is the template with the html stripped out for readability {% for document in documents %} {{ document.content }} {% for doctag in tag_dict[document.uid] %} {{ doctag.tagid }} {% endfor % } {% endfor %} # document.content is fine, but when I try to access tag_dict within the template's for loop, it complains: TemplateSyntaxError: Could not parse the remainder: [document.uid] # I've tried running essentially the same code in python (without touching django templates), and it seems fine. So there's something about django templates that doesn't accessing a particular dictionary element within the opening tag of a for loop. I'm aware that there is a hack whereby one accesses dict.items, but that seems to defeat the whole purpose of a dictionary, which is to quickly access a particular element. # Any help would be 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: accessing dictionary elements in opening tag of django template for loop
Thanks for the response, Norman! Unfortunately, the Google App Engine version of Django doesn't support the 'with' tag (which would otherwise solve my problem). Also, I don't think I can pass in a context var that already has the list I want, because I need a list *per* document. Any suggestions are extremely welcome! I've been banging my head against this problem all day. On May 14, 2:44 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote: > Sorry, I don't know the exact answer but I can point you in right direction. > > templates always use dot notation for dictionary access > > tag_dict.document.uid > > But I don't think that will work inside a "for" tag and also won't work > cause you want the document.uid to be key not "document". > > The workaround I'm aware of is the "with" tag. > > http://www.djangoproject.com/documentation/templates/#with > > something like this > > {% with document.uid as uid %} >{% for doctag in tag_dict.uid %} {{ doctag.tagid }} {% endfor % } > {% endwith %} > > An alternative is to pass in a context var that already has the list you > want. > > -- > Norman J. Harman Jr. 512 912-5939 > Technology Solutions Group, Austin American-Statesman > ___ > Get out and about this spring with the Statesman! In print and online, > the Statesman has the area's Best Bets and recreation events. > Pick up your copy today or go to statesman.com 24/7. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: accessing dictionary elements in opening tag of django template for loop
Thanks, John. Your second suggestion (that I find a way to modify the Document class) put me on the right track. I eventually found this article: http://blog.arbingersys.com/2008/04/google-app-engine-better-many-to-many.html which worked for my problem. On May 14, 7:17 pm, "John Lenton" <[EMAIL PROTECTED]> wrote: > On Wed, May 14, 2008 at 6:33 PM,John<[EMAIL PROTECTED]> wrote: > > > I'm having trouble accessing dictionary elements within a nested for > > loop. here are some code snippets: > > > [...] > > > # so far so good, but then I try to iterate over the documents and > > their associated tags in a template > > # here is the template with the html stripped out for readability > > {% for document in documents %} > > {{ document.content }} > > {% for doctag in tag_dict[document.uid] %} {{ doctag.tagid }} {% > > endfor % } > > {% endfor %} > > > # document.content is fine, but when I try to access tag_dict within > > the template's for loop, it complains: > > TemplateSyntaxError: Could not parse the remainder: [document.uid] > > right, templates are not python :) you can't do that, and it's on > purpose: that kind of fiddling around with the model is best done in > the view, not in the template. > > So... instead of doing e.g. > > documents = Document.objects.all() > tag_dict = {} > for document in documents: > tag_dict[document.uid] = DocumentTag.objects.filter(docid=document.uid) > > and passing those two into the template, you could do something along > the lines of > > documents = [dict(object=document, > tags=DocumentTag.objects.filter(docid=document.uid)) > for document in Document.objects.all()] > > and then in the template, you do > > {% for document in documents %} > {{ document.object.content }} > {% for doctag in document.tags %} {{ doctag.tagid }} {% endfor %} > {% endfor %} > > this is assuming there is some reason for you not to modify the > Document class to give it the appropriate methods or attributes to > access the related DocumentTag directly; if you could do that, life > would be much easier :) > > --JohnLenton ([EMAIL PROTECTED]) -- Random fortune: > The trouble with a lot of self-made men is that they worship their creator. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: unit testing and comparing dictionaries
Dictionaries compare equal if they contain the same data, regardless of key order. There is no need to convert to sorted sequences unless you need to compare the serialized output (such as in doctests). I would guess that one of the models has additional fields added to its __dict__, perhaps through some caching mechanism. Try printing ``vars(mo)`` and ``vars(saved_mo)``, and then examine the output manually. If you truly wish to examine two model objects for equality, you could try the appended code[1] However, I would advise that you remove your test entirely. It is without point, as Django's unit testing already covers the behavior of ``Model.send()``. Restrict testing to your own code, before you go mad "sanity checking" the massive pile of third-party code underlying yours. [1] -- assertEqual (type (mo), type (saved_mo)) # Retrieve a list of database model field names attrs = [f.attname for f in mo._meta.fields] # Construct lists based on the model attributes, and compare them mo_attrs = [getattr (mo, a) for a in attrs] saved_mo_attrs = [getattr (saved_mo, a) for a in attrs] assertEqual (mo_attrs, saved_mo_attrs) -- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: HTML Escaping JSON data?
If the part of the page being changed is complex, the easiest way to do this is to call render_to_response as usual, but with the template containing only a instead of a full HTML page. Handle any escaping needed in the template. If you only want to update the text without adding any markup, use jQuery.fn.text instead of jQuery.fn.html. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
create/drop individual table
Hi, new to django, getting familiar w/ it. So far, love what I've seen. One question: how do I create/drop an individual table, preferably not from the manage.py shell? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Can I prepopulate a SlugField with a ForeignKey?
add another function: def get_fields(self): return self.color, self.size, self.price --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
user object in templates
it seems like I have no user object in my templates, which is weird, as it comes w/ my request object, and I can access it in my views. In other words, request.user.is_authenticated evaluates to True in my views, but to False in my templates. Before you ask, I do have 'django.core.context_processors.auth' in my TEMPLATE_CONTENTS_PROCESSORS, and AuthenticationMiddleware and SessionMiddleware in my MIDDLEWARE_CLASES. I am running the trunk version of django as of today. Has the sintax for accessing the user object ( {{ user.foo }} ) changed, or am I missing something really, really silly? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Contact Form not Rendering Properly
I'm trying to render the contact form in Django. When i enter http://127.0.0.1:8000/contacts/ I'm only getting a partial form (NAME AND PHONE INBOX BOX IS DISPLAYED) with a bunch of html code. The html code isn't being rendered properly.The submit button isn't being displayed. The template, view, and form are in dpaste 18690 [Template] 19181 [View] 19183 [Form] Any advise would be helpful. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
testing questions
coming from Rails so any help appreciated 1) I realize you can use doctests or unit tests - but is one recommended over the other ? 2) Is it recommended to have unit tests within each class in the models.py file or in a separate testing file ? 3) Fixtures using json (I assume json is the recommended approach): can a new object be defined with json with only a few of the fields defined ? 4) The "Writing your first django app" is very good (thanks) - needs a section on demonstrating testing (since testing should be one of the first things done :) I could try to write it but obviously I don't understand python/django testing too well yet. thks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
python autolink that doesnt mangle html
Hello guys I m looking for a library or a scrip that autolinks html + non html content such as i love... Spin the bottle Redneck hoe http://den.com";>A http://www.google.com loves ICP songs and the result should be i love... Spin the bottle Redneck hoe http://den.com";>A http://www.google.com";>http://www.google.com loves ICP songs --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Plz, I am just new to Python...
On Oct 4, 11:09 am, Emperor of thought <[EMAIL PROTECTED]> wrote: > Please i am just new to python and i will like to know how i can go > about in web development. I am migrating from PHP and phyton web > environment does not look very familiar. Python has a number of frameworks and libraries for web development. Django is but one of your choices. I think it's a good choice. Note that Django is a framework. So, that means instead of writing a file for each web page, you'll be writing: * a file for your models (classes), * a file for your views (functions), * a file mapping urls to view functions (a list), and * some files for your templates (html with some extra bits thrown in). The template files look like php files, but with {% ... %} blocks in them instead of blocks. Then the framework takes care of having the right view get called (which then grabs one of the templates) and returns the page to the user that requested it. > I tried downloading Django and installing it on my windows looks very > difficult. Plsease can anyone help me on how to install Django and how > to go about starting web development in Phyton? I'm not sure of the details for doing it on MS Windows. GNU/Linux is a good environment for development of all sorts. I recommend upgrading to Ubuntu. ---John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Hybrid-django server leaving connections open...
On Nov 13, 5:04 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 11/13/07, John Penix <[EMAIL PROTECTED]> wrote: > > > We've stuck a bit of ORM-using code from our "pure" django server into > > another server that was only using django templates. We have been seeing > > connections left open occasionally. I browsed the mailing list archives and > > it sounds like django should be closing the connection. I'm wondering if we > > aren't always tripping the code that closes the database connection since > > this server is not using django to generate responses. > > Because it's oriented around web serving, Django closes the connection > on the "request_finished" signal; if that signal is never fired, > Django will not close the connection. Additionally, if something else > requires database access after the signal is fired, a new connection > will be opened and will not be closed. Cool. So I'm guessing that if we send that signal as described here: http://code.djangoproject.com/wiki/Signals The connection should get closed. I'll report back if it doesn't work. Thanks! John > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem with date based list_filter in django admin
I'm having a problem with the query string link generated in the filter sidebar of the django admin. The problem only happens when there are multiple query parameters like month and year. Here is a snippet from the html source By Date Made Any date Today Past 7 days This month This year The ampersand is getting escaped twice or something obviously. I've tracked the problem down to the use of the iriencode template filter for the query_string in the admin template filter.py, which i've listed here (it's there by default). If I remove the iriencode, I don't get the repeat of the ampersand entity. {{ choice.display| escape }} Does this have something to do with the autoescape revisions that were just put out? I'm working off of the latest revision if that's of any help. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with date based list_filter in django admin
Yep, I reverted to revision 6669 (one before the autoescape update) and the problem went away. When I re-updated to the current revision the problem appeared again. Maybe I'll file a bug report On Nov 19, 3:02 pm, RajeshD <[EMAIL PROTECTED]> wrote: > > Does this have something to do with the autoescape revisions that were > > just put out? I'm working off of the latest revision if that's of any > > help. Thanks. > > It's likely. If you've the time, perhaps revert to a revision just > prior to when the autoescape changes were committed and report back > here if the problem goes away (or even better, open a ticket.) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with date based list_filter in django admin
This is the exact problem i'm having http://code.djangoproject.com/ticket/5983 On Nov 19, 3:40 pm, John <[EMAIL PROTECTED]> wrote: > Yep, I reverted to revision 6669 (one before the autoescape update) > and the problem went away. When I re-updated to the current revision > the problem appeared again. Maybe I'll file a bug report > > On Nov 19, 3:02 pm, RajeshD <[EMAIL PROTECTED]> wrote: > > > > Does this have something to do with the autoescape revisions that were > > > just put out? I'm working off of the latest revision if that's of any > > > help. Thanks. > > > It's likely. If you've the time, perhaps revert to a revision just > > prior to when the autoescape changes were committed and report back > > here if the problem goes away (or even better, open a ticket.) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
I cant but woefully look at Ruby_oN_rails guys adding ranking with just
Hello guys I m having lots of fun with python it is like all of sudden I m unshackled from the days of zope.. Man it is a lot of fun. It is super simple and easy... Ok now to my question, I m trying to add a ranking feature to various objects in the system, the users, their posts, their media etc, suffice to say I have to rank a lot of objects. I can think of implementing this rudimentarily, add python code and copy to do everything. Each object is a postgres db.. eg Table user { username, metadata, RANKING int4, } and so on... I cant but woefully look at Ruby_oN_rails guys adding ranking with just one line @act_as_votable and they are set.. no more bugs to fix, Do you guys have any ideas on how to do this, somehting similar to @checkaccess in atuh also seems reasonable.. thanks a lot for your time and patience keep rockin in the web/python world John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
email not going to bulkfolder
hi guys i have added a few viral features such as email friends, refer, share item etc... but the problem is the email gets delivered to bulk folder by gym... please tell me how to ensure that emails dont get delivered to bulk folder thanks John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
edit_inline behavior
Howdy -- edit_inline seems to be doing something funky when I use it through update_object generic view. I've got a model that looks something like this: class StationEvent(models.Model): date = models.DateTimeField() description = models.CharField(maxlength = 150) class Admin: pass class StationEventParticipant(models.Model): event = models.ForeignKey(StationEvent,edit_inline=models.TABULAR) participant = models.ForeignKey(Member, core=True) The relevant part of the template is: {% for p in form.stationeventparticipant %} Participant: {{ p.participant }} {% for e in p.errors %} {{ e }} {% endfor %} {% endfor %} At first glance it appears to be working -- the update_oject view for StationEvent lists its fields and a field for a participant. But when it's actually saved, what happens is that for each participant listed, it will create a new StationEventParticipant object whether or not it already existed. So every time I come back after saving the list of participants doubles! All of this machinery works fine in the django dupplied admin interface, so I'm guessing it's something I'm doing wrong. Any help would be awesome! Apologies if this is a common issue, but a search through the mailing list doesn't indicate anyone has had this problem. -- John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Admin user privilege elevation (how to prevent it)
I know nothing about mezzanine, but if you have access to the view functions, then perhaps you can use a construct along the lines of: |def view_function(request):| | if request.user.is_superuser:| |return HttpResponse404() # Or perhaps render the view treating all data as unsafe...| | else| |# render the page as previously...| This could be extended to prevent staff users from being subverted in the same way. Perhaps a decorator could be used instead (eg @unsafe_for_superuser, @unsafe_for_staff). This modifies "don't ever trust user content" to "don't trust admin content if you're a superuser". John On 12/05/12 19:45, Nikolas Stevenson-Molnar wrote: > The issue here is that Josh wants to allow certain users (admins) to > create content with tags, but ensure that said users can't > use JavaScript to gain superuser status or otherwise monkey with > things they shouldn't. So while the "don't trust user content" > approach is a good default, I don't think it applies in this case. And > while this may not be//cross site, per se, it is still request forgery. > > _Nik > > On 5/11/2012 7:13 PM, Russell Keith-Magee wrote: >> On Sat, May 12, 2012 at 5:11 AM, Josh Cartmell <joshcar...@gmail.com> wrote: >>> I work a lot with Mezzanine which is a CMS that uses Django. A >>> security issue was recently revealed where an admin user, lets call >>> him A, (they can post rich content) could put a cleverly constructed >>> javascript on a page such that if a superuser, let's call her B, then >>> visited the page it would elevate A to superuser status (a more >>> thorough explanation is here: >>> <a rel="nofollow" href="http://groups.google.com/group/mezzanine-users/browse_thread/thread/14fde9d8bc71555b/8208a128dbe314e8?lnk=gst&q=security">http://groups.google.com/group/mezzanine-users/browse_thread/thread/14fde9d8bc71555b/8208a128dbe314e8?lnk=gst&q=security</a>). >>> Apparently any django app which allowed admin users to post arbitrary >>> html would be vulnerable. >>> >>> My first thought was that csrf protection should prevent this but alas >>> that is not the case. The only real solution found is to restrict >>> admin users from posting any javascript in their content, unless you >>> completely trust the admin users. >> This isn't a CSRF issue. CSRF stands for Cross Site Request Forgery. A >> CSRF attack is characterised by: >> >> * A user U on site S, who has credentials for the site S, and is logged in. >> >> * An attacking site X that is visited by U. >> >> * Site X submits a form (by POST or GET) directly to site S; because >> U is logged in on S, the post is accepted as if it came from U >> directly. >> >> CSRF protection ensures that site X can't submit the form on the >> behalf of U - the CSRF token isn't visible to the attacker site, so >> they can't provide a token that will allow their submission to be >> accepted. >> >> What you're referring to is an injection attack. An injection attack >> occurs whenever user content is accepted and trusted on face value; >> the attack occurs when that content is then rendered. >> >> The canonical example of an injection is "little johnny tables": >> <a rel="nofollow" href="http://xkcd.com/327/">http://xkcd.com/327/</a> >> >> However, the injected content isn't just SQL; all sorts of content can >> be injected for an attack. In this case, you're talking about B >> injecting javascript onto a page viewed by A; when A views the page, >> the javascript will be executed with A's permissions, allowing B to >> modify the site as if they A. >> >> Django already has many forms of protection against injection attacks. >> In this case, the protection comes by way of Django's default template >> rendering using escaped mode. If you have a template: >> >> {{ content }} >> >> and context (possibly extracted from the database): >> >> <script>alert('hello') >> >> Django will render this as: >> >> <script>alert('hello')<script> >> >> which will be interpreted as text, not as a script tag injected into your >> page. >> >> That said, the protection can be turned off. If you modify the template to >> read: >> >> {{ content|safe }} >> >> or >> >> {% autoescape off %} >> {{ content }} >> {% endautoescape %} >> >> or you mark the i
Re: Render time
Look at Boomerang: http://lognormal.github.com/boomerang/doc/ John On 25/06/12 12:34, Larry Martell wrote: > This is not strictly a django question, but I'm hoping someone here > has solved this and can help me. I have a client that has a django app > that collects a bunch of server side statistics on the users > activities - e.g. what reports they run, the number of rows returned, > how long the query took, etc. Now they want me to add to that how long > the browser takes to render the page after it gets the data. So I have > 3 issues here: > > 1) How can I even calculate that? > 2) How I can return it back to the server? > 3) Since the database table is updated with the other statistics > before the data is sent to the browser, assuming I could calculate the > render time and send it back, how could I find the row and update with > that info? > > If anyone has already done something like this, or anyone has any > advise on how I could do it (especially item #1), I'd really > appreciate them sharing it with me. > > TIA! > -larry > -- You received this message because you are subscribed to the Google 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.
Custom Validation on Inline Generic Foreign Key
Hi there, I am writing an app with Django where I have a model with a generic foreign key. I am looking to do some validation on this model based on the content_type of the generic foreign key. When I am modifying this model on its admin page, I am able to easily determine the content_type because it is in the form data. Then I can do a 'switch' on the content type to perform the correct validations. When I use the Model with the generic foreign key inline in another model, I can't seem to find the content_type or content_id in the form data. I would expect there is a way to get that models content_type from within the inline model's form. So am I missing something here, or is there a better way to approach this problem? Thanks is advance. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
query concerning three tables
i had three tables, trademarks, publication, and entry trademarks has a foreign key to publication, and publication has a foreign key to entry, and entry has a field called published_date, which i am intrested in.. how should i go about such using filters or similar.. when i am writing something like this... tm_queryset = Trademarks.objects.all().filter(created_by__id__exact=76). i have tried this.. but guess its too off the mark.. t = Trademark.objects.all().filter(created_by__id__exact=curr_id).select_related('pub_date','publication_id').filter(pub_date__range=(start_date,end_date), status__exact=status_code, publication_id__exact=pubid) -- You received this message because you are subscribed to the Google 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: saving several models with one save() call
the save method that we call on objects can be overridden.. On Aug 24, 3:28 am, ernando wrote: > Hi all, > > maybe it's newbie question but I wasn't able to find clear answer/ > solution on it. > > For example, we have the following models: > > class A(models.Model): > id = models.AutoField(primary_key=True) > title = models.CharField(max_length=30) > > class B(models.Model): > id = models.AutoField(primary_key=True) > title = models.CharField(max_length=30) > aItems = models.OneToOneField(A) > > And try to save them in the following way: > > a = A(title="123") > b = B(title="333", aItems = a) > b.save() > > This code runs with the error: (1364, "Field 'aItems_id' doesn't have > a default value") > if I firstly save a object - everything goes smoothly. So, the > question is - should we always save all related objects manually? > According to django docs we have to create object at first. But that's > now always convenient - e.g. I receive full model from the 3rd part > service and want to save it into DB with one call and not do it for > each item. > > Regards, > Dmitry -- You received this message because you are subscribed to the Google 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: query concerning three tables
On Aug 24, 6:29 pm, Tom Evans wrote: > On Wed, Aug 24, 2011 at 2:12 PM, john wrote: > > i had three tables, > > trademarks, publication, and entry > > trademarks has a foreign key to publication, and publication has a > > foreign key to entry, and entry has a field called published_date, > > which i am intrested in.. > > how should i go about such using filters or similar.. > > when i am writing something like this... > > tm_queryset = > > Trademarks.objects.all().filter(created_by__id__exact=76). > > > i have tried this.. but guess its too off the mark.. > > t = > > Trademark.objects.all().filter(created_by__id__exact=curr_id).select_related('pub_date','publication_id').filter(pub_date__range=(start_date,end_date), > > status__exact=status_code, publication_id__exact=pubid) > > You need to explain more clearly what information you want to > retrieve, what you have tried, what happened, why that isn't what you > want. > > Cheers > > Tom well.. trademark is a table which has a foreignkey (called publication) to table publication. entry is a table with foreignkey (called publication ) to table publication. now i want to retrieve all trademark objects which are published between certain dates and created by some id say 76.. pub_date being a publication table's field.. i write something like this.. ** tobjs = Trademark.objects.filter(created_by__id__exact=76).filter(publication__entry__pub_date__range=('start_date','end_date')) start_date, end_date are defined previously elsewhere.. tobj.count() gives me 0 which should not be the case.. (** i intend this to work as.. get me all trademark objects created by id 76 and span the relationship across publication and entry to get pub_date field which is entry's field and retrieve all published b/w them ).. -- You received this message because you are subscribed to the Google 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: search with a optional value
thank you nan, i thought i could avoid the if-else structure..with some lookups or something On Aug 17, 12:52 am, Nan wrote: > Filters can be applied in multiple statements, and querysets are > evaluated lazily, so the following would work and would only run a > single query, when you finally output or otherwise check the contents > of the results variable: > > def get_results(...): > ... > results = > MyThing.objects.filter(required_field=somevalue).filter(other_required_field=othervalue) > if optional_value_submitted: > results = results.filter(optional_field=optional_value) > if other_optional_value: > results = > results.filter(other_optional_field=other_optional_value) > return results > > On Aug 16, 8:20 am, john wrote: > > > hi, > > i have a form with few fields as optional,i.e can be left blank, > > i want to search my db for values i receive from this form, how should > > i go on about writing my filters when some of values can be " ". > > any reference is kindly 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: query concerning three tables
this gives me 0 as tobjs.count() which shouldn be the case On Aug 25, 12:04 pm, john wrote: > On Aug 24, 6:29 pm, Tom Evans wrote: > > > > > On Wed, Aug 24, 2011 at 2:12 PM, john wrote: > > > i had three tables, > > > trademarks, publication, and entry > > > trademarks has a foreign key to publication, and publication has a > > > foreign key to entry, and entry has a field called published_date, > > > which i am intrested in.. > > > how should i go about such using filters or similar.. > > > when i am writing something like this... > > > tm_queryset = > > > Trademarks.objects.all().filter(created_by__id__exact=76). > > > > i have tried this.. but guess its too off the mark.. > > > t = > > > Trademark.objects.all().filter(created_by__id__exact=curr_id).select_related('pub_date','publication_id').filter(pub_date__range=(start_date,end_date), > > > status__exact=status_code, publication_id__exact=pubid) > > > You need to explain more clearly what information you want to > > retrieve, what you have tried, what happened, why that isn't what you > > want. > > > Cheers > > > Tom > > well.. > trademark is a table which has a foreignkey (called publication) to > table publication. > entry is a table with foreignkey (called publication ) to table > publication. > > now i want to retrieve all trademark objects which are published > between certain dates and created by some id say 76.. pub_date being a > publication table's field.. > i write something like this.. > > ** tobjs = > Trademark.objects.filter(created_by__id__exact=76).filter(publication__entry__pub_date__range=('start_date','end_date')) > > start_date, end_date are defined previously elsewhere.. > tobj.count() gives me 0 which should not be the case.. > (** i intend this to work as.. get me all trademark objects created > by id 76 and span the relationship across publication and entry to get > pub_date field which is entry's field and retrieve all published b/w > them ).. -- You received this message because you are subscribed to the Google 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: Custom Validation on Inline Generic Foreign Key
Any ideas? In the inline model's validation I could hardcode checks for data that I expect will only be in one of the models, but that does not seem like the best option. I am still hoping for a simpler alternative to this. 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: search with a optional value
thanks On Aug 25, 1:13 pm, Jani Tiainen wrote: > On 08/16/2011 03:20 PM, john wrote: > > > hi, > > i have a form with few fields as optional,i.e can be left blank, > > i want to search my db for values i receive from this form, how should > > i go on about writing my filters when some of values can be " ". > > any reference is kindly appreciated > > I had to do that for a good while back and I used following approach: > > # Add "or contains" query for every nonempty value in form data. > q = Q() > for k,v in form.cleaned_data.items(): > if v: > q |= Q(**{k + '__contains' : v}) > > # Get resultset > r = MyModel.objects.filter(q); > > -- > > Jani Tiainen -- You received this message because you are subscribed to the Google 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: Custom Validation on Inline Generic Foreign Key
I went ahead and hardcoded checks for fields that as of today I know will only be in one of the models. I would still love to hear any cleaner solutions if anyone has them. On Aug 26, 10:12 am, John wrote: > Any ideas? > > In the inline model's validation I could hardcode checks for data that > I expect will only be in one of the models, but that does not seem > like the best option. I am still hoping for a simpler alternative to > this. > > 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.
problem with syncdb and MyQSL
I am a total noob so forgive my ignorance, but I have been going through the Django tutorial - https://docs.djangoproject.com/en/1.3/intro/tutorial01/ I am at the point in the tutorial where I run the following command: C:\Python27>python c:\python27\mysite2\manage.py syncdb Creating tables ... Creating table polls_poll Traceback (most recent call last): File "c:\python27\mysite2\manage.py", line 14, in execute_manager(settings) File "C:\Python27\lib\site-packages\django\core\management \__init__.py", line 438, in execute_manager utility.execute() File "C:\Python27\lib\site-packages\django\core\management \__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 220, in execute output = self.handle(*args, **options) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 351, in handle return self.handle_noargs(**options) File "C:\Python27\lib\site-packages\django\core\management\commands \syncdb.py" , line 101, in handle_noargs cursor.execute(statement) File "C:\Python27\lib\site-packages\django\db\backends\util.py", line 34, in e xecute return self.cursor.execute(sql, params) File "C:\Python27\lib\site-packages\django\db\backends\mysql \base.py", line 86 , in execute return self.cursor.execute(query, args) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174, in execute self.errorhandler(self, exc, value) File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in defau lterrorhandler raise errorclass, errorvalue _mysql_exceptions.InterfaceError: (-1, 'error totally whack') Can someone help? I really appreciate it. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: problem with syncdb and MyQSL
b.staticfiles', 'polls' # Uncomment the next line to enable the admin: # 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', ) # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, } } > > > > > > On Fri, Sep 2, 2011 at 11:38 AM, John wrote: > > I am a total noob so forgive my ignorance, but I have been going > > through the Django tutorial - > >https://docs.djangoproject.com/en/1.3/intro/tutorial01/ > > > I am at the point in the tutorial where I run the following command: > > > C:\Python27>python c:\python27\mysite2\manage.py syncdb > > Creating tables ... > > Creating table polls_poll > > Traceback (most recent call last): > > File "c:\python27\mysite2\manage.py", line 14, in > > execute_manager(settings) > > File "C:\Python27\lib\site-packages\django\core\management > > \__init__.py", line > > 438, in execute_manager > > utility.execute() > > File "C:\Python27\lib\site-packages\django\core\management > > \__init__.py", line > > 379, in execute > > self.fetch_command(subcommand).run_from_argv(self.argv) > > File "C:\Python27\lib\site-packages\django\core\management\base.py", > > line 191, > > in run_from_argv > > self.execute(*args, **options.__dict__) > > File "C:\Python27\lib\site-packages\django\core\management\base.py", > > line 220, > > in execute > > output = self.handle(*args, **options) > > File "C:\Python27\lib\site-packages\django\core\management\base.py", > > line 351, > > in handle > > return self.handle_noargs(**options) > > File "C:\Python27\lib\site-packages\django\core\management\commands > > \syncdb.py" > > , line 101, in handle_noargs > > cursor.execute(statement) > > File "C:\Python27\lib\site-packages\django\db\backends\util.py", > > line 34, in e > > xecute > > return self.cursor.execute(sql, params) > > File "C:\Python27\lib\site-packages\django\db\backends\mysql > > \base.py", line 86 > > , in execute > > return self.cursor.execute(query, args) > > File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 174, > > in execute > > self.errorhandler(self, exc, value) > > File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line > > 36, in defau > > lterrorhandler > > raise errorclass, errorvalue > > _mysql_exceptions.InterfaceError: (-1, 'error totally whack') > > > Can someone help? > > > I really appreciate it. > > > -- > > You received this message because you are subscribed to the Google 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. -- You received this message because you are subscribed to the Google 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.
ORM only/defer calls do not work on cross-table relations
Hey, I'm trying to improve the performance of a Django app, and noticed that you can't seem to properly defer fields when making lookups with joins. To demonstrate, I set up a test project with the following models: class ATestModel(models.Model): other = models.ForeignKey('OtherModel') class OtherModel(models.Model): name = models.CharField(max_length=32) then, in the Django shell, I set up 10 'ATestModel's and two 'OtherModel's properly linked up, and ran the following: >>> from testmodule import models >>> testmodels = models.ATestModel.objects.all().only('other__name') >>> print testmodels[0].other.name Test One >>> from django.db import connection >>> print '\n\n'.join([x['sql'] for x in connection.queries]) SELECT "testmodule_atestmodel"."id", "testmodule_atestmodel"."other_id" FROM "testmodule_atestmodel" LIMIT 1 SELECT "testmodule_othermodel"."id", "testmodule_othermodel"."name" FROM "testmodule_othermodel" WHERE "testmodule_othermodel"."id" = 1 I also re-ran that without the 'only' call: >>> testmodels = models.ATestModel.objects.all() >>> print testmodels[0].other.name Test One >>> print '\n\n'.join([x['sql'] for x in connection.queries[2:]]) SELECT "testmodule_atestmodel"."id", "testmodule_atestmodel"."other_id" FROM "testmodule_atestmodel" LIMIT 1 SELECT "testmodule_othermodel"."id", "testmodule_othermodel"."name" FROM "testmodule_othermodel" WHERE "testmodule_othermodel"."id" = 1 The 'only' call does nothing, and two queries are made when one would have sufficed (SELECT testmodule_othermodel.name FROM testmodule_atestmodel LEFT JOIN testmodule_othermodel ON testmodule_atestmodel.id = testmodule_othermodule.id). This raises a huge performance penalty for highly normalized schemas and I would even go so far as to say it in fact makes it impossible to optimize queries with a decently normalized schema. My apologies if someone has brought this up before - I was unable to see anything about it in the django tickets or mailing lists. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ORM only/defer calls do not work on cross-table relations
Works perfectly, thanks :) Tested with a join 4 levels deep too and it made just one query. I use select_related elsewhere for more generic optimizations but it hadn't occurred to me that django would need the hint once in conjunction with an only() call. Perhaps a patch to ensure that the appropriate select_related call is made in conjunction with an only() would make sense? On Sep 27, 8:28 pm, Alasdair Nicol wrote: > Hi John, > > Use select_related [1] to tell Django to 'follow' the foreign key. Try > the following: > > testmodels = > models.ATestModel.objects.all().select_related('other').only('other__name') > print testmodels[0].other.name > > Regards, > Alasdair > > [1]:https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-re... > > On 27/09/11 21:49, John wrote: > > > > > > > > > > > Hey, > > > I'm trying to improve the performance of a Django app, and noticed > > that you can't seem to properly defer fields when making lookups with > > joins. To demonstrate, I set up a test project with the following > > models: > > > class ATestModel(models.Model): > > other = models.ForeignKey('OtherModel') > > > class OtherModel(models.Model): > > name = models.CharField(max_length=32) > > > then, in the Django shell, I set up 10 'ATestModel's and two > > 'OtherModel's properly linked up, and ran the following: > > >>>> from testmodule import models > >>>> testmodels = models.ATestModel.objects.all().only('other__name') > >>>> print testmodels[0].other.name > > Test One > >>>> from django.db import connection > >>>> print '\n\n'.join([x['sql'] for x in connection.queries]) > > SELECT "testmodule_atestmodel"."id", > > "testmodule_atestmodel"."other_id" FROM "testmodule_atestmodel" LIMIT > > 1 > > > SELECT "testmodule_othermodel"."id", "testmodule_othermodel"."name" > > FROM "testmodule_othermodel" WHERE "testmodule_othermodel"."id" = 1 > > > I also re-ran that without the 'only' call: > > >>>> testmodels = models.ATestModel.objects.all() > >>>> print testmodels[0].other.name > > Test One > >>>> print '\n\n'.join([x['sql'] for x in connection.queries[2:]]) > > SELECT "testmodule_atestmodel"."id", > > "testmodule_atestmodel"."other_id" FROM "testmodule_atestmodel" LIMIT > > 1 > > > SELECT "testmodule_othermodel"."id", "testmodule_othermodel"."name" > > FROM "testmodule_othermodel" WHERE "testmodule_othermodel"."id" = 1 > > > The 'only' call does nothing, and two queries are made when one would > > have sufficed (SELECT testmodule_othermodel.name FROM > > testmodule_atestmodel LEFT JOIN testmodule_othermodel ON > > testmodule_atestmodel.id = testmodule_othermodule.id). This raises a > > huge performance penalty for highly normalized schemas and I would > > even go so far as to say it in fact makes it impossible to optimize > > queries with a decently normalized schema. > > > My apologies if someone has brought this up before - I was unable to > > see anything about it in the django tickets or mailing lists. > > -- > Alasdair Nicol > Developer, MEMSET > > mail: alasd...@memset.com > web:http://www.memset.com/ > > Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, > Guildford, Surrey, GU2 7YD, 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: Define Meta attributes at runtime
I don't believe you'd be able to do this without altering the code for the framework itself; the Django model metaclass hides the Meta attribute (among other things) for non-abstract-base classes. On Sep 30, 6:45 am, Isaac wrote: > Hi folks, > > I'm wondering if it's possible to set / redefine Meta attributes of a > given model at runtime. > > The problem arises because I'm using a framework with many classes > defined there, and interacting in a right way. I need to redefine some > of Meta attributes of that class, but without overriding framework file, > because it can cause many trouble in any update. > > Anyone know how I can access them? > > To set an example: > > folder1 > __init__.py > models.py > > from folder1.models import ModelTrouble > > ModelTrouble.Meta.verbose_name = "my_verbose_name" > > Thanks in advance > Isaac -- You received this message because you are subscribed to the Google 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: set_test_cookie() on every page?
While this is not directly your question, if you want to do something on literally every view, the easiest way to do it would most likely be to add a custom middleware with a process_request or process_response method. More to the point, you should not call set_test_cookie on every view - in the example on the Django docs, the view calls set_test_cookie() then checks for success only if the request method is POST, and if it worked, the logic is short-circuited by a return. So effectively, the workflow for that page goes like this: -user requests login page with method GET -set_test_cookie is called on view -user receives page and Set-Cookie header -user logs in, sending form data with POST -view sees user requesting with POST and checks for existence of cookie -if it fails, it tells the user to enable cookies. -otherwise, user is logged in (and the cookie should have been deleted, but it's not a major problem) As the user should request the page normally (a GET) before they log in (a POST), you should be able to detect whether they have cookies enabled. There is a weakness in this logic - if the user POSTs directly to the page, they may not have the test cookie set, but even if you call set_test_cookie on every view, this won't close that. On Sep 29, 8:49 pm, Victor Hooi wrote: > Hi, > > I've read the Django docs on setting test cookies > (https://docs.djangoproject.com/en/dev/topics/http/sessions/#setting-t...), > and I'm still a bit confused. > > One of our views sets a session variable to remember the object a user is > currently viewing (we figured it wasn't worth storing in the database for > this). > > Should I put set_test_cookie() on every view? That seems a bit > silly/redundant. > > However, if I only put it on the view that sets the session variable, > doesn't that mean the user has to visit that page twice - once to set the > cookie, and (since the if test will fail that first time) again to verify it > was set? How will the user even know to do that? > > Do people actually check for the test cookie these days, or do they just > assume it's set? > > But then if we call delete_test_cookie(), doesn't that mean we have to set > it all over again if the user needs to sets thesession variable again? Or > should we not call delete_test_cookie() > > Cheers, > Victor -- You received this message because you are subscribed to the Google 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: Get latest item by many items in a queryset
I believe that there is no real way for you to avoid having to perform a query for each backend instance. Even in raw SQL, I don't think there is a way to do what you want - in postgres, for example, you could not both order by the timestamp and get distinct values based on backend. However, there is an alternative solution - you can make one query and request all statuses from the past 10 minutes, then manually find the most recent statuses per backend. For instance: from datetime import datetime, timedelta backends = Backend.objects.all() statuses = Status.objects.filter(timestamp__gt=(datetime.now()- timedelta(minutes=10))).order_by(timestamp).only('backend') mapping = {} for st in statuses: mapping[st.backend_id] = st print 'The following have had no status update in the past 10 minutes: ' print '\n'.join(map(str, filter(lambda x:(x.id not in mapping), backends))) Depending on how many status updates you make per 10 minute period on each backend, this could have very low (or very high) overhead on database IO and webserver CPU usage. On Sep 29, 7:36 pm, Colin wrote: > Hi Users, > > So I have a DB that has a list of backends and there properties and I > have a table that gets updated with if it is able to access and the > status. It is only updated when it is reported down or, if it was > reported down and is currenly back up. > > What i want to do is make a queryset that will get only the latest > status for a list of backends. > > #models.py > > class Backend(models.Model): > src_host = models.CharField(max_length=255) > ip = models.CharField(max_length=45) > port = models.CharField(max_length=8) > endpoint_name = models.CharField(max_length=255) > service_prop_name = models.CharField(max_length=255) > endpoint_url = models.CharField(max_length=255) > > class Status(models.Model): > backend = models.ForeignKey(Backend) > timestamp = models.DateTimeField() > status = models.CharField(max_length=255) > > class Meta(): > get_latest_by = 'timestamp' > > What I would like to do is get the latest status reported for the last > ten minutes. Without having to loop through a list querysets and > performing the .latest() function on it. > > Is this possible? > > Thanks, > > Colin -- You received this message because you are subscribed to the Google 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: Get latest item by many items in a queryset
That would still return a single value - the status update with the latest timestamp with one of those backends. On Sep 30, 9:47 am, Dmitry Kuznetsov wrote: > Something like this? > > backends = [backend1,backend2,backend3] > latest_status = Status.objects.filter(backend__in=backends).latest() > > Regards, > Dmitry > > On Sep 29, 7:36 pm, Colin wrote: > > > > > > > > > Hi Users, > > > So I have a DB that has a list of backends and there properties and I > > have a table that gets updated with if it is able to access and the > > status. It is only updated when it is reported down or, if it was > > reported down and is currenly back up. > > > What i want to do is make a queryset that will get only the latest > > status for a list of backends. > > > #models.py > > > class Backend(models.Model): > > src_host = models.CharField(max_length=255) > > ip = models.CharField(max_length=45) > > port = models.CharField(max_length=8) > > endpoint_name = models.CharField(max_length=255) > > service_prop_name = models.CharField(max_length=255) > > endpoint_url = models.CharField(max_length=255) > > > class Status(models.Model): > > backend = models.ForeignKey(Backend) > > timestamp = models.DateTimeField() > > status = models.CharField(max_length=255) > > > class Meta(): > > get_latest_by = 'timestamp' > > > What I would like to do is get the latest status reported for the last > > ten minutes. Without having to loop through a list querysets and > > performing the .latest() function on it. > > > Is this possible? > > > Thanks, > > > Colin -- You received this message because you are subscribed to the Google 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.
Tough problem with m2m field
I have been stymied by this one for a day or two now. I have a situation where I have a 'reference' copy of an application which gets deployed as a new django site with it's own database, url's etc. I am trying to automate this deployment as follows: Present a list of existing sites (there are other options such as disabling the site etc.) with a button to 'Add New Site'. In response to add new site, I create a form based on a Client model in the database which has a m2m relationship with a User model, I also add 3 other models to the form including the django-site ( A 'year' and some other basic configuration stuff) by adding to the form Fields list and by adding a custom save method. Now the tricky stuff... I want to maintain a master list of the sites in the reference database but only the active site in the site specific database, I am doing this via a 2-step process of first invoking the custom save method with an argument of 'site-only' and commit=True to add the site record to the reference database, I then do a custom SQL CREATE DATABASE, GRANT etc., dynamically add the new database to the DATABASES in the settings, call_command syncdb(database=new_database) and then call the custom save with commit=True and database=new_database. Believe it or not, this is all working perfectly fine EXCEPT for the m2m relationship with the user (oops, I should have mentioned that I also select one or more admin users from the reference database to add to the new database). Here is the code I have for the custom save method: def save(self, commit=True, site_only=True, database='default'): if not self.site: self.site = Site(name=self.cleaned_data['name'], domain='provision.tigertaxanalytics.com/' + self.cleaned_data['acronym']) if site_only: if commit: self.site.save(using=database) return self.site else: self.client = super(ClientForm, self).save(commit=False) if commit: try: self.site.save(using=database) # When we create the client in the new database we also need to save the site with the already known id except Exception, e: pass # Mostly for debugging where we don't have true multiple sites self.client.save(using=database) client_users = super(ClientForm, self).save_m2m(commit=False) client_users.save(using=database) #for user in self.cleaned_data['users']: #user.save(using=database) #client_user = Client_Users(client_id = self.client.pk, user_id = user.pk) #client_user.save(using=database) self.provision = Provision(client = self.client, title = self.cleaned_data['provision_title']) self.provision.save(using=database) self.tax_year = TaxYear(provision = self.provision, tax_year = self.cleaned_data['tax_year']) self.tax_year.save(using=database) self.period = Period(tax_year = self.tax_year) self.period.save(using=database) return self.client the error that I am getting is: " AttributeError: 'super' object has no attribute 'save_m2m' " when I try and do the .save_m2m, as far as I can see I am trying to call save_mm2m of the base Form object after doing a base Form.save(commit=False) I guess I have a couple of issues that I haven't seen addressed anywhere here: Is there actually a save_m2m(commit=False) ? I don't see anyway around the problem of saving into the new_database Is there another way to get at the default 'through' table, as you see I tried to reproduce what I imagine save_m2m to be doing, but the Client_Users model isn't present in the models. If I take out the save_m2m stuff it all works perfectly (at least from the database analysis viewpoint) but I can't access the site without a user record in the new_database. Thank you. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
passing data between views / functions
Hello all, I'm building an interactive plotting routine. I have a question on how to manage data objects. I have a View (CBV inherited from DetailView and FormView) that uses information in the URL to parse out a few variables. From those variables I make a file system call to create a dictionary. This dictionary is critical to the remainder of my 'workflow', and it takes some seconds for the file system call to complete. Once the dictionary is created, I use it to prepopulate fields in the form. I'm okay up to here, but my question is one of 'design choice'. At this point, I am storing the dictionary in the session for later access. Once the form is posted I use the dictionary again (pulling it from the session). Here comes the part I'm not so sure about. My plotting routines are outside of django, and I don't want (would prefer anyway) to have django as a dependency. I would prefer to just 'pass' the data to the external class/function. The plot routines need to create the png files, and thus, need to tell the calling routine where they files were created, so I can pass this information back in the context to the return render_to_response. I can force things to work if I don't validate the form, but if I validate the form first, I get an error. Any insight on to where that would be coming from?? Is this the correct paradigm for this process? Here's some pseudocode: MyView(DetailView, FormView): def post() H = MyForm( POST ) C = externalClass(H) def get_object: H = externFileCall(*args) def get_context if not POST: C = MyForm(H) put_to_session(H) return render_to_response(C) Actual code here: http://paste2.org/p/1728601 -- You received this message because you are subscribed to the Google 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 DISTINCT on related model fields
I'm trying to express this query using the Django ORM: SELECT DISTINCT test_b.name FROM test_a LEFT JOIN test_b ON test_a.b_id = test_b.id using Django (with models 'A' and 'B') all I seem to be able to get is SELECT DISTINCT test_a.name, test_a.id FROM a INNER JOIN test_b ON test_a.b_id = test_b.id via the query: A.objects.all().distinct('b__name') I've tried various changes, including select_related() to try and convince it to follow the relation, but no matter what I do it ends up using the fields from the A model in the DISTINCT clause rather than B. I assume that part of the problem is that the query I want to express does not return an A object, but I can't think of how to use the B model to phrase it in the ORM (B.objects.all.distinct('name').filter( "has at least one A 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.