Search Results

Search found 15298 results on 612 pages for 'django template tags'.

Page 18/612 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Doing a count over a filter query efficiently in django

    - by apple_pie
    Hello, Django newbie here, I need to do a count over a certain filter in a django model. If I do it like so: my_model.objects.filter(...).count() I'm guessing it does the SQL query that retrieves all the rows and only afterwards does the count. To my knowledge it's much more efficient to do the count without retrieving those rows like so "SELECT COUNT(*) FROM ...". Is there a way to do so in django?

    Read the article

  • customizing Django look and feel in Python

    - by user248237
    I am learning Django and got it to work with wsgi. I'm following the tutorial here: http://docs.djangoproject.com/en/1.1/intro/tutorial01/ My question is: how can I customize the look and feel of Django? Is there a repository of templates that "look good", kind of like there are for Wordpress, that I can start from? I find the tutorial counterintuitive in that it goes immediately toward customizing the admin page of Django, rather than the main pages visible to users of the site. Is there an example of a "typical" Django site, with a decent template, that I can look at and built on/modify? The polls application is again not very representative since it's so specialized. any references on this would be greatly appreciated. thanks.

    Read the article

  • Django: common template subsections

    - by Parand
    What's a good way to handle commonly occurring subsections of templates? For example, there is a sub-header section that's used across 4 different pages. The pages are different enough to not work well with template inheritance (ie. "extends" doesn't fit well). Is "include" the recommended method here? It feels a bit heavyweight, requiring each subsection or snippet to be in its own file. Are there any performance issues in using include or is it smart about forming template from the subsections (ie. if I make extensive use of it, do I pay any penalties)? I think what I'm looking for is something like template tags, but without the programming - a simple way to create a library of html template tags I can sprinkle in other templates.

    Read the article

  • [SOLVED]Django - Passing variables to template based on db

    - by George 'Griffin
    I am trying to add a feature to my app that would allow me to enable/disable the "Call Me" button based on whether or not I am at [home|the office]. I created a model in the database called setting, it looks like this: class setting(models.Model): key = models.CharField(max_length=200) value = models.CharField(max_length=200) Pretty simple. There is currently one row, available, the value of it is the string True. I want to be able to transparently pass variables to the templates like this: {% if available %} <!-- Display button --> {% else %} <!-- Display grayed out button --> {% endif %} Now, I could add logic to every view that would check the database, and pass the variable to the template, but I am trying to stay DRY. What is the best way to do this? UPDATE I created a context processor, and added it's path to the TEMPLATE_CONTEXT_PROCESSORS, but it is not being passed to the template def available(request): available = Setting.objects.get(key="available") if open.value == "True": return {"available":True} else: return {} UPDATE TWO If you are using the shortcut render_to_response, you need to pass an instance of RequestContext to the function. from the django documentation: If you're using Django's render_to_response() shortcut to populate a template with the contents of a dictionary, your template will be passed a Context instance by default (not a RequestContext). To use a RequestContext in your template rendering, pass an optional third argument to render_to_response(): a RequestContext instance. Your code might look like this: def some_view(request): # ... return render_to_response('my_template.html', my_data_dictionary, context_instance=RequestContext(request)) Many thanks for all the help!

    Read the article

  • How can I display multiple django modelformset forms in a grouped fieldsets?

    - by JT
    I have a problem with needing to provide multiple model backed forms on the same page. I understand how to do this with single forms, i.e. just create both the forms call them something different then use the appropriate names in the template. Now how exactly do you expand that solution to work with modelformsets? The wrinkle, of course, is that each 'form' must be rendered together in the appropriate fieldset. For example I want my template to produce something like this: <fieldset> <label for="id_base-0-desc">Home Base Description:</label> <input id="id_base-0-desc" type="text" name="base-0-desc" maxlength="100" /> <label for="id_likes-0-icecream">Want ice cream?</label> <input type="checkbox" name="likes-0-icecream" id="id_likes-0-icecream" /> </fieldset> <fieldset> <label for="id_base-1-desc">Home Base Description:</label> <input id="id_base-1-desc" type="text" name="base-1-desc" maxlength="100" /> <label for="id_likes-1-icecream">Want ice cream?</label> <input type="checkbox" name="likes-1-icecream" id="id_likes-1-icecream" /> </fieldset> I am using a loop like this to process the results (after form validation) base_models = base_formset.save(commit=False) like_models = like_formset.save(commit=False) for base_model, likes_model in map(None, base_models, likes_models): which works as I'd expect (I'm using map because the # of forms can be different). The problem is that I can't figure out a way to do the same thing with the templating engine. The system does work if I layout all the base models together then all the likes models after wards, but it doesn't meet the layout requirements. EDIT: Updated the problem statement to be more clear about what exactly I'm processing (I'm processing models not forms in the for loop)

    Read the article

  • How can I display multiple django modelformset forms together?

    - by JT
    I have a problem with needing to provide multiple model backed forms on the same page. I understand how to do this with single forms, i.e. just create both the forms call them something different then use the appropriate names in the template. Now how exactly do you expand that solution to work with modelformsets? The wrinkle, of course, is that each 'form' must be rendered together in the appropriate fieldset. For example I want my template to produce something like this: <fieldset> <label for="id_base-0-desc">Home Base Description:</label> <input id="id_base-0-desc" type="text" name="base-0-desc" maxlength="100" /> <label for="id_likes-0-icecream">Want ice cream?</label> <input type="checkbox" name="likes-0-icecream" id="id_likes-0-icecream" /> </fieldset> <fieldset> <label for="id_base-1-desc">Home Base Description:</label> <input id="id_base-1-desc" type="text" name="base-1-desc" maxlength="100" /> <label for="id_likes-1-icecream">Want ice cream?</label> <input type="checkbox" name="likes-1-icecream" id="id_likes-1-icecream" /> </fieldset> I am using a loop like this to process the results for base_form, likes_form in map(None, base_forms, likes_forms): which works as I'd expect (I'm using map because the # of forms can be different). The problem is that I can't figure out a way to do the same thing with the templating engine. The system does work if I layout all the base models together then all the likes models after wards, but it doesn't meet the layout requirements.

    Read the article

  • Get filename for puppet template

    - by Noodles
    I have a file that I'd like to reuse for a few different purposes. The file is 90% the same across uses, just slight differences. I'd rather not replicate the content across multiple files in puppet, so is there a way to do something like file { "/tmp/file1" : content => template("module/template.erb") } file { "/tmp/file2" : content => template("module/template.erb") } And in the template: Jack John James <% if file == "/tmp/file2" %> Jim <% end %>

    Read the article

  • Ways to implement tags - pros and cons of each

    - by bobobobo
    Related Using SO as an example, what is the most sensible way to manage tags if you anticipate they will change often? Way 1: Seriously denormalized (comma delimited) table posts +--------+-----------------+ | postId | tags | +--------+-----------------+ | 1 | c++,search,code | Here tags are comma delimited. Pros: Tags are retrieved at once with a single select query. Updating tags is simple. Easy and cheap to update. Cons: Extra parsing on tag retrieval, difficult to count how many posts use which tags. (alternatively, if limited to something like 5 tags) table posts +--------+-------+-------+-------+-------+-------+ | postId | tag_1 | tag_2 | tag_3 | tag_4 | tag_5 | +--------+-------+-------+-------+-------+-------+ | 1 | c++ |search | code | | | Way 2: "Slightly normalized" (separate table, no intersection) table posts +--------+-------------------+ | postId | title | +--------+-------------------+ | 1 | How do u tag? | table taggings +--------+---------+ | postId | tagName | +--------+---------+ | 1 | C++ | | 1 | search | Pros: Easy to see tag counts (count(*) from taggings where tagName='C++'). Cons: tagName will likely be repeated many, many times. Way 3: The cool kid's (normalized with intersection table) table posts +--------+---------------------------------------+ | postId | title | +--------+---------------------------------------+ | 1 | Why is a raven like a writing desk? | table tags +--------+---------+ | tagId | tagName | +--------+---------+ | 1 | C++ | | 2 | search | | 3 | foofle | table taggings +--------+---------+ | postId | tagId | +--------+---------+ | 1 | 1 | | 1 | 2 | | 1 | 3 | Pros: No repeating tag names. More girls will like you. Cons: More expensive to change tags than way #1.

    Read the article

  • Can django's auth_user.username be varchar(75)? How could that be done?

    - by perrierism
    Is there anything wrong with running alter table on auth_user to make username be varchar(75) so it can fit an email? What does that break if anything? If you were to change auth_user.username to be varchar(75) where would you need to modify django? Is it simply a matter of changing 30 to 75 in the source code?: username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters")) Or is there other validation on this field that would have to be changed or any other repercussions to doing so? See comment discussion with bartek below regarding the reason for doing it.

    Read the article

  • Adding links to full change forms for inline items in django admin?

    - by David Eyk
    I have a standard admin change form for an object, with the usual StackedInline forms for a ForeignKey relationship. I would like to be able to link each inline item to its corresponding full-sized change form, as the inline item has inlined items of its own, and I can't nest them. I've tried everything from custom widgets to custom templates, and can't make anything work. So far, the "solutions" I've seen in the form of snippets just plain don't seem to work for inlines. I'm getting ready to try some DOM hacking with jQuery just to get it working and move on. I hope I must be missing something very simple, as this seems like such a simple task! Using Django 1.2.

    Read the article

  • How do I flag only one of the formsets in django admin?

    - by azuer88
    I have these (simplified) models: class Question(models.Model): question = models.CharField(max_length=60) class Choices(models.Model): question = models.ForeignKey(Question) text = models.CharField(max_length=60) is_correct = models.BooleanField(default=False) I've made Choices as an inline of Question (in admin). Is there a way to make sure that only one Choice will have is_correct = True? Ideally, is_correct will be displayed as a radio button when it is displayed in the admin formset (TabularInline). my admin.py has: from django.contrib import admin class OptionInline(admin.TabularInline): model = Option extra = 5 max_num = 5 class QuestionAdmin(admin.ModelAdmin): inlines = [OptionInline, ] admin.site.register(QType) admin.site.register(Question, QuestionAdmin)

    Read the article

  • How can I call model methods or properties from Django Admin?

    - by kg
    Is there a natural way to display model methods or properties in the Django admin site? In my case I have base statistics for a character that are part of the model, but other things such as status effects which affect the total calculation for that statistic: class Character(models.Model): base_dexterity = models.IntegerField(default=0) @property def dexterity(stat_name): total = self.base_dexterity total += sum(s.dexterity for s in self.status.all()]) return total It would be nice if I could display the total calculated statistic alongside the field to change the base statistic in the Change Character admin page, but it is not clear to me how to incorporate that information into the page.

    Read the article

  • Django: Is there any way to have "unique for date range"?

    - by tomwolber
    If my model for Items is: class Item(models.Model): name = models.CharField(max_length=500) startDate = models.DateField("Start Date", unique="true") endDate = models.DateField("End Date") Each Item needs to have a unique date range. for example, if i create an Item that has a date range of June 1st to June 8th, how can I keep and Item with a date range of June 3rd to June 5th from being created (or render an error with template logic)?

    Read the article

  • Django 1.5 custom User model error. "Manager isn't available; User has been swapped"

    - by bpetit
    I extend the django user model as described in the dev doc. I wan't to keep most of the original User model features so I extend the AbstractUser class. I've defined in settings.py: AUTH_USER_MODEL = 'myapp.CustomUser' My user class: class CustomUser(AbstractUser): custom_field = models.ForeignKey('OtherModel') objects = UserManager() Everything seems to work fine but when I try to make it managed by the admin site: admin.site.register(CustomUser, UserAdmin) I get this error on the admin CustomUser creation page (after validation of the password confirmation form): AttributeError: Manager isn't available; User has been swapped for 'myapp.CustomUser' The point is that I need this model managed by the admin site in order to have the same creation process as with the original User model (two step process with password validation). Thanks for any reply

    Read the article

  • Specifying default value for django hidden form field - bone DRY?

    - by jMyles
    So let's say at the last minute (in the view) I decide I want to specify a default for a field and make it hidden, like so: form.fields['coconut'] = forms.ModelChoiceField(label="", widget=forms.HiddenInput(), queryset=swallow.coconuts.all(), initial=some_particular_coconut) My question is this: Do I really need to specify queryset here? I mean, I already know, from initial, exactly which coconut I'm talking about. Why do I also need to specify that the universe of available coconuts is the set of coconuts which this particular swallow carried (by the husk)? Is there a way I can refrain from specifying queryset? Simply omitting causes django to raise TypeError. If indeed it is required, isn't this a bit damp?

    Read the article

  • 500 Internal Server Error when setting up Apache on Ubuntu+Django

    - by ApacheQ
    I tried with Apache on ubuntu 9.04 and get the same error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. And my apache/error.log is: [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] ServerName: 'sapint2' [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] DocumentRoot: '/etc/apache2/htdocs' [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] URI: '/' [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] Location: '/' [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] Directory: None [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] Filename: '/etc/apache2/htdocs' [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] PathInfo: '/' [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] Traceback (most recent call last): [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent) [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg) [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg) [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/modpython.py", line 180, in handler\n return ModPythonHandler()(req) [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/modpython.py", line 142, in call\n self.load_middleware() [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware\n mod = import_module(mw_module) [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module\n import(name) [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/middleware.py", line 4, in \n from django.utils.cache import patch_vary_headers [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/cache.py", line 25, in \n from django.core.cache import get_cache [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/cache/init.py", line 187, in \n cache = get_cache(DEFAULT_CACHE_ALIAS) [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/cache/init.py", line 179, in get_cache\n cache = backend_cls(location, params) [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/cache/backends/memcached.py", line 139, in init\n "Memcached cache backend requires either the 'memcache' or 'cmemcache' library" [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] InvalidCacheBackendError: Memcached cache backend requires either the 'memcache' or 'cmemcache' library [Sat Oct 06 09:51:30 2012] [notice] caught SIGTERM, shutting down [Sat Oct 06 09:51:31 2012] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads. [Sat Oct 06 09:51:31 2012] [notice] mod_python: using mutex_directory /tmp [Sat Oct 06 09:51:31 2012] [notice] Apache/2.2.17 (Ubuntu) PHP/5.3.5-1ubuntu7.11 with Suhosin-Patch mod_python/3.3.1 Python/2.7.1+ mod_wsgi/3.3 configured -- resuming normal operations I need some help Thanks

    Read the article

  • Serve external template in Django

    - by AlexeyMK
    Hey, I want to do something like return render_to_response("http://docs.google.com/View?id=bla", args) and serve an external page with django arguments. Django doesn't like this (it looks for templates in very particular places). What's the easiest way make this work? Right now I'm thinking to use urllib to save the page to somewhere locally on my server and then serve with the templates pointing to there. Note: I'm not looking for anything particularly scalable here, I realize my proposal above is a little dirty.

    Read the article

  • Django template can't see CSS files

    - by Technical Bard
    I'm building a django app and I can't get the templates to see the CSS files... My settings.py file looks like: MEDIA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'media') MEDIA_URL = '/media/' I've got the CSS files in /mysite/media/css/ and the template code contains: <link rel="stylesheet" type="text/css" href="/media/css/site_base.css" />` then, in the url.py file I have: # DEVELOPMENT ONLY (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/media'}), but the development server serves the plain html (without styles). What am I doing wrong?

    Read the article

  • Installing Django on Windows

    - by Pranav
    Ever needed to install Django in a Microsoft Windows environment, here is a quick start guide to make that happen: Read through the official Django installation documentation, it might just save you a world of hut down the road. Download Python for your version of Windows. Install Python, my preference here is to put it into the Program Files folder under a folder named Python<Version> Add your chosen Python installation path into your Windows path environment variable. This is an optional step, however it allows you to just type python in the command line and have it fire up the Python interpreter. An easy way of adding it is going into Control Panel, System and into the Environment Variables section. Download Django, you can either download a compressed file or if you’re comfortable with using version control – check it out from the Django Subversion repository. Create a folder named django under your <Python installation directory>\Lib\site-packages\ folder. Using my example above that would have been C:\Program Files\Python25\Lib\site-packages\. If you chose to download the compressed file, open it and extract the contents of the django folder into your newly created folder. If you’d prefer to check it out from Subversion, the normal check out points are http://code.djangoproject.com/svn/django/trunk/ for the latest development copy or a named release which you’ll find under http://code.djangoproject.com/svn/django/tags/releases/. Done, you now have a working Django installation on Windows. At this point, it’d be pertinent to confirm that everything is working properly, which you can do by following the first Django tutorial. The tutorial will make mention of django-admin.py, which is a utility which offers some basic functionality to get you off the ground. The file is located in the bin folder under your Django installation directory. When you need to use it, you can either type in the full path to it or simply add that file path into your environment variables as well. Hope this helps!

    Read the article

  • Django Error - AttributeError: 'Settings' object has no attribute 'LOCALE_PATHS'

    - by Randy Simon
    I am trying to learn django by following along with this tutorial. I am using django version 1.1.1 I run django-admin.py startproject mysite and it creates the files it should. Then I try to start the server by running python manage.py runserver but here is where I get the following error. Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager utility.execute() File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 303, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv self.execute(*args, **options.__dict__) File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 213, in execute translation.activate('en-us') File "/Library/Python/2.6/site-packages/django/utils/translation/__init__.py", line 73, in activate return real_activate(language) File "/Library/Python/2.6/site-packages/django/utils/translation/__init__.py", line 43, in delayed_loader return g['real_%s' % caller](*args, **kwargs) File "/Library/Python/2.6/site-packages/django/utils/translation/trans_real.py", line 205, in activate _active[currentThread()] = translation(language) File "/Library/Python/2.6/site-packages/django/utils/translation/trans_real.py", line 194, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/Library/Python/2.6/site-packages/django/utils/translation/trans_real.py", line 172, in _fetch for localepath in settings.LOCALE_PATHS: File "/Library/Python/2.6/site-packages/django/utils/functional.py", line 273, in __getattr__ return getattr(self._wrapped, name) AttributeError: 'Settings' object has no attribute 'LOCALE_PATHS' Now, I can add a LOCAL_PATH atribute set to an empty string to my settings.py file but then it just complains about another setting and so on. What am I missing here?

    Read the article

  • Limiting the Amount of Tags for Acts as Taggable On

    - by bob
    Hello, I am wondering how to limit the amount of tags, the tag_cloud function returns for this plugin. http://github.com/collectiveidea/acts-as-taggable-on Also, I would like to know how to order it so that it orders the tags by the highest count. So the most popular are at the top. I tried to do @tags = Post.tag_counts_on(:tags, :limit = 5) but that did not work. Controller: class PostController < ApplicationController def tag_cloud @tags = Post.tag_counts_on(:tags) end end View: <% tag_cloud @tags, %w(css1 css2 css3 css4) do |tag, css_class| %> <%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %> <% end %> Thanks!

    Read the article

  • Django + Apache wsgi = paths problem

    - by Shamanu4
    Hello. I have this view which generates interface language options menu def lang_menu(request,language): lang_choices = [] import os.path for lang in settings.LANGUAGES: if os.path.isfile("gui/%s.py" % lang) or os.path.isfile("gui/%s.pyc" % lang): langimport = "from gui.%s import menu" % lang try: exec(langimport) except ImportError: lang_choices.append({'error':'invalid language file'}) else: lang_choices.append(menu) else: lang_choices.append({'error':'lang file not found'}) t = loader.get_template('gui/blocks/lang_menu_options.html') data = '' for lang in lang_choices: if not 'error' in lang: data = "%s\n%s" % (data,t.render(Context(lang))) if not data: data = "Error! No languages configured or incorrect language files!" return Context({'content':data}) When I'am using development server (python manage.py runserver ...) it works fine. But when I ported my app to apache wsgi server I've got error "No languages configured or incorrect language files!" Here is my Apache config <VirtualHost *:9999> WSGIScriptAlias / "/usr/local/etc/django/terminal/django.wsgi" <Directory "/usr/local/etc/django/terminal"> Options +ExecCGI Allow From All </Directory> Alias /media/ "/usr/local/lib/python2.5/site-packages/django/contrib/admin/media/" <Location /media/> SetHandler None </Location> <Directory "/usr/local/lib/python2.5/site-packages/django/contrib/admin/media/> Allow from all </Directory> Alias /static/ "/usr/local/etc/django/terminal/media/" <Location /static/> SetHandler None </Location> ServerName ******* ServerAlias ******* ErrorLog /var/log/django.error.log TransferLog /var/log/django.access.log </VirtualHost> django.wsgi: import os, sys sys.path.append('/usr/local/etc/django') sys.path.append('/usr/local/etc/django/terminal') os.environ['DJANGO_SETTINGS_MODULE'] = 'terminal.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() It's look like as problem with path configuration but I'm stuck here ...

    Read the article

  • Django caching seems to be causing problems

    - by Issy
    Hey guys, i have just implemented the Django Cache Local Memory back end in some my code, however it seems to be causing a problem. I get the following error when trying to view the site (With Debug On): Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 279, in run self.result = application(self.environ, self.start_response) File "/usr/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 651, in __call__ return self.application(environ, start_response) File "/usr/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 245, in __call__ response = middleware_method(request, response) File "/usr/lib/python2.6/dist-packages/django/middleware/cache.py", line 91, in process_response patch_response_headers(response, timeout) File "/usr/lib/python2.6/dist-packages/django/utils/cache.py", line 112, in patch_response_headers response['Expires'] = http_date(time.time() + cache_timeout) TypeError: unsupported operand type(s) for +: 'float' and 'str' I have checked my code, for caching everything seems to be ok. For example, i have the following in my middleware. MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.cache.FetchFromCacheMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', ) My settings for Cache: CACHE_BACKEND = 'locmem://' CACHE_MIDDLEWARE_SECONDS = '3600' CACHE_MIDDLEWARE_KEY_PREFIX = 'za' CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True And some of my code (template tag): def get_featured_images(): """ provides featured images """ cache_key = 'featured_images' images = cache.get(cache_key) if images is None: images = FeaturedImage.objects.all().filter(enabled=True)[:5] cache.set(cache_key, images) return {'images': images} Any idea what could be the problem, from the error message below it looks like there's an issue in django's cache.py?

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >