[Announce] Django Graphos - Django charting made *really* easy
Hello, I would like to announce Django Graphos - An app which makes it really easy to work with Django graphs. https://github.com/agiliq/django-graphos Graphos is a Django app to plot data into graph. ### Supported Backends: * Python Nested lists * CSV Files * MongoDB * Django ORM ### Charting API Supported * Google charts API * Flot * YUI https://github.com/agiliq/django-graphos Plotting a chart from a model is as simple as: queryset = Accounts.objects.filter(foo=bar) LineChart(ModelDataSource(queryset, fields=["year", "sales", "expenses"])) Looking for review of the code and architecture. Pull reviews very welcome: https://github.com/agiliq/django-graphos -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Using .extra after using .annotate is not working
I am trying to get a field in a queryset which depends on the result of the annotations. I tried using extra on an annotated queryset, which doesn't seem to work. Lets say my models looks like this: class Foo(models.Model): name = models.CharField(...) class FooData(models.Model): foo = models.ForeignKey(Foo) sales = models.PositiveIntegerField() items_sold = models.PositiveIntegerField() I have a queryset of Foo objects some_foos = Foo.objects.filter() I have annotated it to get the sum on FooData. some_foos.object.annotate( total_sales=Sum("foodata__sales"), total_items_sold=Sum("foodata__items_sold") ) Now I want to get the average price for which I am trying to use .extra. They don't seem to work. (I have looked the generated sql queries). #Wont work, fields not defined yet. some_foos.object.annotate( total_sales=Sum("foodata__sales"), total_items_sold=Sum("foodata__items_sold") ).extra(select={'price_avg': "total_sales/total_items_sold"}) #Wont work, this adds an extra clause in group by price_avg = "SUM(appname_foodata.sales)/ SUM(appname_foodata.items_sold)" some_foos.object.annotate( total_sales=Sum("foodata__sales"), total_items_sold=Sum("foodata__items_sold") ) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Editing the RSS in the Django community feeds
Hi Guys, Updating feedburner actually pulled in a lot of old entries in the community feed. I am not sure why. My apologies for pushing this to the feed. Hopefully the feed will pick up only the new entries from now on. On Mar 12, 7:44 pm, Shabda Raaj wrote: > Hi Russel, > > Thanks for your help. > > Looks like I was using this via feedburner, so I just updated it at the > feedburner level. > > > > > > > > On Tuesday, March 12, 2013 7:57:46 AM UTC+5:30, Russell Keith-Magee wrote: > > > Hi Shabda, > > > I've got hold of the server logs - the feeds are tied into a bigger > > framework for actually gathering the blog entries, and older feeds are > > resisting change :-) > > > There are two options here: > > > * You should be able edit the feed yourself: visit > >http://www.djangoproject.com/community/mineand update the details. > > > * Try deleting the feed and re-adding it. > > > If you're still having problems, try emailing > > ja...@jacobian.org- he's got the keys to the servers, and > > should be able to fix things at a > > low level. > > > Yours, > > Russ Magee %-) > > > On Tue, Mar 12, 2013 at 8:21 AM, Russell Keith-Magee < > > rus...@keith-magee.com > wrote: > > >> Hi Shabda, > > >> I took a look at this for you, but for some reason the new URL is > >> throwing an error (on our end) when I try and update it. I'll keep digging > >> and let you know when it's working. > > >> Yours, > >> Russ Magee %-) > > >> On Mon, Mar 11, 2013 at 8:34 PM, Shabda Raaj > >> > >> > wrote: > > >>> Hello, > > >>> The Django community RSS feeds has a form to add new RSS: > >>>https://www.djangoproject.com/community/add/blogs/ > > >>> We have our RSS added in this from way back. However sometime we write > >>> about non-django stuff, which is not relevant in this feed. I would like > >>> to > >>> update this to our Django only feed: > > >>>http://agiliq.com/blog/rss/latest/django/ > > >>> Can someone with access do this? (or advise me who can I contact to edit > >>> this.) > > >>> -- > >>> You received this message because you are subscribed to the Google > >>> Groups "Django users" group. > >>> To unsubscribe from this group and stop receiving emails from it, send > >>> an email to django-users...@googlegroups.com . > >>> To post to this group, send email to > >>> django...@googlegroups.com > >>> . > >>> Visit this group athttp://groups.google.com/group/django-users?hl=en. > >>> For more options, visithttps://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Editing the RSS in the Django community feeds
Hi Russel, Thanks for your help. Looks like I was using this via feedburner, so I just updated it at the feedburner level. On Tuesday, March 12, 2013 7:57:46 AM UTC+5:30, Russell Keith-Magee wrote: > > Hi Shabda, > > I've got hold of the server logs - the feeds are tied into a bigger > framework for actually gathering the blog entries, and older feeds are > resisting change :-) > > There are two options here: > > * You should be able edit the feed yourself: visit > http://www.djangoproject.com/community/mine and update the details. > > * Try deleting the feed and re-adding it. > > If you're still having problems, try emailing > ja...@jacobian.org- he's got the keys to the servers, and should > be able to fix things at a > low level. > > Yours, > Russ Magee %-) > > On Tue, Mar 12, 2013 at 8:21 AM, Russell Keith-Magee < > rus...@keith-magee.com > wrote: > >> Hi Shabda, >> >> I took a look at this for you, but for some reason the new URL is >> throwing an error (on our end) when I try and update it. I'll keep digging >> and let you know when it's working. >> >> Yours, >> Russ Magee %-) >> >> >> On Mon, Mar 11, 2013 at 8:34 PM, Shabda Raaj >> > wrote: >> >>> Hello, >>> >>> The Django community RSS feeds has a form to add new RSS: >>> https://www.djangoproject.com/community/add/blogs/ >>> >>> We have our RSS added in this from way back. However sometime we write >>> about non-django stuff, which is not relevant in this feed. I would like to >>> update this to our Django only feed: >>> >>> http://agiliq.com/blog/rss/latest/django/ >>> >>> Can someone with access do this? (or advise me who can I contact to edit >>> this.) >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users...@googlegroups.com . >>> To post to this group, send email to django...@googlegroups.com >>> . >>> Visit this group at http://groups.google.com/group/django-users?hl=en. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Editing the RSS in the Django community feeds
Hello, The Django community RSS feeds has a form to add new RSS: https://www.djangoproject.com/community/add/blogs/ We have our RSS added in this from way back. However sometime we write about non-django stuff, which is not relevant in this feed. I would like to update this to our Django only feed: http://agiliq.com/blog/rss/latest/django/ Can someone with access do this? (or advise me who can I contact to edit this.) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[Announce]Django-parsley: Easy client side validations for Django
I would like to announce our new app: Django Parsley - https://github.com/agiliq/django-parsley Django forms give you nice server side validations for free. This library adds client side valiadtions with very little effort to you your forms, using parsley.js. Patches and feedback welcome. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Django Design Patterns and Djen of Django books on Kindle Store
We have published our Ebooks on Kindle Store and would love to get some reviews. (Just $1 each) http://www.amazon.com/The-Djen-of-Django-ebook/dp/B006P1K0YY/ref=ntt_at_ep_dpt_2 http://www.amazon.com/Django-Design-Patterns-ebook/dp/B006OYO9SK/ref=ntt_at_ep_dpt_1 (They are also available for free should you prefer that.) http://agiliq.com/books/djenofdjango/ http://agiliq.com/books/djangodesignpatterns/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting started with Django: New Udemy Class, free for a limited time
I was hoping to get about 100 people in a month, but we already have 289 people signed up in a week. :). I wasn't expecting this. (You can verify this at Udemy.) Because I am still adding the content, I am keeping the price to $9 for the whole of February, and would raise once I am done with adding the tutorials. You can join here: http://www.udemy.com/getting-started-with-django2/ Whats added already. 1. 4 part screencast for the four part Django tutorial. 2. Screencasts on using pip, pep8.py, pyflakes, ipython. 3. PDF versions of Django design patterns and Djen of Django book. 4. Various other tutorials. 5. Code samples of all code written in the screencasts and the tutorials. On Jan 28, 11:13 pm, Shabda Raaj wrote: > Here is the link:http://www.udemy.com/getting-started-with-django2/ > > More info: > I am starting aUdemyclass called "Getting started with Django". > This is supposed to be a fast paced introduction to Django, and is > going to be useful to people from beginner to intermediate Django > skills. > > Please join:http://www.udemy.com/getting-started-with-django2/or > forward to people who may be interested. I am keeping the course free > for the first 100 people, and I am going to set the price to 149$ > once > we have the 100 people signed up. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Getting started with Django: New Udemy Class, free for a limited time
Here is the link: http://www.udemy.com/getting-started-with-django2/ More info: I am starting a Udemy class called "Getting started with Django". This is supposed to be a fast paced introduction to Django, and is going to be useful to people from beginner to intermediate Django skills. Please join: http://www.udemy.com/getting-started-with-django2/ or forward to people who may be interested. I am keeping the course free for the first 100 people, and I am going to set the price to 149$ once we have the 100 people signed up. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Cross post from Djangoindia list: [Pycon] IRC Meeting to discuss how to represent Django
[Repost from djangoindia(http://groups.google.com/group/djangoindia) list. Please reply there(http://groups.google.com/group/djangoindia/ browse_thread/thread/72c220038d52f12c) if you are interested.] Hi, With Pycon's talk submission deadline just a week away and only 1 talk on our favourite web framework, I suggest that we organize an IRC meeting hopefully on August 15th (Saturday around evening) and discuss our plans to increase the representation of Django at Pycon. Pycon India happens to give us an opportunity to deliver collaborative talks, conduct sprints and also have BoF [1] sessions. Shabda will let us know the venue of the IRC meeting. In the meantime, let us decide on a suitable timing for the meeting. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Value proposition of Rails
>Nobody ever releases accurate information on site information, so >anything you get here will be a guess. "Five biggest" is kind of a bad >number anyway, since your customer won't be any of them and it's >unlikely you're targeting them as your customers (if you're only looking >at the five biggest, you're missing out on the other few thousand). >Better to look at established companies or busy sites using Django, >rather than saying you had to go as far as the top five to find anything >decent. I want to use that to answer does Django work efficiently and does it scale? When you get asked "My Database has N-Gazillion rows and app needs x concurrent users", showing some sites which use Django and push 500,000 pageviews per day would be good. I tried to glean this information from Djangosites and corelate to Alexa, but maybe I am missing some other big ones. On Mar 19, 6:37 am, Malcolm Tredinnick wrote: > On Wed, 2009-03-18 at 12:23 -0700,shabdawrote: > > [Trying not be trollish, but the subject might be so. My apologies in > > advance.] > > > I run a small Django development firm (www.uswaretech.com), and a > > lot of clients we go after need to be convinced on why they should > > choose Django. What is your experience in this? Specifically am I > > looking for is, > > > 1. Why choose Django over J2EE > > 2. Why choose Django over RoR > > 3. Why choose Django over PHP > > The answer to all of these isn't necessarily to do it, for a customer. > It depends on what resources they have available. There are plenty of > cases where Ruby on Rails is a better choice for an organisation than > Django simply because they have Ruby developers available. > > Also, remember that none of these are an either/or proposition. All can > work together (indeed Django on Jython inside Tomcat, or similar, is > going to be a huge thing, I suspect). As a consultant both as an > individual and as part of a corporate consulting group, I've found it > better to pitch the value of using Python/Django/whatever and why it > solves the problem for an effective cost or timetable or whatever the > client's particular pressing issue is, rather than saying the others are > worse choices. For things like Java and Ruby, it's going to be a bit > insane to diss the languages, as they simply aren't that bad in the > corporate world. > > Even PHP: I mean, Flickr, Wikipedia, Yahoo -- these are some pretty > large sites running on PHP. Another poster's comment about the ability > to hire good talent is valid, but that also counts against Python (and > Ruby). Corporate clients, particularly, become concerned over the > scarcity of available developers. > > > 4. What are the five biggest Django sites, (In number of absolute > > pageviews.) > > Nobody ever releases accurate information on site information, so > anything you get here will be a guess. "Five biggest" is kind of a bad > number anyway, since your customer won't be any of them and it's > unlikely you're targeting them as your customers (if you're only looking > at the five biggest, you're missing out on the other few thousand). > > Better to look at established companies or busy sites using Django, > rather than saying you had to go as far as the top five to find anything > decent. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Value proposition of Rails
Ok, I am stupid! I was reading an article and mistyped! http://jooto.com/blog/index.php/2005/10/29/rails-value-proposition/ On Mar 19, 12:23 am, shabda wrote: > [Trying not be trollish, but the subject might be so. My apologies in > advance.] > > I run a small Django development firm (www.uswaretech.com), and a > lot of clients we go after need to be convinced on why they should > choose Django. What is your experience in this? Specifically am I > looking for is, > > 1. Why choose Django over J2EE > 2. Why choose Django over RoR > 3. Why choose Django over PHP > 4. What are the five biggest Django sites, (In number of absolute > pageviews.) > 5. Objective Benchmarks, Industry Reports, Anectodal evidence, and > testimonials --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Value proposition of Rails
[Trying not be trollish, but the subject might be so. My apologies in advance.] I run a small Django development firm ( www.uswaretech.com ), and a lot of clients we go after need to be convinced on why they should choose Django. What is your experience in this? Specifically am I looking for is, 1. Why choose Django over J2EE 2. Why choose Django over RoR 3. Why choose Django over PHP 4. What are the five biggest Django sites, (In number of absolute pageviews.) 5. Objective Benchmarks, Industry Reports, Anectodal evidence, and testimonials --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Writing a subclassable Django singleton model
I am trying to write a singleton model which can be subclassed. from django.db import models class Singleton(models.Model): name = models.TextField() def save(self): if self.__class__.objects.all().count(): #There exists another object in the DB obj = self.__class__.objects.all()[0] for field in self._meta.fields: if not field.name == self._meta.auto_field.name: setattr(obj, field.name, getattr(self, field.name)) super(Singleton, obj).save() else: super(Singleton, self).save() class SubSingleton(Singleton): tag = models.TextField() I want an API like this, In [1]: from testf.models import SubSingleton In [2]: SubSingleton.objects.all().delete() In [3]: x=SubSingleton(name='a', tag='b') In [4]: x.save() In [5]: SubSingleton.objects.count() Out[5]: 1 In [6]: y=SubSingleton(name='a', tag='b') In [7]: y.save() --- AttributeErrorTraceback (most recent call last) /home/shabda/django_design_pats/ in () /home/shabda/django_design_pats/testf/models.pyc in save(self) 9 obj = self.__class__.objects.all()[0] 10 for field in self._meta.fields: ---> 11 if not field.name == self._meta.auto_field.name: 12 setattr(obj, field.name, getattr(self, field.name)) 13 super(Singleton, obj).save() AttributeError: 'NoneType' object has no attribute 'name' In [8]: SubSingleton.objects.count() Out[8]: 1 So SubSingleton._meta.auto_field is none, while I expect it to be a AutoField with name ='id'. What am I missing? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Anyone maintaining a Svn repo for django-registration?
Django registration has moved from googlecode to Bitbucket, which means my projects which are svn:externaled to django-registration might not get the latest code. Is anyone maintaining an svn repository which is I can svn:external to? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Is there a place from where I can get the completed code for the Django 4-part tutorial?
Is there a place where I can get the app completed as part of http://docs.djangoproject.com/en/dev/intro/tutorial04/#intro-tutorial04 --~--~-~--~~~---~--~~ 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 do test Middleware
I want to write some test for my middleware seperate from the views that would be using them. So I am using this snippet http://www.djangosnippets.org/snippets/963/ to get a request, and calling my middleware with it to test it, but it looks a little hackish to me. Is there a better way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Filtering the modelform in Admin on request.user
I have an Admin site which I want to filter based on request.user. My ModelAdmin class is something like this, class FilterOnUser(admin.ModelAdmin): def queryset(self, request): return self.model._default_manager.filter(user = request.user) def get_form(self, request, obj=None, **kwargs): form_class = super(FilterOnUser, self).get_form(self, request, **kwargs) class MyModelForm(form_class): def get_queryset(self): import pdb pdb.set_trace() return super(MyModelForm, self).get_queryset().filter(board = request.board) return MyModelForm So when I navigate to the change view on my admin site the pdb.set_trace is not hit. What am I doing wrong? --~--~-~--~~~---~--~~ 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: Why is my string not auto escaped?
So if these built in filters are marking my strings safe, inspite of unsafe data being passed in, should they not handle escaping as well? Rajesh Dhawan wrote: > On Oct 29, 8:35 am, shabda <[EMAIL PROTECTED]> wrote: > > I need to create a custom filter which displays some data from db > > depending on its data type. > > > > My code is something like, > > > > from django.template.defaultfilters import linebreaks, urlize > > > > def filterxx(data) > > return linebreaks(urlize(data.value)) > > > > My data.value is > > > > Asdfghjkl > > > > alert('hole') > > > > This is used in templates, and shows up unescaped, which allows users > > to run arbitrary scripts. What am I doing wrong? > > Your filter is internally calling the linebreaks and urlize built-in > filters which end up wrapping that filter's return value into a "safe > string" via django.utils.safestring.mark_safe(). > > See: > http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping > > You should escape your data.value explicitly before passing it on to > those functions. The second bullet point in the above document shows > how you would achieve conditional escaping of data.value in your > filter. > > -RD --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Why is my string not auto escaped?
I need to create a custom filter which displays some data from db depending on its data type. My code is something like, from django.template.defaultfilters import linebreaks, urlize def filterxx(data) return linebreaks(urlize(data.value)) My data.value is Asdfghjkl alert('hole') This is used in templates, and shows up unescaped, which allows users to run arbitrary scripts. What am I doing wrong? --~--~-~--~~~---~--~~ 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 get the Html representation of forms.Fields
I have some forms.Fields, which are not attached to any forms.Form. How can I get the Html representation of 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: trying to understand get_absolute_url, NoReverseMatch and url configs
You want something like this @models.permalink def get_absolute_url(self): return ('orgs.views.org', [self.type.slug, self.slug]) Essentially, you code would be doing something like reverse('/org/ hoa/', kwargs={..}) which fails. Templates supress Exceptions so you do not see them. On Oct 27, 9:48 pm, bobhaugen <[EMAIL PROTECTED]> wrote: > Altho I have read alot of the relevant documentation, and searched > this group and the Web, I remain confused about these topics and their > relationships. Something is not sticking in my brain. > > I usually get something working by blind cut and paste. Looking for a > more conceptual explanation, or even some pointers to where to look > next. > > Here's my current problem: > > in models.py: > > def get_absolute_url(self): > prefix = "/org/%s/" % self.type.slug > return (prefix, None, {"org_slug": iri_to_uri(self.slug)}) > > in urls.py: > > url(r'^org/(\w)+/(?P[-\w]+)/$', 'orgs.views.org', > name='org'), > > in a template: > > {{ org.get_absolute_url }} > > returns nothing. No error message. > > Error message from the shell: > > >>>org,get_absolute_url() > > [...] > NoReverseMatch: Reverse for '/org/hoa/' with arguments '()' and > keyword arguments '{'org_slug': 'cp'}' not found. > > If I enter the urlhttp://127.0.0.1:8000/org/hoa/cp/in the address > bar, it works fine. > > Using current trunk and the Django dev server. > > What am I missing? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Order of fields reset on Dynamically generated Forms.
I need to use DynamicForm(form generated using database values), so I am using this method, http://uswaretech.com/blog/2008/10/dynamic-forms-with-django/ Now the order in which I define the fields is not the same as that for the rendered Html. If I change the line like setattr(EmployeeForm, field.name, copy(type_mapping[field.type])), to setattr(EmployeeForm, field.name, forms.CharField()), the order is maintained. Any pointers? [ Intially I though that return type('EmployeeForm', (forms.Form, ), dict(EmployeeForm.__dict__)), messes up the order, as dict(EmpForm.__dict__) would not keep order, as dicts are unordered, but somehow the order is being maintained even with this line, but setattr(EmployeeForm, field.name, forms.CharField()) ] --~--~-~--~~~---~--~~ 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: Feature like "acts_as" in Django ORM or contrib ?
Ordering: qs = Model.objects.filter(...).order_by('ordering_field') ord_list = [el for el in qs] Versioning: code.google.com/p/django-rcsfield (There are a few others, cant remember the names offhand.) On Oct 21, 12:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 21 oct, 08:37, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > > > > acts_as is a Ruby design pattern rather than a Python one. However, > > for the specific higher/lower functionality, look into > > django-mptt:http://code.google.com/p/django-mptt/ > > Very good. > > Do you know something to do : > > * ordered list > * versionning > > ? --~--~-~--~~~---~--~~ 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: Possible pug with Model inheritence - Inserts instead of Update
As long as model_obj.id is None, Django does an Insert, I want an insert to happen all the time. (Sort of like trying to get FullHistory, wherein I can roll back my object to a previous state. I can do save(force_insert = True), but that also gives me an Exception.) On Oct 12, 6:32 pm, felix <[EMAIL PROTECTED]> wrote: > well this is interesting and curious what you are trying to do. > why are you trying to do this self.id= None ? > > what is the real world purpose ? can you give a non abstract > example ? > > in any case since Bar is a subclass of Foo there are two database > tables. > you set Bar id to None, > but the object still has a Foo ptr id, so ultimately there is still > only one object. > that is, I think, the primary key that is accessed when using > Bar.objects.all() > > really, you have broken it by this self.id = None, > so I would expect more problems > > On Oct 12, 9:16 am, shabda <[EMAIL PROTECTED]> wrote: > > > My models.py > > > class Foo(models.Model): > > name = models.CharField(max_length = 100) > > > def save(self): > > self.id = None > > super(Foo, self).save() > > > class Bar(Foo): > > created = models.DateTimeField(auto_now_add = 1) > > > This gives me, > > > In [1]: from djcalendar.models import Foo > > > In [2]: shabda = Foo(name = 'Shabda') > > > In [3]: shabda.save() > > > In [4]: Foo.objects.all() > > Out[4]: [] > > > In [5]: shabda.name = 'Shabda Raaj' > > > In [6]: shabda.save() > > > In [7]: Foo.objects.all() > > Out[7]: [, ] > > > Which is what I expect. Now doing the same thing to Bar > > > In [1]: from djcalendar.models import Bar > > > In [2]: shabda = Bar(name = 'Shabda') > > > In [3]: shabda.save() > > > In [4]: shabda.name = 'Shabda Raaj' > > > In [5]: shabda.save() > > > In [6]: Bar.objects.all() > > Out[6]: [] > > > Here I am expecting two objects, similar to what happened with Foo, > > but I get only one. > > > Am I missing something, or is this a bug? --~--~-~--~~~---~--~~ 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 can I check which view is being called in response to a specific Url?
One of my views is returning a Http404, and I think it is calling a view function diffrent from what I am expecting to be called. So How can I check which view is being called in response to a specific Url? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Possible pug with Model inheritence - Inserts instead of Update
My models.py class Foo(models.Model): name = models.CharField(max_length = 100) def save(self): self.id = None super(Foo, self).save() class Bar(Foo): created = models.DateTimeField(auto_now_add = 1) This gives me, In [1]: from djcalendar.models import Foo In [2]: shabda = Foo(name = 'Shabda') In [3]: shabda.save() In [4]: Foo.objects.all() Out[4]: [] In [5]: shabda.name = 'Shabda Raaj' In [6]: shabda.save() In [7]: Foo.objects.all() Out[7]: [, ] Which is what I expect. Now doing the same thing to Bar In [1]: from djcalendar.models import Bar In [2]: shabda = Bar(name = 'Shabda') In [3]: shabda.save() In [4]: shabda.name = 'Shabda Raaj' In [5]: shabda.save() In [6]: Bar.objects.all() Out[6]: [] Here I am expecting two objects, similar to what happened with Foo, but I get only one. Am I missing something, or is this a bug? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Arbitrary precision arithmetic in django
I need to do some Financial calculations in an app in Django. models.DecimalField is fixed precision, while I need an arbitrary precision field. How can I do this? --~--~-~--~~~---~--~~ 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 test Client problems
I have some code like this, c = Client() client.get('/myurl/') where '//myurl' calls view function, def foo(request): ip_addrs = request.META['REMOTE_ADDR'] This view function works when I use a browser, as request.META['REMOTE_ADDR'] is populated. But when I use test Client, I get a keyerror, as resquests generated by Clinet() do not have request.META['REMOTE_ADDR'] populated. Related question, how do I set a value on requests.sessions before making a call to Client().get() --~--~-~--~~~---~--~~ 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 Tutorial Clarification
> I have never used generic views, so share your confusion Well you really should. :) Well I have seen your name many times on the list so know that you are a longtime Django user. If you are not using generic views, you are missing something. On Jun 13, 12:41 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 13-Jun-08, at 12:54 PM, wave connexion(BQ) wrote: > > > 1. in reading overview, "you've got a free, and rich, Python API to > > access your data. The API is created on the fly, no code generation > > necessary?" > > > Does this mean Django generated API code for you? > > django does not generate a single line of code - unlike some other > frameworks which need to generate all sorts of files with all sorts > of rules about filenames and position of the file. > > > > > 2. in tutorial part 1, "What's the difference between a project and > > an app? An app is a Web application that does something — e.g., a > > weblog system, a database of public records or a simple poll app. A > > project is a collection of configuration and apps for a particular > > Web site. A project can contain multiple apps. An app can be in > > multiple projects." > > > Here, that an app can be in multiple projects means the app code > > can be copied/imported into different projects rather than shared > > between different projects? > > app code can be imported into different projects. apps need not be > under the project directory, they can be anywhere in the file system > as long as django can find them (installed apps). > > > > > 3. in tutorial part 4 - > > "Use generic views: Less code is better... > > url(r'^(?P\d+)/results/$', > > 'django.views.generic.list_detail.object_detail', dict(info_dict, > > template_name='polls/results.html'), 'poll_results'), " > > > not very clear on this. more explanation is appreciated. > > I have never used generic views, so share your confusion > > -- > > regards > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ 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: oracle-django problem
Or use this, >From http://www.djangoproject.com/documentation/model-api/#table-names "To override the database table name, use the db_table parameter in class Meta." On Jun 9, 7:46 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Mon, Jun 9, 2008 at 6:43 AM, Harish <[EMAIL PROTECTED]> wrote: > > > hi friends > > > i have a django application, which works on postgres as back-end. > > now i want to migrate the application back-end from postgres to > > oracle. > > > The problem i am facing is that, the existing data table names in > > postgres is too long > > (basically the table name is a combination of application name and > > class name), which is not allowed > > in oracle. (using oracle 11g) Basically oracle only allows 30 > > character as table name. > > > I am looking forward for any solution to my problem > > It isn't clear if you are actually encountering a problem or just > anticipating one. I have no experience with Oracle, but it would seem that > the "naming issues" note here: > > http://www.djangoproject.com/documentation/databases/#naming-issues > > indicates that the developers of the Oracle support were aware of this issue > and dealt with it. Are you running into a problem with this method of > handling the Oracle limitation? > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Trouble trying to use formtools.preview.FormPreview
I am trying to use formtools.preview.FormPreview after reading http://www.djangoproject.com/documentation/form_preview/ and am getting weird errors. This is what I did, 1. Have a form called AddReviewForm which is working as expected. 2. Created a class class ReviewPreviewForm(FormPreview): def done(self, request, cleaned_data): import pdb pdb.set_trace() 3. In my urls.py added this line url(r'^post/$', ReviewPreviewForm(AddReviewForm), name='reviews_preview'), 4. Changed template to post the form to '/post/' 5. Now I am expecting that the preview should appear on form posting, but I am getting exception with traceback, Traceback: File "C:\Python25.1\lib\site-packages\django\core\handlers\base.py" in get_response 82. response = callback(request, *callback_args, **callback_kwargs) File "C:\Python25.1\lib\site-packages\django\contrib\formtools \preview.py" in __call__ 31. return method(request) File "C:\Python25.1\lib\site-packages\django\contrib\formtools \preview.py" in preview_post 58. f = self.form(request.POST, auto_id=AUTO_ID) Exception Type: TypeError at /reviews/post/ Exception Value: __init__() takes at least 4 non-keyword arguments (2 given) What am I doing wrong? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Getting template errors before control goes to Django (Or so it seems)
I am trying to access an URL, and I get an error like this, Traceback (most recent call last): File "C:\Python25.1\lib\site-packages\django\core\servers \basehttp.py", line 277, in run self.result = application(self.environ, self.start_response) File "C:\Python25.1\lib\site-packages\django\core\servers \basehttp.py", line 631, in __call__ return self.application(environ, start_response) File "C:\Python25.1\lib\site-packages\django\core\handlers\wsgi.py", line 205, in __call__ response = self.get_response(request) File "C:\Python25.1\lib\site-packages\django\core\handlers\base.py", line 108, in get_response return callback(request, **param_dict) File "C:\Python25.1\lib\site-packages\django\views\defaults.py", line 80, in page_not_found return http.HttpResponseNotFound(t.render(RequestContext(request, {'request_path': request.path}))) File "C:\Python25.1\lib\site-packages\django\template\__init__.py", line 176, in render return self.nodelist.render(context) File "C:\Python25.1\lib\site-packages\django\template\__init__.py", line 751, in render bits.append(self.render_node(node, context)) File "C:\Python25.1\lib\site-packages\django\template\__init__.py", line 764, in render_node return node.render(context) File "C:\Python25.1\lib\site-packages\django\template \loader_tags.py", line 71, in render compiled_parent = self.get_parent(context) File "C:\Python25.1\lib\site-packages\django\template \loader_tags.py", line 66, in get_parent raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent TemplateSyntaxError: Template u'base.html' cannot be extended, because it doesn't exist So I cannot understand which template is extending 'base.html', from the traceback. Also, he traceback shows up as raw traceback, not as the formatted page which Django shows! --~--~-~--~~~---~--~~ 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-India Google group
Hello All Django people based in India! Did you know that there was no django-india Google group? Ouch. So I have created the Django-India google group. [http:// groups.google.com/group/djangoindia]. If you are a django-developer based in India join this group, so we have a centraol place to find and talk to other Django people based in India. Here is the text of welcome post of Django-india - Django India is a group of Django people based in India. (Wasn't that insightful?). There is still very limited recognition about Django in India. And there is no central place to find and talk to other Django people from India. For example if you are A Django developer looking for local jobs, there aren't many places apart from www.djangogigs.com. Or if you have a startup looking for skilled Django people, it can get **really** hard. In this group, let us try to overcome this shortcoming. Let us decide the group charter when we have some people, but I am thinking along these lines, 1. Help promote Django in India. 2. Organize local meetups. 3. Repository of Indian Startups/Companies/People using Django. 4. Help each other. :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Installing GeoDjango help
Is there a simpler way to install GeoDjango, than the one mentioned at http://code.djangoproject.com/wiki/GeoDjangoInstall ? Also is there any documentation about GeoDjango apart form the one at the wiki? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Announce: Djikiki - Django wiki application
Wanted to announce Djikiki - A Django based wiki to the community. Looks like there is no Django wiki, well apart from [1]. I had this done a few months ago, but I wanted to polish thing up a bit before I announced it here, but I guess right now I am going to be sorta busy for a long time with www.42topics.com, so here is Djikiki. Source is available from, http://code.google.com/p/djikiki/ An install for Djikiki can be seen at www.djikiki.com Its features include 1. All pages are versioned. (It is a wiki, what do you expect. ) 2. All pages have an associated discussion page. (Which is also versioned.) 3. See edit history, for all users, all pages etc. 4. Featured pages. 5. Only registered users can edit. (But registering takes a few second). 6. Wikicreole based markup. Please take it for a spin. Feedback, patches welcome. :) [1] http://showmedo.com/videos/video?name=110&fromSeriesID=110 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Repost] Error with .extra(tables=[]) after qs-rf
Reposting: Essentially my question is, what does "If that isn’t possible, put your extra() call at the front of the queryset construction so that your table is the first use of that table." mean? If I have overriden .get_query_set, to add a .extra, how can I move it too beginning of queryset construction? [Previous post] - I have a queryset with .extra call where I do something like this, self.get_query_set().extra ... tables=['news_topic as permission_table'] .. Pre qs-rf, the values in tables were not being escaped and so this was working, with qs-rf the value in tables is escaped, so my code fails. http://www.djangoproject.com/documentation/db-api/#extra-select-none-... tells me, [1]First, see if you can get by without including the extra table and use the one already in the query. [2]If that isn’t possible, put your extra() call at the front of the queryset construction so that your table is the first use of that table. [3]Finally, if all else fails, look at the query produced and rewrite your where addition to use the alias given to your extra table. The alias will be the same each time you construct the queryset in the same way, so you can rely upon the alias name to not change. 1. I need this table an extra time. 2. I do not understand this. My code is somethings like this, class LinkManager(models.Model): def get_query_set(): super(LinkManager, self).get_query_set().extra() def get_query_set_with_user(self, user): return self.get_query_set().extra() The erros comes in get_query_set_with_user, and I have extra call in get_query_set(), so I guess I can not do this. 3. I guess I can do this, but it seems sort of fragile. Would it not be better to have an option to alias? --~--~-~--~~~---~--~~ 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: Suggestions on UI (client side web) framework to complement Django
We used Dojo for our last project, but there was far too many things happening behind the scenes, and not really documented. We finally decided to rewrite evrything in Jquery. Now I never look farther than JQuery. :) Andre Meyer wrote: > On Tue, Apr 29, 2008 at 9:00 PM, Szaijan <[EMAIL PROTECTED]> wrote: > > > > > In searching for a JS toolkit for my first JS app, I found YUI and > > Dojo to be of equal power and utility, but YUI is MUCH better > > documented. > > > bad documentation for Dojo is a myth - nowadays. Dojo 1.1 is well documented > and has a couple of great features that other frameworks lack; just look at > dojox.gfx or dojox.cometd, for example, as well as http://dojocampus.org/ - > dojo rocks. > > my 2c > andré --~--~-~--~~~---~--~~ 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: Tutorial: __str__() problems
Though __str__ should work here, until you can get this working, try writing __unicode__ method [EMAIL PROTECTED] wrote: > Hello, > I'm just going through the mysite tutorial and can't seem to get the > __str__() method to work when adding it to the two classes, I still > get []. This happened before and I'm not really > sure what fixed it. I'm running .096 > > polls/models.py: > from django.db import models > import datetime > > class Poll(models.Model): > question = models.CharField(maxlength=200) > pub_date = models.DateTimeField('date published') > def __str__(self): > return self.question > def was_published_today(self): > return self.pub_date.date() == datetime.date.today() > > class Choice(models.Model): > poll = models.ForeignKey(Poll) > choice = models.CharField(maxlength=200) > votes = models.IntegerField() > def __str__(self): > return self.choice > > Thanks for any help, > Jason --~--~-~--~~~---~--~~ 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: Tutorial: __str__() problems
Though __str__ should work here, until you can get this working, try writing __unicode__ method [EMAIL PROTECTED] wrote: > Hello, > I'm just going through the mysite tutorial and can't seem to get the > __str__() method to work when adding it to the two classes, I still > get []. This happened before and I'm not really > sure what fixed it. I'm running .096 > > polls/models.py: > from django.db import models > import datetime > > class Poll(models.Model): > question = models.CharField(maxlength=200) > pub_date = models.DateTimeField('date published') > def __str__(self): > return self.question > def was_published_today(self): > return self.pub_date.date() == datetime.date.today() > > class Choice(models.Model): > poll = models.ForeignKey(Poll) > choice = models.CharField(maxlength=200) > votes = models.IntegerField() > def __str__(self): > return self.choice > > Thanks for any help, > Jason --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Regression with QS-RF
I have a queryset with .extra call where I do something like this, self.get_query_set().extra ... tables=['news_topic as permission_table'] .. Pre qs-rf, the values in tables were not being escaped and so this was working, with qs-rf the value in tables is escaped, so my code fails. http://www.djangoproject.com/documentation/db-api/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none tells me, [1]First, see if you can get by without including the extra table and use the one already in the query. [2]If that isn’t possible, put your extra() call at the front of the queryset construction so that your table is the first use of that table. [3]Finally, if all else fails, look at the query produced and rewrite your where addition to use the alias given to your extra table. The alias will be the same each time you construct the queryset in the same way, so you can rely upon the alias name to not change. 1. I need this table an extra time. 2. I do not understand this. My code is somethings like this, class LinkManager(models.Model): def get_query_set(): super(LinkManager, self).get_query_set().extra() def get_query_set_with_user(self, user): return self.get_query_set().extra() The erros comes in get_query_set_with_user, and I have extra call in get_query_set(), so I guess I can not do this. 3. I guess I can do this, but it seems sort of fragile. Would it not be better to have an option to alias? --~--~-~--~~~---~--~~ 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: Multi DB question
>You could use SQLAlchemy to access your forum database, as long as you >don't need it in the admin. As, I just need to access the other DB in one place, I think this is the way to go here. On Apr 17, 7:50 pm, "Ariel Mauricio Nunez Gomez" <[EMAIL PROTECTED]> wrote: > On Thu, Apr 17, 2008 at 6:00 AM, shabda <[EMAIL PROTECTED]> wrote: > > > I have a forum(non-Django) and a Django app both are in different > > databases. > > Can you install django on the forum database? It would probably make your > life a lot easier as you could write custom django models to use the forum > app tables and handle them via the admin or scripts. > > Regards, > Ariel. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Multi DB question
I have a forum(non-Django) and a Django app both are in different databases. When a user is created in the Django I want to create another User in Forum. Do I need to use MultiDB branch for this, or is there a simpler way? Maybe using python-MysqlDB directly? Is there a recent merge of Django and MultiDB? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Dynamic queryset to ModelChoiceField
I have a form where I want to do something like, class SetDefaultForm(forms.Form): topics = forms.ModelChoiceField() def __init__(self, user): super(SetDefaultForm, self).__init__() self.fields['topics'].queryset = Topic.objects.filter(user) This does not work, of course, as ModelChoiceField has queryset as required argument. So I have to do something like, class SetDefaultForm(forms.Form): topics = forms.ChoiceField() def __init__(self, user): super(SetDefaultForm, self).__init__() self.fields['topics'].choices= [topic for topic in Topic.objects.filter(user)] Is there a better way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: I'd like to learn more about Django internals
I have been meaning to learn the code in django.db, but I can never get my head around metaclasses enough to do so. Anything you can suggest, Malcom? On Apr 12, 5:52 pm, "Erik Vorhes" <[EMAIL PROTECTED]> wrote: > You might be thinking of this > flowchart:http://www.djangobook.com/en/1.0/chapter03/#cn60 > > Erik > > On Sat, Apr 12, 2008 at 7:00 AM, Tim Chase > > <[EMAIL PROTECTED]> wrote: > > > > As the subject says, I'd love to learn more about how django > > > works internally. > > > One of the best pages I've found detailing this: > > > http://www.b-list.org/weblog/2006/jun/13/how-django-processes-request/ > > > There was a nice image/flowchart I stumbled across once, but I > > can't disinter it from the web. Perhaps someone else on the list > > will know where to find it. > > > -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: How we can integrate Django app in Google appengine.
[Shameless plug :)] http://www.42topics.com/dumps/django/docs.html http://www.42topics.com/dumps/appengine/doc.html On Apr 12, 4:49 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote: > I'm not sure wether you're asking how to run django on GAE [1], or how > to do that using appengine's webapp framework [2]. > > [1]http://code.google.com/appengine/articles/django.html > [2]http://code.google.com/appengine/docs/gettingstarted/ > > Bear in mind that AFAIK right now there's no official way to make django > components that use the ORM work. Beside that, there's a ticket with a > patch for a GAE DS session backend [1], and there are efforts to make > the whole thing tie together too [2]. > > [1]http://code.djangoproject.com/ticket/7008 > [2]http://code.google.com/p/google-app-engine-django/ > > ~ Chris > > El sáb, 12-04-2008 a las 08:42 -0400, rajiv bammi escribió: > > > Dear developers, > > > Just a basic query, i am still not able to understand that how we can > > integrate Django app with Google appengine.. > > > Let say we have a simple program in Django which says hello world.. > > how using django i can do it in Google Appengine.. > > > Thanks & Regards > > Rajiv --~--~-~--~~~---~--~~ 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: Tree from the model.
Though I do not always use a reusable app, even if it exists, (leaky abstractions[1]), django-mptt is awesome. It does what it claims to do, and stays out of the way. Very recommended if you need to model hierarchical data. On Apr 11, 11:43 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > 2008/4/11 Dmitriy Sodrianov <[EMAIL PROTECTED]>: > > > Is it possible to use only Django's built-in functions? > > Yes, but you will end up essentially re-implementing all the code in > the application Alex suggested. > > When an application exists that helps you to do what you want, it's > quite silly to go duplicating all the code. > > -- > "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: Using Django with appengine - Port of the django tutorial for appengine
Oops, gave wrong link. The correct link is http://www.42topics.com/dumps/django/docs.html . That one I wrote yesterday for people who already know Django. On Apr 10, 11:35 pm, shabda <[EMAIL PROTECTED]> wrote: > I have tried to write a Django tutorial for Appengine. This can be > found herehttp://www.42topics.com/dumps/appengine/doc.html. This is a > port of the django tutorial > fromhttp://www.djangoproject.com/documentation/tutorial01/ > to use Appengine. A live install of this can be seen > athttp://blogango.appspot.com > . > This is released under a creative commons attribution, license, so > feel free to modify it. The reStructured text doc source can be found > athttp://www.42topics.com/dumps/django/docs.txt > > If you need any help with this, please ask in this thread, and I will > try to help. > > Also I would love to get you feedback about this tutorial, and how can > I make this better. --~--~-~--~~~---~--~~ 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 Django with appengine - Port of the django tutorial for appengine
I have tried to write a Django tutorial for Appengine. This can be found here http://www.42topics.com/dumps/appengine/doc.html. This is a port of the django tutorial from http://www.djangoproject.com/documentation/tutorial01/ to use Appengine. A live install of this can be seen at http://blogango.appspot.com . This is released under a creative commons attribution, license, so feel free to modify it. The reStructured text doc source can be found at http://www.42topics.com/dumps/django/docs.txt If you need any help with this, please ask in this thread, and I will try to help. Also I would love to get you feedback about this tutorial, and how can I make this better. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Anybody successfully deployed their Django app to Appengine?
Anybody successfully deployed their Django app to Appengine, and willing to share their code? I have a fair bit of code working on the dev_webserver, but it fails on deploying. Until the logging bug is resolved I think I am stuck behind seeing 500 server errors. I am sure I am missing something obvious, and if I look at somebody's deployed I can find the problem. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Appengine, a few questions about imports
In Django's code I see from imp import find_module [1] However in google's runtime the app module is empty.[2] Can someone more experienced than me, tell when this code will be hit, and what can I do to not hit this code. [1] http://www.google.com/search?q=django+%22from+imp+import%22+site%3Acode.djangoproject.com&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_enIN217IN217&aq=t [2] http://code.google.com/appengine/docs/python/purepython.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: When does form.clean get called?
>From my code, try: user = User.objects.get(username__iexact = self.cleaned_data['username']) except User.DoesNotExist, KeyError: raise forms.ValidationError('Invalid username, please try again.') if not user.check_password(self.cleaned_data['password']): raise forms.ValidationError('Invalid password, please try again.') So I just want to check that user exists and knows correct password. The reason I do this in clean is as the order of field.clean is not guaranteed, I would have to do User.objects.get(username__iexact = self.cleaned_data['username']) two times with two database hits. (Probably premature optimisation :) )So essentially what I want to know should I be always checking ``if field in self.cleaned_data:`` before using them in form.clean? On Apr 9, 7:02 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2008-04-07 at 07:29 -0700, shabda wrote: > > So is there a cleaner way to work in form.clean instead of doing > > if for.cleaned_datahas_key(field): > > for every element? > > It depends what you want to do in the clean() method. The example you > gave in your first post in this thread is not a good use of clean(), > since you are just doing single field validation, so you might as well > have written clean_username and clean_password methods, except you > didn't need those either because you were just testing if the fields > were present and for required fields, the default cleaning methods will > flag that as an error in any case. Basically, the initial example you > posted needed no extra cleaning methods beyond what Django provides by > default. > > If you're trying to do something else in clean(), explain what you're > wanting to achieve and we might be able to suggest something. > > Regards, > Malcolm > > -- > Depression is merely anger without > enthusiasm.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 -~--~~~~--~~--~--~---
Using Django with Appengine tutorial
Hi, I have written about how to build a Simple Django blog with appengine. You can find the tutorial here, http://www.42topics.com/dumps/appengine/doc.html. This documents what I learnt playing with appengine yesterday, and is very much a work in progress. This doc is released under CreateCommon liscence, so please feel free to modify, (The rest source for this doc is at http://www.42topics.com/dumps/appengine/docs.txt) and add what you learnt from it. If you use this tutorial, and have problems, please ask them in this thread, and I will only be too happy to help. You can download this working from http://www.42topics.com/dumps/appengine/appenginetest1.zip --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Anybody successfully deployed Django to appengine? Having some problems
I am trying to follow http://code.google.com/appengine/articles/django.html Which has a line # Log errors. django.dispatch.dispatcher.connect( log_exception, django.core.signals.got_request_exception) but log_exception is not defined/imported, so it gives a NameError. I guess they left the correct import. By removing this line I can get the app to run, but it does not send the tracebacks to admin console. Any body knows the correct import to use here? --~--~-~--~~~---~--~~ 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: Anybody used Google app engine, and wanna share their experience?
Ya same here. Will try to play around with it later tonight, but first looks say running django apps with only modifying the db part should be possible. On Apr 8, 10:41 am, davenaff <[EMAIL PROTECTED]> wrote: > I think everyone was given a denied message initially. I got an > acceptance note around 10:15, but haven't had time to play around with > it yet. > > On Apr 7, 9:14 pm, shabda <[EMAIL PROTECTED]> wrote: > > > I got the news too late, and no more invites were avialable. Anyone > > who is using this, and their views ... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
cursor.execute throws exception on MySql warning
I have a call like, crsr = connection.cursor() crsr.execute('DROP TABLE IF EXISTS news_linksearch') when table news_linksearch does not exists this would lead to a mysql warning, (Not an error, as it has a IF EXISTS clause), but this leads to a django exception. Should not the behaviour in this case be not raising an exception? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Anybody used Google app engine, and wanna share their experience?
I got the news too late, and no more invites were avialable. Anyone who is using this, and their views ... --~--~-~--~~~---~--~~ 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: When does form.clean get called?
So is there a cleaner way to work in form.clean instead of doing if for.cleaned_datahas_key(field): for every element? On Apr 7, 6:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Mon, Apr 7, 2008 at 8:19 AM, shabda <[EMAIL PROTECTED]> wrote: > > > If I have a required field and I do not specify a value for the field, > > should form.clean get called? My understanding, after reading > > >http://www.djangoproject.com/documentation/newforms/#custom-form-and-... > > , > > is that it should not, as clean_ will fail, and so form.clean > > will not be called. However this is not happening with my code, > > details follow. > > > I have a form like [http://dpaste.com/43538/] > > > [code snipped] > > From the page you linked to: > > The clean() method for the Form class or subclass is always run. If that > method raises a ValidationError, cleaned_data will be an empty dictionary. > This approach allows you to flag all errors in the submitted data at once, > versus having to force the user through a painful one-by-one > fix-and-resubmit cycle for a form with multiple errors. > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
When does form.clean get called?
If I have a required field and I do not specify a value for the field, should form.clean get called? My understanding, after reading http://www.djangoproject.com/documentation/newforms/#custom-form-and-field-validation, is that it should not, as clean_ will fail, and so form.clean will not be called. However this is not happening with my code, details follow. I have a form like [http://dpaste.com/43538/] class LoginForm(forms.Form): """Login form for users.""" username = forms.RegexField(r'^[a-zA-Z0-9_]{1,30}$', max_length = 30, min_length = 1, widget = widgets.TextInput(attrs={'class':'input'}), error_message = 'Must be 1-30 alphanumeric characters or underscores.', required = True) password = MarkedField(min_length = 1, max_length = 128, widget = widgets.PasswordInput(attrs={'class':'input'}), label = 'Password', required = True) remember_user = forms.BooleanField(required = False, label = 'Remember Me') def clean(self): import pdb pdb.set_trace() super(LoginForm, self).clean() try: user = User.objects.get(username__iexact = self.cleaned_data['username']) except User.DoesNotExist, KeyError: raise forms.ValidationError('Invalid username, please try again.') if not user.check_password(self.cleaned_data['password']): raise forms.ValidationError('Invalid password, please try again.') return self.cleaned_data If I do not specify anything for username, password, I am getting a keyerror. (While I am expecting a vlidation error.) If I change my code to, class LoginForm(forms.Form): """Login form for users.""" username = forms.RegexField(r'^[a-zA-Z0-9_]{1,30}$', max_length = 30, min_length = 1, widget = widgets.TextInput(attrs={'class':'input'}), error_message = 'Must be 1-30 alphanumeric characters or underscores.', required = True) password = MarkedField(min_length = 1, max_length = 128, widget = widgets.PasswordInput(attrs={'class':'input'}), label = 'Password', required = True) remember_user = forms.BooleanField(required = False, label = 'Remember Me') def clean(self): import pdb pdb.set_trace() try: if self.cleaned_data.has_key('username') : user = User.objects.get(username__iexact = self.cleaned_data['username']) except User.DoesNotExist, KeyError: raise forms.ValidationError('Invalid username, please try again.') if self.cleaned_data.has_key('password') and not user.check_password(self.cleaned_data['password']): raise forms.ValidationError('Invalid password, please try again.') return self.cleaned_data This works as expected. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Making login work with every page.
If a user is not logged in, then on each page, I have a login form. This form posts to /accounts/login/ which does calls contrib.auth.views.login. This view only logs in a user if the session.test_cookie_worked(). So this means that from each page I need to call, if not request.user.is_authenticated(): if not request.session.test_cookie_worked(): request.session.set_test_cookie() Is there a easier way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Weird unicode errors when using cutsom sql
Ouch, there was a % in the generated SQL. Guess I should have debugged a little more before posting here. :) On Apr 5, 1:44 pm, shabda <[EMAIL PROTECTED]> wrote: > I am using MYSql with latin-1 encoding. > > I get some weird intermittent errors when using custom sql. I have a > large programatically generated sql, and when I try to run this as > cursor.execute(sql), it works sometime but fails other times. The only > big difference I can see between the sqls is that whenever it fails it > has a unicode char. Traceback follows. Any pointers where I should be > looking to solve this problem. > > G:\tapicks\news\cron.py in find_recommeneded_for_username(username) > 114 import pdb > 115 pdb.set_trace() > --> 116 cursor.execute(sql) > 117 return cursor.fetchall() > 118 > > C:\Python24\lib\site-packages\django\db\backends\util.py in > execute(self, sql, params) > 19 finally: > 20 stop = time() > ---> 21 sql = self.db.ops.last_executed_query(self.cursor, > sql, params) > 22 self.db.queries.append({ > 23 'sql': sql, > > C:\Python24\lib\site-packages\django\db\backends\__init__.py in > last_executed_query(self, cursor, sql, params) > 148 u_params = dict([(to_unicode(k), to_unicode(v)) > for k, v in params.items()]) > 149 > --> 150 return smart_unicode(sql) % u_params > 151 > 152 def last_insert_id(self, cursor, table_name, pk_name): > > TypeError: not enough arguments for format string --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Weird unicode errors when using cutsom sql
I am using MYSql with latin-1 encoding. I get some weird intermittent errors when using custom sql. I have a large programatically generated sql, and when I try to run this as cursor.execute(sql), it works sometime but fails other times. The only big difference I can see between the sqls is that whenever it fails it has a unicode char. Traceback follows. Any pointers where I should be looking to solve this problem. G:\tapicks\news\cron.py in find_recommeneded_for_username(username) 114 import pdb 115 pdb.set_trace() --> 116 cursor.execute(sql) 117 return cursor.fetchall() 118 C:\Python24\lib\site-packages\django\db\backends\util.py in execute(self, sql, params) 19 finally: 20 stop = time() ---> 21 sql = self.db.ops.last_executed_query(self.cursor, sql, params) 22 self.db.queries.append({ 23 'sql': sql, C:\Python24\lib\site-packages\django\db\backends\__init__.py in last_executed_query(self, cursor, sql, params) 148 u_params = dict([(to_unicode(k), to_unicode(v)) for k, v in params.items()]) 149 --> 150 return smart_unicode(sql) % u_params 151 152 def last_insert_id(self, cursor, table_name, pk_name): TypeError: not enough arguments for format string --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Transactions with custom sql
I am using mysql ith InooDB. I have some cutsom sql doing inserts. These inserts are not visible after the function returns, if I so something like sql = 'INSERT INTO tbl1 ...' from django.db import connection cursor = connection.cursor() cursor.execute(sql) return cursor.fetchall() However if I do something like cursor.execute("set autocommit = 1") and then do the above code the inserts are visible in a dirrent mysql session. So how does django transaction management work with custom sql, and would my calling cursor.execute("set autocommit = 1") interfare with 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 -~--~~~~--~~--~--~---
How to pass location to profiler.hotshot?
By default profiler.hostshot[1] creates profiling info in "/var/log/ cmsprofile". I am on a shred hosting, and do not have access to this location. Is there any way I can specify the location without modifying this django file. Currently this values is hardcoded into this file as PROFILE_DATA_DIR = "/var/log/cmsprofile" Should not this be a settings.py variable? http://code.djangoproject.com/browser/django/trunk/django/core/handlers/profiler-hotshot.py --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Making TransactionMiddleware play nice with processException
I have TransactionMiddleware in my settings.py, to tie transactions to HttpRequests. I also have a custom mIddleware which has a processException, it catches the Exceptions and returns user friendly responses for the exceptions. This means that TransactionMiddleware thinks that exception was not raised, and the changes are commited. Is there some thing I can do so that TransactionMiddleware can rollback the changes and then my Middleware catch the exception and return user friendly 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 -~--~~~~--~~--~--~---
Using CsrfMIddleware with ajax post requests
I have a some links, simple like .. . I handle clicks on them as ajax, and do a post . I want to protect this post against CSRF attacks, but CsrfMiddleware works only for form posts, because it add a form field. Is there some way I can get the CsrfMiddleware to work with ajax posts? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Optional else block in for
I was looking at jinja[1] and there was one feature which I really liked "for loops have an optional else block executed if there was no iteration." Right now most of my for loops are like, {% if comments %} {% for comment in comments %} {{comment}} {% endfor %} {% else %} There are no comments. {% endif %} It would be much `cooler` to write {% for comment in comments %} {{comment}} {% else %} There are no comments. {% endfor %} Of course this is not a huge improvement, but I need to do this so many times, might be this is a common use case. :) --~--~-~--~~~---~--~~ 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: sports ratings
Read this, www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/ , and create a standalone django script. Then set up a cron job to run your script when you want. On Mar 29, 11:53 pm, ameriblog <[EMAIL PROTECTED]> wrote: > i have my own formula used for sports ratings (like jeff sagarin, the > bcs, etc). right now i have an old Visual Basic code that updates the > ratings and i just save it as a text file and ftp to the web. i'd > really love to make it dynamic, so it presents better ( > likehttp://kenpom.com/rpi.php), but also giving me the option of better > utilizing the data and do some other studies easily. > > i new to django, i'm experienced with php. i could do it in php no > doubt, but am really looking at doing a few projects in django as > learning experiences. > > the formula isn't complex essentially an adjusted winning percentage > (wins / games played). the tricky part is doing iterations until the > ratings stabilize, right now i'm the ratings average out to 0.5 and i > iterate the ratings over and over until none of them change more than > 0.1. > > my dealings with django have been setting up like a blog, so i'm > comfortable in writing everything to do with outputting the info once > it's computed, but haven't done anything where it's a script/code that > only i run, once a week that computes the ratings. > > any tips/tutorials on doing stuff like this? --~--~-~--~~~---~--~~ 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 are you storing binary data in db
Yes I was looking for snippets and recipes, not storing them in DB. There are some instances when storing things in DB is just too convinient comaring to storing them on files. For example I get some JSON from a external web service call. I want to cache it in the system, so I want to just pickle it and dump it i the db. Blob would be very nice here. On Mar 28, 10:48 am, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote: > I think he meant recipes in that are there any recipes to accomplish > this (storing binary data to the DB). Unless I'm getting this > completely wrong, he was not talking about cooking recipes :). > > I would be interested in a solution for this too. There are cases > where apps running as the apache/web user do not have write > permissions to the local FS (an example would be the sourceforge > servers). In these situations, having your db store this information > is the only way to go. > > Best, > > R > > On Fri, Mar 28, 2008 at 7:45 AM, Dan Ellis <[EMAIL PROTECTED]> wrote: > > > On Mar 27, 9:05 pm, Mike H <[EMAIL PROTECTED]> wrote: > > > > Reading large > > > chunks of file data from a db just wastes db resources > > > A recipe is unlikely to be a large chunk of file data. Pictures of > > food, sure, don't store those in the DB. Storing the text in the DB > > also means you can make use of its full text searching capability. --~--~-~--~~~---~--~~ 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 check the SQL that the Django ORM is executing?
wouldn't getting the queries from connection.queries be abetter approach? On Mar 28, 1:15 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > http://www.djangoproject.com/documentation/faq/#how-can-i-see-the-raw... > > or > > you can make a function like this: > > In [19]: def show_sql(query): >: clauses = query._get_sql_clause() >: return 'SELECT %s %s' % (', '.join(clauses[0]), > clauses[1]) >: > > In [21]: show_sql(Page.objects.all()) > Out[21]: 'SELECT "main_page"."id", "main_page"."title", > "main_page"."slug", "main_page"."content" FROM "main_page" ORDER BY > "main_page"."id" ASC' > > On Mar 27, 3:01 pm, qwerty <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > I want so see the SQL that the Django ORM is executing behind the > > scenes. I know that SQLObject has this but I wanted to see if there is > > some similar functionality in Django. Is it? > > > Thanks, > > Angel --~--~-~--~~~---~--~~ 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 are you storing binary data in db
Considering that BlobField is not supported, what are you using to store binary data. Recipes, snippets .. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Is identity map planned for Django ORM?
A test case showing the problem http://dpaste.com/41542/ . I always get bitten by this behaviour when I am writing tests. There was a discussion long ago about adding this feature of Identity maps http://groups.google.com/group/django-users/browse_thread/thread/56698424ae3708ea/88496cb950e75c37?lnk=gst&q=identity+map#88496cb950e75c37 , a very long time ago. Is this feature planned anytime soon? --~--~-~--~~~---~--~~ 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: Log a user in after registration?
You need to call authenticate() before you can call login() http://www.djangoproject.com/documentation/authentication/#how-to-log-a-user-in On Mar 26, 10:52 pm, truebosko <[EMAIL PROTECTED]> wrote: > I want to log a user in after they have registered on my site. > > Right now, I am using django-registration to handle user registration > but it is modified to not have activation. I know it doesn't really > matter what I am using as all the login is handled by > django.contrib.auth > > I've looked in the files and tried to replicate it, but all I get is > various errors. I am probably doing it horrilbly wrong. I simply want > to pass in the users new information, and then have it log them in > > I've tried doing: > login(request, new_user) after my user has registered, new_user is > the info I get from registering. > > login is referencing: from django.contrib.auth import login (I import > it right beofre that line). I've gotten the following error now: > > 'User' object has no attribute 'backend' > Request Method: POST > Request URL:http://localhost:8000/accounts/register/ > Exception Type: AttributeError > Exception Value:'User' object has no attribute 'backend' > > Here is my registration code and where I am calling login. What is > wrong with this? > if request.method == 'POST': > form = form_class(request.POST) > if form.is_valid(): > new_user = form.save(profile_callback=profile_callback) > > from django.contrib.auth import login > login(request, new_user) > > return HttpResponseRedirect(success_url) > else: > form = form_class() > return render_to_response(template_name, > { 'form': form }, > context_instance=RequestContext(request)) --~--~-~--~~~---~--~~ 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 do background processing with Django
Not the end user but the people who would be downloading this application, and want to use this, in a shared hosting environment. On Mar 26, 7:39 pm, "Ian Lawrence" <[EMAIL PROTECTED]> wrote: > Hi > > > are django and apache. Adding a HTTP server or configuring django- > > queuing is too painful for the average user. :( > > what does the end user have to do with this? > you have a server by doing > wgethttp://svn.cherrypy.org/trunk/cherrypy/wsgiserver/__init__.py-O > wsgiserver.py > and setting up xml-rpc is not much more than this...i did this recently > athttps://help.ubuntu.com/community/UMEGuide/ApplicationDevelopment/GPS... > and it is pretty simple to do (and really the best way IMO to run > background processes) > > Ian > > --http://ianlawrence.info --~--~-~--~~~---~--~~ 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 do background processing with Django
The problem with these aproaches is that they add an extra layer of things to do. I want to package it so that the only required things are django and apache. Adding a HTTP server or configuring django- queuing is too painful for the average user. :( On Mar 26, 2:28 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Mar 26, 7:58 pm, shabda <[EMAIL PROTECTED]> wrote: > > > I response to some urls, my views need to start some potentially time > > taking actions. So how can I start background process, would it be as > > simple as > > > ... > > t = threading.Thread(...) > > t.setDaemon(True) > > t.start() > > return HttpResponse(..) > > > Or does django/apache have limitation on how threading can be used? > > Would my thread be killed, once the response is sent back? > > You are much much better off having a back end process which embeds a > mini HTTP server set up to respond to XML-RPC requests. The Apache/ > Django processes can then make an XML-RPC request to the long running > persistent back end process which then does the work in a separate > thread, via some form of queuing mechanism and thread pooling > mechanism as needs be to keep number of active threads down, or using > other means as appropriate. > > Being in a single back end process, you can then also support XML-RPC > requests to check on status of jobs being done, cancel jobs etc etc. > You also don't then have to deal with the fact that Apache is > multiprocess and subsequent requests may not come back to the same > process if something needs to query outcome of job. You also don't > have to deal with possibility of Apache killing off one its processes, > which might contain running jobs, when it is recycling its processes. > > Graham --~--~-~--~~~---~--~~ 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 often do you update your django?
And if you are on windows, TortoiseSvn is a great way to get strated with svn. On Mar 26, 3:06 pm, James Tauber <[EMAIL PROTECTED]> wrote: > It might be worth adding that this approach works for Django because > development takes place on branches not the trunk. Other open source > projects may use the trunk for development, in which case what people > are saying about how often they update Django won't apply to those > projects. > > Just thought I'd add that as the original poster is new to getting > stuff from svn. > > James > > On Mar 25, 2008, at 12:58 PM, Justin Lilly wrote: > > > I update it every time I'm reminded of it (I just updated), at the > > end of a sprint or when I get errors (in hopes it was a bug that was > > fixed). > > > -justin > > > On Tue, Mar 25, 2008 at 12:50 PM, jmDesktop > > <[EMAIL PROTECTED]> wrote: > > > How often do you use svn to get the latest django and update your > > implementation? I'm new to all of this and never have used cvs or svn > > and am trying to figure out the best way to use it. > > > -- > > Justin Lilly > > Web Developer/Designer > >http://justinlilly.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 -~--~~~~--~~--~--~---
How to do background processing with Django
I response to some urls, my views need to start some potentially time taking actions. So how can I start background process, would it be as simple as ... t = threading.Thread(...) t.setDaemon(True) t.start() return HttpResponse(..) Or does django/apache have limitation on how threading can be used? Would my thread be killed, once the response is sent back? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Object paginator deprecated?
What are he new capbilities of the new paginator? Is there some wiki page tracking the deprications, like the backwardsincompatible changes? --~--~-~--~~~---~--~~ 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: Should not select related be default?
Ah, but practicality beats purity :) But of course I have not fully profiled, the times so might be not select_related as default is a good idea. On Mar 24, 5:40 pm, "Tom Badran" <[EMAIL PROTECTED]> wrote: > On Mon, Mar 24, 2008 at 11:03 AM, shabda <[EMAIL PROTECTED]> wrote: > > > In most of my pages, select_related dramatically reduces the number of > > queries the page is needing, so I was wondering what is the reason > > behind not making select_related default and providing a method for > > do_not_select_related > > Explicit is better than implicit > > Try an "import this" on a python shell. > > Tom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Should not select related be default?
In most of my pages, select_related dramatically reduces the number of queries the page is needing, so I was wondering what is the reason behind not making select_related default and providing a method for do_not_select_related --~--~-~--~~~---~--~~ 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: Easy PDF generation using PISA HTML2PDF
I have used html2pdf in the past and it is awfully easy! In one of my apps, I had a requirement that each page be also available as pdf. so def view_func(self): ..normal processing if request.GET.has_key('pdf'): #Get the pdf template html = StringIO.StringIO(template.render(Context(payload))) result = StringIO.StringIO() pdf = pisa.CreatePDF(html, result) return HttpResponse(result.getvalue(), mimetype='application/ pdf') On Mar 24, 2:25 am, coulix <[EMAIL PROTECTED]> wrote: > Thanks ! > Easier than reportlab :) > Greg > > On Mar 23, 7:37 pm, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Hi, > > > I updated pisa which now includes a complete Django example. > > >http://pypi.python.org/pypi/pisa/3.0.17 > > > Enjoy it. > > Dirk --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Appending a variable to the query string for the current URL
On each of my pages I want to show a link, which outputs the current page in pdf. To do so I want to append ?pdf=1 or &pdf=1 to the current url. I do so using the code if request.META['QUERY_STRING']: pdfpath = '%s&pdf=1' % request.get_full_path() else: pdfpath = '%s?pdf=1'% request.get_full_path() and in the template. Is there a simpler way? (Some template tag maybe?) --~--~-~--~~~---~--~~ 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 get unclean data from newform?
Even after reading those two links I can not figure out the answer to my question. :( Brot wrote: > Hello, > > http://www.b-list.org/weblog/2007/nov/22/newforms/ > http://blog.michaeltrier.com/2007/11/23/getting-started-with-newforms > > Bernd > > On 26 Feb., 07:28, shabda <[EMAIL PROTECTED]> wrote: > > I have a newform form. It has data bound to it. But it may be invalid. > > I want to get the data bound to each of its field. How can I do this? > > I can not use form.cleaned_data because that would work only when the > > form was valid. If I try > > for name, value in form.fields.iteritems(): > >print name, value > > > > This prints , while I want the > > values. --~--~-~--~~~---~--~~ 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 get unclean data from newform?
I have a newform form. It has data bound to it. But it may be invalid. I want to get the data bound to each of its field. How can I do this? I can not use form.cleaned_data because that would work only when the form was valid. If I try for name, value in form.fields.iteritems(): print name, value This prints , while I want the values. --~--~-~--~~~---~--~~ 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 Filebrowser with FastCGI
I think, In a lot of old code, _ was automatically imported as ugettext, while the newer code explicitly imports it as from django.utils.translation import ugettext_lazy as _ Might be when you are running fastcgi, you are hitting some path where, _ is not imported, while under mod_python, you are hitting paths where they are defined. (All this is just a guess.) On Feb 24, 3:35 pm, patrickk <[EMAIL PROTECTED]> wrote: > hi stephane, > > i´ve never used the filebrowser with fastcgi. not sure whether this is > a django or a filebrowser-issue. > maybe someone with more experience using fastcgi has an idea ... > > patrick > > On Feb 23, 3:12 pm, Rufman <[EMAIL PROTECTED]> wrote: > > > Hey Guys > > > I'm using the django filebrowser (http://code.google.com/p/django- > > filebrowser/) for my django site. When I run it on my local server > > using Apache and mod_python I don't have any problems. But when I > > attempt to use the filebrowser through fastcgi I get the error global > > ' _' not defined. I'm relatively new to django and python, but I found > > out that the variable '_' holds the last not None result (in the > > python interactive interpreter). > > > Any help/ideas are welcome ...thanks > > > Stephane --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: File uploads with django - memory usage questions
Read that patch, but considering that this has not been merged, I think are soem known issues with this patch. Reading it, I cant figure out, what the pros, cons are. Any help? Suppose I do not apply this patch, the is there some way to specify that django not accept any file above a fixed size. Or should this setting be specified somewhere in apache config? On Feb 24, 3:46 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > There is a ticket related to this:http://code.djangoproject.com/ticket/2070 > there is a patch that based on the comments should work. > > On Feb 23, 2:48 pm, shabda <[EMAIL PROTECTED]> wrote: > > > I have a form which allows users to upload files. > > > The form is, > > class AddFileForm(forms.Form): > > """Add a file.""" > > filename = forms.FileField() > > > I am using S3 to store files, my view is something like, > > > if request.method == 'POST': > > addfileform = bforms.AddFileForm(request.POST, request.FILES) > > if addfileform.is_valid(): > > conn = S3.AWSAuthConnection(secrets.aws_id, > > secrets.aws_key) > > filename = '/%s/%s' % (project, > > addfileform.cleaned_data['filename'].filename) > > response = conn.put(bucket, filename, > > addfileform.cleaned_data['filename'].content) > > > So my question is would using a call like > > addfileform.cleaned_data['filename'].content in my view mean that if > > an user uploads a 100 MB file, the server would have that data in > > memory? What can I do to counter this? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
File uploads with django - memory usage questions
I have a form which allows users to upload files. The form is, class AddFileForm(forms.Form): """Add a file.""" filename = forms.FileField() I am using S3 to store files, my view is something like, if request.method == 'POST': addfileform = bforms.AddFileForm(request.POST, request.FILES) if addfileform.is_valid(): conn = S3.AWSAuthConnection(secrets.aws_id, secrets.aws_key) filename = '/%s/%s' % (project, addfileform.cleaned_data['filename'].filename) response = conn.put(bucket, filename, addfileform.cleaned_data['filename'].content) So my question is would using a call like addfileform.cleaned_data['filename'].content in my view mean that if an user uploads a 100 MB file, the server would have that data in memory? What can I do to counter this? --~--~-~--~~~---~--~~ 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 compare between two attributes of the model?
I have a model like, class Project(models.Model): name = models.CharField() expected_start_date = models.DateField() actual_start_date = models.DateField() I want to translate the SQL query, SELECT * FROM project WHERE expected_start_date > actual_start_date, I cant do something like Project.objects.filter( expected_start_date__gt = actual_start_date), so how can I translate the above sql query? --~--~-~--~~~---~--~~ 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.test.client.Client returns HttpResponse/ How to make the test client follow 302 status codes?
Please ignore the previous message. I think I am too sleepy now, and am seeing things which do not exist. :) . On Feb 22, 11:57 pm, shabda <[EMAIL PROTECTED]> wrote: > Aww, I seems a call to c.get('/dashboard/') gets an object of type > HttpResponse while c.get('/dashboard/', {}) gets a Response object. > > On Feb 22, 11:50 pm, shabda <[EMAIL PROTECTED]> wrote: > > > I have some test code written like, > > > def testDashBoard(self): > > c = Client() > > print c.login(username = 'Shabda', password= 'shabda') > > response = c.get('/dashboard/') > > print response.headers['X-View'] > > > This is giving me error > > > == > > ERROR: testDashBoard (prajact.project.tests.TestUrls) > > -- > > Traceback (most recent call last): > > File "G:\prajact\project\tests.py", line 822, in testDashBoard > > print response.headers['X-View'] > > AttributeError: 'HttpResponse' object has no attribute 'headers' > > > But according to the documentation c.get must return objects of type > > reponse, and not HttpReponse. What am I doing wrong? > > > Also I want the test client to follow the HttpReponseRedirects, so > > that I can see the actual view which the user will see, but the test > > client does not do this by default. How can I do this? --~--~-~--~~~---~--~~ 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.test.client.Client returns HttpResponse/ How to make the test client follow 302 status codes?
Aww, I seems a call to c.get('/dashboard/') gets an object of type HttpResponse while c.get('/dashboard/', {}) gets a Response object. On Feb 22, 11:50 pm, shabda <[EMAIL PROTECTED]> wrote: > I have some test code written like, > > def testDashBoard(self): > c = Client() > print c.login(username = 'Shabda', password= 'shabda') > response = c.get('/dashboard/') > print response.headers['X-View'] > > This is giving me error > > == > ERROR: testDashBoard (prajact.project.tests.TestUrls) > -- > Traceback (most recent call last): > File "G:\prajact\project\tests.py", line 822, in testDashBoard > print response.headers['X-View'] > AttributeError: 'HttpResponse' object has no attribute 'headers' > > But according to the documentation c.get must return objects of type > reponse, and not HttpReponse. What am I doing wrong? > > Also I want the test client to follow the HttpReponseRedirects, so > that I can see the actual view which the user will see, but the test > client does not do this by default. How can I do this? --~--~-~--~~~---~--~~ 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.test.client.Client returns HttpResponse/ How to make the test client follow 302 status codes?
I have some test code written like, def testDashBoard(self): c = Client() print c.login(username = 'Shabda', password= 'shabda') response = c.get('/dashboard/') print response.headers['X-View'] This is giving me error == ERROR: testDashBoard (prajact.project.tests.TestUrls) -- Traceback (most recent call last): File "G:\prajact\project\tests.py", line 822, in testDashBoard print response.headers['X-View'] AttributeError: 'HttpResponse' object has no attribute 'headers' But according to the documentation c.get must return objects of type reponse, and not HttpReponse. What am I doing wrong? Also I want the test client to follow the HttpReponseRedirects, so that I can see the actual view which the user will see, but the test client does not do this by default. How can I do this? --~--~-~--~~~---~--~~ 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 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: 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: 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 -~--~~~~--~~--~--~---
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&q=queryset > +slicing#a6ce6074ceab7438http://groups.google.com/group/django-users/browse_thread/thread/ > 3b98ffd38969c49a/a56354e0c0e61a9a?lnk=gst&q=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 -~--~~~~--~~--~--~---
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 -~--~~~~--~~--~--~---
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 -~--~~~~--~~--~--~---
How to use filefield, and specify custom, dynamic upload_to
I have a model like class File(models.Model): file = models.FileField(upload_to = 'files') project = models.ForeignKey(Project) class Project(models.Model): name = models.CharField(max_length = 100) I want to have each file go a specific directory corresponding to its project_name So I want to do something like, class File(models.Model): file = models.FileField(upload_to = project.name) project = models.ForeignKey(Project) But of course this won work, as until the metaclass magic happens and I have an object project dos not have the name attribute. So how can I achieve this. --~--~-~--~~~---~--~~ 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: Setting request.GET when sending an HttpResponse
Umm, if you want to persist state across HTTP requests, why not use session? On Feb 14, 2:28 pm, mario <[EMAIL PROTECTED]> wrote: > Etienne, thanks for answering, > > > I believe you got this wrong a little. A HttpResponse object doesn't modify > > the query string. That should be done in your form markup, > > or even in a javascript file, in case you want to do it programmatically. > > Yes, I understand that a HttpResponse cannot modify the query string. > What I really want is a behavior, which looks like modifying the query > string, but in fact is a common submit/response practice that I do not > know how to implement. This is what I need: > - user enters a query form (through a 1st GET request), > - user selects some filtering options (e.g. combo, check box) and then > presses the submit button (thus I receive a POST request) > - system sends an HTTP response with the query result and the same > filtering options set by the user. However, I wish that the same > filtering options set by the user (that I received through a POST), do > also appear in the query string. > > Is there any way to do that? Or I'm completely wrong on what I'm > trying to do? > > I carefully read the Django "Request and response objects" docs, but I > can't find a strightforward way to get this behavior done. If you know > of any example or code snippet for such behavior, please let me know. > > On 13 Feb, 22:40, "Etienne Robillard" <[EMAIL PROTECTED]> > wrote: > > > I'll try to help ya a little... > > > > I receive a request via GET and, based on request.GET, I generare a > > > result and send a HttpResponse. However, when sending the response, > > > I'd like to set additional parameters in the query string. > > > > For example, suppose I receive the following request: > > > > http://domain.com/myurl/myform/?query=whatever > > > I believe you got this wrong a little. A HttpResponse object doesn't modify > > the query string. That should be done in your form markup, > > or even in a javascript file, in case you want to do it programmatically. > > > > Then, my form will query the database, build the result set and send a > > > initial HTTP response. Then the user will (for example) toggle a > > > "order by" option. Now, what I would like is to return a HttpResponse > > > but ALSO, extend the query string, for example > > > > http://domain.com/myurl/myform/?query=whatever&orderby=foo > > > > so that on the next request.GET I find the new "orderby" parameter. > > > Nothing prevent's you to use another view which could then handle > > this new POSTed parameter. > > > > This seems a tremendously common and simple problem. However, I'm not > > > finding a way to solve it. If I use a HttpResponseRedirect instead of > > > an HttpResponse, what I get is a "Found a cyclic link" problem. > > > > Any suggestion? > > > I suggest you > > read:http://www.djangoproject.com/documentation/request_response/ > > > Regards, > > Etienne --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Newfroms - How to get the id for a field
When using newforms, I want to get the id set on the input field. I am doing something like, {% for field in form %} {{ field }} ... Now this {{field}} will render as something like, Withing the template how can I access the value for id. If this is not possible where in code does Django set the value for id? (It seems to me to be newforms.form.BaseField.as_widget, I just can't figure out how! ) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---