QuerySets - Reverse Look-Up for Index

2010-03-06 Thread Hasan Karahan
Hi, I'm wondering if there is an efficient way to look-up the index of a given object in a query-set? I'm using now the following approach: def get_index (id): bids = BID.objects.filter (..) obj2idx = dict (zip (bids, xrange (bids.count ())) bid = BID.objects.get (id=ID) return obj2idx (bid)

Django File Storage Issue

2010-03-06 Thread jechu
Hello, I'm curious as to how to correctly store user uploaded files to a database in Django. I was able to do this once in my django code, but I replicated this in another section and it doesn't work. Basically, I have added a new field in my model: img = models.ImageField(upload_to='folder/').

Re: IE not recognising media url

2010-03-06 Thread timdude
The depth of your generosity is overwhelming. Thank you for your help. Crisis averted! 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-us...@googlegroups.com. To unsubscribe from this group,

Re: problem with objects.get(id=None)

2010-03-06 Thread Karen Tracey
On Sat, Mar 6, 2010 at 7:46 PM, Ilya Braude wrote: > So perhaps a section in the documentation that talks about known quirks of > the various DB backends could help many people. > http://docs.djangoproject.com/en/1.1/ref/databases/#ref-databases Alternatively, there are

Re: IE not recognising media url

2010-03-06 Thread Sam Lai
I managed to reproduce it even when the JPG is saved locally, so it is something to do with the JPG format. Google tells me this - "the reason that two images don't show in IE is that they have been saved in CYMK format instead of RGB format."

Re: Django User Registration tutorial

2010-03-06 Thread Ilya Braude
Hudar wrote: Hello, I am new to django and still go through the tutorial. Just made a simple registration form using django and found this error : http://dpaste.com/168746/ Below are the register function I wrote : def register(request): if request.method == "POST": form =

Re: IE not recognising media url

2010-03-06 Thread timdude
Hey thanks Sam, the full URL is: http://media.bluecaravan.net/bluecaravan/view-cart.jpg I'm testing it on IE7, and this URL just brings up a red cross. Cheers, Tim -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

Re: IE not recognising media url

2010-03-06 Thread Sam Lai
On 7 March 2010 12:17, timdude wrote: > Yoyo, > > Why would IE not be able to see images served from templates that use > img src="{{ MEDIA_URL }}buttons/home.png" ...when they are visible in > other browsers...other than the fact that IE is crap. > > .but seriously,

IE not recognising media url

2010-03-06 Thread timdude
Yoyo, Why would IE not be able to see images served from templates that use img src="{{ MEDIA_URL }}buttons/home.png" ...when they are visible in other browsers...other than the fact that IE is crap. .but seriously, why would this be happening? Cheers, Tim -- You received this message

Re: problem with objects.get(id=None)

2010-03-06 Thread Ilya Braude
Masklinn wrote: On 6 Mar 2010, at 05:43 , Ilya Braude wrote: Karen Tracey wrote: I'm guessing you are using MySQL That's just how it behaves, by default. See: http://dev.mysql.com/doc/refman/5.1/en/server-session-variables.html#sysvar_sql_auto_is_null Wow, thanks. I now see

Re: ForeignKey / ManyToManyField / admin interface

2010-03-06 Thread Matthew Warren
Ok, thanks for the reply. I had wondered along those lines myself, and changed the code to; class elements(models.Model): name=models.CharField(max_length=21) elementgroup=models.ForeignKey(grouping) class grouping(models.Model): name=models.CharField(max_length=48) Though now when

Django User Registration tutorial

2010-03-06 Thread Hudar
Hello, I am new to django and still go through the tutorial. Just made a simple registration form using django and found this error : http://dpaste.com/168746/ Below are the register function I wrote : def register(request): if request.method == "POST": form =

newbie - query not working!! Help please!!

2010-03-06 Thread uthaman
url: url(r'top25/(?P\d{1})/$', views.top25_test, name='top25_test'), view: def top25_test(request, poll): entry = Poll.objects.filter(poll_id=poll) model: class Poll(models.Model): PUBLISHED_STATUS = 1 DARK_STATUS = 2 STATUS_CHOICES = (

Count number of objects with no ManyToMany connections

2010-03-06 Thread Rob Carlson
I want to find how many Resources in my dataset have no Widgets associated with them. Resources and Widgets have a ManyToMany relationship: class Resource(models.Model): widgets = models.ManyToManyField(Widget, null=True, blank=True) I finally settled on the code below, but I was wondering

django+modelform+Foreignkey

2010-03-06 Thread Arkeoloji.web.tr
Hi all, I have some ModelForms.. This ModelForms based some ForeignKey included models. When i want to create a ModelForm I got these ForeignKey fields something like (in a dropdown menu) "BlaBla object". But i want to get in that dropdown menus something like "Linus Torvalds". I mean how can I

django+modelform+Foreignkey

2010-03-06 Thread H . İbrahim Yılmaz
Hi all, I have some ModelForms.. This ModelForms based some ForeignKey included models. When i want to create a ModelForm I got these ForeignKey fields something like (in a dropdown menu) "BlaBla object". But i want to get in that dropdown menus something like "Linus Torvalds". I mean how can I

Many-to-many or a better way/read-only admin after creation.

2010-03-06 Thread eddie
Hi everyone, I've got few questions that my experience can't answer... I'm not sure the best way to proceed. I'm piggy-backing using the admin interface as a sort-of glorified spreadsheet (accessible to everyone). I've created a model that contains information about drivers licenses. Name,

Re: ForeignKey / ManyToManyField / admin interface

2010-03-06 Thread Christophe Pettus
On Mar 6, 2010, at 10:37 AM, Matthew Warren wrote: Hi, I have a model like the following; class elements(models.Model): name=models.CharField(max_length=21) class grouping(models.Model): name=models.CharField(max_length=48) elementgroup=models.ForeignKey(elements) I'm

Re: Selecting rows from 4 in one to many relationship, please help

2010-03-06 Thread Matthew Warren
>From what you've written, my best guess would be something like, select car.id where car.id in (Select CarOperation.id_car where CarOperation.status='exact') and car.id not in (select CarReservation.id_car where GIVEN_DATE > CarReservation.ariv_date and GIVEN_DATE < CarReservation.dep_date)

ForeignKey / ManyToManyField / admin interface

2010-03-06 Thread Matthew Warren
Hi, I have a model like the following; class elements(models.Model): name=models.CharField(max_length=21) class grouping(models.Model): name=models.CharField(max_length=48) elementgroup=models.ForeignKey(elements) I'm assuming this means that a grouping may relate to multiple

Selecting rows from 4 in one to many relationship, please help

2010-03-06 Thread Alexis Selves
Hello! I have four tables: Car(id, manufacturer, kind) CarReservation(id, id_car, dep_date,ariv_date) CarOperation(id, id_car, id_parking, status...) Parking(id, street, gps) Now I need to select cars, which are on exact parking and are not reserved for given date.. I am totally hopelles..

Re: How to display PendingDeprecationWarning using dev. server?

2010-03-06 Thread Karen Tracey
On Sat, Mar 6, 2010 at 11:53 AM, Brian Neal wrote: > Thanks Karen. Yes, I'm using Ubuntu, and running with --noreload > allows me to see the PendingDeprecationWarning. Is this worthy of a > bug report? > Sure. Just please don't put it in the 1.2 milestone; it's not a release

Re: How to display PendingDeprecationWarning using dev. server?

2010-03-06 Thread Brian Neal
On Mar 6, 10:29 am, Karen Tracey wrote: > This appears to be due to the way runserver reloads the process when > monitoring for source code changes.  If you specify --noreload on runserver > I bet you will see the warnings. The behavior appears to be OS-specific: I > can

Re: How to display PendingDeprecationWarning using dev. server?

2010-03-06 Thread Karen Tracey
On Fri, Mar 5, 2010 at 9:28 PM, Brian Neal wrote: > Any ideas? Can anyone else try this and report back? Just insert the > code below into a view function and start the dev. server with "python > -Wall manage.py runserver". Thanks. > This appears to be due to the way runserver

Re: How to display PendingDeprecationWarning using dev. server?

2010-03-06 Thread pjrhar...@gmail.com
On Mar 6, 2:28 am, Brian Neal wrote: > Any ideas? Can anyone else try this and report back? Just insert the > code below into a view function and start the dev. server with "python > -Wall manage.py runserver". Thanks. Hi, Just to confirm I tried it and can't see them either,

Re: Get id attribute in a form

2010-03-06 Thread leoz01
Thanks for your answers, I don't understand why there is no id getter or property while it is important for javascript. I think i'll override the render method like you Sam. Thanks again ! On 4 mar, 12:17, Sam Lai wrote: > On 25 February 2010 07:05, leoz01

Re: problem with objects.get(id=None)

2010-03-06 Thread Matthew Warren
I guess the aim of documaentation is to be helpful and assist the end user. While it makes no sense to document mysql within Django, wouldn't it make sense to document specific interactions between Django and it's supported back-end DB's that are likely to catch people out? - maybe just as

Re: Formset: 'ArticleForm' object does not support item assignment

2010-03-06 Thread coco
AND THE ANSWER IS : [...] if formset.is_valid(): # do something with the formset.cleaned_data cd = formset.cleaned_data for i in range(len(cd)): cd[i]['answer'] = cd[i]['x'] + cd[i]['y'] formset = ArticleFormSet(initial=cd) [...] -- You received this message because

Re: problem with objects.get(id=None)

2010-03-06 Thread Masklinn
On 6 Mar 2010, at 05:43 , Ilya Braude wrote: > > Karen Tracey wrote: >> I'm guessing you are using MySQL That's just how it behaves, by default. See: >> >> http://dev.mysql.com/doc/refman/5.1/en/server-session-variables.html#sysvar_sql_auto_is_null > > Wow, thanks. I now see that this has been

Admin widgets in my page

2010-03-06 Thread Alexis Selves
Hello everyone, I am trying to use datetime picker from django.contrib.admin I am succesful, but my picker has no style. I see only numbers, but no border, background.. html(shortened) Find parking {% block stylesheet_extra %}{% endblock %}