Re: ModelChoiceField queryset option

2009-06-11 Thread googletorp
Hi. You should take a read on the queryset api, that would help you a lot In the furture. For distinct values add .distinct() so you fx get ...filter(...).distinct() ~Jakob On Jun 11, 7:28 pm, Bobby Roberts wrote: > > The issue is the line: WebPage.objects.filter(page_plaque!='').  The > > quer

Re: Getting a distinct list of Users from two related Models

2009-06-09 Thread googletorp
You can do Users.objects.exclude(project__owner__isnull=True, other__model__isnull=True).distinct() ~Jakob On Jun 9, 7:49 pm, Streamweaver wrote: > I have two models with Foreign Key relationships to Users and what I'm > looking to do is reterive a unique list of u

Re: Slightly OT: Why use dpaste?

2009-06-04 Thread googletorp
dpaste is a good tool if you have a long code sample or traceback that are giving you some problems. Usually when responding to the thread with a solution, the poster with copy the relevant snippet making the dpaste obsolete for further references. This might not always be the case, but for most

Re: forms with ajax - how to use ModelForm?

2009-06-04 Thread googletorp
First of, when you use modelforms, you can instead do: if form.is_valid(): form.save() It doesn't make any difference to Django if you post the data via AJAX or regular form submit, the only thing you want to make different is probably the return value (redirect or json). This can be done usi

Re: TemplateSyntaxError

2009-05-28 Thread googletorp
You can do validation inside the template to check the data and raise errors accordingly. You can also check the data so you should be able to check if instance.property.id is a valid value and then only use it, if it is. It all comes down to how you would like your template tag to function. In so

Re: clean_ method not getting called

2009-05-25 Thread googletorp
Hi. I dont see anything wrong with the form code, could be the cod in your views that is causing the problem. Try posting that part aswell. ~Jakob On May 25, 11:27 pm, marstein wrote: > I have a ModelForm like this: > > > class PlanForm(forms.ModelForm): >     funds  = forms.ChoiceField(widget

Re: Selecting only published Articles

2009-05-25 Thread googletorp
Article.objects.filter(pub_status=1) You should look at the queryset api on docs.djangoproject.com ~Jakob On May 25, 10:48 pm, Alex Jonsson wrote: > Hey! > > In my Article model I have a pub_status which can be either 0 (draft) > or 1 (published). How can I make sure that every time I try to f

Re: validation and the ORM layer

2009-05-25 Thread googletorp
Django 1.1 is im pure bigfix and stabalization mode, to get it out asap, so they probably wont fix this issue for version 1.1 ~Jakob On May 25, 8:32 pm, martin f krafft wrote: > also sprach Alex Gaynor [2009.05.25.1945 +0200]: > > > Django does not currently support model-validation, there is

Re: How to convert 10 digit mysql date to django date format

2009-05-21 Thread googletorp
Hi It looks like a unix timestamp. I cant remember what python uses to convert unix to a date objecr but should be pretty simple. Maybe strftime/strptime or you can just google it. ~Jakob On May 22, 8:13 am, laspal wrote: > Hi, > > How to convert mysql 10 digit date format to django date format

Re: Using Ajax with django from different domain and technology

2009-05-21 Thread googletorp
Hi AJAX doesn't care what tech is serving the data as long as the format is what it expects (JSON). Doing cross domain AJAX calls it a bit more tricky, but you can do it with JSONP. It's not hard to setup when you have control of the json output. I know jQuery has it, but try to google it, there a