cache large files
Hi, I am using memcached for caching my sites. The documentation says when not to use it: http://code.google.com/p/memcached/wiki/WhyNotMemcached one point is output larger 1 MB I have a site producing pdf files only, where size can easily go over 1 MB. As the docs above mention mogilefs as an alternative, I wonder if this is the right way to do it, as there is no batterie for djangos caching system. I know that the cach system has support for filesystem cache - has someone used this for large files? and maybe even in conjunction with GlusterFS (http://www.gluster.org/), as that seems to be more complete then mogilefs? What about concurrent writes from different hosts to the cache system? -- Hinnack -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Cannot convert float to Decimal. First convert the float to a string Error
On Fri, Jan 22, 2010 at 1:13 AM, grp25 wrote: > got error: > Cannot convert float to Decimal. First convert the float to a string > > our code is: > usr.ratings=usr.ratings-0.5 > usr.save() > > 'usr.ratings' is a float field. > Are you absolutely sure of that? It rather sounds like usr.ratings is a DecimalField, not a FloatField. Perhaps it is a float at the database level but defined as a DecimalField in the model? In which case the fix is to make it a FloatField in the Django model so that the database and Django representations match. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Cannot convert float to Decimal. First convert the float to a string Error
got error: Cannot convert float to Decimal. First convert the float to a string our code is: usr.ratings=usr.ratings-0.5 usr.save() 'usr.ratings' is a float field. Help resolve it... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Import problem on the attempt to use {% url %}
On Thu, Jan 21, 2010 at 9:28 PM, Felipe wrote: > Hello Friends, > > Someone here know what this error mean? > > http://www.catojo.com.br/contact/ > > This generally happens when I try to use something like {% url %} tag. > > But I've been ensured that the view 'home.views' exists and it is > placed in blog.home.views directory, however, by some unknown issue > this error message are appearing my browser. > > Someone have a tip to me fix the problem ? > > You've got a url pattern in your configuration that references a module named 'home.views', but Python cannot find any module named that. Based on the traceback information, /home/storage/b/fe/45/catojo/wsgi_apps is in the PYTHONPATH. Apparently under that you have blog/, then home/, then a views.py in there? But combining what you have in your path plus home.views results in Python attempting to find a file named: /home/storage/b/fe/45/catojo/wsgi_apps/home/views.py not: /home/storage/b/fe/45/catojo/wsgi_apps/blog/home/views.py The blog part has to be either included in the url pattern reference or in a PYTHONPATH entry. As it is, neither has it, so Python cannot find any module named home.views when searching through the Python path. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Import problem on the attempt to use {% url %}
Hello Friends, Someone here know what this error mean? http://www.catojo.com.br/contact/ This generally happens when I try to use something like {% url %} tag. But I've been ensured that the view 'home.views' exists and it is placed in blog.home.views directory, however, by some unknown issue this error message are appearing my browser. Someone have a tip to me fix the problem ? Thanks in advanced. Felipe. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Multiple icontains using OR - Is it possible?
This worked! Thank you On Dec 15 2009, 11:27 pm, HARRY POTTRER wrote: > you're going to need the Q object, it seems. > > from django.db.models import Q > MyModel.objects.filter(Q(summary__icontains=q) | Q > (title__icontains=q)) > > On Dec 15, 10:32 pm, tm wrote: > > > > > Hello Django Users, > > > I'm trying to use icontains to check 2 fields in the same table for a > > keyword entered into a search. > > > ex I've tried: > > > queryset = MyModel.objects.filter(summary__icontains=q).filter > > (title__icontains=q) > > > and > > > queryset = MyModel.objects.filter(summary__icontains=q, > > title__icontains=q) > > > Neither work, although judging by the docs the second one shouldn't in > > this case. Has anyone successfully searched a MySQL DB using > > icontains on 2 filelds in the same model? Any help greatly > > appreciated :) > > > T -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django-authopenid user timeout
I've just installed django-authopenid in a project, and it seems to be working just fine, apart from one minor issue. (The creator of django-authopenid isn't maintaining the project any more, and there isn't a mailing list, hence why I'm asking this question here rather than elsewhere.) So, as I say, it works fine except the user's login gets timed-out after a short while, and I'd like to keep people logged in unless they explicitly logged out. Anyone know how to do this? I can't see any reference to timeouts in the documentation. Actually, I'm not even sure whether this timeout is caused in django-authopenid or down at the core django level or elsewhere. Any pointers very welcome! Rachel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
newline in GET data
Hi , I am having newlines in GET data , but when the data comes to server newline chars are removed. Is that any way I can retain new line chars ? Thanks Sumanth -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Making InlineModelAdmin objects required.
Thanks mate, I'll look into that at some point. It's not a major requirement of the project, so I'll put it on the backburner for now. Cheers, Brenton. On Jan 21, 5:21 pm, "mattimust...@gmail.com" wrote: > Hi, > > Take a look athttp://code.google.com/p/wadofstuff/wiki/WadOfStuffDjangoForms > as the RequireOneFormSet class may give you some hints on how to do > this. > > regards > > Matthew > > On Jan 21, 3:57 pm, iliveinapark > wrote: > > > > > Hi all, > > > I'm wondering if there's a way to make InlineModelAdmin objects > > required, so that if a user saves on an admin page without completing > > the fields of the inline model, it displays big red "This field is > > required." Errors like it does with the included fields. > > > Cheers. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ChoiceField
The code {% for choice_value, choice_text in myform.fields.choicefieldname.choices %} choice_value: {{ choice_value }} choice_text: {{ choice_text }} {% endfor %} gives the choices text and values associated to each choice, but actually do not render the html form, which is what I'm looking for. On Jan 22, 2:59 am, Shawn Milochik wrote: > > I think there might be a terminology issue here. I suspect the OP is > > looking for all the possible value of a model field with `choices` > > set. Which, is not easily possible from a template (although you can > > do it in Python: MyModel._meta.get_field_by_name('myfield') > > [0].choices) > > -- > > DR. > > -- > > My last post gave exactly that -- all the possible values of the choices > model field. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to Model a relationship on a constrained subset of the foreign key.
@Taliesin Remember we are all volunteers, here. -wolf sent from the research lab at http://networksecuritynews.net On Jan 21, 2010 3:35 AM, "taliesin" wrote: taliesin wrote: > > HI. I have a newbie-ish question, if that's alright. I don't know how to model a... Okay, clearly no-one wants to touch my question. : / Let me ask a different related one then... What would happen if I added a constraint directly to the underlying database? I'm using PostgreSQL so I can create foreign keys on composite columns if I wish. WIll Django explode? I know that it produces the situation where I might get exceptions raised if Django tried to add an entry that its model predicted was valid but the database rejected, but if I'm going to have to handle this situation by excluding invalid options in the GUI anyway, I see no harm in barring those same entries at the database level just for integrity's sake. Anyone see a problem with that? If I need to go into more detail on my posts, please let me know. Thanks, Taliesin. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin calendar popups on datefield suddenly missing
On Thu, Jan 21, 2010 at 5:31 PM, Walt wrote: > Okay... The latest release of django that I downloaded has this: > > > A previous version that is currently working is this: > > > How can I modify or specify that path? And why would it have > changed? Because in the development version that was [1]changed to use an absolute path that are derived from the real location of such resource instead of having a hardwired relative path ("../../../jsi18n/") that would break when used from pages located in places different from two levels deeper in the path hierarchy, and so it was made more usable from anywhere. I've just tested this and it is working correctly here for a standard admin app installation, so we should find why it is faling for you. Do you have customized admin views? Why isn't the /admin/jsi18n/ URL a correct one in your installation? What do you get when you access it with your browser? -- Ramiro Morales | http://rmorales.net PS: Also, if you are using the development version it would be a good idea to get accustomed to read the changelog and/or follow the Django Trac timeline so you can anticipate, detect and solve issues of this type for youself. 1. http://code.djangoproject.com/ticket/11478 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django utf-8 Error; field.get_default? I don't think the string I feed to Location should be signed to field.get_default
2010/1/21 iasybvm > I have created an object Location: > class Location(models.Model): >city = models.CharField(max_length=50) >state = models.CharField(max_length=50) >... > I think you've left out a key bit here. The traceback you include shows the problem happens when Django tries to force the the default value for a field to unicode, yet you don't show any default values being specified. Given the traceback shows the problem is that the default value is some sort of proxy object, I'm going to guess that what you've actually specified for a default value for one or more of these fields is the result of a django.utils.translation.ugettext_lazy call. If so, be sure that the you have specified the argument to ugettext_lazy as a unicode literal, not a bytestring. If not, please show what you have specified for defaults on the model fields, because that is what is causing the problem. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: I'm wanting to modify Django CMS so I can restrict the content I make to particular users site side?
On 21 Sty, 12:15, littlejim84 wrote: > I have content that I've created in Django CMS that I then want to > restrict access to on the site site (not the editing side, like with > the CMS_PERMISSIONS option in Django CMS). I've been told that I can > use either Middleware or Template Context Processors to inject my own > code into the way Django CMS is doing things. i'm not sure if i understand you well, but if i do, your problem seems to be quite simple to resolve. each page in django-cms has two options in "advanced settings" section (at the very bottom of editing page): * login required * menu login required HTH -- greetings, ojo -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django utf-8 Error; field.get_default? I don't think the string I feed to Location should be signed to field.get_default
I have created an object Location: class Location(models.Model): city = models.CharField(max_length=50) state = models.CharField(max_length=50) ... But I can't initialize it with either unicode data or utf-8 data. I created a record by hand in my postgresql database. I can now read it using django Location.objects.get function. Then I tried to create a similar record in my database with Django. But I got: location2 = Location.objects.get(pk=2) print city,state,country 北京 北京 中国 city = location2.city state = location2.state country = location2.country l = Location(city=city, state=state,country=country, district='') Traceback (most recent call last): File "", line 1, in File "/usr/lib/pymodules/python2.5/django/db/models/base.py", line 303, in __init__ val = kwargs.pop(field.attname, field.get_default()) File "/usr/lib/pymodules/python2.5/django/db/models/fields/ __init__.py", line 245, in get_default return force_unicode(self.default, strings_only=True) File "/usr/lib/pymodules/python2.5/django/utils/encoding.py", line 92, in force_unicode raise DjangoUnicodeDecodeError(s, *e.args) DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128). You passed in () -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Analyzing modules before application start
On Jan 22, 12:00 am, Filip Gruszczyński wrote: > I would like to go through all registered apps before server is > started and check if certain modules (and then process them). I guess > this mechanism is similar to the one, which looks for models or tests > in django application. Is there any easy way to do this and where > should inject such code? Into manage.py? This is the registration pattern, used by django.contrib.admin Look through the source of django.contrib.admin, and pay attention to the autoregister() function. Matt. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
unicode LookupError with Django + mod_wsgi
Hi all, I also asked this on the mod_wsgi list but it seems like it may be being caused by Django so I figured this might help. Sorry if it turns out to not be Django-related, but the exception is getting raised by Django code. So I'm running into some strange errors with Django + mod_wsgi. Here's a stack trace - this happens every few hours or so for a site with around 1 request per second load: [Sun Jan 10 10:14:02 2010] [error] [client 127.0.0.1] mod_wsgi (pid=29947): Exception occurred within WSGI script '/home/prod/repo/ web/apache/django.wsgi'. [Sun Jan 10 10:14:02 2010] [error] [client 127.0.0.1] Traceback (most recent call last): [Sun Jan 10 10:14:02 2010] [error] [client 127.0.0.1] File "/var/ lib/ python-support/python2.5/django/core/handlers/wsgi.py", line 231, in __call__ [Sun Jan 10 10:14:03 2010] [error] [client 127.0.0.1] set_script_prefix(base.get_script_name(environ)) [Sun Jan 10 10:14:03 2010] [error] [client 127.0.0.1] File "/var/ lib/ python-support/python2.5/django/core/handlers/base.py", line 199, in get_script_name [Sun Jan 10 10:14:03 2010] [error] [client 127.0.0.1] return force_unicode(environ.get('SCRIPT_NAME', u'')) [Sun Jan 10 10:14:03 2010] [error] [client 127.0.0.1] File "/var/ lib/ python-support/python2.5/django/utils/encoding.py", line 68, in force_unicode [Sun Jan 10 10:14:03 2010] [error] [client 127.0.0.1] s = s.decode (encoding, errors) [Sun Jan 10 10:14:03 2010] [error] [client 127.0.0.1] LookupError: no codec search functions registered: can't find encoding I added print statements and the encoding is simply "utf-8" here, and s is the empty string. When I run "".decode("utf-8") from the python interpreter, it works fine. How could this be happening? I'm running mod_wsgi in daemon mode with the parameters WSGIDaemonProcess prod processes=3 maximum-requests=500 threads=10 WSGIProcessGroup prod WSGIScriptAlias / /home/prod/repo/web/apache/django.wsgi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin calendar popups on datefield suddenly missing
Okay... The latest release of django that I downloaded has this: A previous version that is currently working is this: How can I modify or specify that path? And why would it have changed? Thanks, Walt -~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin calendar popups on datefield suddenly missing
That line is there, but for some reason *that* is the broken link! That at least gives me something to track down... Thank you for your help! Walt -~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin calendar popups on datefield suddenly missing
On Jan 21, 5:51 pm, Walt wrote: > Okay, we're getting somewhere. It can find the JS file(s) just fine > and I see that the calendars are added dynamically. However, I'm > have found that it is generating a javascript error when the page > loads: > > Error: gettext is not defined > Source File:http://tachamber.org/media/admin/js/calendar.js > Line: 26 [monthsOfYear: gettext('January February March April May June > July August September October November December').split(' '),] > > Error: gettext is not defined > Source File:http://tachamber.org/media/admin/js/admin/DateTimeShortcuts.js > Line: 134 [today_link.appendChild(document.createTextNode(gettext > ('Today')));] > > Any ideas? > > Walt > > -~ You need to be sure that the page loads the 'jsi18n' javascript first. By default, admin templates include this: -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ChoiceField
On Jan 21, 3:59 pm, Shawn Milochik wrote: > > I think there might be a terminology issue here. I suspect the OP is > > looking for all the possible value of a model field with `choices` > > set. Which, is not easily possible from a template (although you can > > do it in Python: MyModel._meta.get_field_by_name('myfield') > > [0].choices) > > -- > > DR. > > -- > > My last post gave exactly that -- all the possible values of the choices > model field. > > Shawn No, you gave the choices for the ChoiceField **form** field, a different thing entirely. As you've shown, assuming you've got a form, it's easy to get the field choices. But if you don't have a form to start with, it's hard to get the field choices, even though they are stored on the model. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: about django 1.2 alpha release
On Thu, Jan 21, 2010 at 12:09 PM, rodel bosque wrote: > is django 1.2 alpha release support python version 3? As the main Django documentation page suggests, it's a good idea to consult the FAQ: http://docs.djangoproject.com/en/1.1/faq/install/#can-i-use-django-with-python-3-0 -- "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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
about django 1.2 alpha release
hi, is django 1.2 alpha release support python version 3? thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Best Practice for developing djangoapp in a repository
Hello, my problem is maybe not very specific but more a problem with an approach. Let's say I want to work on a djangoapp (in this case django- tagging, the famous tagging app). I'm not very satisified with the code and want to simplify it. if I clone the repository I have a folder 'django-tagging' wich contains several files (e.g. the LICENSE.txt, the setup.py) and a folder with the djangoapp itself called tagging. when working on the code i want to test the tagging app with ./ manage.py test tagging. so atm I see two possibilities: 1.) the folder django-tagging is a djangoproject and all the files not concerning the djangoapp (e.g. the manage.py) are not in the repository. then I can change the code, test it, submit the changes and everything is cool except I mess the djangoproject files and the files of the app. 2.) I could install the app with the setup.py and everytime I change the code I have to reinstall it in order to test it within a djangoapp. this is another possibility, but makes me not happy. 3.) ??? so what's the best practice to solve that problem? extending sys.path and keeping the folder its own place? Regards Julian -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
GET request breadcrumbs
So far I have seem template inheritance based examples for breadcrumbs in django. However for a project I am working on that does not quite work because all templates inherit from base. For eg. templates/base.html common/ a.html, b.html, c.html myapp/ m.html, n,.html, q.html So a GET request to a gets the "Super" breadcrumb from base ,like Home->a and that to B gets Home ->b, but a GET request from a-> b will still show Home->b , I would like it to be Home->a->b I am thinking I might need to capture the browsing history for a session ? Any ideas how to do this ? Thanks Meenal -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin calendar popups on datefield suddenly missing
Okay, we're getting somewhere. It can find the JS file(s) just fine and I see that the calendars are added dynamically. However, I'm have found that it is generating a javascript error when the page loads: Error: gettext is not defined Source File: http://tachamber.org/media/admin/js/calendar.js Line: 26 [monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),] Error: gettext is not defined Source File: http://tachamber.org/media/admin/js/admin/DateTimeShortcuts.js Line: 134 [today_link.appendChild(document.createTextNode(gettext ('Today')));] Any ideas? Walt -~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
FormWrapper in django1.1
Hello any substitute for forms.FormWrapper in django1.1. ? sorry for my poor english thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django custom fields and generic relationships
Hi, I'm struggling to find any useful tutorials on how best to achieve this so a nudge in the right direction would be greatly appreciated. I've set up a model which references django_content_type. My idea is to use this model to reference other models so that they can be marked as "featured" content, without me having to put a new "isFeatured" field on every model. All I want to be able to do is have a check box appear on the forms of my admin for each model, which indicates if the content is featured or not. If you check it, it's added to the table, if you un-check it removes it. class FeaturedContent(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') An example model I would like to use with this is: class Institute(models.Model): name = models.CharField(max_length=200) slug = models.SlugField(max_length=200,unique=True) Firstly, is this the right approach? Do I need to create a custom form/model field? and how do I introduce this field to the admin template? I've been looking inside of (django.contrib.contenttypes) generic.py and you can clearly see where the template data is being loaded and also which template is being used. I'm wondering if perhaps I just need to extend this class rather than write my own field? Thanks for any help, James -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Should a decorator be used here or should I do something else.
A decorator is certainly a clean way to apply consistent checking to a bunch of views. But it is primarily useful if the selection of the view function by the urlconf gives you all you need to know about for what age groups the *CONTENT* is appropriate. If, on the other hand, different rows in the same table (different instances of the same model) are appropriate for different age groups, then you're stuck with either doing your object query in the decorator and passing it to the view, which might be too magic. (Maybe pass a base queryset to the view for further filtering, but still pretty magic.) A shared function that you call from the view to filter a queryset based on age criteria might feel more explicit. Bill On Wed, Jan 20, 2010 at 5:15 PM, Jeffrey Taggarty wrote: > Hi Guys, I have a bit of a dilemma in terms of design of a small web > application... > > I have this requirement where content is being served by age group. On > first load the user selects their age group and I store that in the > cookie. I read that cookie and query content for the pages based on > that agegroup cookie. My question is should I use a decorator to check > the cookie on every new page requested to make sure they're getting > the proper content served based on that agegroup in the cookie? I have > about 6 functions in total in my views. I was thinking just writing a > decorator to handle that but I am not sure that's the best way to go > about this. > > Thanks > > > Jeff > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin calendar popups on datefield suddenly missing
Make sure you can download the JS file. It could be a permissions problem, or your static content server is down. Walt wrote: On Jan 21, 10:28 am, Daniel Roseman wrote: Do you have TinyMCE on the same admin page? And are you using Firefox 3.5+? If so it might be this bug:http://code.djangoproject.com/ticket/11967 No, I don't think this is the problem. First, I'm not using TinyMCE on the app at all, secondly, the problem happens across all browsers, and third the code to display the date picker isn't even present in the source HTML for the admin pages, so I think something happened server-side to turn that feature off. Thanks! Walt -~ -- Carl Zmola czm...@woti.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin calendar popups on datefield suddenly missing
On Jan 21, 10:28 am, Daniel Roseman wrote: > > Do you have TinyMCE on the same admin page? And are you using Firefox > 3.5+? If so it might be this bug:http://code.djangoproject.com/ticket/11967 No, I don't think this is the problem. First, I'm not using TinyMCE on the app at all, secondly, the problem happens across all browsers, and third the code to display the date picker isn't even present in the source HTML for the admin pages, so I think something happened server-side to turn that feature off. Thanks! Walt -~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Table with 4 Milions of rows
I'm a little late, but if you create the correct indexes on the table, you will be fine. Also, use unique id fields as much as possible for linking your tables. Carl nameless wrote: Hi at all. I have a project with 2 applications ( books and reader ). Books application has a table with 4 milions of rows with this fields: book_title = models.CharField(max_length=40) book_description = models.CharField(max_length=400) To avoid to query the database with 4 milions of rows, I am thinking to divide it by subject ( 20 applications with 20 tables with 200.000 rows ( book_horror, book_drammatic, ecc ). In "reader" application, I am thinking to insert this fields: reader_name = models.CharField(max_length=20, blank=True) book_subject = models.IntegerField() book_id = models.IntegerField() So instead of ForeignKey, I am thinking to use a integer "book_subject" (which allows to access the appropriate table) and "book_id" (which allows to access the table specified in the book "book_subject"). Is a good solution to avoid to query a table with 4 milions of rows ? Is there an alternative solution ? Thanks ^__^ -- Carl Zmola 301-562-1900 x315 czm...@woti.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Setting a user to have particular permission group when registering with django-registration?
I'm using django-registration and want to set a user to have a paricular permission group when they sign in. What is the best way to implement this without messing with the source of the actual app? Any information at all would be good. I'm having no luck at all on the IRC chat group. James -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Finding the Min time_of_day from a date field (in a query set)
I am starting to understand aggregation and annotation in django, but I am having a hard time translating the following sql select au.username as 'user name', count(1) as event_count , min(time(log.start_date)) as min_tod, max(time(log.start_date)) as max_tod from log as log join auth_user as au on log.user_id=au.user_id group by au.username order by event_count desc; This will give me the number of events per user, and the max and min time of day that this occured (so I can know the working hours of a specific individual). However, I can't figure out how to perform "min(time(log.start_date))" since django.db.models.Mintakes a field name, and I want to run datetime.time on the field before performing the min function. Is there a way to do this without dropping into raw mode? Carl -- Carl Zmola 301-562-1900 x315 czm...@woti.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Templating problem: equal symbol "=" escaped to "=3D"
Ok maybe I got it. I found those "=3D" symbols just looking at the output of the Python SMTP server that simulates the email process. I think that those mime escaped characters will be correctly converted back to "=" symbols when processed by a mail client. Am I correct? On Thu, Jan 21, 2010 at 4:49 PM, Enrico Sartorello < enrico.sartore...@gmail.com> wrote: > You're right, it's the mime escaping! > > In order to send emails I simply use: > > render_to_string(file) > send_mail() > > How can I send plain text messages with '=' symbols without getting it > escaped? > > > > On Thu, Jan 21, 2010 at 4:20 PM, Malcolm Box wrote: > >> Are you sure it's django templates that are doing the escaping? =3D is >> the mime escaping for = - could it be something else in your email >> processing chain that's escaping the sign? >> Malcolm >> >> On 1/21/10, Enrico Sartorello wrote: >> > Hi, >> > i'm using Django template system to render some text files (not HTML >> pages) >> > that I use to send emails. >> > >> > I have a problem: in a template file, any occurence of the "=" symbol is >> > escaped to "=3D" no matter what is placed before or after it. >> > '=' is strangely escaped to '=3D' even if autoescape is off or the >> > containing string is marked with 'safe' filter. >> > >> > What's wrong with that? >> > >> > Please help me because I've lost a lot of time trying to solve this >> issue! >> > >> > Thanks in advance :-) >> > >> > -- >> > Enrico Sartorello >> > >> >> -- >> Sent from my mobile device >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> >> >> > > > -- > Enrico Sartorello > -- Enrico Sartorello -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ChoiceField
>> > > I think there might be a terminology issue here. I suspect the OP is > looking for all the possible value of a model field with `choices` > set. Which, is not easily possible from a template (although you can > do it in Python: MyModel._meta.get_field_by_name('myfield') > [0].choices) > -- > DR. > -- My last post gave exactly that -- all the possible values of the choices model field. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Templating problem: equal symbol "=" escaped to "=3D"
You're right, it's the mime escaping! In order to send emails I simply use: render_to_string(file) send_mail() How can I send plain text messages with '=' symbols without getting it escaped? On Thu, Jan 21, 2010 at 4:20 PM, Malcolm Box wrote: > Are you sure it's django templates that are doing the escaping? =3D is > the mime escaping for = - could it be something else in your email > processing chain that's escaping the sign? > Malcolm > > On 1/21/10, Enrico Sartorello wrote: > > Hi, > > i'm using Django template system to render some text files (not HTML > pages) > > that I use to send emails. > > > > I have a problem: in a template file, any occurence of the "=" symbol is > > escaped to "=3D" no matter what is placed before or after it. > > '=' is strangely escaped to '=3D' even if autoescape is off or the > > containing string is marked with 'safe' filter. > > > > What's wrong with that? > > > > Please help me because I've lost a lot of time trying to solve this > issue! > > > > Thanks in advance :-) > > > > -- > > Enrico Sartorello > > > > -- > Sent from my mobile device > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- Enrico Sartorello -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ChoiceField
On Jan 21, 2:14 pm, Shawn Milochik wrote: > What did you try? > > I found it easily. > > First: > print dir(myform) > #I found that myform has a 'fields' attribute. > > Second: > print dir(myform.fields['choicefieldname']) > > #found myform.fields['choicefieldname'].choices > > Third: > print myform.fields['choicefieldname'].choices > #got all the nice options I was looking for! > > Then, in my template: > > {% for choice_value, choice_text in > myform.fields.choicefieldname.choices %} > choice_value: {{ choice_value }} > choice_text: {{ choice_text }} > {% endfor %} > > Shawn I think there might be a terminology issue here. I suspect the OP is looking for all the possible value of a model field with `choices` set. Which, is not easily possible from a template (although you can do it in Python: MyModel._meta.get_field_by_name('myfield') [0].choices) -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin calendar popups on datefield suddenly missing
On Jan 21, 3:23 pm, Walt wrote: > Hi all, > > I don't know of any changes I've made recently other than > checking out the latest django code but the date picker / > popup on all admin datefields has suddenly disappeared. > > Any clues as to how to get this back or what might have > caused it to disappear in the first place? > > Thanks, > Walt > > -~ Do you have TinyMCE on the same admin page? And are you using Firefox 3.5+? If so it might be this bug: http://code.djangoproject.com/ticket/11967 -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Admin calendar popups on datefield suddenly missing
Hi all, I don't know of any changes I've made recently other than checking out the latest django code but the date picker / popup on all admin datefields has suddenly disappeared. Any clues as to how to get this back or what might have caused it to disappear in the first place? Thanks, Walt -~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Templating problem: equal symbol "=" escaped to "=3D"
Are you sure it's django templates that are doing the escaping? =3D is the mime escaping for = - could it be something else in your email processing chain that's escaping the sign? Malcolm On 1/21/10, Enrico Sartorello wrote: > Hi, > i'm using Django template system to render some text files (not HTML pages) > that I use to send emails. > > I have a problem: in a template file, any occurence of the "=" symbol is > escaped to "=3D" no matter what is placed before or after it. > '=' is strangely escaped to '=3D' even if autoescape is off or the > containing string is marked with 'safe' filter. > > What's wrong with that? > > Please help me because I've lost a lot of time trying to solve this issue! > > Thanks in advance :-) > > -- > Enrico Sartorello > -- Sent from my mobile device -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Templating problem: equal symbol "=" escaped to "=3D"
Hi, i'm using Django template system to render some text files (not HTML pages) that I use to send emails. I have a problem: in a template file, any occurence of the "=" symbol is escaped to "=3D" no matter what is placed before or after it. '=' is strangely escaped to '=3D' even if autoescape is off or the containing string is marked with 'safe' filter. What's wrong with that? Please help me because I've lost a lot of time trying to solve this issue! Thanks in advance :-) -- Enrico Sartorello -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ChoiceField
What did you try? I found it easily. First: print dir(myform) #I found that myform has a 'fields' attribute. Second: print dir(myform.fields['choicefieldname']) #found myform.fields['choicefieldname'].choices Third: print myform.fields['choicefieldname'].choices #got all the nice options I was looking for! Then, in my template: {% for choice_value, choice_text in myform.fields.choicefieldname.choices %} choice_value: {{ choice_value }} choice_text: {{ choice_text }} {% endfor %} Shawn-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
view_form for class ModelAdmin
Has anybody ever implemented an extension to class ModelAdmin to add "view_form" function and templates? I'm in a situation where the logged user can list both draft and published files. With ModelAdmin.queryset i filter the files the user is allowed to list in "change_list" view, but those files include also the published one that should only be viewed, not edited, by an editor user. I tried to use the .has_change_permission, but this is a shortcut to a Permission Denied exception, rather that a .view_"form" page. So I was planning to add this feature. I had two ways in my mind: - the cleaner one: modify / override some methods of the ModelAdmin class so that if the current user do not has_change_permission for a model instance and clicks the widget to edit the instance, he is presented with a simple view page, that has the same look of the other admin pages and simply shows all the fields of the instance (it could look for a class attribute "display_empty" to decide whether to output empty fields or not) - the dirty way: (which I think could be easier for a Django newbie like me) in urlconf "trap" the edit url with the admin prefix for each model. The view checks if the user is allowed to edit the instance (and thus the default admin view for change_form should be returned) or not, and in the latter case the user is presented with a view_form. Due to my newbieness I am thinking about going the dirty way, but I do not know how the change_form view is called and how url regexp splitting is performed (is it with ?P or just parenthesis?). Please, can anybody give me any hints? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Analyzing modules before application start
I would like to go through all registered apps before server is started and check if certain modules (and then process them). I guess this mechanism is similar to the one, which looks for models or tests in django application. Is there any easy way to do this and where should inject such code? Into manage.py? -- Filip Gruszczyński -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with Django
these error messages seem to rather explanatory. you are trying to serialize data that the serializer you are using can not serialize. you will have to convert the data into a format that is serializeable before hand and then send it. On Jan 21, 3:16 am, Meenu wrote: > My form contains date of birth and total income field. I am getting > following errors: > > datetime.date is not json serializable > decimal is not json serializable. > > On Jan 21, 11:06 am, Prashanth wrote: > > > Hi, > > > On Thu, Jan 21, 2010 at 10:53 AM, Meenu wrote: > > > > I've noticed that my form submission seems to randomly fail on the > > > line var response_obj = eval('(' + o.responseText + ')'); in my > > > javascript. My form contains date and decimal fields. > > > Pretty hard to figure out just with the javascript line though eval > > looks fine, print the response that you are getting from django and > > try to debug or if you want people to point out do a pastebin of your > > view and response that you are doing in the javascript. > > > -- > > regards, > > Prashanth > > twitter: munichlinux > > blog: prashanthblog.appspot.com > > irc: munichlinux, JSLint, munichpython. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Creating a dashboard item
Hi, I've created a little to-do list model. I'm trying to get a list to appear on the dashboard (like the history list) with a tickbox next to each item. Would I need to change a template somewhere (i.e. code something to render the list like this: http://www.djangobook.com/en/beta/chapter18/) to achieve this, or is there a setting I can enable in my admin.py? I've been searching all day for ways to do this, not sure I am using the right terminology though. If anyone could give me some direction, that would be greatly appreciated. Thanks, J -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
I'm wanting to modify Django CMS so I can restrict the content I make to particular users site side?
Hello. I'm not really an expert in Python or Django, but am looking for a solution to this problem. I've had no luck with this in the Django CMS mailing list or IRC and it's really more about Django and how to mod things generally so I can have more control over things. I'm not wanting to mod the actual code of Django CMS as I want to retain it so it doesn't mess with any updates of it in the future. I'm not an expert enough to be able to submit patches to it or anything like. I have content that I've created in Django CMS that I then want to restrict access to on the site site (not the editing side, like with the CMS_PERMISSIONS option in Django CMS). I've been told that I can use either Middleware or Template Context Processors to inject my own code into the way Django CMS is doing things. I'm basically wanting to have a login on the site site where users can sign up (I presume I should use django-registration app for this?) and only when they have signed up they can have access to all my content I've made in Django CMS that will most probably be at the URL of 'http://domain.com/students/'. Thing is, I'm not really too sure how to do this? Do I use Middleware or use Context Processors? How do I check the URLs in these things? I could really do with some baby steps to help me here... I'm looking at this as a general way to mod Django apps in the future without having to mess with their code at all. I'm presuming this is the way to do it for these sort of things? Thank you in advance. Please help a sorta noob! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django and caching when data is updated
On Thu, Jan 21, 2010 at 6:00 PM, Malcolm Box wrote: > Hi, > > On Thu, Jan 21, 2010 at 7:35 AM, Russell Keith-Magee > wrote: >> >> On Thu, Jan 21, 2010 at 7:47 AM, Malcolm Box >> wrote: >> > >> > I've got a simple question that I can't find the answer to: if the data >> > that a view depends on changes, does Django do anything smart to >> > invalidate >> > the cache for that view, or is it left to the programmer? > > >> >> >Your suspicions are correct - there is no systematic cache >> invalidation tied to Django's models. >> > Thanks for the confirmation! > >> >> If you want to invalidate a specific view, you will need to use the >> cache key tools to django.utils.cache to reconstruct the key for the >> view that needs to be invalidated. See the cache middleware for >> examples of usage. > > So a higher-level question - is this the prefered design approach - have the > views that alter data explicitly invalidate the views in the cache for the > ones who's data has been changed? > > It feels a bit too tightly coupled to me - and fragile if new views are > added. > > What's the recommended approach, or what have others done that's worked? As with all interesting questions, the answer is "it depends" :-) You are correct that high level view caching is potentially fragile. It's a fine strategy if you have static content that isn't going to change very often (e.g., displaying an article for a newspaper), but it isn't so helpful if you have highly dynamic sites. The right solution will very much depend on the exact content you want to display, and the frequency with which various parts of it will be updated. You're going to need to analyse the way your site is being used in order to work out how to best exploit caching. Firstly, cache parts of pages, rather than full pages. The template cache tag could be helpful here. Another approach is to use the low level cache API to cache specific queries or computed responses. In both these cases, you are in completely control of the cache keys, so you can generate keys in a known space to make them easy to expire. Secondly, exploit the signals framework. Django issues signals whenever objects (and in Django 1.2, m2m relations) are updated; these signals give you an entry point to expire or update caches whenever a specific object is updated. Looking slightly more broadly, it *might* be possible to develop a generic app/library for cache expiry by wrapping the low level cache primitives with knowledge of the objects they are caching. However, this is green fields territory - I can't say I've ever seen a truly generic cache expiry framework. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django and caching when data is updated
Hi, On Thu, Jan 21, 2010 at 7:35 AM, Russell Keith-Magee wrote: > On Thu, Jan 21, 2010 at 7:47 AM, Malcolm Box > wrote: > > > > I've got a simple question that I can't find the answer to: if the data > > that a view depends on changes, does Django do anything smart to > invalidate > > the cache for that view, or is it left to the programmer? > > >Your suspicions are correct - there is no systematic cache > invalidation tied to Django's models. > > Thanks for the confirmation! > If you want to invalidate a specific view, you will need to use the > cache key tools to django.utils.cache to reconstruct the key for the > view that needs to be invalidated. See the cache middleware for > examples of usage. > So a higher-level question - is this the prefered design approach - have the views that alter data explicitly invalidate the views in the cache for the ones who's data has been changed? It feels a bit too tightly coupled to me - and fragile if new views are added. What's the recommended approach, or what have others done that's worked? A few more details on my app if that helps: it's a voting app, so some data (e.g. the polls, questions etc) change infrequently, whereas the number of votes and current result change frequently. I'm aiming to scale to handle tens of thousands of votes per second. Cheers, Malcolm -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with Django
My form contains date of birth and total income field. I am getting following errors: datetime.date is not json serializable decimal is not json serializable. On Jan 21, 11:06 am, Prashanth wrote: > Hi, > > On Thu, Jan 21, 2010 at 10:53 AM, Meenu wrote: > > > I've noticed that my form submission seems to randomly fail on the > > line var response_obj = eval('(' + o.responseText + ')'); in my > > javascript. My form contains date and decimal fields. > > Pretty hard to figure out just with the javascript line though eval > looks fine, print the response that you are getting from django and > try to debug or if you want people to point out do a pastebin of your > view and response that you are doing in the javascript. > > -- > regards, > Prashanth > twitter: munichlinux > blog: prashanthblog.appspot.com > irc: munichlinux, JSLint, munichpython. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to Model a relationship on a constrained subset of the foreign key.
taliesin wrote: HI. I have a newbie-ish question, if that's alright. I don't know how to model a particular relationship in Django. I have an Account model which represents a customer account - billing address, balance and all that. And I have a Contact model, which represents actual people we would pick up the phone and call. The relationship of Contact to Account is Many to One and I have set a ForeignKey(Account) attribute on the Contact model. This is all fine so far. Accounts can have a variable number of divisions within them, e.g. Europe, America, whatever. I have therefore created a Division model which has a ForeignKey(Account) attribute as well. This is fine - divisions are attached to accounts, they don't cross account boundaries even if two Accounts had a "Europe" division for example, they're not actually the same division. I want to have contacts optionally assigned to a division as well as to an account. I can do that by giving the Contact model a ForeignKey(Division) attribute and this works, but I can't find a way of constraining it to only those divisions that belong to the same Account. I can fudge it in the forms and views, of course, but it seems there should be a way of representing this relationship in the models. Do I create a special Contact-Division model and have foreign keys to it? Is there a way of doing ForeignKey(Account,Division). How can I do this or is it not possible to represent this constraint at the model layer? Any help is much valued. Thanks, Taliesin. Okay, clearly no-one wants to touch my question. : / Let me ask a different related one then... What would happen if I added a constraint directly to the underlying database? I'm using PostgreSQL so I can create foreign keys on composite columns if I wish. WIll Django explode? I know that it produces the situation where I might get exceptions raised if Django tried to add an entry that its model predicted was valid but the database rejected, but if I'm going to have to handle this situation by excluding invalid options in the GUI anyway, I see no harm in barring those same entries at the database level just for integrity's sake. Anyone see a problem with that? If I need to go into more detail on my posts, please let me know. Thanks, Taliesin. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Easy database modeling question
If you want to add a profile for each user, check out http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/ the key in django is reusing existing "applications" maybe this might help http://code.google.com/p/django-messages/ On Thu, Jan 21, 2010 at 6:16 AM, Chris wrote: > This is my first Django experience and I'm having trouble figuring out > the right answer to the right relationship to have. (brain fart > maybe.. ) > I have a site that users have profiles and can message each other. So > my model looks like: > > class User(models.Model): >username = models.CharField(max_length=50) >password = models.CharField(max_length=50) >profile = models.ForeignKey(Profile) > > class Profile(models.Model): >username = models.CharField(max_length=50, primary_key=True) >sex = models.CharField(max_length=50) >location = models.CharField(max_length=100) > > > class Messages(models.Model): >sender = models.CharField(max_length=100) >to = models.CharField(max_length=100) >subject = models.CharField(max_length=100) >message = models.TextField() >date = models.DateTimeField() > > My question here is this a one-to-many relationship from Profile to > Messages? In that each profile has many messages or is it many-to-many > as each message has a sender and a recipient. Ultimately I want to be > able to easily pull the profile for the sender and recipient from the > message and from the User show their messages. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.