How to use pychecker with Django
I want to use pychecker to do static analysis on my code. So I set up DJAGO_SETTINGS_MODULE and run pychecker from shell. I am getting exceptions like, G:\prajact>pychecker project\urls.py G:\prajact>C:\Python24\python.exe C:\Python24\Lib\site-packages \pychecker\checker.py project\urls.py Processing urls... Caught exception importing module urls: File "C:\Python24\Lib\site-packages\pychecker\checker.py", line 621, in setupMainCode() module = imp.load_module(self.moduleName, file, filename, smt) File "G:\prajact\..\prajact\project\urls.py", line 4 from rss import * File "G:\prajact\..\prajact\project\rss.py", line 4 from helpers import * File "G:\prajact\..\prajact\project\helpers.py", line 8 from models import * File "G:\prajact\project\models.py", line 41 class Project(models.Model): File "C:\Python24\lib\site-packages\django\db\models\base.py", line 53, in __new__() new_class._meta.app_label = model_module.__name__.split('.')[-2] IndexError: list index out of range Warnings... urls:1: NOT PROCESSED UNABLE TO IMPORT The checker runs fine on non Django code. It seems that some of the model metaclass magic clashes with pychecker. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Assigning Dates to DateField instances
I think we'd need to see your Event model class too. It really would be a good idea to take advantage of the validation from doing this as a django form, just passing in POST is dangerous. It would also abstract the whole datetime handling issue for you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to stop validations duplications in forms and models?
>(the save() method shouldn't raise >any validation errors except those triggered by the database server due >to IntegrityErrors). So what is the recommended place to write validations in models, for now? On Feb 22, 12:25 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-02-21 at 08:54 -0800,shabdawrote: > > I have some models, and some forms to write data to them. The > > attributes in models need to have soem validations, (For example, name > > must be alpha numeric, price must be less that 1000 etc). SO I write > > the validations in model.save() and raise Exceptions, when a > > validation fails. I also need to write the same validations in > > newforms as I do not want the form post to happen unless the > > validation passes. This means that I have the same validation at two > > places. (I can't raise ValidationException from models). Is there a > > way to remove this duplication? > > Some current work-in-progress is model-aware validation. This will > provide a validate() method on models (the save() method shouldn't raise > any validation errors except those triggered by the database server due > to IntegrityErrors). At the same time, this means forms created directly > from models will use the models' validation functions to validate the > fields. Finally, the validation functions will be able to be used mostly > identically for form fields and model fields. > > So, it's coming. Just wait a little longer. > > Malcolm > > -- > Always try to be modest and be proud of it!http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Creating a form with only foreign keys?
If you use old forms.. you'd just do something like this .. for each of the attributes you want to search on. class MyManipulator(forms.Manipulator): def __init__(self): sizes = [] all_sizes = Size.objects.all() if all_sizes: sizes = [(obj.name, obj.name) for obj in all_sizes] self.fields = ( forms.SelectField(field_name="size", is_required=False,choices=sizes), ) On Feb 19, 3:57 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > On Feb 19, 3:53 pm, Adam Stein <[EMAIL PROTECTED]> wrote: > > > I can upgrade to the current trunk. The whole Django application is > > completely under my control. 'newforms' seems to already be in v0.96 > > (since I'm able to use form_for_model() out of newforms), don't know > > about 'ModelForm'. > > Sorry, I was unclear. Newforms started off in 0.96 but has evolved > quite heavily through the trunk. In particular, the ModelForm's > mechanism is new in development and not available in 0.96. > > For a quick intro see:http://www.djangoproject.com/documentation/modelforms/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: loaddata on big fixture doesn't seem to end
On Fri, Feb 22, 2008 at 12:07 PM, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Thu, 2008-02-21 at 18:58 -0800, msoulier wrote: > > Hi, > > > > I'm loading a fixture with 2500 objects in it into postgres 7.4. > > > > For some reason, loaddata is looking in a lot of additional places > > than the file I'm handing it. > > If you read the documentation carefully (in django-admin.txt), you'll > see that "loaddata" appends the name it's given to a whole bunch of > prefixes. It doesn't expect to be handed an absolute filename. Whilst this is correct, I think this report may be an indicator of a subtle bug - the '11 fixtures loaded' is obviously wrong, and 27500 is 11x2500. I have a nasty feeling that the fixture loader may actually be loading the fixture 11 times, due to the way that os.path.join ignores any provided path once an absolute path name is provided on the list of paths to join. I've logged this as #6643. I'm hoping to have some time tonight to look at a few outstanding fixture tickets; I'll add this one to the list. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Resolving dynamic dictionary parameters in templates
I recently found that snippet, which you could use to assign a temporary variable in your template: http://www.djangosnippets.org/snippets/539/ In theory, it's bad practice, but so useful in some situation ;) On Feb 22, 1:13 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-02-21 at 20:47 -0500, Nick Fishman wrote: > > Hey everyone. I've run into an issue with dictionaries in templates, and > > I'm kind of stuck. I'm trying to track incidents by username and month. > > Here's what I have passed into a template: > > > months = ['Mar', 'Feb', 'Aug', 'Sep', 'Apr', 'Jan', 'May', 'Nov', 'Dec', > > 'Oct'] > > mapping = {'username': u'jdoe5', 'incidents': {'Mar': 0L, 'Feb': 28L, > > 'Aug': 0L, 'Sep': 0L, 'Apr': 0L, 'Jan': 0L, 'May': 0L, 'Nov': 0L, 'Dec': > > 0L, 'Oct': 0L}} > > > Here's where the problem occurs: > > > {% for month in month %} > > {{ mapping.incidents.month }} > > {% endfor %} > > > I'm trying to make Django call mapping['incidents']['Mar'], > > mapping['incidents']['Jul'], and so on for each month in the months > > list. But instead, Django seems to be doing > > mapping['incidents']['month'] each time. > > > Is there any way to resolve the dynamic "month" variable inside the > > mapping.incidents.month call? Something almost like {{ > > mapping.incidents.param="month" }}? > > What you're wanting to do here (indirect variable lookup) isn't possible > in the template system out of the box. The reason is simplicity (or, > rather, anti-complexity): there's no way to really tell the difference > between "month" as a direct attribute and "month" as a variable to use > to get the value of the attribute to use (the indirect version). We'd > have to add yet more markup and it's not really worth it. > > If I was doing this, I'd probably write a filter so you could write > > {{ mapping.incidents|lookup:month }} > > I wouldn't be too surprised if something like that already existed at > djangosnippets.org, but, if not, it should be only a couple of lines to > write one. > > Regards, > Malcolm > > -- > The early bird may get the worm, but the second mouse gets the > cheese.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: loaddata on big fixture doesn't seem to end
On Thu, 2008-02-21 at 18:58 -0800, msoulier wrote: > Hi, > > I'm loading a fixture with 2500 objects in it into postgres 7.4. > > For some reason, loaddata is looking in a lot of additional places > than the file I'm handing it. > > [EMAIL PROTECTED] teleworker]# PYTHONPATH=.. python manage.py > loaddata /root/clients.json If you read the documentation carefully (in django-admin.txt), you'll see that "loaddata" appends the name it's given to a whole bunch of prefixes. It doesn't expect to be handed an absolute filename. It's possibly not crazy to add this option (Russell might know of a reason why it's a bad idea, but I can't immediately think of one), but, at the moment, it's behaving as intended and as documented. Regards, Malcolm -- Tolkien is hobbit-forming. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
loaddata on big fixture doesn't seem to end
Hi, I'm loading a fixture with 2500 objects in it into postgres 7.4. For some reason, loaddata is looking in a lot of additional places than the file I'm handing it. [EMAIL PROTECTED] teleworker]# PYTHONPATH=.. python manage.py loaddata /root/clients.json Loading '/root/clients.json' fixtures... Installing json fixture '/root/clients' from '/usr/lib/python2.3/site- packages/django/contrib/auth/fixtures'. Installing json fixture '/root/clients' from '/usr/lib/python2.3/site- packages/django/contrib/contenttypes/fixtures'. Installing json fixture '/root/clients' from '/usr/lib/python2.3/site- packages/django/contrib/sessions/fixtures'. Installing json fixture '/root/clients' from '/etc/e-smith/web/django/ teleworker/dashboard/fixtures'. Installing json fixture '/root/clients' from '/etc/e-smith/web/django/ teleworker/icps/fixtures'. Installing json fixture '/root/clients' from '/etc/e-smith/web/django/ teleworker/clients/fixtures'. Installing json fixture '/root/clients' from '/etc/e-smith/web/django/ teleworker/advanced/fixtures'. Installing json fixture '/root/clients' from '/etc/e-smith/web/django/ teleworker/proxies/fixtures'. Installing json fixture '/root/clients' from '/etc/e-smith/web/django/ teleworker/metrics/fixtures'. Installing json fixture '/root/clients' from '/etc/e-smith/web/django/ teleworker/js/fixtures'. Installing json fixture '/root/clients' from absolute path. Installed 27500 object(s) from 11 fixture(s) Is there a way to skip everything else and just load the one fixture I handed it? Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Phantom Query
Malcolm! You rock! I had put a function before every render_to_response to analyze the queries made by every function and I still couldn't find it. Your solution went deeper and i found the strange query being made in the default 500 page rendering! How bazar. Thanks a ton for your help. That's the only way i would have found it. On Feb 21, 2:27 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-02-21 at 00:37 -0800, Dave Fowler wrote: > > I have a phantom query that is just killing my database. I have a > > model named Stats and django is executing the equivalent to > > Link.objects.all() in my Stats app. > > > # Query_time: 20 Lock_time: 0 Rows_sent: 659528 Rows_examined: 659528 > > SELECT > > `stats_link`.`id`,`stats_link`.`title`,`stats_link`.`url`,`stats_link`.`last_modified`,`stats_link`.`subdomain_id`,`stats_link`.`avg_time`,`stats_link`.`rating`,`stats_link`.`dlevel`,`stats_link`.`visits` > > FROM `stats_link`; > > > I've combed my code 100 times and cannot find a single place where I > > do anything remotely like this. I have almost a 700,000 entries in my > > link table and it takes 20 seconds to execute. > > > I added the snippet that shows what queries are executed on each page, > > but it shows up on none of my pages. I have a large amount of ajax > > for my site so its I can't see every function that way. > > > Does anyone know of any other tools beside that snippet to view all my > > queries and see what function they're coming from? > > Modify the execute() method in > django.db.backend.utils.CursorDebugWrapper to also log a stack trace > each time execute() is called. If you log the query, plus the result of > traceback.print_stack() or traceback.extract_stack() to a file you > should be able to work out where the call is coming from. > > Malcolm > > -- > A conclusion is the place where you got tired of > thinking.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Resolving dynamic dictionary parameters in templates
On Thu, 2008-02-21 at 20:47 -0500, Nick Fishman wrote: > Hey everyone. I've run into an issue with dictionaries in templates, and > I'm kind of stuck. I'm trying to track incidents by username and month. > Here's what I have passed into a template: > > months = ['Mar', 'Feb', 'Aug', 'Sep', 'Apr', 'Jan', 'May', 'Nov', 'Dec', > 'Oct'] > mapping = {'username': u'jdoe5', 'incidents': {'Mar': 0L, 'Feb': 28L, > 'Aug': 0L, 'Sep': 0L, 'Apr': 0L, 'Jan': 0L, 'May': 0L, 'Nov': 0L, 'Dec': > 0L, 'Oct': 0L}} > > Here's where the problem occurs: > > {% for month in month %} > {{ mapping.incidents.month }} > {% endfor %} > > I'm trying to make Django call mapping['incidents']['Mar'], > mapping['incidents']['Jul'], and so on for each month in the months > list. But instead, Django seems to be doing > mapping['incidents']['month'] each time. > > Is there any way to resolve the dynamic "month" variable inside the > mapping.incidents.month call? Something almost like {{ > mapping.incidents.param="month" }}? What you're wanting to do here (indirect variable lookup) isn't possible in the template system out of the box. The reason is simplicity (or, rather, anti-complexity): there's no way to really tell the difference between "month" as a direct attribute and "month" as a variable to use to get the value of the attribute to use (the indirect version). We'd have to add yet more markup and it's not really worth it. If I was doing this, I'd probably write a filter so you could write {{ mapping.incidents|lookup:month }} I wouldn't be too surprised if something like that already existed at djangosnippets.org, but, if not, it should be only a couple of lines to write one. Regards, Malcolm -- The early bird may get the worm, but the second mouse gets the cheese. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Resolving dynamic dictionary parameters in templates
Hey everyone. I've run into an issue with dictionaries in templates, and I'm kind of stuck. I'm trying to track incidents by username and month. Here's what I have passed into a template: months = ['Mar', 'Feb', 'Aug', 'Sep', 'Apr', 'Jan', 'May', 'Nov', 'Dec', 'Oct'] mapping = {'username': u'jdoe5', 'incidents': {'Mar': 0L, 'Feb': 28L, 'Aug': 0L, 'Sep': 0L, 'Apr': 0L, 'Jan': 0L, 'May': 0L, 'Nov': 0L, 'Dec': 0L, 'Oct': 0L}} Here's where the problem occurs: {% for month in month %} {{ mapping.incidents.month }} {% endfor %} I'm trying to make Django call mapping['incidents']['Mar'], mapping['incidents']['Jul'], and so on for each month in the months list. But instead, Django seems to be doing mapping['incidents']['month'] each time. Is there any way to resolve the dynamic "month" variable inside the mapping.incidents.month call? Something almost like {{ mapping.incidents.param="month" }}? Or should I try to rework the way my code works? Thanks for the help, Nick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Transient ViewDoesNotExist errors
On Feb 22, 11:02 am, Richard Jones <[EMAIL PROTECTED]> wrote: > On Feb 22, 9:54 am, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > Or use one of the many other options for serving Django applications > > (mod_wsgi, cherryPy's server, nginx + fastcgi, lighttpd + fastcgi, ...). > > I have compiled and installed the latest mod_wsgi. I'll see how that > goes. I'm still getting the errors reported like: ViewDoesNotExist: Tried diary_display in module pyweek.challenge.views.challenge. Error was: 'module' object has no attribute 'Manipulator' and upon hitting the URL in question myself I do not get the error. Richard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Transient ViewDoesNotExist errors
On Feb 22, 9:54 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > Or use one of the many other options for serving Django applications > (mod_wsgi, cherryPy's server, nginx + fastcgi, lighttpd + fastcgi, ...). I have compiled and installed the latest mod_wsgi. I'll see how that goes. Richard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to query ManyToManyFields
On Thu, Feb 21, 2008 at 5:06 PM, Albert Hopkins <[EMAIL PROTECTED]> wrote: > I have a model with a M2M field and I want to filter based on the field > being empty. How do I do this? I tried > MyModel.objects.filter(m2mfield=[]) but that raises a (MySQL) exception. Is this what you want? MyModel.objects.filter(m2mfield__pk__isnull=True) Brett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to query ManyToManyFields
I have a model with a M2M field and I want to filter based on the field being empty. How do I do this? I tried MyModel.objects.filter(m2mfield=[]) but that raises a (MySQL) exception. -a --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Transient ViewDoesNotExist errors
On Thu, 2008-02-21 at 14:48 -0800, Richard Jones wrote: > On Feb 12, 11:03 am, Richard Jones <[EMAIL PROTECTED]> wrote: > > On Feb 9, 5:19 pm, Richard Jones <[EMAIL PROTECTED]> wrote: > > > > > I'm still getting thetransienterrors mentioned in my OP though. > > > > Anyone? I'd be happy to provide more detail if there was any that > > might help? > > Still getting these errors. Silence from here. I guess I'll be > rewriting it in TG :( Or use one of the many other options for serving Django applications (mod_wsgi, cherryPy's server, nginx + fastcgi, lighttpd + fastcgi, ...). Malcolm -- Works better when plugged in. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Transient ViewDoesNotExist errors
On Feb 12, 11:03 am, Richard Jones <[EMAIL PROTECTED]> wrote: > On Feb 9, 5:19 pm, Richard Jones <[EMAIL PROTECTED]> wrote: > > > I'm still getting thetransienterrors mentioned in my OP though. > > Anyone? I'd be happy to provide more detail if there was any that > might help? Still getting these errors. Silence from here. I guess I'll be rewriting it in TG :( Richard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Changes in views don't have effect
On Feb 21, 2:37 am, Richard Dahl <[EMAIL PROTECTED]> wrote: > If you are using Apache or other web server on the external site, > changes will not propagate until you restart the web server. Depending on the web server hosting solution you may not have to restart the web server. If using mod_wsgi 2.0 with daemon mode and process reloading option enabled, or if using certain fastcgi solutions, it is enough to touch the script file which is entry point for your application. It is still an extra step, but this way you do not necessarily need to have root access to restart the whole web server. Graham > On Feb 20, 2008, at 9:25 AM, Constantin Christmann wrote: > > > > > Hello, > > > I am relatively new to django but I like this framework a lot... > > > Unfortunately I have some trouble running my django project outside my > > localhost enviroment. > > I moved the project on another server and got the site working in > > debug > > mode (same as on my localhost). > > Now I habe trouble seeing changes I make in views instantly. > > For example this simple view > > > def index(request): > > forum_list = Forum.objects.all() > > assert(False) > > return render_to_response('frontend/index.html', > > {'forum_list':forum_list}, context_instance=RequestContext(request)) > > > doesn't lead to an assert when accessing this view but shows the same > > page as without this assert. Do I have to trigger a recompilation > > of my > > py files or is maybe the caching a problem here. > > How can I find out where the problem is? On my localhost I have seen > > changes instantly. > > > Thanks! > > Constantin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django for xml api based sites
Hello, We have an opportunity to switch over from Java to something easier for a series of sites that we will be doing. They will be small simple sites but with a reasonable amount of traffic so performance will be important. If this was a database based app I'd go into this meeting suggesting django all the way but there are some caveats to this project. I was hoping to get some opinions from this list about what I should look into and if infact I should recommend django for these. These sites wont be database based, we will get the content through an xml based api. So obviously caching will be important in this. The other requirements are - 1.need an equivalent option to tomcats servlet filters, to read the headers and modify the request before it is processed. 2.Custom tags, this will be because the site will be viewed on different media with diferent capabilities and different tags, so based on things found in requirement 1 these custom tags will be replaced with the correct thing. I call them custom tags because in java world that is what I would use. I'm not looking for detailed explanations of how to do this, just a nod in the direction like - django templates can do that, yeah we have intercepters for number 1, yeah use django it rocks. I am quite biased since I've been looking for an excuse to use django for a while. I even bought the book before, have to enter my email everytime I open it - how annoying is that. But I must persuade others it is the way to go. Thanks for any help Bob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Javascript, Access Radio Button Elements
Your right, I looked too quickly and saw the for instead of the id. Thanks for the correction. On Feb 21, 3:54 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On 21 Feb, 18:57, Little_Grungy <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > I have a form definition for two radio buttons named choices. I want > > to loop through the radio buttons to perform a check with javascript > > in the rendered html page, however due to the radio button _id's that > > are rendered by the template, I cannot access them with javascript > > using getElementById(). Wondering if anyone can suggest how to solve > > this? > > > My form definition contains: > > > choices = forms.ChoiceField(label='Choices', required=True, > > widget=forms.RadioSelect, choices=options) > > options = (('good', 'Good'), ('bad', 'Bad')) > > > The rendered html is as follows: > > > > > Choices: > > > > > > > > > > > >> value="good"/> > > Good > > > > > > > > > > > > Bad > > > > > > > > > My Javascript function is passed an object obj which contains a > > choices paramater. obj.choices will be either "good" or "bad" so I > > would normally be able to set it based on what is passed. My normal > > approach would be to check the current setting by using > > getElementById, then comparing to what is passed from obj.choices and > > if equal, setting the relevant radio. > > > As I have two id's id_choices_0 and id_choices_1 I'm guessing that I > > can't use id_choices_0 in getElementById as in previous worlds. Before > > Django my radio buttons would only have one id which I would use to > > reference. > > > for (var i=0; i < document.getElementById('id_choices_0').length; i++) > > { > > if (document.getElementById(id_choices_[i]).value == obj.choices) > > document.getElementById(id_choices_[i]).checked = true; > > } > > > Can anyone help? > > It's not Django that's the problem, it's the javascript. Why not try > something like this (untested): > > var choice; > var choice_length = 2; > for (var i=0; i < choice_length; i++) > { > choice = document.getElementById('id_choices_' + i); > if (choice.value == obj.choices) > { > choice.checked = true; > } > > } > > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Assigning Dates to DateField instances
I'm not sure I understand what I'm doing here. I'm trying to create an Event object from the data in a form (a simple html form, not a django form). I want to do this: lDay = int(request.POST['DayNo']) lMonth = int(request.POST['MonthNo']) lYear = int(request.POST['YearNo']) lEvent = Event(request.POST) if lEvent.id == 0: lEvent.id = None lEvent.date = datetime(lYear,lMonth,lDay) lEvent.save() and I'm getting the error Exception Type: ProgrammingError Exception Value:can't adapt Exception Location: /usr/lib/python2.5/site-packages/django/db/backends/util.py in execute, line 12 where the last bit of my code it hit was the save method. Have I obviously done something wrong or is the problem data related? I suspect it's caused by the date assignment? Any thoughts/pointers appreciated. Thanks, Tim. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Javascript, Access Radio Button Elements
On 21 Feb, 18:57, Little_Grungy <[EMAIL PROTECTED]> wrote: > Hi, > > I have a form definition for two radio buttons named choices. I want > to loop through the radio buttons to perform a check with javascript > in the rendered html page, however due to the radio button _id's that > are rendered by the template, I cannot access them with javascript > using getElementById(). Wondering if anyone can suggest how to solve > this? > > My form definition contains: > > choices = forms.ChoiceField(label='Choices', required=True, > widget=forms.RadioSelect, choices=options) > options = (('good', 'Good'), ('bad', 'Bad')) > > The rendered html is as follows: > > > Choices: > > > > > >value="good"/> > Good > > > > > > Bad > > > > > My Javascript function is passed an object obj which contains a > choices paramater. obj.choices will be either "good" or "bad" so I > would normally be able to set it based on what is passed. My normal > approach would be to check the current setting by using > getElementById, then comparing to what is passed from obj.choices and > if equal, setting the relevant radio. > > As I have two id's id_choices_0 and id_choices_1 I'm guessing that I > can't use id_choices_0 in getElementById as in previous worlds. Before > Django my radio buttons would only have one id which I would use to > reference. > > for (var i=0; i < document.getElementById('id_choices_0').length; i++) > { > if (document.getElementById(id_choices_[i]).value == obj.choices) > document.getElementById(id_choices_[i]).checked = true; > } > > Can anyone help? It's not Django that's the problem, it's the javascript. Why not try something like this (untested): var choice; var choice_length = 2; for (var i=0; i < choice_length; i++) { choice = document.getElementById('id_choices_' + i); if (choice.value == obj.choices) { choice.checked = true; } } -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need to change newform label from within view
Actually, it looks like I can use a formfield callback. Not sure exactly how to do it yet, but they are described in the djangoproject newforms library doc. On Feb 21, 2:51 pm, Michael Newman <[EMAIL PROTECTED]> wrote: > not in the views per se, but you can certainly take care of this in > the templates, just manually define each of the fields. > > On Feb 21, 1:23 pm, csmith87 <[EMAIL PROTECTED]> wrote: > > > Hello, > > > Newbie django user > > > Is it possible to change a newform label (from the one in the model) > > to one > > set in the view ? (i.e. I want the tags lefttag, righttag) in the > > view below to > > appear in the generated form as the label, not the model label. > > > Thanks in advance ... > > > Here is my model ... > > > class Response( models.Model ): > > > type = models.IntegerField() > > left = models.TextField() > > right = models.TextField() > > login_id = models.CharField( maxlength=32 ) > > entry_date = models.DateTimeField() > > > class Admin: > > pass > > > Here is my view ... > > > def getif( request ): > > lefttag = 'if' > > righttag = 'then' > > AddResponseForm = forms.form_for_model( Response ) > > > if request.method == 'POST': > > form = AddResponseForm( request.POST ) > > if form.is_valid(): > > form.save() > > return HttpResponseRedirect( '/if' ) > > else: > > form = AddResponseForm() > > > return render_to_response( 'AddResponseForm.html', {'form': form } ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need to change newform label from within view
not in the views per se, but you can certainly take care of this in the templates, just manually define each of the fields. On Feb 21, 1:23 pm, csmith87 <[EMAIL PROTECTED]> wrote: > Hello, > > Newbie django user > > Is it possible to change a newform label (from the one in the model) > to one > set in the view ? (i.e. I want the tags lefttag, righttag) in the > view below to > appear in the generated form as the label, not the model label. > > Thanks in advance ... > > Here is my model ... > > class Response( models.Model ): > > type = models.IntegerField() > left = models.TextField() > right = models.TextField() > login_id = models.CharField( maxlength=32 ) > entry_date = models.DateTimeField() > > class Admin: > pass > > Here is my view ... > > def getif( request ): > lefttag = 'if' > righttag = 'then' > AddResponseForm = forms.form_for_model( Response ) > > if request.method == 'POST': > form = AddResponseForm( request.POST ) > if form.is_valid(): > form.save() > return HttpResponseRedirect( '/if' ) > else: > form = AddResponseForm() > > return render_to_response( 'AddResponseForm.html', {'form': form } ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Javascript, Access Radio Button Elements
Hmm this is interesting because django is rendering out poor html if your example is correct. IDs in the DOM should be unique. I don't imagine that this would validate the way you want it to either. Why not just have 2 form.BooleanField objects and in the def clean make sure that one is taken care of. I hope that helps. On Feb 21, 1:57 pm, Little_Grungy <[EMAIL PROTECTED]> wrote: > Hi, > > I have a form definition for two radio buttons named choices. I want > to loop through the radio buttons to perform a check with javascript > in the rendered html page, however due to the radio button _id's that > are rendered by the template, I cannot access them with javascript > using getElementById(). Wondering if anyone can suggest how to solve > this? > > My form definition contains: > > choices = forms.ChoiceField(label='Choices', required=True, > widget=forms.RadioSelect, choices=options) > options = (('good', 'Good'), ('bad', 'Bad')) > > The rendered html is as follows: > > > Choices: > > > > > >value="good"/> > Good > > > > > > Bad > > > > > My Javascript function is passed an object obj which contains a > choices paramater. obj.choices will be either "good" or "bad" so I > would normally be able to set it based on what is passed. My normal > approach would be to check the current setting by using > getElementById, then comparing to what is passed from obj.choices and > if equal, setting the relevant radio. > > As I have two id's id_choices_0 and id_choices_1 I'm guessing that I > can't use id_choices_0 in getElementById as in previous worlds. Before > Django my radio buttons would only have one id which I would use to > reference. > > for (var i=0; i < document.getElementById('id_choices_0').length; i++) > { > if (document.getElementById(id_choices_[i]).value == obj.choices) > document.getElementById(id_choices_[i]).checked = true; > } > > Can anyone help? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: inline editing?
ok, thanks /me goes in the corner RTFM :-) -- error: one bad user found in front of screen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to stop validations duplications in forms and models?
On Thu, 2008-02-21 at 08:54 -0800, shabda wrote: > I have some models, and some forms to write data to them. The > attributes in models need to have soem validations, (For example, name > must be alpha numeric, price must be less that 1000 etc). SO I write > the validations in model.save() and raise Exceptions, when a > validation fails. I also need to write the same validations in > newforms as I do not want the form post to happen unless the > validation passes. This means that I have the same validation at two > places. (I can't raise ValidationException from models). Is there a > way to remove this duplication? Some current work-in-progress is model-aware validation. This will provide a validate() method on models (the save() method shouldn't raise any validation errors except those triggered by the database server due to IntegrityErrors). At the same time, this means forms created directly from models will use the models' validation functions to validate the fields. Finally, the validation functions will be able to be used mostly identically for form fields and model fields. So, it's coming. Just wait a little longer. Malcolm -- Always try to be modest and be proud of it! http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Converting relational data to hiechical data
On Thu, Feb 21, 2008 at 10:22 AM, shabda <[EMAIL PROTECTED]> wrote: > > I have a model like > > class Task(models.Model): > name = Models.CharField(max_length = 100) > parent = models.ForeignKey('Task', null = True) > > Using this model say I have got a table like, > > Task > --- > ID Name Parent_id > 1 Foo null > 2 Bar 1 > 3 Baz1 > 4 Bax2 > > [...] > > Essentially I want to convert a relational data to monarchical data. > Does any body have snippets/recipe to do something similar? I am using > mySQL Isn't just for this kind of cases that [1]django-mptt has beeen created? -- Ramiro Morales 1. http://code.google.com/p/django-mptt/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: inline editing?
As Karen said, You didn't set up the inline right. Read through the docs she pointed you to and fix your errors and the big error will go away. On Feb 21, 1:31 pm, "Almir Karic" <[EMAIL PROTECTED]> wrote: > On Thu, Feb 21, 2008 at 3:02 PM, Karen Tracey <[EMAIL PROTECTED]> wrote: > > On Thu, Feb 21, 2008 at 3:55 AM, Almir Karic <[EMAIL PROTECTED]> wrote: > > > > from django.db import models > > > from django.contrib import admin > > > > # Create your models here. > > > > class Category(models.Model): > > >name = models.CharField(max_length=50) > > > >def __str__(self): > > >return self.name > > > > class Forum(models.Model): > > >cat = models.ForeignKey(Category) > > >name = models.CharField(max_length=50) > > > >def __str__(self): > > >return self.name > > > > class Category_admin(admin.ModelAdmin): > > >model = Category > > >inlines = [Forum] > > > You don't list your Model classes directly in inlines, but rather create a > > class based off of admin.StackedInline or admin.TabularInline (which is > > where you specify the actual Model), and list that class in inlines. > > > See: > >http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIsetupedit_in... > > and the last part of:http://code.djangoproject.com/wiki/NewformsAdminBranch > > for examples. > > thanks :) > > what about that error? any ideas how to 'fix' it? > > -- > error: one bad user found in front of screen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Authentication not applied in base template
That worked great for the base template. But how do I pass database values to a view in an app? I have a a view that should have all the records available for a template so that I can loop through each record and display on the screen. I cannot figure out how to give the template access to the whole table essentially. Other views that look at specific records work fine. On Feb 20, 10:45 pm, quizkiwi <[EMAIL PROTECTED]> wrote: > That is the second time RequestContext has come back to bite me, I > guess I did not understand it the first time. Thanks! > > On Feb 20, 6:53 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > > > On Wed, Feb 20, 2008 at 5:18 PM, quizkiwi <[EMAIL PROTECTED]> wrote: > > > Is there some difference in authentication between the app and the > > > main site? > > >http://www.djangoproject.com/documentation/templates_python/#subclass... > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > > correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Converting relational data to hiechical data
That would help once I get the relational data to a hierarchical list, and that is the difficult part! On Feb 21, 10:59 pm, Brian Luft <[EMAIL PROTECTED]> wrote: > http://www.djangoproject.com/documentation/templates/#unordered-list > > On Feb 21, 4:22 am, shabda <[EMAIL PROTECTED]> wrote: > > > I have a model like > > > class Task(models.Model): > > name = Models.CharField(max_length = 100) > > parent = models.ForeignKey('Task', null = True) > > > Using this model say I have got a table like, > > > Task > > --- > > ID Name Parent_id > > 1 Foo null > > 2 Bar 1 > > 3 Baz1 > > 4 Bax2 > > > I want to display this information hierchically in the template, > > something like > > > > > Foo > > > >Bar > > Bax > >Baz > > > > > > > Essentially I want to convert a relational data to monarchical data. > > Does any body have snippets/recipe to do something similar? I am using > > mySQL --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Javascript, Access Radio Button Elements
Hi, I have a form definition for two radio buttons named choices. I want to loop through the radio buttons to perform a check with javascript in the rendered html page, however due to the radio button _id's that are rendered by the template, I cannot access them with javascript using getElementById(). Wondering if anyone can suggest how to solve this? My form definition contains: choices = forms.ChoiceField(label='Choices', required=True, widget=forms.RadioSelect, choices=options) options = (('good', 'Good'), ('bad', 'Bad')) The rendered html is as follows: Choices: Good Bad My Javascript function is passed an object obj which contains a choices paramater. obj.choices will be either "good" or "bad" so I would normally be able to set it based on what is passed. My normal approach would be to check the current setting by using getElementById, then comparing to what is passed from obj.choices and if equal, setting the relevant radio. As I have two id's id_choices_0 and id_choices_1 I'm guessing that I can't use id_choices_0 in getElementById as in previous worlds. Before Django my radio buttons would only have one id which I would use to reference. for (var i=0; i < document.getElementById('id_choices_0').length; i++) { if (document.getElementById(id_choices_[i]).value == obj.choices) document.getElementById(id_choices_[i]).checked = true; } Can anyone help? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: [newforms-admin] inline editing?
On Thu, Feb 21, 2008 at 3:02 PM, Karen Tracey <[EMAIL PROTECTED]> wrote: > On Thu, Feb 21, 2008 at 3:55 AM, Almir Karic <[EMAIL PROTECTED]> wrote: > > > > > from django.db import models > > from django.contrib import admin > > > > > > # Create your models here. > > > > class Category(models.Model): > >name = models.CharField(max_length=50) > > > >def __str__(self): > >return self.name > > > > class Forum(models.Model): > >cat = models.ForeignKey(Category) > >name = models.CharField(max_length=50) > > > >def __str__(self): > >return self.name > > > > class Category_admin(admin.ModelAdmin): > >model = Category > >inlines = [Forum] > > > > > > You don't list your Model classes directly in inlines, but rather create a > class based off of admin.StackedInline or admin.TabularInline (which is > where you specify the actual Model), and list that class in inlines. > > See: > http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIsetupedit_inline > and the last part of: http://code.djangoproject.com/wiki/NewformsAdminBranch > for examples. thanks :) what about that error? any ideas how to 'fix' it? -- error: one bad user found in front of screen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Need to change newform label from within view
Hello, Newbie django user Is it possible to change a newform label (from the one in the model) to one set in the view ? (i.e. I want the tags lefttag, righttag) in the view below to appear in the generated form as the label, not the model label. Thanks in advance ... Here is my model ... class Response( models.Model ): type = models.IntegerField() left = models.TextField() right = models.TextField() login_id = models.CharField( maxlength=32 ) entry_date = models.DateTimeField() class Admin: pass Here is my view ... def getif( request ): lefttag = 'if' righttag = 'then' AddResponseForm = forms.form_for_model( Response ) if request.method == 'POST': form = AddResponseForm( request.POST ) if form.is_valid(): form.save() return HttpResponseRedirect( '/if' ) else: form = AddResponseForm() return render_to_response( 'AddResponseForm.html', {'form': form } ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Weighted Random Sample
Oh, duh, that's so much simpler. (Now I feel like a nitwit.) Should I be concerned about the performance issues with frequent selects of that type? The table size is on the order of hundreds of thousands (not tens of thousands) of rows. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: wordpress hooks and actions system in django?
While not exactly Django-specific, I wrote up an article[1] last month, describing an easy way to enable plugins in any Python application. I don't know if that's what you're looking for, but it's probably worth a look, anyway. -Gul [1] http://gulopine.gamemusic.org/2008/jan/10/simple-plugin-framework/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: wordpress hooks and actions system in django?
On Thu, Feb 21, 2008 at 9:13 AM, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > I was looking at that before, but... aren't django signals mostly for > one-sided communication? I.e. I signal something, someone else catches > it and does something. > > In wordpress it's very much 2-sided communication... 2 sided as in the hook gets the info back from the plugin? Djangos Dispatcher does this, the sender gets the results back from the receiver. I do not believe Django makes use of this anywhere (but have not checked to be sure) To write a plugin manager in your case you would have to write your own sender, so that each consecutive plugin listening to a particular signal, got the results from the previous plugin not the unmodified results Totally Untested example based on the webcast you linked to ( http://dpaste.com/36295/ ) The majority of your work would come in creating the signals, and what each signal should contain and where it should be sent from --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Converting relational data to hiechical data
http://www.djangoproject.com/documentation/templates/#unordered-list On Feb 21, 4:22 am, shabda <[EMAIL PROTECTED]> wrote: > I have a model like > > class Task(models.Model): > name = Models.CharField(max_length = 100) > parent = models.ForeignKey('Task', null = True) > > Using this model say I have got a table like, > > Task > --- > ID Name Parent_id > 1 Foo null > 2 Bar 1 > 3 Baz1 > 4 Bax2 > > I want to display this information hierchically in the template, > something like > > > Foo > >Bar > Bax >Baz > > > > Essentially I want to convert a relational data to monarchical data. > Does any body have snippets/recipe to do something similar? I am using > mySQL --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: self referential manytomany
validation meaning python manage.py validate and python manage.py syncdb. I really don't know what is messing up other than the fact that module has a circular load. I have no idea to fix this one. Thanks Evert for your help. Anyone else? On Feb 21, 12:44 pm, Evert Rol <[EMAIL PROTECTED]> wrote: > > That would be true if I defined both models in the same models.py, and > > Profile was trying to use Bookmark before it was loaded in the file. > > Because this is an import the quotes won't work. That being said this > > in one model works when I don't need to put a import statement in it. > > So: > > > profiles/models.py > > ### > > > class Profile(models.Model): > > ...bookmarks = models.ManyToManyField(Webpage, > > related_name='bookmarks') > > > from profiles.models import Profile > > ...author = models.ForeignKey(Profile) > > > ### > > This validates, but it's not as modular as I would like. Any other > > ideas? > > Sorry, my bad: I wasn't reading your previous mail properly. > > Actually, I do this myself, but I don't apply validation. > In fact, what kind of validation do you mean? Just trying to run the > development server (providing everything is synced to the database), > ie, 'Python' validation; or something along the lines of form > validation? If the latter, perhaps importing Profile into the views.py? > It must be similar to using contrib.auth.user and extending the user > profile with your own class. > Otherwise, I'm currently out of suggestions... > >Evert > > > > >>> I am a bit confused as to why it is that this gives me an error. I > >>> hope someone could explain it to me. > > >>> Let's say I have users with Profiles that can be connected to the > >>> one > >>> Web page that they can author. The other Users can bookmark that > >>> page. > >>> So my models look like this: > > >>> profiles.models.py > > >>> from bookmarks.models import Bookmark > > >>> class Profile(models.Model): > >>> ...bookmarks = models.ManyToManyField(Webpage) > > >>> > >>> bookmarks.models.py > > >>> from profiles.models import Profile > >>> ...author = models.ForeignKey(Profile) > > >> Michael, could this have to do with the note in this section: > >>http://www.djangoproject.com/documentation/model-api/#many-to-one- > >> relationships > >> "Note, however, that you can only use strings to refer to models in > >> the same models.py file -- you cannot use a string to reference a > >> model in a different application, or to reference a model that has > >> been imported from elsewhere." > >> So try to quote 'Profile', instead of importing it. > > >>> I get an import error when I try to validate this. I realize that > >>> there is a little of cross referencing occurring, but I really > >>> cannot > >>> think of a better way to accomplish this. Any ideas? > > >>> Thanks, Michael Newman --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Evaluating/stepping through sliced QuerySets
> There is a threaded comments app http://code.google.com/p/django- > threadedcomments/ > , Now that I think about it, they surely would be doing this > conversion from relational to hierarchical format. I will read the > code and let you know if I can find something useful. While I had been searching on djangosnippets.org, I had completely overlooked searching (properly) on Google; I completely missed this app. Thanks for the pointer! >>Hi folks, >> >> I'm somewhat new to Django, happily plodding along creating apps for >> a website, when I stumbled upon oddities when slicing QuerySets. I'm >> using 0.97pre (checked out from SVN about a month ago) on Mac OS X >> 10.4, Python 2.5. >> With the following very simply class: >> >> class Article(models.Model): >> text = models.CharField(max_length=100, default='lorem ipsum') >> def __unicode__(self): >> return self.text >> >> I can do the following: > from dtest.models import Article > for x in range(1, 5): >> ... a = Article(text='article no %d' % x) >> ... a.save() >> ... > articles = Article.objects.all() > for a in articles: >> ... print a >> ... >> article no 1 >> article no 2 >> article no 3 >> article no 4 >> >> That all works fine. Things get weird when I slice the QuerySet (I'm >> using the id-ing and type-ing to check on the object): > selection = Article.objects.all()[0:3] > print id(selection), type(selection) >> 20614928 > for a in selection: >> ... print a >> ... >> article no 1 >> article no 2 >> article no 3 >> > selection = Article.objects.all()[0:3] > print id(selection), type(selection) >> 20627632 > for i in range(4): >> ... print selection[i] >> ... >> article no 1 >> article no 2 >> article no 3 >> article no 4 >> >> ??? >> This is what I didn't expect: where's the IndexError (or >> ObjectNotFound)? >> >> But if I evaluate the selection before (using len(), to minimize >> output; print also works, for example), it does work as I expect: > selection = Article.objects.all()[0:3] > print id(selection), type(selection) >> 20615056 > len(selection) >> 3 > print id(selection), type(selection) >> 20615056 > for i in range(4): >> ... print selection[i] >> ... >> article no 1 >> article no 2 >> article no 3 >> Traceback (most recent call last): >>File "", line 2, in >>File "/sw/lib/python2.5/site-packages/django/db/models/query.py", >> line 161, in __getitem__ >> return self._result_cache[k] >> IndexError: list index out of range >> >> It obviously has to do with how and when QuerySets are evaluated; it >> looks like that before evaluation, the slice hasn't 'worked' yet. The >> id() and type() statements suggest it's still completely the same >> object though, before and after; nothing has apparently changed. >> (In fact, this is the reason I'm not recycling the first articles or >> selection QuerySet, but instead do an objects.all() each time; it >> gets evaluated in the first for-loop, and when recycled, things work >> as I expect). >> I found a few threads on the mailing list on this, bit I'm not sure >> if they explain this behaviour to me (threads referenced below). >> Could someone point me in the right direction/documentation on this, >> or just change how my mind works (nothing too drastically, please). >> Do I really need to evaluate the selection beforehand? >> Obviously, the example above is simplistic and should be done >> differently, but I do have a situation where I'd like to be able to >> index a sliced QueyrSet step by step, instead of iterating through >> it. Or, what possibly could also solve my problem: can I iterate >> through a (sliced) QuerySet step by step, by eg calling something >> like a next() method each time I needed the next element? (I've >> tried, but there's no next() method on QuerySets apparently). >> >> Thanks a lot, >> >>Evert >> >> http://groups.google.com/group/django-users/browse_thread/thread/ >> aef03c62f655fe45/a6ce6074ceab7438?lnk=gst=queryset >> +slicing#a6ce6074ceab7438http://groups.google.com/group/django- >> users/browse_thread/thread/ >> 3b98ffd38969c49a/a56354e0c0e61a9a?lnk=gst=queryset >> +slicing#a56354e0c0e61a9a > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: self referential manytomany
> That would be true if I defined both models in the same models.py, and > Profile was trying to use Bookmark before it was loaded in the file. > Because this is an import the quotes won't work. That being said this > in one model works when I don't need to put a import statement in it. > So: > > profiles/models.py > ### > > class Profile(models.Model): > ...bookmarks = models.ManyToManyField(Webpage, > related_name='bookmarks') > > from profiles.models import Profile > ...author = models.ForeignKey(Profile) > > > ### > This validates, but it's not as modular as I would like. Any other > ideas? Sorry, my bad: I wasn't reading your previous mail properly. Actually, I do this myself, but I don't apply validation. In fact, what kind of validation do you mean? Just trying to run the development server (providing everything is synced to the database), ie, 'Python' validation; or something along the lines of form validation? If the latter, perhaps importing Profile into the views.py? It must be similar to using contrib.auth.user and extending the user profile with your own class. Otherwise, I'm currently out of suggestions... Evert >> >>> I am a bit confused as to why it is that this gives me an error. I >>> hope someone could explain it to me. >> >>> Let's say I have users with Profiles that can be connected to the >>> one >>> Web page that they can author. The other Users can bookmark that >>> page. >>> So my models look like this: >> >>> profiles.models.py >> >>> from bookmarks.models import Bookmark >> >>> class Profile(models.Model): >>> ...bookmarks = models.ManyToManyField(Webpage) >> >>> >>> bookmarks.models.py >> >>> from profiles.models import Profile >>> ...author = models.ForeignKey(Profile) >> >> Michael, could this have to do with the note in this section: >> http://www.djangoproject.com/documentation/model-api/#many-to-one- >> relationships >> "Note, however, that you can only use strings to refer to models in >> the same models.py file -- you cannot use a string to reference a >> model in a different application, or to reference a model that has >> been imported from elsewhere." >> So try to quote 'Profile', instead of importing it. >> >> >> >>> I get an import error when I try to validate this. I realize that >>> there is a little of cross referencing occurring, but I really >>> cannot >>> think of a better way to accomplish this. Any ideas? >> >>> Thanks, Michael Newman > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Evaluating/stepping through sliced QuerySets
There is a threaded comments app http://code.google.com/p/django-threadedcomments/ , Now that I think about it, they surely would be doing this conversion from relational to hierarchical format. I will read the code and let you know if I can find something useful. On Feb 20, 7:10 pm, Evert Rol <[EMAIL PROTECTED]> wrote: >Hi folks, > > I'm somewhat new to Django, happily plodding along creating apps for > a website, when I stumbled upon oddities when slicing QuerySets. I'm > using 0.97pre (checked out from SVN about a month ago) on Mac OS X > 10.4, Python 2.5. > With the following very simply class: > > class Article(models.Model): > text = models.CharField(max_length=100, default='lorem ipsum') > def __unicode__(self): > return self.text > > I can do the following: > >>> from dtest.models import Article > >>> for x in range(1, 5): > ... a = Article(text='article no %d' % x) > ... a.save() > ... > >>> articles = Article.objects.all() > >>> for a in articles: > ... print a > ... > article no 1 > article no 2 > article no 3 > article no 4 > > That all works fine. Things get weird when I slice the QuerySet (I'm > using the id-ing and type-ing to check on the object): > >>> selection = Article.objects.all()[0:3] > >>> print id(selection), type(selection) > 20614928 > >>> for a in selection: > ... print a > ... > article no 1 > article no 2 > article no 3 > > >>> selection = Article.objects.all()[0:3] > >>> print id(selection), type(selection) > 20627632 > >>> for i in range(4): > ... print selection[i] > ... > article no 1 > article no 2 > article no 3 > article no 4 > > ??? > This is what I didn't expect: where's the IndexError (or > ObjectNotFound)? > > But if I evaluate the selection before (using len(), to minimize > output; print also works, for example), it does work as I expect: > >>> selection = Article.objects.all()[0:3] > >>> print id(selection), type(selection) > 20615056 > >>> len(selection) > 3 > >>> print id(selection), type(selection) > 20615056 > >>> for i in range(4): > ... print selection[i] > ... > article no 1 > article no 2 > article no 3 > Traceback (most recent call last): >File "", line 2, in >File "/sw/lib/python2.5/site-packages/django/db/models/query.py", > line 161, in __getitem__ > return self._result_cache[k] > IndexError: list index out of range > > It obviously has to do with how and when QuerySets are evaluated; it > looks like that before evaluation, the slice hasn't 'worked' yet. The > id() and type() statements suggest it's still completely the same > object though, before and after; nothing has apparently changed. > (In fact, this is the reason I'm not recycling the first articles or > selection QuerySet, but instead do an objects.all() each time; it > gets evaluated in the first for-loop, and when recycled, things work > as I expect). > I found a few threads on the mailing list on this, bit I'm not sure > if they explain this behaviour to me (threads referenced below). > Could someone point me in the right direction/documentation on this, > or just change how my mind works (nothing too drastically, please). > Do I really need to evaluate the selection beforehand? > Obviously, the example above is simplistic and should be done > differently, but I do have a situation where I'd like to be able to > index a sliced QueyrSet step by step, instead of iterating through > it. Or, what possibly could also solve my problem: can I iterate > through a (sliced) QuerySet step by step, by eg calling something > like a next() method each time I needed the next element? (I've > tried, but there's no next() method on QuerySets apparently). > > Thanks a lot, > >Evert > > http://groups.google.com/group/django-users/browse_thread/thread/ > aef03c62f655fe45/a6ce6074ceab7438?lnk=gst=queryset > +slicing#a6ce6074ceab7438http://groups.google.com/group/django-users/browse_thread/thread/ > 3b98ffd38969c49a/a56354e0c0e61a9a?lnk=gst=queryset > +slicing#a56354e0c0e61a9a --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: self referential manytomany
That would be true if I defined both models in the same models.py, and Profile was trying to use Bookmark before it was loaded in the file. Because this is an import the quotes won't work. That being said this in one model works when I don't need to put a import statement in it. So: profiles/models.py ### class Profile(models.Model): ...bookmarks = models.ManyToManyField(Webpage, related_name='bookmarks') from profiles.models import Profile ...author = models.ForeignKey(Profile) ### This validates, but it's not as modular as I would like. Any other ideas? Thanks for tip anyway. On Feb 21, 11:58 am, Evert Rol <[EMAIL PROTECTED]> wrote: > On 21 Feb 2008, at 16:44 , Michael Newman wrote: > > > > > > > I am a bit confused as to why it is that this gives me an error. I > > hope someone could explain it to me. > > > Let's say I have users with Profiles that can be connected to the one > > Web page that they can author. The other Users can bookmark that page. > > So my models look like this: > > > profiles.models.py > > > from bookmarks.models import Bookmark > > > class Profile(models.Model): > > ...bookmarks = models.ManyToManyField(Webpage) > > > > > bookmarks.models.py > > > from profiles.models import Profile > > ...author = models.ForeignKey(Profile) > > Michael, could this have to do with the note in this section: > http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships > "Note, however, that you can only use strings to refer to models in > the same models.py file -- you cannot use a string to reference a > model in a different application, or to reference a model that has > been imported from elsewhere." > So try to quote 'Profile', instead of importing it. > > > > > I get an import error when I try to validate this. I realize that > > there is a little of cross referencing occurring, but I really cannot > > think of a better way to accomplish this. Any ideas? > > > Thanks, Michael Newman --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: wordpress hooks and actions system in django?
Dj Gilcrease wrote: > On Thu, Feb 21, 2008 at 6:23 AM, Bram - Smartelectronix > <[EMAIL PROTECTED]> wrote: >> Basically plugins can register with the host app and say "I want to be >> plugged in here or there" (the hook). The host app in various places has >> calls which "apply" whatever is hooked into that location. >> >> >> If anyone has any ideas or pointers as to how this could be done, please >> let me know. > > This sounds like a good application for the Dispatcher in Django ( > http://code.djangoproject.com/wiki/Signals ) > You write your own signals, that the plugins will listen for, they > manipulate the data they need and the dispatcher returns all the > responses. I was looking at that before, but... aren't django signals mostly for one-sided communication? I.e. I signal something, someone else catches it and does something. In wordpress it's very much 2-sided communication... - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Converting relational data to hiechical data
> I have a model like > > class Task(models.Model): > name = Models.CharField(max_length = 100) > parent = models.ForeignKey('Task', null = True) > > Using this model say I have got a table like, > > Task > --- > ID Name Parent_id > 1 Foo null > 2 Bar 1 > 3 Baz1 > 4 Bax2 > > I want to display this information hierchically in the template, > something like > > > Foo > >Bar > Bax >Baz > > > > Essentially I want to convert a relational data to monarchical data. > Does any body have snippets/recipe to do something similar? I am using > mySQL Shabda, does the piece of code below help? Your problem is very similar to what I just have tried to do. In my case, for a threaded forum display. I've created a class ThreadList, which creates ThreadListItems one by one. You then create a ThreadList object on a QuerySet, and step through it in your template. Let me know if it's useful, and suggestions for improvements if you use it (one thing I'm thinking of, is allowing the user to specify the "" and "" tags; could be s, for example). And I could certainly use a better solution for iterating through the query_set (this is where my last question came from: http:// groups.google.com/group/django-users/browse_thread/thread/ 15c236dedb08b4c4/cf6464805af429ff?hl=en#cf6464805af429ff Evert Class definitions all the way at the bottom. Somewhere in your views.py: responseDict['thread'] = ThreadList(Task.objects.all()) # filter as you like; you can use Paginator objects as well, as long as the result a QuerySet (actually, a list might also work) Somewhere in your template: {% if thread %} {% for t in thread %} {{ t.step }} {{ t.name }} {% endfor %} {{ thread.final }} {% endif %} The if-clause isn't really necessary, just to prevent an empty . The t.step method steps you 'inwards' or 'outwards', depending on the level. The thread.final is necessary to trace backwards enough, so that you close all levels The class definitions: class ThreadListItem(object): def __init__(self, item, depth): self._item = item self.depth = depth def step(self): if self.depth > 0: return mark_safe(u'' * self.depth) else: return mark_safe(u'' * abs(self.depth)) def item(self): return self._item def __unicode__(self): return self.thread_in() + unicode(self.item()) + self.thread_out() class ThreadList(object): def __init__(self, query_set, depth='depth', parent='parent'): # Note: I'm using len() instead of .count(), so the query_set # gets evaluated. Without evaluation, the query_set indexing # in next() goes awry # 'quick note added in proof/email': the 'depth' key could be used if your model has a # specific thread-depth parameter. Otherwise, preferably set to None. self.query_set = query_set self.max = len(self.query_set) self.depth = depth self.parent = parent self.reset() def __iter__(self): return self def next(self): self.i += 1 if self.i >= self.max: raise StopIteration else: item = self.query_set[self.i] if self.depth and hasattr(item, self.depth): depth = int(item.__getattribute__(self.depth)) elif self.parent and hasattr(item, self.parent): depth = 0 p = item.__getattribute__(self.parent) while p: depth += 1 p = p.__getattribute__(self.parent) d = depth - self.current_level self.current_level = depth return ThreadListItem(item, d) def final(self): return mark_safe(u'' * self.current_level) def reset(self): self.i = -1 self.current_level = 0 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: self referential manytomany
On 21 Feb 2008, at 16:44 , Michael Newman wrote: > > I am a bit confused as to why it is that this gives me an error. I > hope someone could explain it to me. > > Let's say I have users with Profiles that can be connected to the one > Web page that they can author. The other Users can bookmark that page. > So my models look like this: > > profiles.models.py > > from bookmarks.models import Bookmark > > class Profile(models.Model): > ...bookmarks = models.ManyToManyField(Webpage) > > > bookmarks.models.py > > from profiles.models import Profile > ...author = models.ForeignKey(Profile) Michael, could this have to do with the note in this section: http:// www.djangoproject.com/documentation/model-api/#many-to-one-relationships "Note, however, that you can only use strings to refer to models in the same models.py file — you cannot use a string to reference a model in a different application, or to reference a model that has been imported from elsewhere." So try to quote 'Profile', instead of importing it. > > > > I get an import error when I try to validate this. I realize that > there is a little of cross referencing occurring, but I really cannot > think of a better way to accomplish this. Any ideas? > > Thanks, Michael Newman > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to stop validations duplications in forms and models?
I have some models, and some forms to write data to them. The attributes in models need to have soem validations, (For example, name must be alpha numeric, price must be less that 1000 etc). SO I write the validations in model.save() and raise Exceptions, when a validation fails. I also need to write the same validations in newforms as I do not want the form post to happen unless the validation passes. This means that I have the same validation at two places. (I can't raise ValidationException from models). Is there a way to remove this duplication? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
self referential manytomany
I am a bit confused as to why it is that this gives me an error. I hope someone could explain it to me. Let's say I have users with Profiles that can be connected to the one Web page that they can author. The other Users can bookmark that page. So my models look like this: profiles.models.py from bookmarks.models import Bookmark class Profile(models.Model): ...bookmarks = models.ManyToManyField(Webpage) bookmarks.models.py from profiles.models import Profile ...author = models.ForeignKey(Profile) I get an import error when I try to validate this. I realize that there is a little of cross referencing occurring, but I really cannot think of a better way to accomplish this. Any ideas? Thanks, Michael Newman --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Issues with IE7 and {% for %} {% endfor %} tag
It was a cookie issue. I had looked over this... but missed it on first glance. My apologies MerMer On Feb 21, 4:17 pm, merric <[EMAIL PROTECTED]> wrote: > I've commented out all the HTML on the template, so my template now > reads as follows > > {% for i in prizes %} {{i.id }} {% endfor %} > > There is nothing else on the page except the commented out HTML. > > In firefox this displays without any problem, in IE7 I get a blank > page, even when looking at the source HTML. > > When I make any other changes to the template, IE7 picks it up, > straight away. It is only the {% for %} tag that seems to be coming > up blank. > I'm completely baffled. > > On Feb 21, 3:37 pm, kevinski <[EMAIL PROTECTED]> wrote: > > > > This iterates fine in Firefox, but in IE7 it keeps coming up blank. > > > I can't see any html issues. I am working off my localhost. Is this > > > a IE7 security issue or something else I have not thought of? > > > I had a the similar problem once with IE7. It ended up being due to > > CSS incompatibility that caused the text to be hidden in IE. Try > > loading the page without any markup, if you see the text you will know > > this is the problem. > > > Kin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Issues with IE7 and {% for %} {% endfor %} tag
I've commented out all the HTML on the template, so my template now reads as follows {% for i in prizes %} {{i.id }} {% endfor %} There is nothing else on the page except the commented out HTML. In firefox this displays without any problem, in IE7 I get a blank page, even when looking at the source HTML. When I make any other changes to the template, IE7 picks it up, straight away. It is only the {% for %} tag that seems to be coming up blank. I'm completely baffled. On Feb 21, 3:37 pm, kevinski <[EMAIL PROTECTED]> wrote: > > This iterates fine in Firefox, but in IE7 it keeps coming up blank. > > I can't see any html issues. I am working off my localhost. Is this > > a IE7 security issue or something else I have not thought of? > > I had a the similar problem once with IE7. It ended up being due to > CSS incompatibility that caused the text to be hidden in IE. Try > loading the page without any markup, if you see the text you will know > this is the problem. > > Kin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: managers vs static/class methods ?
On Thu, Feb 21, 2008 at 9:35 AM, glopglop <[EMAIL PROTECTED]> wrote: > Not trying to be slow-witted, but couldn't you do > > objects = MyModel.unfiltered() if request.user.is_admin else > MyModel.filtered() > (where objects is a queryset) > > is there a functionnal difference or is it more of a style (which can > have its importance) ? This only works in Python 2.5. The other works in every version of Python Django supports. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Issues with IE7 and {% for %} {% endfor %} tag
On Thu, Feb 21, 2008 at 8:26 AM, merric <[EMAIL PROTECTED]> wrote: > > I have a template that uses {% for i in prize %} {{ i.description }} > {% endfor %} > > This iterates fine in Firefox, but in IE7 it keeps coming up blank. > I can't see any html issues. I am working off my localhost. Is this > a IE7 security issue or something else I have not thought of? > > Cheers > > MerMer Have you run the resulting HTML through the W3C Validator? In particular, look for any unclosed style or script tags. Jonathan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Issues with IE7 and {% for %} {% endfor %} tag
> This iterates fine in Firefox, but in IE7 it keeps coming up blank. > I can't see any html issues. I am working off my localhost. Is this > a IE7 security issue or something else I have not thought of? I had a the similar problem once with IE7. It ended up being due to CSS incompatibility that caused the text to be hidden in IE. Try loading the page without any markup, if you see the text you will know this is the problem. Kevin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: managers vs static/class methods ?
On 20 fév, 17:07, Michael Elsdörfer <[EMAIL PROTECTED]> wrote: > > I understand you could also reuse it from model to model, but in my > > code I have rarely found reusing those methods between different > > models, except some ways that would generally be better solved with > > model inheritance. > > Managers as a concept are very useful. For example, they can also > inherit from one another, which I use in a couple instances. A base > class might provide the initial queryset, which is further modified by > descendant managers: One returning only rows that are intended for the > general public, while another might allow access to everything, > including e.g. unapproved records. Couldn't that be done using chaining staticmethods, such as @classmethod def even_positive_low(cls) : return cls.positive().filter(bar__lt=25) > > With static methods, you also couldn't do things like: > > if request.user.is_admin: > manager = MyModel.objects > else: > manager = MyModel.public_objects > > # work with ``manager`` Not trying to be slow-witted, but couldn't you do objects = MyModel.unfiltered() if request.user.is_admin else MyModel.filtered() (where objects is a queryset) is there a functionnal difference or is it more of a style (which can have its importance) ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple ForeignKey Relationship
Hi Michael, Thanks a lot. That query made me realize I've got to re-think this. http://groups.google.com/group/django-users/browse_thread/thread/477915b60c5d160e/ff677bbbf87ea9b3?lnk=gst=django+edit+inline#ff677bbbf87ea9b3 On Feb 21, 8:21 am, Michael Newman <[EMAIL PROTECTED]> wrote: > http://www.djangoproject.com/documentation/model-api/#many-to-one-rel... > > look at the edit inline option. The blogosphere is also nice enough to > have posted hundreds of examples and test cases that might meet your > purposes. Google django edit inline for these examples. > > On Feb 21, 9:56 am, [EMAIL PROTECTED] wrote: > > > I'm trying to work out how I'm going to setup a model structure a > > video section of my website. Say I have this scenario. > > > - Each video belongs to a set of 4-5 videos. > > - Depending on the set the video belongs too, certain information will > > need to be attached to that video (ie> recipe/chef information, wines > > to drink with this recipe. Etc.) > > - Videos need to be able to be independent as well, in case the set is > > removed but the video is still wanted on the site. Same goes for > > Recipes as they will exist independently on the site. > > - In the future Videos will reside within different sets and require > > different information then these. > > > So, my situation is this: > > > I have a Video model setup as a ForeignKey to my VideoSet model. I > > then have Recipe and Chef information each setup as a ForeignKey to > > Video. This is great for adding Recipe and Chef info to a video > > directly through the admin, however the Recipe and Chef information do > > not get attached to the Video within the VideoSet admin interface. > > > Is there a way to nest ForeignKey relationships? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: managers vs static/class methods ?
Fine, it's clearer for me now (with the added smart examples). "The distinguishing factor between manager methods and class or static methods should be the database. Managers handle table-wide operations ; Python- level operations don't know anything about a database at all." Maybe a sentence like that should be added in the documentation (as a note or something) explaining managers, to make that thing more explicit (because it's an important concept to be shared and I'm sure I am not the only one to wonder if it's worth it). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple ForeignKey Relationship
http://www.djangoproject.com/documentation/model-api/#many-to-one-relationships look at the edit inline option. The blogosphere is also nice enough to have posted hundreds of examples and test cases that might meet your purposes. Google django edit inline for these examples. On Feb 21, 9:56 am, [EMAIL PROTECTED] wrote: > I'm trying to work out how I'm going to setup a model structure a > video section of my website. Say I have this scenario. > > - Each video belongs to a set of 4-5 videos. > - Depending on the set the video belongs too, certain information will > need to be attached to that video (ie> recipe/chef information, wines > to drink with this recipe. Etc.) > - Videos need to be able to be independent as well, in case the set is > removed but the video is still wanted on the site. Same goes for > Recipes as they will exist independently on the site. > - In the future Videos will reside within different sets and require > different information then these. > > So, my situation is this: > > I have a Video model setup as a ForeignKey to my VideoSet model. I > then have Recipe and Chef information each setup as a ForeignKey to > Video. This is great for adding Recipe and Chef info to a video > directly through the admin, however the Recipe and Chef information do > not get attached to the Video within the VideoSet admin interface. > > Is there a way to nest ForeignKey relationships? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Issues with IE7 and {% for %} {% endfor %} tag
If that isn't the issue make sure to look at the source HTML. If it is rendering the code then there is something wrong with your styles that IE is hiding your content (Most likely a position:relative float thing). Or you might want to kick apache, sometimes it loads old settings. Last thing that I think it could be is a cache issue. If you are loading the file into the html IE holds onto non-timestamped files longer. Clear it and see if that fixes it. On Feb 21, 9:52 am, David Marquis <[EMAIL PROTECTED]> wrote: > Malcom is right, this has absolutely nothing to do with the {% for %} > tag. > > My guess is that your IE7 might be more restrictive on cookies and not > allowing the server to create a session cookie. > If your view code assumes that there is a session and you fetch > "prize" from the session, then "prize" might simply be empty in IE. > > -- > David > > On 21-Feb-08, at 8:26 AM, merric wrote: > > > > > I have a template that uses {% for i in prize %} {{ i.description }} > > {% endfor %} > > > This iterates fine in Firefox, but in IE7 it keeps coming up blank. > > I can't see any html issues. I am working off my localhost. Is this > > a IE7 security issue or something else I have not thought of? > > > Cheers > > > MerMer > > > > > > smime.p7s > 5KDownload --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Informix
Mateusz, Even though we corresponded on IRC, I'd like to respond for the benefit of the community. First, there is no dedicated GeoDjango list (yet) -- but we do have a dedicated channel on freenode (#geodjango). There are no Django database backends for Informix and DB2. GeoDjango requires support in Django first before a spatial backend may be written. The situation is much better than before, as IBM has taken the initiative and written a Python DB-API adaptor (`ibm-db`) for DB2 and Informix -- prior to this, the community depended on the ill- maintained PyDB2 adaptor. I tried to install Informix to gauge the difficulty of writing both the database backend and spatial backend. I was completely stymied by installation and IBM's incorrectly maintained packages (the Solaris x86 package contained SPARC binaries!). Unfortunately, I do not have the time to navigate the complex installation process and write/ maintain all database backend code for this platform. Unless I'm provided with an economic incentive (e.g., someone hires me to write this), I'm going to leave it for another day, or to the community to provide a patch for support. Best Regards, -Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multiple ForeignKey Relationship
I'm trying to work out how I'm going to setup a model structure a video section of my website. Say I have this scenario. - Each video belongs to a set of 4-5 videos. - Depending on the set the video belongs too, certain information will need to be attached to that video (ie> recipe/chef information, wines to drink with this recipe. Etc.) - Videos need to be able to be independent as well, in case the set is removed but the video is still wanted on the site. Same goes for Recipes as they will exist independently on the site. - In the future Videos will reside within different sets and require different information then these. So, my situation is this: I have a Video model setup as a ForeignKey to my VideoSet model. I then have Recipe and Chef information each setup as a ForeignKey to Video. This is great for adding Recipe and Chef info to a video directly through the admin, however the Recipe and Chef information do not get attached to the Video within the VideoSet admin interface. Is there a way to nest ForeignKey relationships? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Issues with IE7 and {% for %} {% endfor %} tag
Malcom is right, this has absolutely nothing to do with the {% for %} tag. My guess is that your IE7 might be more restrictive on cookies and not allowing the server to create a session cookie. If your view code assumes that there is a session and you fetch "prize" from the session, then "prize" might simply be empty in IE. -- David On 21-Feb-08, at 8:26 AM, merric wrote: I have a template that uses {% for i in prize %} {{ i.description }} {% endfor %} This iterates fine in Firefox, but in IE7 it keeps coming up blank. I can't see any html issues. I am working off my localhost. Is this a IE7 security issue or something else I have not thought of? Cheers MerMer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~--- smime.p7s Description: S/MIME cryptographic signature
Re: wordpress hooks and actions system in django?
On Thu, Feb 21, 2008 at 6:23 AM, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > Basically plugins can register with the host app and say "I want to be > plugged in here or there" (the hook). The host app in various places has > calls which "apply" whatever is hooked into that location. > > > If anyone has any ideas or pointers as to how this could be done, please > let me know. This sounds like a good application for the Dispatcher in Django ( http://code.djangoproject.com/wiki/Signals ) You write your own signals, that the plugins will listen for, they manipulate the data they need and the dispatcher returns all the responses. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
wordpress hooks and actions system in django?
hey guys, I've been asked to write a wordpress-like system in django, with hooks and action-hooks for plugin-creation alla wordpress. Now the question is - how would you guys handle this? I was thinking that hooks could be represented by template tags which pass the context to whatever plugin is called, but other than that it's a bit... misty. For those who don't know how this exactly works in wordpress there's a (very) basic introduction screencast here: http://txfx.net/files/wp-movies/001-your-first-wp-plugin.mov Basically plugins can register with the host app and say "I want to be plugged in here or there" (the hook). The host app in various places has calls which "apply" whatever is hooked into that location. If anyone has any ideas or pointers as to how this could be done, please let me know. - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: [newforms-admin] inline editing?
On Thu, Feb 21, 2008 at 3:55 AM, Almir Karic <[EMAIL PROTECTED]> wrote: > > from django.db import models > from django.contrib import admin > > > # Create your models here. > > class Category(models.Model): >name = models.CharField(max_length=50) > >def __str__(self): >return self.name > > class Forum(models.Model): >cat = models.ForeignKey(Category) >name = models.CharField(max_length=50) > >def __str__(self): >return self.name > > class Category_admin(admin.ModelAdmin): >model = Category >inlines = [Forum] > > You don't list your Model classes directly in inlines, but rather create a class based off of admin.StackedInline or admin.TabularInline (which is where you specify the actual Model), and list that class in inlines. See: http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowdoIsetupedit_inlineand the last part of: http://code.djangoproject.com/wiki/NewformsAdminBranch for examples. Karen > admin.site.register(Category, Category_admin) > > this is my models.py, when i try to access the admin interface for my > Category object i get an ugly error google knows nothing about :( > > Environment: > > Request Method: GET > Request URL: http://chat.kiberpipa.org:5222/admin/forum/category/2/ > Django Version: 0.97-newforms-admin-SVN-7135 > Python Version: 2.4.4 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'django.contrib.admin', > 'mysite.forum', > 'mysite.todo', > 'django_evolution'] > Installed Middleware: > ('django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.middleware.doc.XViewMiddleware') > > > Traceback: > File "/home/redduck666/django/newforms-admin/django/core/handlers/base.py" > in get_response > 82. response = callback(request, *callback_args, > **callback_kwargs) > File > "/home/redduck666/django/newforms-admin/django/contrib/admin/sites.py" > in root > 137. return self.model_page(request, *url.split('/', 2)) > File > "/home/redduck666/django/newforms-admin/django/contrib/admin/sites.py" > in model_page > 154. return admin_obj(request, rest_of_url) > File > "/home/redduck666/django/newforms-admin/django/contrib/admin/options.py" > in __call__ > 258. return self.change_view(request, unquote(url)) > File > "/home/redduck666/django/newforms-admin/django/contrib/admin/options.py" > in change_view > 568. for FormSet in self.formsets_change(request, obj): > File > "/home/redduck666/django/newforms-admin/django/contrib/admin/options.py" > in formsets_change > 715. yield inline.formset_change(request, obj) > > Exception Type: AttributeError at /admin/forum/category/2/ > Exception Value: 'Forum' object has no attribute 'formset_change' > > > any hints? > > -- > error: one bad user found in front of screen > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
A coffe break
Do you like milk coffe ? http://www.mediaportal.ro/play.php?pid=6560%20cu%20lapte!%20natural(a) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using HttpResponse as a file - 'HttpResponse' object has no attribute 'seek' error
Thanks Ned, I had misunderstood the concept of "file-like" and you've explained it admirably, exactly what I needed to know. Though Malcolm's tip regarding the unsuitability of HttpResponse as a flotation device will be a life-saver for many, I'm sure. This is what works for me: import cStringIO, zipfile response = HttpResponse(mimetype='application/zip') response['Content-Disposition'] = 'attachment; filename=zipfile.zip' fobj = cStringIO.StringIO() f = zipfile.ZipFile(fobj, "w") f.write(filename) f.close() zip = fobj.getvalue() fobj.close() response.write(zip) return response On Feb 21, 12:34 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote: > In Python, there is a loose concept of a "file-like" object. This means > that the object behaves like a file under duck-typing, meaning it has > the right methods to be treated just as if it were a file. But the > concept is only loosely defined, and different file-like objects > implement different numbers of methods, according to their abilities. > HttpResponse does not implement seek(), and many consumers of file-like > objects don't ever call seek(), so HttpResponses can be used as files in > many cases. ZipFile seems to be one case where it cannot, because > ZipFile calls seek(). > > Both the HttpRequest docs > (http://www.djangoproject.com/documentation/request_response/) and the > Python file docs (http://docs.python.org/lib/bltin-file-objects.html) > mention "file-like" obliquely, with reference to methods that are or are > not, or may or may not, be implemented. > > As Malcolm points out, seek() would require buffering, which you can > provide by using an intermediary like StringIO. > > --Ned.http://nedbatchelder.com/blog > > > > Malcolm Tredinnick wrote: > > On Thu, 2008-02-21 at 03:41 -0800, kip wrote: > > >> I thought I would be able to use an HttpResponse object as the file > >> argument for ZipFile, like this: > > >> response = HttpResponse(mimetype='application/zip') > >> response['Content-Disposition'] = 'attachment; filename=zipfile.zip' > >> file = zipfile.ZipFile(response, "w") > > >> but as soon as I try to write to it I get the error "'HttpResponse' > >> object has no attribute 'seek'". > > >> Am I missing something here? > > > No, you have all the information that's required to diagnose what you're > > doing wrong. ZipFile apparently expects something with a seek() method > > and HttpResponse doesn't have one (since it outputs content in a linear > > fashion). You also cannot use HttpResponse as a lawn mower or an a > > floatation device as it's similarly not appropriate. > > > An HttpResponse is something that is designed to produce a string. That > > string is sent back to the user. Since ZipFile wants something that acts > > as a file, you need to turn the HttpResponse into something like that. > > Try using StringIO. > > > Regards, > > Malcolm > > -- > Ned Batchelder,http://nedbatchelder.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Issues with IE7 and {% for %} {% endfor %} tag
On Thu, 2008-02-21 at 05:26 -0800, merric wrote: > I have a template that uses {% for i in prize %} {{ i.description }} > {% endfor %} > > This iterates fine in Firefox, but in IE7 it keeps coming up blank. > I can't see any html issues. I am working off my localhost. Is this > a IE7 security issue or something else I have not thought of? It's got nothing to do with the browser. The browser will never see the Django templating code, since the Template.render() function turns it into a string long before it is sent to the browser. Are you saying that different HTML is delivered to the browser when it is IE 7? Malcolm -- I've got a mind like a... a... what's that thing called? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Issues with IE7 and {% for %} {% endfor %} tag
I have a template that uses {% for i in prize %} {{ i.description }} {% endfor %} This iterates fine in Firefox, but in IE7 it keeps coming up blank. I can't see any html issues. I am working off my localhost. Is this a IE7 security issue or something else I have not thought of? Cheers MerMer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Sqlite permissions problem - Help :(
:O Well that was stupid of me... I think I assumed it worked since the testing server worked. :P Thanks! All fixed --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using HttpResponse as a file - 'HttpResponse' object has no attribute 'seek' error
In Python, there is a loose concept of a "file-like" object. This means that the object behaves like a file under duck-typing, meaning it has the right methods to be treated just as if it were a file. But the concept is only loosely defined, and different file-like objects implement different numbers of methods, according to their abilities. HttpResponse does not implement seek(), and many consumers of file-like objects don't ever call seek(), so HttpResponses can be used as files in many cases. ZipFile seems to be one case where it cannot, because ZipFile calls seek(). Both the HttpRequest docs (http://www.djangoproject.com/documentation/request_response/) and the Python file docs (http://docs.python.org/lib/bltin-file-objects.html) mention "file-like" obliquely, with reference to methods that are or are not, or may or may not, be implemented. As Malcolm points out, seek() would require buffering, which you can provide by using an intermediary like StringIO. --Ned. http://nedbatchelder.com/blog Malcolm Tredinnick wrote: > On Thu, 2008-02-21 at 03:41 -0800, kip wrote: > >> I thought I would be able to use an HttpResponse object as the file >> argument for ZipFile, like this: >> >> response = HttpResponse(mimetype='application/zip') >> response['Content-Disposition'] = 'attachment; filename=zipfile.zip' >> file = zipfile.ZipFile(response, "w") >> >> but as soon as I try to write to it I get the error "'HttpResponse' >> object has no attribute 'seek'". >> >> Am I missing something here? >> > > No, you have all the information that's required to diagnose what you're > doing wrong. ZipFile apparently expects something with a seek() method > and HttpResponse doesn't have one (since it outputs content in a linear > fashion). You also cannot use HttpResponse as a lawn mower or an a > floatation device as it's similarly not appropriate. > > An HttpResponse is something that is designed to produce a string. That > string is sent back to the user. Since ZipFile wants something that acts > as a file, you need to turn the HttpResponse into something like that. > Try using StringIO. > > Regards, > Malcolm > > -- Ned Batchelder, http://nedbatchelder.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Converting relational data to hiechical data
I have a model like class Task(models.Model): name = Models.CharField(max_length = 100) parent = models.ForeignKey('Task', null = True) Using this model say I have got a table like, Task --- ID Name Parent_id 1 Foo null 2 Bar 1 3 Baz1 4 Bax2 I want to display this information hierchically in the template, something like Foo Bar Bax Baz Essentially I want to convert a relational data to monarchical data. Does any body have snippets/recipe to do something similar? I am using mySQL --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: cycle tag doesn't cycle?
I didn't understand the docs. Apologies to those who do. On Feb 19, 11:23 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-02-19 at 14:35 -0800, itpaul wrote: > > [...] > > > this also means that the documentation > > (http://www.djangoproject.com/documentation/templates/#cycle > > ) is either misleading or plain wrong. it reads: > > The documentation says it will cycle through strings and/or variables > and gives an example involving both. > > Thanks, > Malcolm > > -- > Atheism is a non-prophet organization.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using HttpResponse as a file - 'HttpResponse' object has no attribute 'seek' error
On Thu, 2008-02-21 at 03:41 -0800, kip wrote: > I thought I would be able to use an HttpResponse object as the file > argument for ZipFile, like this: > > response = HttpResponse(mimetype='application/zip') > response['Content-Disposition'] = 'attachment; filename=zipfile.zip' > file = zipfile.ZipFile(response, "w") > > but as soon as I try to write to it I get the error "'HttpResponse' > object has no attribute 'seek'". > > Am I missing something here? No, you have all the information that's required to diagnose what you're doing wrong. ZipFile apparently expects something with a seek() method and HttpResponse doesn't have one (since it outputs content in a linear fashion). You also cannot use HttpResponse as a lawn mower or an a floatation device as it's similarly not appropriate. An HttpResponse is something that is designed to produce a string. That string is sent back to the user. Since ZipFile wants something that acts as a file, you need to turn the HttpResponse into something like that. Try using StringIO. Regards, Malcolm -- I just got lost in thought. It was unfamiliar territory. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Sendmail
Thanks Brian On Feb 20, 9:03 pm, Brian Morton <[EMAIL PROTECTED]> wrote: > By default, Django assumes that the SMTP server is running locally. > If you don't have one running locally, you need to set EMAIL_HOST and > EMAIL_PORT in your settings.py file to a valid SMTP server. > > On Feb 20, 12:20 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Hi everyone: > > I am currently testing my Sendmail code on a local machine (on > > localhost), which is similar to djangobook chapter 14: other > > contributed sub-frameworks, the codes are below: > > > python manage shell > > > from django.contrib.auth.models import User > > email = ' [EMAIL PROTECTED]' > > username = 'xiaodong' > > password = 'xiaodong' > > new_user = User.objects.create_user(username, password, email) > > new_user.save() > > from django.core.mail import send_mail > > from django.contrib.sites.models import Site > > current_site = Site.objects.get_current() > > send_mail('Thanks for subscribing to %s alerts' % current_site.name, > > 'Thanks for your subscription. We appreciate it.\n\n-The %s team.' % > > current_site.name, '[EMAIL PROTECTED]' % current_site.domain, > > [new_user.email]) > > > However, i had some error message as below: > > Traceback (most recent call last): > > File "", line 1, in > > File "/usr/lib/python2.5/site-packages/django/core/mail.py", line > > 49, in send_mail > > return send_mass_mail([[subject, message, from_email, > > recipient_list]], fail_silently, auth_user, auth_password) > > File "/usr/lib/python2.5/site-packages/django/core/mail.py", line > > 66, in send_mass_mail > > server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) > > File "smtplib.py", line 244, in __init__ > > (code, msg) = self.connect(host, port) > > File "smtplib.py", line 310, in connect > > raise socket.error, msg > > error: (111, 'Connection refused') > > > it's about the smtp server or it's can not run on a local machine? > > > Thanks a lot > > > Dong --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using HttpResponse as a file - 'HttpResponse' object has no attribute 'seek' error
I thought I would be able to use an HttpResponse object as the file argument for ZipFile, like this: response = HttpResponse(mimetype='application/zip') response['Content-Disposition'] = 'attachment; filename=zipfile.zip' file = zipfile.ZipFile(response, "w") but as soon as I try to write to it I get the error "'HttpResponse' object has no attribute 'seek'". Am I missing something here? Thanks, Kip. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Phantom Query
On Thu, 2008-02-21 at 00:37 -0800, Dave Fowler wrote: > I have a phantom query that is just killing my database. I have a > model named Stats and django is executing the equivalent to > Link.objects.all() in my Stats app. > > # Query_time: 20 Lock_time: 0 Rows_sent: 659528 Rows_examined: 659528 > SELECT > `stats_link`.`id`,`stats_link`.`title`,`stats_link`.`url`,`stats_link`.`last_modified`,`stats_link`.`subdomain_id`,`stats_link`.`avg_time`,`stats_link`.`rating`,`stats_link`.`dlevel`,`stats_link`.`visits` > FROM `stats_link`; > > I've combed my code 100 times and cannot find a single place where I > do anything remotely like this. I have almost a 700,000 entries in my > link table and it takes 20 seconds to execute. > > I added the snippet that shows what queries are executed on each page, > but it shows up on none of my pages. I have a large amount of ajax > for my site so its I can't see every function that way. > > Does anyone know of any other tools beside that snippet to view all my > queries and see what function they're coming from? Modify the execute() method in django.db.backend.utils.CursorDebugWrapper to also log a stack trace each time execute() is called. If you log the query, plus the result of traceback.print_stack() or traceback.extract_stack() to a file you should be able to work out where the call is coming from. Malcolm -- A conclusion is the place where you got tired of thinking. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Checkboxes in newforms
Thanks Malcolm, I'd over-egged the html pudding Regards, Eamon Carron On Feb 20, 5:18 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-02-20 at 05:28 -0800,Eamonwrote: > > Hi All, > > > I am a newbie and I can't seem to get my checkbox code working using > > newforms. > > > FORMS.PY > > class MyForm(forms.Form): > > cb = forms.BooleanField(widget=forms.CheckboxInput(),initial=True, > > required=False) > > ... > > > VIEWS.PY > > ... > > if request.method == 'POST': > > form = MyForm(request.POST) > > if form.is_valid(): > > bChecked = form.clean_data['cb'] > > > MYHTML.HTML > > > value="Fulfilled" checked="checked" {{ form.cb }}>Fulfilled > > Have a look at the HTML this generates. It won't be anything like what > you expect. {{form.cb}} is a complete HTML layout section, with a label > and an input widget and everything. Putting all that markup inside > another HTML input element is going to lead to tears. > > Malcolm > > -- > Telepath required. You know where to > apply...http://www.pointy-stick.com/blog/- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problem with django tagging application
See the changes listed here: http://code.google.com/p/django-tagging/wiki/BackwardsIncompatibleChanges you may be able to give directly the queryset rather than the model On Thu, Feb 21, 2008 at 1:25 AM, cesco <[EMAIL PROTECTED]> wrote: > Hi, > > I'm using the latest version of the django tagging application (rev. > 132) and I'm having problems with the get_by_model method of the > TaggedItem manager. > > Say I have a QuerySet1 generated as follow: > QuerySet1 = TaggedItem.objects.get_by_model(MyModel, 'tag1') > and a QuerySet2 generated as follow: > QuerySet2 = TaggedItem.objects.get_by_model(MyModel, 'tag2') > > If at this point I try to '&' the two query sets as in: > QuerySet3 = QuerySet1 & QuerySet2 > then I get the following error: > "ambiguous column name: tagging_taggeditem.object_id" > > Do you have any idea of why I'm getting this error and how I could > solve the problem? > For completeness in dpaste is the complete traceback I get: > http://dpaste.com/36177/ > > Any help would be very appreciated. > > Thanks > Francesco > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problem with django tagging application
Hi, > Any chance you were using django-tagging previously and recently > updated to trunk? There are backwards incompatible changes - the > relation names have > changed:http://code.google.com/p/django-tagging/wiki/BackwardsIncompatibleCha... I was actually getting the same error before and after the updates. Thanks anyway Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problem with django tagging application
Hi > So the SQL that is being constructed by the joined queryset isn't valid. > I'm almost certain the answer to this is "it's fixed in > queryset-refactor, so will one day be fixed in trunk." Thanks for the work you are doing:-) > Pull the results back into Python and merge them manually. Could I ask you to be a bit more specific (not so experienced with python and django)? You mean I should take the two query sets separately and merge them based on the id of the objects in each of the querysets? Thanks again Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django hosting service running Os C
I have a dedicated macmini for around 75 euro's a month, At cqhosting.nl. On Feb 18, 12:12 am, Flavio Curella <[EMAIL PROTECTED]> wrote: > Hi, > > I developed a small application using django and CoreGraphics library > as a school project. I'm wondering to put it online and I googled > around looking for a web hosting solution (shared or VPS) running on > Os X and that supports Django. > > Does anybody know one? > > Thanks, > Flavio Curella. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms-admin: howto define custom ModelForm for usage in admin interface
thanks! a subclass of newforms.BaseForm did the job! lowshoe On Feb 20, 11:35 pm, presclark <[EMAIL PROTECTED]> wrote: > Hello, I was having a similar, but slightly different problem. > > My hangup was that the form_change form wasn't being populated. It > seems that the optional 'form' parameter for form_for_(model/instance) > should probably be a subclass of newforms.BaseForm, and not of > newforms.ModelForm. > > seehttp://code.djangoproject.com/ticket/3632 > > So your test-case might become: > > class DocumentForm(forms.BaseForm): > pass > > Still in the process of working on this myself, but I hope it helps, > > preston > > On Feb 12, 6:14 am, lowshoe <[EMAIL PROTECTED]> wrote: > > > hi, > > > i'm trying to use acustomform for one of my models inside the admin > > interface . i need this to docustomvalidation. > > > so far, i have created a DocumentForm that inherits from > > newforms.ModelFormand define my Model as model attribute inside the > > Meta class (as seen > > athttp://www.djangoproject.com/documentation/modelforms/) > > > --- > > from django import newforms as forms > > > class DocumentForm(forms.ModelForm): > > class Meta: > > model = models.Document > > --- > > > then i overwrote form_add and form_change in my Options class: > > > --- > > from django.contrib.admin import ModelAdmin > > > class DocumentOptions(ModelAdmin): > > > def form_add(self, request): > > if self.declared_fieldsets: > > fields = flatten_fieldsets(self.declared_fieldsets) > > else: > > fields = None > > return forms.form_for_model(self.model, form=DocumentForm, > > fields=fields, > > > formfield_callback=self.formfield_for_dbfield) > > > def form_change(self, request, obj): > > if self.declared_fieldsets: > > fields = flatten_fieldsets(self.declared_fieldsets) > > else: > > fields = None > > > return forms.form_for_instance(obj, form=DocumentForm, > > fields=fields, > > > formfield_callback=self.formfield_for_dbfield) > > > admin.site.register(models.Document, DocumentOptions) > > --- > > > but now i get an error when trying tro add or edit a document: > > > Exception Type: TypeError > > Exception Value:'NoneType' object is not callable > > Exception Location: /usr/lib/python2.5/site-packages/django/newforms/ > > models.py in __init__, line 270 > > > Traceback: > > [..] > > File "/usr/lib/python2.5/site-packages/django/newforms/models.py" in > > __init__ > > 270. self.instance = opts.model() > > > i don't understand why calling opts.model() fails. this should be > > exactly my Document model which i defined inside the Meta class. Did i > > miss something or whats wrong there? > > > regards, lowshoe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
[newforms-admin] inline editing?
from django.db import models from django.contrib import admin # Create your models here. class Category(models.Model): name = models.CharField(max_length=50) def __str__(self): return self.name class Forum(models.Model): cat = models.ForeignKey(Category) name = models.CharField(max_length=50) def __str__(self): return self.name class Category_admin(admin.ModelAdmin): model = Category inlines = [Forum] admin.site.register(Category, Category_admin) this is my models.py, when i try to access the admin interface for my Category object i get an ugly error google knows nothing about :( Environment: Request Method: GET Request URL: http://chat.kiberpipa.org:5222/admin/forum/category/2/ Django Version: 0.97-newforms-admin-SVN-7135 Python Version: 2.4.4 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'mysite.forum', 'mysite.todo', 'django_evolution'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware') Traceback: File "/home/redduck666/django/newforms-admin/django/core/handlers/base.py" in get_response 82. response = callback(request, *callback_args, **callback_kwargs) File "/home/redduck666/django/newforms-admin/django/contrib/admin/sites.py" in root 137. return self.model_page(request, *url.split('/', 2)) File "/home/redduck666/django/newforms-admin/django/contrib/admin/sites.py" in model_page 154. return admin_obj(request, rest_of_url) File "/home/redduck666/django/newforms-admin/django/contrib/admin/options.py" in __call__ 258. return self.change_view(request, unquote(url)) File "/home/redduck666/django/newforms-admin/django/contrib/admin/options.py" in change_view 568. for FormSet in self.formsets_change(request, obj): File "/home/redduck666/django/newforms-admin/django/contrib/admin/options.py" in formsets_change 715. yield inline.formset_change(request, obj) Exception Type: AttributeError at /admin/forum/category/2/ Exception Value: 'Forum' object has no attribute 'formset_change' any hints? -- error: one bad user found in front of screen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django hosting service running Os C
If it's for school project, and you just need to demo it, why not host it on your own machine and use one of the free dynamic DNS services and host it on the development machine? --Jon > > On Feb 17, 2008 3:12 PM, Flavio Curella <[EMAIL PROTECTED]> wrote: > > > > > > Hi, > > > > > > I developed a small application using django and CoreGraphics library > > > as a school project. I'm wondering to put it online and I googled > > > around looking for a web hosting solution (shared or VPS) running on > > > Os X and that supports Django. > > > > > > Does anybody know one? > > > > > > A quick Google search found a few, but most of them were way over > > priced for what you got (One I saw was $55/month for shared hosting). > > http://serverlogistics.com/hosting.php seemed like the most reasonably > > priced one I could find > > > > > > > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Phantom Query
yes, i've taken them all out, even the ones that shouldn't have gotten close to my stats_link table 2008/2/21 Jarek Zgoda <[EMAIL PROTECTED]>: > > Dave Fowler napisał(a): > > > I have a phantom query that is just killing my database. I have a > > model named Stats and django is executing the equivalent to > > Link.objects.all() in my Stats app. > > > > # Query_time: 20 Lock_time: 0 Rows_sent: 659528 Rows_examined: 659528 > > SELECT > > > `stats_link`.`id`,`stats_link`.`title`,`stats_link`.`url`,`stats_link`.`last_modified`,`stats_link`.`subdomain_id`,`stats_link`.`avg_time`,`stats_link`.`rating`,`stats_link`.`dlevel`,`stats_link`.`visits` > > FROM `stats_link`; > > > > I've combed my code 100 times and cannot find a single place where I > > do anything remotely like this. I have almost a 700,000 entries in my > > link table and it takes 20 seconds to execute. > > Did you check also select_related() calls? This may have large overhead > sometimes when not used carefully. > > -- > Jarek Zgoda > Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101 > > "We read Knuth so you don't have to." (Tim Peters) > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Phantom Query
Dave Fowler napisał(a): > I have a phantom query that is just killing my database. I have a > model named Stats and django is executing the equivalent to > Link.objects.all() in my Stats app. > > # Query_time: 20 Lock_time: 0 Rows_sent: 659528 Rows_examined: 659528 > SELECT > `stats_link`.`id`,`stats_link`.`title`,`stats_link`.`url`,`stats_link`.`last_modified`,`stats_link`.`subdomain_id`,`stats_link`.`avg_time`,`stats_link`.`rating`,`stats_link`.`dlevel`,`stats_link`.`visits` > FROM `stats_link`; > > I've combed my code 100 times and cannot find a single place where I > do anything remotely like this. I have almost a 700,000 entries in my > link table and it takes 20 seconds to execute. Did you check also select_related() calls? This may have large overhead sometimes when not used carefully. -- Jarek Zgoda Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Phantom Query
I have a phantom query that is just killing my database. I have a model named Stats and django is executing the equivalent to Link.objects.all() in my Stats app. # Query_time: 20 Lock_time: 0 Rows_sent: 659528 Rows_examined: 659528 SELECT `stats_link`.`id`,`stats_link`.`title`,`stats_link`.`url`,`stats_link`.`last_modified`,`stats_link`.`subdomain_id`,`stats_link`.`avg_time`,`stats_link`.`rating`,`stats_link`.`dlevel`,`stats_link`.`visits` FROM `stats_link`; I've combed my code 100 times and cannot find a single place where I do anything remotely like this. I have almost a 700,000 entries in my link table and it takes 20 seconds to execute. I added the snippet that shows what queries are executed on each page, but it shows up on none of my pages. I have a large amount of ajax for my site so its I can't see every function that way. Does anyone know of any other tools beside that snippet to view all my queries and see what function they're coming from? Thanks Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---