Re: When is a good time to use db_index? Rule of thumb?
Another clarification: It tells django to create an index on that field when you run syncdb to create the tables for your apps. Adding it to an existing model won't change anything by itself. If you decide a field needs an index you can add it to the model definition, and then you can use the "manage.py sqlindexes" command to see what the sql commands are to create the indexes. You'll need to run the create index sql for that field manually using psql (assuming postgres) or some other database client to add the indexes outside of 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: is photologue still maintained?
It may or may not help you, but ImageKit seems actively maintained: https://github.com/jdriscoll/django-imagekit http://groups.google.com/group/django-photologue/browse_thread/thread/4b37b40721a30fcb/f0620ebe8672a34c#f0620ebe8672a34c As far as I understand it, a new version of Photologue was planned, which would be based on Imagekit. I have no idea whether that happened or not. As far as I can see the original developer seems to be inactive on both projects. On Sep 16, 2:02 am, bedros <2bed...@gmail.com> wrote: > any idea who's maintaining photologue and if still has a support > community? and which fork repo supports the latest django release, > there are bunch of forks on googlecode, github, bitbucket? > > Thanks, > > Bedros -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Template loader cannot find admin_doc templates
On Sep 16, 6:33 am, James Bennett wrote: > Worth noting that this is the first thing you're instructed to do in > the documentation for the admin docs system: > > https://docs.djangoproject.com/en/1.3/ref/contrib/admin/admindocs/ > > Might be a good idea to double-check the rest of your setup against > that to make sure nothing else is missing. Thanks James. Even when the Documentation system seemed to be working now, I took your advice and double checked. The instructions I read, however, seem somewhat confusing and in some areas lacking. I could be mistaken, so I hope someone can help me out to understand how all this works. In the link above one reads: -- 1. "Optional: Linking to templates requires the ADMIN_FOR setting to be configured." -- To the best of my knowledge, the templates seem to be working now-- after all I no longer receive TemplateDoesNotExist exceptions anymore (is that not an indication that the linking is up and running?)-- yet I have not set the ADMIN_FOR in my settings file. So why say the linking "requires" it, when it seems not to? It continues: -- 2. "Optional: Using the admindocs bookmarklets requires the XViewMiddleware to be installed." -- I searched the locally generated sphinx Django docs and googled to find the only reference to admindocs bookmarklets is from where I quote it above (i.e. there is no explanation as to what it is and what it actually does), so I don't know if and why I want to use them; but if I assume they are a kind of helper system to organize references that developers might find important, then kindly allow me to suggest that instructions as to how to install the XViewMiddleware are missing from the django docs. One has to grep the django source to see that "XViewMiddleware" is defined in "django\middleware\doc.py" and has to google it to see that inserting 'django.middleware.doc.XViewMiddleware' in MIDDLEWARE_CLASSES [1] is probably the right way to install it. Shouldn't that be in the docs? Best regards [1] http://code.google.com/appengine/articles/django.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: When is a good time to use db_index? Rule of thumb?
To expand, a better answer is when you have profiled your application and have shown a bottleneck, and have tested it with an index on that column and seen an improvement. db_index isn't free, it incurs a penalty on writes so you need to be careful when using them. On Friday, September 16, 2011 at 12:08 AM, Micah Carrick wrote: > As an oversimplification.. any time you will be looking up a record based on > a field, then you want an index on that (or those) fields. If you're finding > a row based on a slug, you want to index that slug field. > > A good tool is to use the Django debug toolbar. When you load a page you can > take a look at the SQL queries. You can then use the 'dbshell' management > command to open up your database shell. Then you can then add "EXPLAIN " > before the SELECT queries to see how it's finding your data. Do a google > search on your database indexes and you'll find all sorts of details. > On Thu, Sep 15, 2011 at 8:38 PM, Micky Hulse (mailto:rgmi...@gmail.com)> wrote: > > Hello, > > > > I have been using this great category/tag model: > > > > https://github.com/praekelt/django-category/blob/master/category/models.py > > > > ... and I noticed that the author added a db_index on the SlugField of > > the Category model. > > > > I hate to admit it, but I don't think I have ever explicitly used > > db_index parameter on any of my models. > > > > When's a good time to use db_index? Is there a general rule of thumb > > when coding Django models? > > > > Sorry if silly question. > > > > Thanks so much! > > > > Cheers, > > Micky > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com > > (mailto:django-users@googlegroups.com). > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > (mailto:django-users%2bunsubscr...@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 > (mailto:django-users@googlegroups.com). > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > (mailto: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.
Re: When is a good time to use db_index? Rule of thumb?
As an oversimplification.. any time you will be looking up a record based on a field, then you want an index on that (or those) fields. If you're finding a row based on a slug, you want to index that slug field. A good tool is to use the Django debug toolbar. When you load a page you can take a look at the SQL queries. You can then use the 'dbshell' management command to open up your database shell. Then you can then add "EXPLAIN " before the SELECT queries to see how it's finding your data. Do a google search on your database indexes and you'll find all sorts of details. On Thu, Sep 15, 2011 at 8:38 PM, Micky Hulse wrote: > Hello, > > I have been using this great category/tag model: > > https://github.com/praekelt/django-category/blob/master/category/models.py > > ... and I noticed that the author added a db_index on the SlugField of > the Category model. > > I hate to admit it, but I don't think I have ever explicitly used > db_index parameter on any of my models. > > When's a good time to use db_index? Is there a general rule of thumb > when coding Django models? > > Sorry if silly question. > > Thanks so much! > > Cheers, > Micky > > -- > You received this message because you are subscribed to the Google 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.
When is a good time to use db_index? Rule of thumb?
Hello, I have been using this great category/tag model: https://github.com/praekelt/django-category/blob/master/category/models.py ... and I noticed that the author added a db_index on the SlugField of the Category model. I hate to admit it, but I don't think I have ever explicitly used db_index parameter on any of my models. When's a good time to use db_index? Is there a general rule of thumb when coding Django models? Sorry if silly question. Thanks so much! Cheers, Micky -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Template loader cannot find admin_doc templates
On Thu, Sep 15, 2011 at 8:29 PM, Piper wrote: > Solved by adding 'django.contrib.admindocs' to the INSTALLED_APPS. Worth noting that this is the first thing you're instructed to do in the documentation for the admin docs system: https://docs.djangoproject.com/en/1.3/ref/contrib/admin/admindocs/ Might be a good idea to double-check the rest of your setup against that to make sure nothing else is missing. -- "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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Template loader cannot find admin_doc templates
Solved by adding 'django.contrib.admindocs' to the 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
CSS can't load when deploy to GAE
Hi, when I runserver on my localhost, CSS can load on the web site. Before I deployed to GAE, I only change the app.yaml setting: - url: /media/admin static_dir: django/contrib/admin/media expiration: '0' to - url: /static static_dir: static expiration: '0' After I deployed to GAE, I only can see the image can work. However, CSS not only can't work on the homepage, but the admin page. But I try the link of CSS can work. I don't know why the image can work, but CSS can't work. How to solve the problem? 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.
TabularInline ordering ignored
The ordering option of TabularInline is ignored on my Django 1.3 installation. It just orders by the default ascending Id. Any ideas on how to activate this option? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
is photologue still maintained?
any idea who's maintaining photologue and if still has a support community? and which fork repo supports the latest django release, there are bunch of forks on googlecode, github, bitbucket? Thanks, Bedros -- You received this message because you are subscribed to the Google 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: memcached problems with cache.clear()
Hallöchen! Tom Evans writes: > [...] > > from django.core.cache import cache for i in xrange(2): cache.set(str(i), str(i)) > ... cache.get('1') > '1' from django.conf import settings settings.CACHES > {'default': {'LOCATION': '10.0.12.11:11211', 'BACKEND': > 'django.core.cache.backends.memcached.CacheClass'}} Could you -- or anybody -- try this again for "93.129.33.177:11211"? This is the IP of my private PC for the next 8 hours (ping wilson(dot)homeunix(dot)com). For me, this fails. If it doesn't fail for you, it is my client's configuration. Thank you! Tschö, Torsten. -- Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Template loader cannot find admin_doc templates
Hello, I tried enabling the admin_doc system in Django 1.3.1 and I got a TemplateDoesNotExist exception as follows: [CUT] TemplateDoesNotExist at /admin/doc/ admin_doc/missing_docutils.html Request Method: GET Request URL:http://127.0.0.1:8000/admin/doc/ Django Version: 1.3.1 Exception Type: TemplateDoesNotExist Exception Value: admin_doc/missing_docutils.html Exception Location: C:\users\Piper\projs\pystuff\lib\site-packages \django\template\loader.py in find_template, line 138 Python Executable: C:\users\Piper\projs\pystuff\Scripts\python.exe Python Version: 2.7.1 [/CUT] My urls.py has the following: [CUT] urlpatterns = patterns('', # Examples: # url(r'^$', 'cms.views.home', name='home'), # url(r'^cms/', include('cms.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), url(r'', include('django.contrib.flatpages.urls')), ) [/CUT] And settings.py has the following in the templates section: [CUT] # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) # more settings... and later: TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/ django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. os.path.join(PROJECT_DIR, 'templates'), ) [/CUT] where PROJECT_DIR = os.path.dirname(__file__) and that is set earlier in top of the settings file. Some of the details of the TemplateDoesNotExist exception reported above are as follows: [CUT] Server time:Thu, 15 Sep 2011 21:57:58 +0300 Template-loader postmortem Django tried loading these templates, in this order: Using loader django.template.loaders.filesystem.Loader: c:\users\Piper\projs\djprojs\cms\templates\admin_doc \missing_docutils.html (File does not exist) Using loader django.template.loaders.app_directories.Loader: c:\users\Piper\projs\pystuff\lib\site-packages\django\contrib \admin\templates\admin_doc\missing_docutils.html (File does not exist) [/CUT] I understand that the first location Django tries is the path I gave in the settings file for my project's own templates, but the second location that Django tries seems odd to me. The actual template directory (and actual file) is in contrib.admindocs: C:\Users\Piper\projs\pystuff\Lib\site-packages\django\contrib\admindocs \templates\admin_doc Not in the subdirectory of contrib.admin: c:\users\Piper\projs\pystuff\lib\site-packages\django\contrib\admin \templates\admin_doc\ Why is Django searching the admin subdirectory instead of admindocs' for the templates of the latter? Any thoughts? -- You received this message because you are subscribed to the Google 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 Connect to Server with Postgresql (9.0)
Hello, Eric Welcome to Django! * Can you ping the server? * Are you sure about your username and password? Try creating a new login role through PgAdmin and use that instead to see if the error is in the connection or in the authentication process. * Does your pg_hba.conf file have an entry which matches the IP from which you are accessing the database? (check towards the very end) -- this shouldn't raise an error on localhost connections, but you never know Try #django and #postgres on irc.freenode.org for help too! Cheers, AT On Thu, Sep 15, 2011 at 3:37 PM, ericdoesdjango wrote: > Windows (vista) > > I did the djangoproject tutorial and I am now going through > djangobook. The first time (going through the djangoproject > tutorial), after creating tables, I tried to enter values in the table > through the django models. This was a couple of weeks ago and I > forgot what error it returned. I then switched into my postgres shell > and entered the first data entry manually. It worked and I was able > to enter subsequent data through the Django framework, so I didn't > think much of it. > > More recently (going through the djangobook example), I have set up a > database connection and created my first tables. Again I tried to > enter the first table values through Django's models framework. This > time I received the error: > > 'could not connect to the server: connection refused (0x274D/ > 10061) > is the server running on host ??? and accepting TCP/IP connections on > port 5432?' > > At first I thought this may have been a problem with my host info in > the settings.py file. However, I now receive this same message when I > try to login to postgres from the windows command line (except '???' > is replaced with 'localhost'). > > I've never had this problem before when using postgres. > 1. How might have Django caused this problem? > 2. How can I fix it? I'm new to Postgresql as well, so I have been > having difficulty finding out how to fix it on their end. > > -- > You received this message because you are subscribed to the Google 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.
Re: memcached problems with cache.clear()
Hallöchen! Tom Evans writes: > On Thu, Sep 15, 2011 at 3:49 PM, Torsten Bronger > wrote: >> Hallöchen! >> >> >> It works for me too if it only accesses localhost. However, if I >> say >> >> "LOCATION": ["192.168.26.130:11211", "192.168.26.131:11211"], >> >> I see that fatal behaviour. >> > > Not for me: Okay, thank you for your input; it narrowed the erroneous case a bit. But how to proceed? Is Django using the memcached module wrongly, or is the memcached module buggy? Tschö, Torsten. -- Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Caching static images using memcache/nginx
Aha! That's briliant, but doesn't nginx set those headers for me when returning a static resource like a image? Thomas On Thu, Sep 15, 2011 at 4:52 PM, Ilian Iliev wrote: > How about to set correct headers and make the images cached on user side > instead > of wasting memchached resources? > If you are serving tons of thumbs multiple times I bet that the traffic will > be bigger problem > than the time it took for these images to be read from disk. > > Check this post -> > http://ilian.i-n-i.org/caching-web-sites-and-web-applications/ there you > can see which headers you need to set to tell the client browser to cache a > resource. > > > On Thu, Sep 15, 2011 at 4:51 PM, Thomas Weholt > wrote: >> >> Good point Cliff! I just assumed serving static content would benefit >> from caching, but perhaps my effort is more well spent focusing on >> other aspects of my app right now. >> >> Thanks :-) >> >> Thomas >> >> >> On Thu, Sep 15, 2011 at 3:42 PM, J. Cliff Dyer >> wrote: >> > What is your goal in doing this? You are unlikely to see any >> > performance gains from this effort. >> > >> > It won't render any faster for your users. Sending bytes over the >> > network is far slower than reading them off disk, so it's not likely to >> > be a bottleneck in terms of page loading. >> > >> > Your filesystem is likely caching commonly read items for you already. >> > Trying to outsmart this system is likely to just waste memory and slow >> > things down by caching the wrong things. >> > >> > Have you determined that this is actually a bottleneck in your app? It >> > seems unlikely that serving static thumbnails is actually the thing >> > slowing your app down. >> > >> > Cheers, >> > Cliff >> > >> > >> > On Thu, 2011-09-15 at 15:24 +0200, Thomas Weholt wrote: >> >> Ok, this might sound a bit off-topic but bear with me. >> >> >> >> I got a templatetag in an app that generates thumbnails ( >> >> django-photofile ). In my templates it might look like this >> >> >> >> >> >> >> >> It will generate a thumbnail of the photo in 100x100 in a folder >> >> served by nginx for all static content and return an url pointing to >> >> the thumbnail, for instance >> >> '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg'. >> >> >> >> This all works nice and dandy, but I want to cache the static photos >> >> using memcache, so that when the page is rendered and the templatetag >> >> returns the url '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg' >> >> nginx will look for it on disk, cache it using memcache and return it >> >> so that the next time the page is rendrered it will be read from the >> >> cache and not from disk. >> >> >> >> I got a folder served by nginx with all my static content (js, css, >> >> images ), including the thumbnails and I want to cache it all ( using >> >> the assigned amount of ram to memcache of course, but I hope this is >> >> handled by memcache ). >> >> >> >> I've read through a few articles about nginx, memcache etc, but still >> >> haven't a clue on how to do this. >> >> >> >> NB! The reason I think/hope this is on topic is the fact I use a >> >> templatetag to generate the url etc. Sorry if it's still of topic. >> >> >> >> -- >> >> Mvh/Best regards, >> >> Thomas Weholt >> >> http://www.weholt.org >> >> >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "Django users" group. >> > To post to this group, send email to django-users@googlegroups.com. >> > To unsubscribe from this group, send email to >> > django-users+unsubscr...@googlegroups.com. >> > For more options, visit this group at >> > http://groups.google.com/group/django-users?hl=en. >> > >> > >> >> >> >> -- >> Mvh/Best regards, >> Thomas Weholt >> http://www.weholt.org >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > > > -- > eng. Ilian Iliev > Web Software Developer > > Mobile: +359 88 66 08 400 > Website: http://ilian.i-n-i.org > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Mvh/Best regards, Thomas Weholt http://www.weholt.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/grou
Re: sending and receiving data using ajax/html
Check this out: http://www.micahcarrick.com/ajax-form-submission-django.html 2011/9/15 jay K. > I do not know anything about send and receiving data using forms in html > django, > I just heard that ajax was good for receiving and sending data (it was > faster) > > any suggestions would be good > > 2011/9/15 Yaşar Arabacı > >> Why do you want to use ajax, instead of regular form post to next page. >> When in next page, you can create hidden form fields to store data you >> passed from first page, and then you can post them again in any page you >> want. >> >> 2011/9/15 jay K. >> >> >>> Hello >>> >>> I have a page where a user makes a selection >>> >>> What I want to do is to take the user's selection to the "next page" >>> so I can process the user's request in a new page >>> >>> How can I do that? >>> >>> I know I have to use ajax (but if there is a better method please let >>> me know), so >>> how can I use ajax to send and receive the information? >>> >>> Thanks >>> >>> Regards >>> >>> -- >>> You received this message because you are subscribed to the Google 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. >>> >>> >> >> >> -- >> http://yasar.serveblog.net/ >> >> -- >> You received this message because you are subscribed to the Google 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. > -- http://yasar.serveblog.net/ -- You received this message because you are subscribed to the Google 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.
Cannot Connect to Server with Postgresql (9.0)
Windows (vista) I did the djangoproject tutorial and I am now going through djangobook. The first time (going through the djangoproject tutorial), after creating tables, I tried to enter values in the table through the django models. This was a couple of weeks ago and I forgot what error it returned. I then switched into my postgres shell and entered the first data entry manually. It worked and I was able to enter subsequent data through the Django framework, so I didn't think much of it. More recently (going through the djangobook example), I have set up a database connection and created my first tables. Again I tried to enter the first table values through Django's models framework. This time I received the error: 'could not connect to the server: connection refused (0x274D/ 10061) is the server running on host ??? and accepting TCP/IP connections on port 5432?' At first I thought this may have been a problem with my host info in the settings.py file. However, I now receive this same message when I try to login to postgres from the windows command line (except '???' is replaced with 'localhost'). I've never had this problem before when using postgres. 1. How might have Django caused this problem? 2. How can I fix it? I'm new to Postgresql as well, so I have been having difficulty finding out how to fix it on their end. -- You received this message because you are subscribed to the Google 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.
Subclassing the ForeignKey field type
Hi all I'm adding an XML mapping feature to Django db models. The idea is to add as little XML mapping information as possible to existing models (such as: which fields get mapped to XML, what is their XPath...) in order to be able to automatically: 1. produce an XML representation of an object; 2. parse a valid XML representation into a new object; and 3. get an XSD schema of the model. I'm well ahead. I have all three features working for some simple models. But I've hit a wall with regard to object relations, or ForeignKey fields. Apparently any subclasses of ForeignKey are completely ignored by Django at runtime, even if they declare __metaclass__ = SubfieldBase I guess they would need a special kind of metaclass, which I guess has not been written yet. Can anybody help me understand what piece is failing? How can I make it work? -Tobia Here is a (non) working example: ### test/models.py: from django.db.models import * # subclassing works for any simple field type, why not related fields? class MyForeignKey(ForeignKey): __metaclass__ = SubfieldBase def __init__(self, *args, **kwargs): ForeignKey.__init__(self, *args, **kwargs) class TestSub(Model): pass class Test(Model): sub = MyForeignKey(TestSub) ### shell: >>> from test.models import Test, TestSub >>> ts = TestSub.objects.create() >>> t = Test.objects.create(sub=ts) Traceback (most recent call last): ... AttributeError: 'Test' object has no attribute 'sub_id' >>> -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ENjhq8ZL_-AJ. 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.
banu
http://123maza.com/65/fun564/ -- You received this message because you are subscribed to the Google 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.
Composite OneToOneFields in Django?
I am fairly new to Django and I think I pretty much get the basic idea of ORM. However, there is a peculiar situation to which I do not see a plausible solution. I have a legacy database for which I am trying to write a Django app. The sql structure of both the tables is: mysql> describe event; +---+--+--+-+-+---+ | Field | Type | Null | Key | Default | Extra | +---+--+--+-+-+---+ | sid | int(10) unsigned | NO | PRI | NULL| | | cid | int(10) unsigned | NO | PRI | NULL| | | signature | int(10) unsigned | NO | MUL | NULL| | | timestamp | datetime | NO | MUL | NULL| | +---+--+--+-+-+---+ mysql> describe alerts; ++---+--+-+--- ++ | Field | Type | Null | Key | Default | Extra | ++---+--+-+--- ++ | id | int(11) | NO | PRI | NULL | auto_increment | | sid| int(11) | YES | MUL | NULL || | cid| int(11) | YES | | NULL || | confidence | int(11) | YES | | NULL || | cvss_base | float | YES | | NULL || | composite_conf | float | YES | | NULL || ++---+--+-+--- ++ The first table cannot be altered because it would break a lot of code (which I have not written). The second table was written by me (hence the surrogate key).In the second ('alerts') table, (sid,cid) is unique. The problem is that (sid,cid) is the key on which tables can be effectively joined. How should the models be re-written so that Django can accurately capture the relation between the two tables? I tried OnetoOne for both sid and cid separately but that is clearly not useful since OnetoOne should apply on (sid,cid) simultaneously. OnetoMany is also of no use and neither is ForeignKey since I need (sid,cid) to be the foreign key. It appears that (sid,cid) composite field should be OnetoOne but I don't know how to achieve that. Note - (sid,cid) value will be of the type 1-55,2-55,3-55,1-56,2-57,3-60 etc. all of which are unique and will have only one entry in both the tables. -- You received this message because you are subscribed to the Google 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: sending and receiving data using ajax/html
Why do you want to use ajax, instead of regular form post to next page. When in next page, you can create hidden form fields to store data you passed from first page, and then you can post them again in any page you want. 2011/9/15 jay K. > > Hello > > I have a page where a user makes a selection > > What I want to do is to take the user's selection to the "next page" > so I can process the user's request in a new page > > How can I do that? > > I know I have to use ajax (but if there is a better method please let > me know), so > how can I use ajax to send and receive the information? > > Thanks > > Regards > > -- > You received this message because you are subscribed to the Google 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. > > -- http://yasar.serveblog.net/ -- You received this message because you are subscribed to the Google 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: sending and receiving data using ajax/html
I do not know anything about send and receiving data using forms in html django, I just heard that ajax was good for receiving and sending data (it was faster) any suggestions would be good 2011/9/15 Yaşar Arabacı > Why do you want to use ajax, instead of regular form post to next page. > When in next page, you can create hidden form fields to store data you > passed from first page, and then you can post them again in any page you > want. > > 2011/9/15 jay K. > > >> Hello >> >> I have a page where a user makes a selection >> >> What I want to do is to take the user's selection to the "next page" >> so I can process the user's request in a new page >> >> How can I do that? >> >> I know I have to use ajax (but if there is a better method please let >> me know), so >> how can I use ajax to send and receive the information? >> >> Thanks >> >> Regards >> >> -- >> You received this message because you are subscribed to the Google 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. >> >> > > > -- > http://yasar.serveblog.net/ > > -- > You received this message because you are subscribed to the Google 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.
sending and receiving data using ajax/html
Hello I have a page where a user makes a selection What I want to do is to take the user's selection to the "next page" so I can process the user's request in a new page How can I do that? I know I have to use ajax (but if there is a better method please let me know), so how can I use ajax to send and receive the information? Thanks Regards -- You received this message because you are subscribed to the Google 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.
What to use for Auth_LDAP credentials?
Hello everyone, I am trying to get the http://packages.python.org/django-auth-ldap to work, but I am having trouble. If someone can give me any ideas, thanks. What is the user i am supposed to use when I log on because I am always getting authentication failed in my environment. Am i supposed to logging with u...@domain.com or with user id only? Any help would be apprreciated here is a link of my settings.py AUTH_LDAP_BIND_DN = "cn=scotty,dc=scottdomain,dc=com" AUTH_LDAP_BIND_PASSWORD = "password" AUTH_LDAP_SERVER_URI = "ldap://server5.scottalvarino.com"; AUTH_LDAP_USER_SEARCH = LDAPSearch("OU=Employees,OU=Users,OU=IT,OU=General,OU=Enterprise,DC=scottdomain,DC=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)") AUTH_LDAP_USER_ATTR_MAP = { "first_name": "givenName", "last_name": "sn", "email": "mail" } AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends.ModelBackend',) -- You received this message because you are subscribed to the Google 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: memcached problems with cache.clear()
On Thu, Sep 15, 2011 at 3:49 PM, Torsten Bronger wrote: > Hallöchen! > > > It works for me too if it only accesses localhost. However, if I > say > > "LOCATION": ["192.168.26.130:11211", "192.168.26.131:11211"], > > I see that fatal behaviour. > Not for me: >>> from django.core.cache import cache >>> for i in xrange(2): cache.set(str(i), str(i)) ... >>> cache.get('1') '1' >>> from django.conf import settings >>> settings.CACHES {'default': {'LOCATION': '10.0.12.11:11211', 'BACKEND': 'django.core.cache.backends.memcached.CacheClass'}} Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Caching static images using memcache/nginx
How about to set correct headers and make the images cached on user side instead of wasting memchached resources? If you are serving tons of thumbs multiple times I bet that the traffic will be bigger problem than the time it took for these images to be read from disk. Check this post -> http://ilian.i-n-i.org/caching-web-sites-and-web-applications/ there you can see which headers you need to set to tell the client browser to cache a resource. On Thu, Sep 15, 2011 at 4:51 PM, Thomas Weholt wrote: > Good point Cliff! I just assumed serving static content would benefit > from caching, but perhaps my effort is more well spent focusing on > other aspects of my app right now. > > Thanks :-) > > Thomas > > > On Thu, Sep 15, 2011 at 3:42 PM, J. Cliff Dyer > wrote: > > What is your goal in doing this? You are unlikely to see any > > performance gains from this effort. > > > > It won't render any faster for your users. Sending bytes over the > > network is far slower than reading them off disk, so it's not likely to > > be a bottleneck in terms of page loading. > > > > Your filesystem is likely caching commonly read items for you already. > > Trying to outsmart this system is likely to just waste memory and slow > > things down by caching the wrong things. > > > > Have you determined that this is actually a bottleneck in your app? It > > seems unlikely that serving static thumbnails is actually the thing > > slowing your app down. > > > > Cheers, > > Cliff > > > > > > On Thu, 2011-09-15 at 15:24 +0200, Thomas Weholt wrote: > >> Ok, this might sound a bit off-topic but bear with me. > >> > >> I got a templatetag in an app that generates thumbnails ( > >> django-photofile ). In my templates it might look like this > >> > >> > >> > >> It will generate a thumbnail of the photo in 100x100 in a folder > >> served by nginx for all static content and return an url pointing to > >> the thumbnail, for instance > >> '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg'. > >> > >> This all works nice and dandy, but I want to cache the static photos > >> using memcache, so that when the page is rendered and the templatetag > >> returns the url '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg' > >> nginx will look for it on disk, cache it using memcache and return it > >> so that the next time the page is rendrered it will be read from the > >> cache and not from disk. > >> > >> I got a folder served by nginx with all my static content (js, css, > >> images ), including the thumbnails and I want to cache it all ( using > >> the assigned amount of ram to memcache of course, but I hope this is > >> handled by memcache ). > >> > >> I've read through a few articles about nginx, memcache etc, but still > >> haven't a clue on how to do this. > >> > >> NB! The reason I think/hope this is on topic is the fact I use a > >> templatetag to generate the url etc. Sorry if it's still of topic. > >> > >> -- > >> Mvh/Best regards, > >> Thomas Weholt > >> http://www.weholt.org > >> > > > > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > > > > > -- > Mvh/Best regards, > Thomas Weholt > http://www.weholt.org > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- eng. Ilian Iliev Web Software Developer Mobile: +359 88 66 08 400 Website: http://ilian.i-n-i.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: memcached problems with cache.clear()
Hallöchen! Tom Evans writes: > On Thu, Sep 15, 2011 at 2:31 PM, Torsten Bronger > wrote: > >> [...] >> >> I found an easy way to reproduce this (with memcached activated in >> settings.py): >> >> chantal@mandy:~/chantal$ ./manage.py shell >> Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) >> [GCC 4.4.3] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> (InteractiveConsole) > from django.core.cache import cache > for i in xrange(2000): cache.set(str(i), str(i)) >> ... >> Traceback (most recent call last): >> File "", line 1, in >> File > "/usr/lib/python2.6/dist-packages/django/core/cache/backends/memcached.py", > line 64, in set >> File "/usr/lib/pymodules/python2.6/memcache.py", line 502, in set >> File "/usr/lib/pymodules/python2.6/memcache.py", line 675, in _set >> File "/usr/lib/pymodules/python2.6/memcache.py", line 278, in _get_server >> File "/usr/lib/pymodules/python2.6/memcache.py", line 883, in connect >> File "/usr/lib/pymodules/python2.6/memcache.py", line 897, in _get_socket >> File "/usr/lib/python2.6/socket.py", line 182, in __init__ >> error: [Errno 24] Too many open files >> >> It *seems* (I don't know for sure) that a socket it opened by >> cache.set() but not closed. Is this the expected behaviour? > > It behaves for me - different OS mind. > > [...] from django.conf import settings settings.CACHES > {'default': {'LOCATION': '127.0.0.1:11211', 'BACKEND': > 'django.core.cache.backends.memcached.CacheClass'}} It works for me too if it only accesses localhost. However, if I say "LOCATION": ["192.168.26.130:11211", "192.168.26.131:11211"], I see that fatal behaviour. Tschö, Torsten. -- Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with Foreign Key on self table and delete() object
Hi all, I tried my code on virtualenv with django 1.3 and this problem is solved, but I have to write this app for django 1.2 :/ I'm thinking that this problem is caused by relationship of the objects, but now I created a new object without 'use' field and immediately deleted it after the .save(). With my surprise all objects in this table was deleted :( In [7]: Test.objects.all() Out[7]: [, , , ] In [8]: obj1 = Test(host_name="othertest") In [9]: obj1.save() In [10]: obj1.delete() In [11]: Test.objects.all() Out[11]: [] Can I avoid this problem ? Thank you in advance Dave On Thu, 1 Sep 2011 08:01:20 -0700 (PDT) davegarath wrote: > Hi all, > > I using django 1.2 > I have a problem with model and Foreign Key on self table. > > I try to explain the problem with an example: > > I have one table like this : > > class Test_obj ( models.Model ): > name = models.CharField(max_length=255, unique=True, null=True) > use = models.ForeignKey('self', to_field='name',null=True, > db_column='use') > > class Meta: > abstract = True > > > class Test ( Test_obj ): > host_name = models.CharField(max_length=255, > unique=True, null=True) > alias = models.CharField(max_length=255, > null=True) > > def __unicode__(self): > if self.name: > return self.name > else: > return self.host_name > > > Now, in shell, I create some objects and I delete a parent object > "template1" and django works as I'm expect emulating > on delete cascade : > > In [8]: template1 = Test(name='template1') > > In [9]: template1.save() > > In [10]: host1 = Test(host_name='host1') > > In [11]: host2 = Test(host_name='host2') > > In [12]: host3 = Test(host_name='host3') > > In [13]: host1.use = template1 > > In [14]: host2.use = template1 > > In [15]: host3.use = template1 > > In [16]: host1.save() > > In [17]: host2.save() > > In [18]: host3.save() > > In [19]: Test.objects.all() > Out[19]: [, , , host3>] > > In [20]: template1.delete() > > In [21]: Test.objects.all() > Out[21]: [] > > > But I don't understand why django do the same thing when I delete a > children : > > In [27]: Test.objects.all() > Out[27]: [, , , template1>] > > In [28]: hos1 = Test.objects.get(host_name='host1') > > In [29]: host1.delete() > > In [30]: Test.objects.all() > Out[30]: [] > > > Is this a django bug or I'm wrong something ? > > Thank you, > Dave -- You received this message because you are subscribed to the Google 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: memcached problems with cache.clear()
On Thu, Sep 15, 2011 at 2:31 PM, Torsten Bronger wrote: > Hallöchen! > > Torsten Bronger writes: > >> Sometimes, we experience a massive increase in active connections >> to the memcached server when calling cache.clear(). This causes >> server tracebacks because the server cannot open files >> (e.g. Python modules) anymore: "error 24: Too many open files". > > I found an easy way to reproduce this (with memcached activated in > settings.py): > > chantal@mandy:~/chantal$ ./manage.py shell > Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > (InteractiveConsole) from django.core.cache import cache for i in xrange(2000): cache.set(str(i), str(i)) > ... > Traceback (most recent call last): > File "", line 1, in > File > "/usr/lib/python2.6/dist-packages/django/core/cache/backends/memcached.py", > line 64, in set > File "/usr/lib/pymodules/python2.6/memcache.py", line 502, in set > File "/usr/lib/pymodules/python2.6/memcache.py", line 675, in _set > File "/usr/lib/pymodules/python2.6/memcache.py", line 278, in _get_server > File "/usr/lib/pymodules/python2.6/memcache.py", line 883, in connect > File "/usr/lib/pymodules/python2.6/memcache.py", line 897, in _get_socket > File "/usr/lib/python2.6/socket.py", line 182, in __init__ > error: [Errno 24] Too many open files > > It *seems* (I don't know for sure) that a socket it opened by > cache.set() but not closed. Is this the expected behaviour? > > Tschö, > Torsten. > It behaves for me - different OS mind. Python 2.7.1 (r271:86832, Dec 13 2010, 15:52:15) [GCC 4.2.1 20070719 [FreeBSD]] on freebsd8 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.core.cache import cache >>> for i in xrange(20): cache.set(str(i), str(i)) ... >>> cache.get('1') '1' >>> from django.conf import settings >>> settings.CACHES {'default': {'LOCATION': '127.0.0.1:11211', 'BACKEND': 'django.core.cache.backends.memcached.CacheClass'}} At a guess I'd say your memcached client library is not closing its socket. > $ pkg_info | grep memca libmemcached-0.49 A C and C++ client library to the memcached server memcached-1.4.5_2 High-performance distributed memory object cache system > $ pip freeze | grep memc python-memcached==1.45 Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Caching static images using memcache/nginx
What is your goal in doing this? You are unlikely to see any performance gains from this effort. It won't render any faster for your users. Sending bytes over the network is far slower than reading them off disk, so it's not likely to be a bottleneck in terms of page loading. Your filesystem is likely caching commonly read items for you already. Trying to outsmart this system is likely to just waste memory and slow things down by caching the wrong things. Have you determined that this is actually a bottleneck in your app? It seems unlikely that serving static thumbnails is actually the thing slowing your app down. Cheers, Cliff On Thu, 2011-09-15 at 15:24 +0200, Thomas Weholt wrote: > Ok, this might sound a bit off-topic but bear with me. > > I got a templatetag in an app that generates thumbnails ( > django-photofile ). In my templates it might look like this > > > > It will generate a thumbnail of the photo in 100x100 in a folder > served by nginx for all static content and return an url pointing to > the thumbnail, for instance > '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg'. > > This all works nice and dandy, but I want to cache the static photos > using memcache, so that when the page is rendered and the templatetag > returns the url '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg' > nginx will look for it on disk, cache it using memcache and return it > so that the next time the page is rendrered it will be read from the > cache and not from disk. > > I got a folder served by nginx with all my static content (js, css, > images ), including the thumbnails and I want to cache it all ( using > the assigned amount of ram to memcache of course, but I hope this is > handled by memcache ). > > I've read through a few articles about nginx, memcache etc, but still > haven't a clue on how to do this. > > NB! The reason I think/hope this is on topic is the fact I use a > templatetag to generate the url etc. Sorry if it's still of topic. > > -- > Mvh/Best regards, > Thomas Weholt > http://www.weholt.org > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Caching static images using memcache/nginx
Good point Cliff! I just assumed serving static content would benefit from caching, but perhaps my effort is more well spent focusing on other aspects of my app right now. Thanks :-) Thomas On Thu, Sep 15, 2011 at 3:42 PM, J. Cliff Dyer wrote: > What is your goal in doing this? You are unlikely to see any > performance gains from this effort. > > It won't render any faster for your users. Sending bytes over the > network is far slower than reading them off disk, so it's not likely to > be a bottleneck in terms of page loading. > > Your filesystem is likely caching commonly read items for you already. > Trying to outsmart this system is likely to just waste memory and slow > things down by caching the wrong things. > > Have you determined that this is actually a bottleneck in your app? It > seems unlikely that serving static thumbnails is actually the thing > slowing your app down. > > Cheers, > Cliff > > > On Thu, 2011-09-15 at 15:24 +0200, Thomas Weholt wrote: >> Ok, this might sound a bit off-topic but bear with me. >> >> I got a templatetag in an app that generates thumbnails ( >> django-photofile ). In my templates it might look like this >> >> >> >> It will generate a thumbnail of the photo in 100x100 in a folder >> served by nginx for all static content and return an url pointing to >> the thumbnail, for instance >> '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg'. >> >> This all works nice and dandy, but I want to cache the static photos >> using memcache, so that when the page is rendered and the templatetag >> returns the url '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg' >> nginx will look for it on disk, cache it using memcache and return it >> so that the next time the page is rendrered it will be read from the >> cache and not from disk. >> >> I got a folder served by nginx with all my static content (js, css, >> images ), including the thumbnails and I want to cache it all ( using >> the assigned amount of ram to memcache of course, but I hope this is >> handled by memcache ). >> >> I've read through a few articles about nginx, memcache etc, but still >> haven't a clue on how to do this. >> >> NB! The reason I think/hope this is on topic is the fact I use a >> templatetag to generate the url etc. Sorry if it's still of topic. >> >> -- >> Mvh/Best regards, >> Thomas Weholt >> http://www.weholt.org >> > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Mvh/Best regards, Thomas Weholt http://www.weholt.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: memcached problems with cache.clear()
Hallöchen! Torsten Bronger writes: > Sometimes, we experience a massive increase in active connections > to the memcached server when calling cache.clear(). This causes > server tracebacks because the server cannot open files > (e.g. Python modules) anymore: "error 24: Too many open files". I found an easy way to reproduce this (with memcached activated in settings.py): chantal@mandy:~/chantal$ ./manage.py shell Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.core.cache import cache >>> for i in xrange(2000): cache.set(str(i), str(i)) ... Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/dist-packages/django/core/cache/backends/memcached.py", line 64, in set File "/usr/lib/pymodules/python2.6/memcache.py", line 502, in set File "/usr/lib/pymodules/python2.6/memcache.py", line 675, in _set File "/usr/lib/pymodules/python2.6/memcache.py", line 278, in _get_server File "/usr/lib/pymodules/python2.6/memcache.py", line 883, in connect File "/usr/lib/pymodules/python2.6/memcache.py", line 897, in _get_socket File "/usr/lib/python2.6/socket.py", line 182, in __init__ error: [Errno 24] Too many open files It *seems* (I don't know for sure) that a socket it opened by cache.set() but not closed. Is this the expected behaviour? Tschö, Torsten. -- Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using gedit for django development
Yes. I mostly use vim+yakuake. I really like gedit and have used it for large projects too. Notably: I will try this gedit-django-project pluggin as it never hurts to know your way around multiple IDE's. sam_w -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Caching static images using memcache/nginx
Ok, this might sound a bit off-topic but bear with me. I got a templatetag in an app that generates thumbnails ( django-photofile ). In my templates it might look like this It will generate a thumbnail of the photo in 100x100 in a folder served by nginx for all static content and return an url pointing to the thumbnail, for instance '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg'. This all works nice and dandy, but I want to cache the static photos using memcache, so that when the page is rendered and the templatetag returns the url '/static/thumb/4432lkj432kl5k4l26k_100x100.jpg' nginx will look for it on disk, cache it using memcache and return it so that the next time the page is rendrered it will be read from the cache and not from disk. I got a folder served by nginx with all my static content (js, css, images ), including the thumbnails and I want to cache it all ( using the assigned amount of ram to memcache of course, but I hope this is handled by memcache ). I've read through a few articles about nginx, memcache etc, but still haven't a clue on how to do this. NB! The reason I think/hope this is on topic is the fact I use a templatetag to generate the url etc. Sorry if it's still of topic. -- Mvh/Best regards, Thomas Weholt http://www.weholt.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
memcached problems with cache.clear()
Hallöchen! Sometimes, we experience a massive increase in active connections to the memcached server when calling cache.clear(). This causes server tracebacks because the server cannot open files (e.g. Python modules) anymore: "error 24: Too many open files". Increasing the allowed files for www-data in /etc/security/limits didn't help. Currently, the only solution I see is to replace cache.clear() with subprocess.call(["/etc/init.d/memcached", "restart"]). Has anybody had a similar problem? Tschö, Torsten. -- Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
[JOB] Django/Python Developer, NYC | 90-110k
Details here: http://opensourcestaffing.wordpress.com/2011/09/14/job-django-python-developer-nyc-90-110k -- You received this message because you are subscribed to the Google 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 mysite problem
This is my PATH variable -C:\Python27\lib\site-packages\django\bin\ and django-admin.py is located in this path. This is my PYTHONPATH variable-C:\Python27;c:\Python27\lib\site-packages\django Im able to import django and dont have problems when I execute the django.VERSION command. On Wed, Sep 14, 2011 at 10:26 PM, Yves S. Garret wrote: > Is Python in your path? > > On Wed, Sep 14, 2011 at 10:01 PM, PremAnand Lakshmanan > wrote: > >> I have a problem executing this command, >> >> C:\Python27\Lib\site-packages\django\bin\django-admin.py startproject >> mysite2 >> >> SyntaxError: invalid syntax >> >> I get the above error.. >> >> -- >> Prem >> >> -- >> You received this message because you are subscribed to the Google 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. > -- Prem 408-393-2545 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Caching/Reload problem - cannot refresh model data
On Thu, Sep 15, 2011 at 9:56 AM, Ilian Iliev wrote: > "Any UPDATE or INSERT will always commit the current transaction." ??? > > If this is correct(which I doubt) then you do not have transactions at all. > As I know > the idea of transaction is to run multiple statements in a way that they are > independent form > the other statements run at the same time? > You're right, I hadn't had my coffee :/ Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: nested forms from model with manytomany
On Sep 14, 2011, at 11:32 PM, Visgean wrote: Hello I have these two models: class SubOrder(models.Model): """ This is model for single order it should be used later in complex order """ product = models.ForeignKey(Product) quantity = models.SmallIntegerField() class Order(models.Model): "Model for complex order containing many SubOrder instances" customer = models.CharField(max_length = 20) day = models.DateField(auto_now = True) paid = models.BooleanField(default = False) delivered = models.BooleanField(default = False) sub_orders = models.ManyToManyField(SubOrder) selled_by = models.ForeignKey(User) The problem is that I want to do views for adding Order model with possibility to add as many SubOrders as user wants. Currently I solve this by reading POST data... ( code: https://github.com/A3soft/Lisculea/blob/master/Lisculea/Cafe/ views.py#L24 and https://github.com/A3soft/Lisculea/blob/master/Lisculea/Templates/cafe/order_new.djhtml ) The problem is that I want users to be able to add SubOrders to Order object using formset. So I need to add/select subOrder from the same views as Order, I also need to display Order formset and be able to edit/add suborders later. And all SubOrders as their full widget -and not only as selection for instance. So, do you have any ideas how to do this without avoiding a lot of coding - i mean using django forms and formsets? Hi Visgean, I think you want inline formsets: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/ #inline-formsets Cheers, Roald -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Caching/Reload problem - cannot refresh model data
"Any UPDATE or INSERT will always commit the current transaction." ??? If this is correct(which I doubt) then you do not have transactions at all. As I know the idea of transaction is to run multiple statements in a way that they are independent form the other statements run at the same time? -- eng. Ilian Iliev Web Software Developer Mobile: +359 88 66 08 400 Website: http://ilian.i-n-i.org On Thu, Sep 15, 2011 at 11:43 AM, Tom Evans wrote: > On Wed, Sep 14, 2011 at 6:57 PM, Ilian Iliev wrote: > > Hi Tom, > > I checked the link you send and probably you are right but > > can you explain why this is a bad solution? > > Yes using autocommit() or disabling transactions seems more right > > are there any downsides of the update() that you are seeing? > > Image a case when you want to update the result set without breaking the > > transaction(is this possible)? > > I am not trolling just asking? > > Regards, > > Ilian Iliev > > It's bad for future maintenance. Other developers may not know that > trick, and be confused why you are doing a 'pointless' update, without > grokking the unannounced side effect. It is always better to be > explicit rather than implicit. > > Any UPDATE or INSERT will always commit the current transaction. > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > 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.
Re: Caching/Reload problem - cannot refresh model data
On Wed, Sep 14, 2011 at 6:57 PM, Ilian Iliev wrote: > Hi Tom, > I checked the link you send and probably you are right but > can you explain why this is a bad solution? > Yes using autocommit() or disabling transactions seems more right > are there any downsides of the update() that you are seeing? > Image a case when you want to update the result set without breaking the > transaction(is this possible)? > I am not trolling just asking? > Regards, > Ilian Iliev It's bad for future maintenance. Other developers may not know that trick, and be confused why you are doing a 'pointless' update, without grokking the unannounced side effect. It is always better to be explicit rather than implicit. Any UPDATE or INSERT will always commit the current transaction. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: newbie question on activating the automatic admin
Cool On 9/14/11, nara wrote: > Finally! The admin interface worked, when I used the dev version > in a virtualenv. I cleaned every trace of Django in my system, > and I had to compile (requires python-dev package in > Ubuntu) and install MySQLdb into the virtualenv. > > Not sure what exactly was wrong before, but Babatunde's suggestion > that I had mixed up code installed (some in system files, and also > mixed Django1.3 and the dev release) seems like the best guess. > > Thanks for everyone's help ;) > Nara > > On Sep 11, 10:44 pm, Babatunde Akinyanmi wrote: >> And reply here if you don't see problems :) >> >> On 9/12/11, nara wrote: >> >> >> >> >> >> >> >> >> >> > ok, i am planning to remove all traces of all django installations >> > from my >> > system, and re-install the dev version (and if that still does not >> > work 3.1) >> > under virtualenv. >> >> > Will repost here if I still see problems. >> >> > Nara >> >> > On Sep 10, 7:16 pm, Babatunde Akinyanmi wrote: >> >> Hi nara, >> >> Please post the debug output you get when you try to view the admin >> >> page from your browser. >> >> >> Meanwhile, while switching versions of django, you have to make sure >> >> you remove completely every file from the old version. Failure to do >> >> that will break django. >> >> >> On 9/10/11, nara wrote: >> >> >> > ok, I switched to the 1.3.1 released version of Django, and >> >> > also tried Python2.6 instead of Python2.7 on the dev version >> >> > of Django. Things are still majorly broken, see the following >> >> > in the django shell on a fresh startproject, I could not >> >> > import even the top level django module. Then, >> >> > I set PYTHONPATH to /home/nara/Django1.3/django, >> >> > and after that, in the shell, I am still unable to >> >> > directly import the admin module, I have to do this: >> >> >> import django >> >> import django.contrib >> >> import django.contrib.admin >> >> >> > So, the problem is not just in the admin module, it >> >> > is likely all over the place (entire django module hierarchy). >> >> >> > Oh well, looks like I have to cool this off for a while. >> >> >> > Thanks for everyone's help. >> >> > Nara >> >> >> > On Sep 10, 2:17 pm, nara wrote: >> >> >> I'll get through this yet :) >> >> >> >> I tried the commands you have under the django shell, and I got >> >> >> 'example.com' >> >> >> on the django.Site query, and not an error. Also, interestingly, >> >> >> within the shell, I don't see >> >> >> django on the sys.path at all (shown below), but I do see my project >> >> >> mblog. This could >> >> >> be the cause of not seeing the admin. I could switch to python 2.6 >> >> >> instead >> >> >> of python 2.7, but I doubt that that is going fix this issue. >> >> >> Dropping >> >> >> my project >> >> >> table and doing a new syncdb did not help either. >> >> >> >> Here is the path, prettified: >> >> >> >> ['/home/nara/dj/mblog' >> >> >> '/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg' >> >> >> '/usr/local/lib/python2.7/dist-packages/grin-1.2.1-py2.7.egg' >> >> >> '/usr/local/lib/python2.7/dist-packages/pip-1.0.2-py2.7.egg' >> >> >> '/usr/lib/python2.7' >> >> >> '/usr/lib/python2.7/plat-linux2' >> >> >> '/usr/lib/python2.7/lib-tk' >> >> >> '/usr/lib/python2.7/lib-old' >> >> >> '/usr/lib/python2.7/lib-dynload' >> >> >> '/usr/local/lib/python2.7/dist-packages' >> >> >> '/usr/lib/python2.7/dist-packages' >> >> >> '/usr/lib/python2.7/dist-packages/PIL' >> >> >> '/usr/lib/pymodules/python2.7/gtk-2.0' >> >> >> '/usr/lib/python2.7/dist-packages/gst-0.10' >> >> >> '/usr/lib/python2.7/dist-packages/gtk-2.0' >> >> >> '/usr/lib/pymodules/python2.7' >> >> >> '/usr/lib/pymodules/python2.7/ubuntuone-control-panel' >> >> >> '/usr/lib/pymodules/python2.7/libubuntuone' >> >> >> '/usr/lib/pymodules/python2.7/ubuntuone-storage-protocol' >> >> >> '/usr/lib/pymodules/python2.7/ubuntuone-client'] >> >> >> >> Thanks >> >> >> Nara >> >> >> >> On Sep 9, 9:56 pm, Babatunde Akinyanmi wrote: >> >> >> >> > Hi nara, >> >> >> > This error is normally thrown when the sites app is being used in >> >> >> > a >> >> >> > django project. I think it can also occur if the sites tables in >> >> >> > the >> >> >> > database is not properly created during django-admin startproject. >> >> >> > Someone else reported that he was able to solve the problem by >> >> >> > using >> >> >> > a >> >> >> > user name without special characters. >> >> >> >> > This might be difficult to debug since you are using a development >> >> >> > version however: >> >> >> > 1. Go to the inbuilt django shell and enter these commands: >> >> >> > from django.contrib.sites.models import Site >> >> >> > From django.conf import settings >> >> >> > x = settings.SITE_ID >> >> >> > Site.objects.get(pk=x) >> >> >> >> > You should get the same "site matching query does not exist" >> >> >> > error. >> >> >> > Now print x and then check the django_site_table in your database. >> >> >> > x >> >> >>