Using distinct and ordering

2011-06-24 Thread Chris Matthews
#x27;s the correct way if you use ordering on another column. self.filter(town_name__istartswith='Randfo').values('town_name').distinct().order_by() - this works as I would have expected 'cos it drops the SQL ORDER BY. So it would be nice to do this: self.filter(town_name_

RE: Django app for data management and visualization

2011-04-07 Thread Chris Matthews
. I'll keep you guys updated on my progress and would love to get all your feedback on the direction I'm taking and if it's something that any of you can use on your projects. looking forward to it. cheers, Marwan On Thu, Apr 7, 2011 at 9:50 AM, Chris Matthews wrote: > Hi Marwan,

RE: Django app for data management and visualization

2011-04-06 Thread Chris Matthews
Hi Marwan, I am considering an "Excel Export" button wherever I have a table (or jQuery-UI grid). If you just want data sheets, before writing something, consider this: xlwt 0.7.2 Library to create spreadsheet files compatible with MS Excel 97/2000/XP/2003 XLS files, on any platform, with Pytho

RE: using a models fields

2011-04-05 Thread Chris Matthews
Hi Jay, I am no Geo expert but if you use the CharField then you can specify N/E/S/W (North/East/South/West) or + and - to control latitude & longitude. With the DecimalField you can only use the + and -. BTW, Marty Alchin's book Pro Django (Chapter 5 page 118), shows a nice example to validat

RE: Python Decorators

2011-04-05 Thread Chris Matthews
Hi cootetom, For decorators you must have a look at the excellent articles/tutorials: http://www.artima.com/weblogs/viewpost.jsp?thread=240808 http://www.artima.com/weblogs/viewpost.jsp?thread=240845 It covers decorators with (what you want to do) and without parameters. Regards

RE: How to check the text field values are in my database or not ?

2011-03-31 Thread Chris Matthews
Hi Nge, Use pgAdmin that was installed with your postgresql. Open a connection to your database->Schema->Public->Tables. Right-click on your table and click on View data and then take one of the view options. You can also open a SQL window and run the SQL select yourself. See pgAdmin's help.

RE: staticfile app question

2011-03-31 Thread Chris Matthews
Hi, I liked this explanation/convention http://forum.webfaction.com/viewtopic.php?id=4345 (I opted for this one). If you want more consider django-css https://github.com/dziegler/django-css#readme (I have not tried this). Regards Chris -Original Message- From: django-users@googlegroup

RE: multiline TextField

2011-03-31 Thread Chris Matthews
By using the Textarea widget: class SomeForm(forms.Form): description = forms.CharField(widget=forms.Textarea()) Regards Chris -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of electrocoder Sent: 31 March 2011 00:18 To: Djang

RE: model manager and request

2011-03-30 Thread Chris Matthews
Hi, 1) My need for getting the current user is that I want the following columns on all tables: created, created_by, updated and updated_by. So I defined this abstract class which I inherit from on all models: class AbstractCommonAll(models.Model): r''' All our tables will be defined with t

RE: ANN: Django 1.3 released

2011-03-23 Thread Chris Matthews
@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Russell Keith-Magee Sent: 23 March 2011 12:47 To: django-users@googlegroups.com Subject: Re: ANN: Django 1.3 released On Wed, Mar 23, 2011 at 6:25 PM, Chris Matthews wrote: > I must add my SHA1 on Django-1.3.tar.gz

RE: ANN: Django 1.3 released

2011-03-23 Thread Chris Matthews
I must add my SHA1 on Django-1.3.tar.gz is 63e62f9a4834c1c8dbb591aac4ef2b1b84c5ea63 (on all of the downloads I did). From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Chris Matthews Sent: 23 March 2011 12:20 To: django-users@googlegroups.com Subject: RE

RE: ANN: Django 1.3 released

2011-03-23 Thread Chris Matthews
Well done! Thanks for all the hard work. I downloaded my version from http://www.djangoproject.com/download/ and Chrome says it comes from http://media.djangoproject.com/releases/1.3/Django-1.3.tar.gz 7zip says "Data error in Django-1.3.tar' File is broken". I have downloaded it a few times with

RE: Tracking Row changes

2011-02-24 Thread Chris Matthews
Hi Andre, Also have a look at: http://code.google.com/p/django-history-tables/ and http://qr7.com/2010/10/django-simple-history-ftw/ by Corey Bertram based on book ProJango by Marty Alchin Chapter 11 (page 263 onwards) Regards Chris From: django-users@googlegroups.com [mailto:django-users@google

RE: field choices() as queryset?

2011-02-24 Thread Chris Matthews
Typo choices.append((item.name, item.name)) should be choices.append((item.id, item.name)) From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Mike Ramirez Sent: 24 February 2011 14:10 To: django-users@googlegroups.com Subject: Re: field choices() as queryset?

RE: urls.py and views.generic issue

2011-02-22 Thread Chris Matthews
(r'^(?P\d{4})/(?P\[a-z]{3})/(?P\w{1,2})/ $','archive_day',dict(info_dict,template_name='blog/list.html')), (r'^(?P\d{4})/(?P\[a-z]{3})/$','archive_month', dict(info_dict, template_name='blog/list.html')), (r&

RE: urls.py and views.generic issue

2011-02-20 Thread Chris Matthews
It also seems that the space preceding the caret ^ should not be there So ^blog/ ^(?P\d{4})/$ Should be ^blog/^(?P\d{4})/$ -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of jnns Sent: 20 February 2011 03:07 To: Django users

RE: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
you Chris Matthews for your reply. I'm working on a online examination system. I could able to generate some random questions from a data base containg hundreds of questions. So when ever a user answer and submit those random questions a dictionary contating a "Question_id and Answer&quo

RE: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
Oh and you probably wanted: if request.method=="POST": data = request.POST id_list = [int(x) for x in data.values()] questions = MyModel.objects.filter(id__in = id_list) From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behal

RE: list indices must be integers not unicode

2011-02-18 Thread Chris Matthews
Hi Balu, Numeric data from the form must be converted to int. I suspect you wanted to index data; not id_list. if request.method=="POST": data = request.POST temp_list = data.keys() id_list = [] for i in temp_list: id_list.append(id_li

RE: How to Auto fill fields on Save in Django Admin?

2011-02-16 Thread Chris Matthews
Hi Matteius, You must set blank=True in the model so that the form can be returned to you with those fields empty and then you fill it in the save(). pub_date = models.DateTimeField(blank=True) author = models.ForeignKey(User, blank=True, verbose_name='Author') Also read up on editable=

RE: how can I filter related (foreign key) objects?

2011-02-16 Thread Chris Matthews
Hi Serek, Try this def doMagic(self): date = '2010-05-04' #//here I need to take 10 conencted Bbb objects whcich data is less then date previous10days = Bbb.objects.filter(date__lt=date).order_by('data') Also read up about managers http://docs.djangoproject.c

RE: form select box how to (help needed)

2011-02-16 Thread Chris Matthews
Hi Bobby, See http://adil.2scomplement.com/2008/05/django-add-choices-to-form-fields-on-runtime/ Try something like the following: # Define your choices LOCATION_CHOICES = ((1,'location1'), (2,'location2'), (3,'location3'), (4,'locatio

RE: 'str' object is not callable

2011-02-16 Thread Chris Matthews
Hi Patrick, You can typically get it by: 1)missing the % for a string format: x = "Hello number %d" (5) TypeError: 'str' object is not callable 2) And if you overwrite a function name with a string, e.g." >>> min(5,2,3) 2 >>> hour,min,sec = "14:59:03".split(":") >>> m

RE: Importing modules in code

2011-02-16 Thread Chris Matthews
Hi Galago, For some conventions see http://docs.djangoproject.com/en/dev/internals/contributing/?from=olddocs#django-conventions and http://www.python.org/dev/peps/pep-0008/ Generally I do imports at the top of the module in this order (with a blank line inbetween): 1. python modules 2.

RE: Progress Bar/ProgressBarUploadHandler Documentation Examples

2011-02-15 Thread Chris Matthews
Hi Hank, I just got the book "jQuery UI 1.7" by Dan Wellman. Chapter 8 covers Progressbar. Have not worked through it yet so I can't give my view on it. Regards Chris -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of hank23 Sent:

RE: Saving multiple records from admin list page

2011-02-15 Thread Chris Matthews
Hi Sithembewena, If you want to monitor changes to tables then you might also be interested in keeping audit/history records. See the book ProJango by Marty Alchin Chapter 11 (page 263 onwards) and http://qr7.com/2010/10/django-simple-history-ftw/ by Corey Bertram Regards Chris From: django-

RE: Django Form Doesn't Render

2011-02-14 Thread Chris Matthews
Hi Dean, Looks like you pass the class ContractForm in to your render (and not the variable contractForm). Also on naming (PEP 8) contract_form would have been nicer for the variable (and would have stood out more so that the error was easier to spot). Regards Chris -Original Messa

RE: Need a tutorial for 'regexpr'

2011-02-10 Thread Chris Matthews
) nmatches = nmatches + 1 Insert (de-dented once, same as for line 148): #_Start Chris Matthews 10 May 2005 self.grouplist.insert(END, "Named Groups:") GroupDict = m.groupdict()

RE: Adding popups for edit

2011-02-02 Thread Chris Matthews
Hi Marco, Again the book "Django JavaScript Integration: AJAX and jQuery" by Jonathan Hayward. In Chapter 6 he covers jQuery In-place editing by using http://www.appelsiini.net/projects/jeditable PS: I have never met Jonathan, I live far-away in Africa, so I am not plugging his book. I happen

RE: Filtered drop down choice django

2011-02-02 Thread Chris Matthews
Hi Sushanth, I am currently working through the book "Django JavaScript Integration: AJAX and jQuery" by Jonathan Hayward. In Chapter 7 he covers autocomplete (see http://jqueryui.com/ or more specifically http://jqueryui.com/demos/autocomplete/) to handle filtered drop down. From: django-use

RE: Django SQL Query does not stop

2011-02-01 Thread Chris Matthews
Hi Ivo, SQL is like regular expressions. You can go complex (with one mega query/expression) but it could create a maintenance nightmare. See if you cannot simplify the query into multiple queries and a bit of code (for loops and using the joining columns) to lash them together. The code sequen

RE: Django Template CSS Load Path

2011-01-30 Thread Chris Matthews
change href='{{ MEDIA_URL }}/static/PageStyle.css' /> to href='{{ MEDIA_URL }}static/PageStyle.css' /> -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of octopusgrabbus Sent: 29 January 2011 21:17 To: Django users Subject: Re: Django

RE: abstract base class and overwriting save()

2011-01-28 Thread Chris Matthews
The "save def save(self, *args, **kwargs):" should not have the leading save. Also, if you are making a car system then this structure seems more appropriate: class CarMake(models.Model): ... class Car(models.Model): make = models.ForeignKey(CarMaker) ... def save(self, *args, **kwargs

RE: Challenge with installing django on windows 7 64 bit

2011-01-26 Thread Chris Matthews
1) Generally "not a valid archive" means the file was corrupted during the download/copy or the download/copy did not complete. If you used ftp to copy the file and the file mode settings was ASCII (not binary) then you can have a corrupt file (because CR 0x0D gets converted to CRLF 0x0D0A). If

RE: forbid clones

2011-01-26 Thread Chris Matthews
Have a look at unique_together: Django | Model Meta options | Django documentation http://docs.djangoproject.com/en/dev/ref/models/options/ Jump to unique_together‎: Options.unique_together¶. Sets of field names that, ... For convenience, unique_together can be a single list when dealing ... docs

RE: DB-Views or read-only tables in models

2011-01-25 Thread Chris Matthews
Not sure if http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/ will be of some help. See admin.site.disable_action('delete_selected') ; but this is only via the admin app. You could build some logic in the model by overriding the save() method, conditionally, based upon user. So your

RE: list of lists in template

2011-01-07 Thread Chris Matthews
{% for Ltarp in smth.3 %} SHOULD BE {% for Ltarp in smth.2 %} 'cos Lans only has 3 elements and Ltarp is Lans[2]. Chris -Original Message- From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On Behalf Of gintare Sent: 07 January 2011 08:52 To: Django users Sub