Re: Form validation in Admin Panel

2009-04-13 Thread Alex Gaynor
project.com/en/dev/ref/contrib/admin/#form Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this

Re: django and i18n what's wrong???

2009-04-13 Thread Alex Gaynor
erence only javascript is correctly translated. I have the same > > issue if I change > > > > request.LANGUAGE_CODE > > > > or > > > > request.session[settings.LANGUAGE_COOKIE_NAME] > > > > so the problem seems related to locale middleware. >

Re: How do List, Tuple or Dictionarie mapping (ORM)

2009-04-13 Thread Alex Gaynor
welcome to create your own field types(or check a site like Djangosnippets for already existing ones). Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~--

Re: django and i18n what's wrong???

2009-04-13 Thread Alex Gaynor
> > > > this is a really strange behaviour ... > > > > To which one of the *gettext* function(s) are the _ alias > > defined in both models.py and views.py? > > > > -- > > Ramiro Moraleshttp://rmorales.net > > > Yes, for any module le

Re: list to queryset

2009-04-14 Thread Alex Gaynor
wargs) > >class Meta: >model=Sequence > > > Am I doing this completely the wrong way? > > > > > You can rewrite that query as: ElementType.objects.filter(sequence__in=job.sequences.all()) Which is both a queryset, and more efficient since it will only

Re: single queryset from multiple tables

2009-04-14 Thread Alex Gaynor
time field from each queryset, however the fieldnames for each of > the date time fields from each queryset are different. Is there a way > around this, should I actually be looking at a custom sql query? > > On Apr 11, 12:55 am, Alex Gaynor wrote: > > On Fri, Apr 1

Re: get_absolute_url method append extra text

2009-04-14 Thread Alex Gaynor
em. In fact the code and > templates are from another app and they work just fine. > > > > > It's because your urls don't start with a / so they are relative to your current location. Alex -- "I disapprove of what you say, but I will defend to the death your right t

Re: get_absolute_url method append extra text

2009-04-14 Thread Alex Gaynor
On Tue, Apr 14, 2009 at 11:19 AM, nixon66 wrote: > > Alex, > > Ok, I'm going to ram my head into a wall now. Seriously thanks. > > On Apr 14, 11:03 am, Alex Gaynor wrote: > > On Tue, Apr 14, 2009 at 11:01 AM, nixon66 wrote: > > > > > I hav

Re: Adding model instance attributes

2009-04-14 Thread Alex Gaynor
Thanks for the help! > > > In my view this is perfectly acceptable. Django is just python and that's completely legal Python and even idiomatic. Indeed just adding attribute is how annotations work in the development version. Alex -- "I disapprov

Re: Temperature degree ascii code error on cvs output file

2009-04-14 Thread Alex Gaynor
, publication.pubwebaddress]) >return response > > Is there someway to unicode the writer? > > > > > Simon Willison(I think) wrote up a class that implements the same API but handles unicode: http://www.djangosnippets.org/snippets/993/ Alex -- "I disapprove of what

Re: Random Syntax Errors on Download

2009-04-14 Thread Alex Gaynor
ors showing up and how can > I fix it? > > > > That charecter is most assuradley supposed to be there u indicates the string is a unicode literal. Django does not work with Python 3.0 as documented. It works with Python 2.3-2.6. Alex -- "I disapprove of what you say, but I wil

Re: Statistic gathering

2009-04-14 Thread Alex Gaynor
external link is clicked is to have some javascript fire that sends off an AJAX request to your site to tell it an external link was pressed, you then need to have a view that handles that data and inserts it into the DB. Alex -- "I disapprove of what you say, but I will defen

Re: Creating an object with a FileField programmatically

2009-04-14 Thread Alex Gaynor
lready relative to your MEDIA_ROOT you need to do: m = MyModel() m.file_field.save('new_file_name', open('/path/to/file').read()). Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is th

Sending large, generated files

2009-04-14 Thread Alex Loddengaard
ty.close() > yield noop.getvalue() > I'm wondering if there is a better way to accomplish this? I don't quite understand why HTTP responses are written to stdout. Possibly orthogonal to that, it seems like, in theory, yielding an empty value in the generator should work, bec

Re: Custom Model Fields / Multi-table inheritance / get_db_prep_value / postgresql_psycopg2

2009-04-14 Thread Alex Gaynor
nce, > its primary key in the database was being created by django as a > OneToOneField (which is correct, of course), and it was creating the > column using the proper type and everything, but you can see that > without the little part that I added, the value was not being properly >

Re: Adding a "View" Link (similar to add and change links) to the admin

2009-04-15 Thread Alex Gaynor
t; You'd need to overide the admin template to do this, as documented here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's g

Re: finding out what SQL Django generated

2009-04-15 Thread Alex Gaynor
he database server? > > (Sorry if this is a FAQ, I've been looking for a while. Pointers to > docs gladly accepted.) > > -Chris > > > If it's docs links you want :) : http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-run

Re: Sending large, generated files

2009-04-15 Thread Alex Loddengaard
7;ll give this a go in WSGI and see what happens. In the meantime, I suppose the empty gzipped file gets the job done. Thanks again for all the responses. Go Django! Alex On Wed, Apr 15, 2009 at 8:36 AM, Rick Wagner wrote: > > > > On Apr 14, 6:55 pm, Graham Dumpleton >

Re: Does QuerySet have a refresh to catch when database data changes underneath running django?

2009-04-15 Thread Alex Gaynor
qs2.count() # after the _clone, this should now check the DB again and >> be 6L >> 5L >> >>> raise "Darn! I wish I could ask the qs object to go back to the db for >> all further queries." # D'oh. >> >>> >> >> Thanks in advance!

Re: finding out what SQL Django generated

2009-04-15 Thread Alex Gaynor
-Justin > > > Using query.as_sql() doesn't work for any query which doesn't return a queryset, include aggregate(), count() and update(). Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good i

Re: Serving Static Files - Pics work, but CSS doesn't

2009-04-15 Thread Alex Gaynor
up, but the text doesn't turn green like I think it > should. > > Any help would be appreciated! > > > Where is your CSS file located? Specifically is it in the same directory as the image. Alex -- "I disapprove of what you say, but I will defend to the death you

Re: Serving Static Files - Pics work, but CSS doesn't

2009-04-15 Thread Alex Gaynor
On Wed, Apr 15, 2009 at 6:59 PM, Anthony wrote: > > Yes, they are right next to each other in the same folder. > > On Apr 15, 3:55 pm, Alex Gaynor wrote: > > On Wed, Apr 15, 2009 at 6:50 PM, Anthony wrote: > > > > > Hello, > > > > > I'm

Re: request.urlconf does not get used in URL template tag

2009-04-15 Thread Alex Gaynor
f anyone out > there has come across this let me know. It seems to work fine for now > though. > > > > > It's a bad idea because your application is not threadsafe at all, if you try to run your application in a threaded enviroment you will get lots of reverses that re

Re: signals vs. save()

2009-04-16 Thread Alex Gaynor
ns to use signals in that situation is because you can't change the code in that application. Say you want to trigger something on the User object being saved, you don't want to monkey patch django.contrib.auth so use just use the signal for code clarity. Alex -- "I disappro

Re: possible filter bug with manytomany fields and slice?

2009-04-16 Thread Alex Gaynor
hat area, but I'm now a bit suspicious that something > is going wrong. > > Regards, > Malcolm > > > > > > Are you using MySQL? I know it doesn't support limits int nested querysets, perhaps it's just not returning anything instead of throwing an

Re: Fewer columns in admin popups

2009-04-16 Thread Alex Gaynor
f.list_display_links = [u'username'] >return super(CustomUserAdmin, self).changelist_view(request, > *args, **kwargs) > > admin.site.unregister(User) > admin.site.register(User, CustomUserAdmin) > > > > This code isn't threadsafe. If you use your app

Re: How do I exclude a list from my search?

2009-04-17 Thread Alex Gaynor
e, I will like to store the above 3 cities in a > list. > > > City.objects.exclude(city_name__in=['Toronto', 'Richmond', 'Montreal']) should do exactly what you want. Alex -- "I disapprove of what you say, but I will

Re: Block delete

2009-04-17 Thread Alex Gaynor
te() Won't pull in each of the objects to delete them: http://docs.djangoproject.com/en/dev/topics/db/queries/#topics-db-queries-delete Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."

Re: Block delete

2009-04-17 Thread Alex Gaynor
On Fri, Apr 17, 2009 at 4:05 PM, koranthala wrote: > > > > On Apr 17, 11:57 pm, koranthala wrote: > > On Apr 17, 11:51 pm, Alex Gaynor wrote: > > > > > > > > > On Fri, Apr 17, 2009 at 2:47 PM, koranthala > wrote: > > > > > >

Re: Unittests

2009-04-17 Thread Alex Gaynor
reading the docs but it's not coming to me what I messed up. > > > Camel case really shouldn't be the convention, as PEP-8 clearly says to use names_with_underscores, but you're correct that the test name must begin with the word test. Alex -- "I disapprove of what you say,

Re: Anyone else having issues with saving M2M in trunk?

2009-04-17 Thread Alex Gaynor
ssue). It should be noted that we have a rather large test suite, and it all currently runs just fine for me, and it would be failing quite loudly if saivng m2ms didn't work. So my inclination i that the bug is not in Django. Alex -- "I disapprove of what you say, but I will defend to

Re: Unittests

2009-04-17 Thread Alex Gaynor
> > > > A cursory review of the file and I don't see any mention of it, so please file a ticket for this. It's almost certainly in Python's unittest docs, but we want to make the barrier to entry as low as possible when writing tests. Alex -- "I disapprove of what

Re: Unittests

2009-04-17 Thread Alex Gaynor
gt; reproduction of the entire Python unittest documentation in the name > of a seamless Django experience. If you want to open a ticket for this > (and even write the patch - it shouldn't be too hard), I'll get it > into trunk. > > Yours, > Russ Magee %-) > > >

Re: How to display the recent comments

2009-04-18 Thread Alex Gaynor
can interact and preform queries with it the same way you would with any model: from django,contrib.comments.models import Comment Comment.objects.all().filter(site=1).order_by('-submit_date')[:10] Would give you the 10 most recent comments on site '1'. Alex -- "I disapp

Re: How to set up MySQL replication on Django?

2009-04-19 Thread Alex Koshelev
There is an existing production-ready application [1] that allows you to use MySQL replication facilities. It is formed as django database backend with some additional functional. We use it for our high-load Django powered content services. [1]: http://softwaremaniacs.org/soft/mysql_replicated/e

Re: Resize image on the fly during uploading

2009-04-19 Thread Alex Gaynor
in God the chances are your God is too small. > > Read my blog: http://joshuajava.wordpress.com/ > Follow us on twitter: http://twitter.com/scrum8 > > > > Django doesn't include anything to do this, you need to use PIL. Alex -- "I disapprove of what you say, but

Re: Writing a request filter to find objects without related objects

2009-04-19 Thread Alex Gaynor
dvance for any help, > > BWeiss > > > > If I follow correctly you're just looking to do the opposite of what you're already doing, so far you using the filter() method, so what you need is the opposite of that. Luckily we have just the thing! The exclude() method, http://d

Re: Resize image on the fly during uploading

2009-04-19 Thread Alex Gaynor
On Sun, Apr 19, 2009 at 9:41 PM, Joshua Partogi wrote: > > On Apr 20, 10:24 am, Alex Gaynor wrote: > > On Sun, Apr 19, 2009 at 8:22 PM, Joshua Partogi >wrote: > > > > > > > > > > > > > Dear all, > > > > > Does django ha

Re: Optimal Django / Apache / mod_wsgi configuration

2009-04-19 Thread Alex Gaynor
> > > To my understanding having something like nginx out front serving media and proxying to apache is the best setup memory wise. That obviously requires installing and setting up nginx though. Alex -- "I disapprove of what you say, but I will defend to

Re: Models Aliases

2009-04-20 Thread Alex Koshelev
Hi, Bastien. I think the simple solution with property may be the best aproach if you cannot change dependent code: user = property(lambda self: self.author) On Mon, Apr 20, 2009 at 3:37 PM, Bastien wrote: > > You're right Dougal, I *should* do that I have various apps already > working with

Re: inlineformsets version 1.0.2

2009-04-20 Thread Alex Gaynor
msets.py", > line 96, in _construct_form > self.add_fields(form, i) > > File "/usr/lib/python2.4/site-packages/django/forms/models.py", line > 494, in add_fields > form.fields[self.fk.name] = InlineForeignKeyField(self.instance, > label=form.fields[self.fk.nam

Re: Admin site error

2009-04-21 Thread Alex Gaynor
27; object has no attribute 'urls' > > any idea why? and how to fix it? > > thanks in advance. > cheers > > > You are following the instructions for the Django development version, when you are using django 1.0. Follow the instructions here: http://docs.djangoproj

Re: Problem with GenericRelation

2009-04-22 Thread Alex Gaynor
s')) > > print b.comments > > 3 > > > c = Model3.objects.annotate(comment_cnt=Count('comments')) > > print c.comments > > 3 > > It's bug.. It should by only 1 comment for each models. I tried with > distinct=True and related_name, but i

Re: Problem with GenericRelation

2009-04-22 Thread Alex Gaynor
On Wed, Apr 22, 2009 at 11:07 AM, eli wrote: > > Thank You Alex. This patch will be available in Django 1.1 ? > > On 22 Kwi, 16:56, Alex Gaynor wrote: > > On Wed, Apr 22, 2009 at 10:49 AM, eli wrote: > > > > > Hi, > > > > > I have a pr

Re: annotate over period of time

2009-04-22 Thread Alex Gaynor
mercado, when I think you want to filter > > > for all the price points for a particular product in a particular > > > market, which is an AND operation. Try filter(mercado=mercado, > > > producto=producto, etc...) instead! > > > > > - -- > > > Randy Barlow

Re: Hierarchy menu system

2009-04-22 Thread Alex Gaynor
ignkey to itself. Then you know that the root items are those with "parent=NULL". You can use something like django-mptt or -treebeard to give you a very natural tree like interface to working with these. Alex -- "I disapprove of what you say, but I will defend to the death

Re: Update only one field on save

2009-04-23 Thread Alex Gaynor
? > > Best regards, > > > In Django 1.1 you can do: Model.objects.filter(pk=z).update(hits=F('hits')+1) Which will be atomic at the DB level. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The

Re: django forms validation with choice and m2m fields

2009-04-23 Thread Alex Gaynor
gt; sure on every one of my fields that the entered value is what was in > the list? > > TIA > > > Yes, if someone submits data that isn't a valid choice Django forms will validate and reject it. Alex -- "I disapprove of what you say, but I will defend to the death you

Re: automatic updates for a set of model objects via email

2009-04-23 Thread Alex Gaynor
e if it determines that the object has been changed, and it would just send emails to everyone who's email is in the table. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."

Re: urlconf {{ app }}/{{ view }}

2009-04-24 Thread Alex Gaynor
ce any type of convention on the type of urls you use. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You recei

Re: how to display m2m fields in template

2009-04-24 Thread Alex Gaynor
You need to use article.publications.all since a Manager(which is what article.publications is) isn't iterable, just like you can't iterate over Author.objects, you need to use all. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it.&qu

Re: admin area language settings

2009-04-25 Thread Alex Gaynor
would take precedence when users > > come to the site. > > > > The problem is that django-admin is alot better in English, but I get > > it in Hebrew. > > Well, you could help Alex Gaynor et al getting the Hebrew translation of > Django so it is complete/comfort

Re: m2m trouble when referencing "self"

2009-04-25 Thread Alex Gaynor
her* models, not to "self") on my site suffer from this problem. > > Any direction at all would be immensely appreciated. > > I'm using the latest django SVN update, Python 2.5.4, MySQL. > > Thanks, > Tim > > > The issue is by default m2m relationships are

Re: using django 1.1 beta and having problem with cleaned_data attribute

2009-04-26 Thread Alex Gaynor
2.6.2 > Python Path:['C:\\Documents and Settings\\kchan\\My Documents\ > \Scripts\\play_django', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\ > \Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win', > 'C:\\Python26\\lib\

Re: Disabling PRG Pattern

2009-04-26 Thread Alex Gaynor
you talking about? No where does django impose upon you a post-redirect-get pattern for your own views, it just happens to be the convention. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltai

Re: using django 1.1 beta and having problem with cleaned_data attribute

2009-04-26 Thread Alex Gaynor
content, name > > I used name and it works. I am assuming the "name_contains" is > deprecated in Django 1.1? Thanks. > > > On Apr 26, 7:39 pm, Alex Gaynor wrote: > > On Sun, Apr 26, 2009 at 7:37 PM, tekion wrote: > > > > > All, > > >

Re: Overriding save() method on models to automatically add ManyToMany relationship

2009-04-27 Thread Alex Gaynor
> The issues if the method, it's nonsensical and doesn't correspond to anything(you are instantiating models.Model with save as the first argument), in Python the correct way to call the parent class's method is: super(MyClass, self).save(*args, **kwargs) Alex -- "I disap

Re: MySQL issues

2009-04-28 Thread Alex Robbins
Yeah, I think that is the problem. You have to execute CREATE DATABASE books; from the mysql command line. Syncdb will make tables, but it won't make the initial database. Hope that helps, Alex On Apr 27, 4:04 am, google torp wrote: > Hi. > > I haven't used Django with mysq

Re: i need a unlimited subcategories

2009-04-28 Thread Alex Robbins
y, it works in my head. I haven't actually coded any of it. Hope that helps, Alex On Apr 27, 8:52 am, joker wrote: > how can i use unlimited category? > > like > > category1 >     subcategory1-1 >          subcategory1-1-1 >          subcategory1-1-2 &

Re: How do I retrieve this Customer.objects.filter(serial<>'')

2009-04-28 Thread Alex Gaynor
not defined. > > Thank you for any help. > > > > > You want to use the exclude option to remove any items that match a given criteria so: Customer.objects.exclude(serial='') Alex -- "I disapprove of what you say, but I will defend to the death your r

Re: manage.py runfcgi options

2009-04-28 Thread Alex Koshelev
Built-in help has the answers: $ ./manage.py help runfscgi On Tue, Apr 28, 2009 at 10:36 PM, Continuation wrote: > > In the doc an example of running django under fastcgi is given as: > > ./manage.py runfcgi method=threaded host=127.0.0.1 port=3033 > > > But isn't it also necessary to tell

Re: Finding Reason for Form.is_valid()

2009-04-29 Thread Alex Gaynor
bsequently the views being tested, may become > > daunting. I could always drop to an interactive shell, instantiate > > objects and inspect their contents and stuff, but the alternative to > > use pdb the way you have suggested is much, much better and more > > convenient.

Re: Do you know about Django 1.1 current status

2009-04-29 Thread Alex Gaynor
t a real roadmap from here on out, other than it will be released(following a release candidate) once we are reasonably sure we have most of the bugs out. The roadmap page on trac shows a little more than 100 more bugs to be fixed. So it isn't really a matter of having a roadmap, just of hunk

Re: Caught an exception while rendering: coercing to Unicode: need string or buffer, SentenceText found

2009-04-30 Thread Alex Gaynor
; > I need help > > > You need to return unicode(self.label) since you're return a different object and __unicode__ *needs* to return a unicode string. Also your SenteceText.__unicoed__ will fail since it adds a string to an int. Alex -- "I disapprove of what you say, but I wil

Re: Template help

2009-04-30 Thread Alex Gaynor
te.com/39858/ > > I am mainly concerned with lines 3 to 7. Ignore that I should use a > variable for "Submit Query". These lines are being repeated in every > template that I have. Especially the user/profile bit. > > Advice is welcome, thank you. > -Alex > > >

Re: Tables with same schema

2009-04-30 Thread Alex Gaynor
t; The above however doesn't work. > Any idea? > > Thanks, > Ram > > > > I'd do it with one class that has all the common fields that is an abstract class(check the docs for this). And then just 2 classes that subclass it. This should do just what you want. Alex

Re: Tables with same schema

2009-04-30 Thread Alex Gaynor
dels represent tables with same schema. I'm looking for > > > something like- > > > > > class Person2(Person): > > >pass > > > > > The above however doesn't work. > > > Any idea? > > > > > Thanks, > > >

Re: "DeprecationWarning: the sets module is deprecated"

2009-05-01 Thread Alex Koshelev
You see MySQLdb warning not Django. May be you are using MySQLdb version that is not full compatible with Python 2.6 On Sat, May 2, 2009 at 1:59 AM, nbv4 wrote: > > Whenever I run the syncdb command, I get this error: > > ch...@chris-desktop:~/Websites/jobmap$ python manage.py syncdb > /var/li

Retrieving data from a form ChoiceField

2009-05-03 Thread Alex Rades
Hi, i have a simple form which among other fields has a ChoiceField with some choices: CHOICES=( (1, u'Bar basf asdf'), (2, u'Asdf', qewr'), (3, u'Afefafafa saef3') ) when i receive the form, i do all the usual procedure until i want to retrieve the value of the choicefield (have to produc

Re: Adding RSS Feed to planet Django

2009-05-05 Thread Alex Gaynor
ding an RSS-Feed to > http://www.djangoproject.com/community/. > > The URL of the feed is: > > http://www.getlfs.com/feeds/django > > Thanks > Kai > > > The right person to email for that is Jacob Kaplan-Moss, whose email is at the bottom of that page. Alex -- "I disapprove o

Re: invoke model's method from template

2009-05-05 Thread Alex Gaynor
ainer request.user %} # this doesn't work > > or should I write my own tag ? > > Kind Regards > > > > Yes, it's necessary to write your own tag, as you can't call methods that take parameters from the template language. Alex -- "I disapprove of wha

Re: Introducing FirePy, a FirePHP server library for Django

2009-05-05 Thread Alex Gaynor
SQL queries in FirePython (I may have just missed them). Regardless everyone is probably best served by the two projects working together, as there's clearly lots of cool work that you guys are doing. ALex -- "I disapprove of what you say, but I will defend to the death your rig

Re: Django and a basic SQL join

2009-05-06 Thread Alex Koshelev
On Wed, May 6, 2009 at 8:48 PM, jrs_66 wrote: > > Hi, > > I have 2 models... > [skip] > > e = FlattenedCategory.objects.select_related('category').filter > (member_of_category=15) > > which works... This, however, doesn't > > e = e.category > > How do I access the related records from the Cat

Re: QuerySet.values() for single object?

2009-05-08 Thread Alex Gaynor
George > > > > You can do .filter(stuff).values(fields_list).get() and it will return a dictionary. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~

Re: save_formset in admin

2009-05-08 Thread Alex Gaynor
ntegrityError: null value in column "lastChangedBy_id" violates not-null > constraint > > > because I haven't had chance to set it yet. > > > Can anyone give me any clues? > > > Cheers, > > > Tim.. > > > This

Re: Clearing ImageField from django admin

2009-05-08 Thread Alex Gaynor
>> > > > > > This isn't currently possible and is the subject of: http://code.djangoproject.com/ticket/7048 Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest

Re: models.ForeignKey('self' ... -> Can't create new elem

2009-05-09 Thread Alex Gaynor
oesn't work > > Thanks for you help > > > Did you syncdb before settings the fkey to null? Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--

Re: How do I handle urls with different names?

2009-05-11 Thread Alex Gaynor
th on the model I'd just hook up the view at r'^(?P\w+)-(?P\w+)/$' and then in the view you can filter by type and name individually. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good i

upload_to usage

2009-05-12 Thread Alex Rades
Hi, I'd like to save my images using this schema (which is, I think, something 99% of web sites do): def upload_to(instance, filename): return "photos/%s/%s"%(instance.pk % 1000, filename) the problem is that, as mentioned in the documentation about the "instance" parameter of upload_to: "In

Re: two models, 1 table

2009-05-12 Thread Alex Gaynor
models you're > talking about. Overlaying models onto an already existing table is > normally a use-case for setting managed=False. > > Regards, > Malcolm > > > > > > Indeed, Django works fine (as far as I know) if a table actually has a superset of the fields

Re: upload_to usage

2009-05-12 Thread Alex Gaynor
On Tue, May 12, 2009 at 4:24 AM, Alex Rades wrote: > > Hi, > I'd like to save my images using this schema (which is, I think, > something 99% of web sites do): > > def upload_to(instance, filename): > return "photos/%s/%s"%(instance.pk % 1000, filename) >

Re: exclude subquery executed twice?

2009-05-12 Thread Alex Gaynor
ll do it in a few minutes if no one still has), but AFAICT the issue is here: http://code.djangoproject.com/browser/django/trunk/django/db/models/sql/query.py#L1622 with the if not value triggering the issue. It's probably solvable by changing that to if (not hasattr(value, 'as_sql') and n

Re: How do I handle urls with different names?

2009-05-12 Thread Alex Gaynor
ct=type) > > If my table has 1000s of pets, isn't the above a bit slow when > compared to the retrieving a pet by id? How is this kind of situation > handle in some of the Django web application out there? > > On May 11, 11:00 pm, Mike Ramirez wrote: > > On M

Re: how can I modify automatic ordering of fields in a ModelForm?

2009-05-12 Thread Alex Gaynor
ModelAdmin form factory pattern is a pretty good one to follow. > > -- > George > > > > You can control the order of fields on a modelform by settings the ordering in the fields option in the inner Meta class. That is if you set fields = ['b', 'a', 'c&#

Re: How do you handle apostrophe and spaces in dynamic url?

2009-05-12 Thread Alex Gaynor
is to have a seperate slug field, Django's SlugField for models serves to fill this exact purpose, it can only be used in conjuction with the prepopulated_fields ModelAdmin option. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --V

Re: I/O operation on closed file

2009-05-12 Thread Alex Gaynor
/django-trunk/django/db/models/fields/files.py", > line > 239, in save > self._dimensions_cache = get_image_dimensions(content) > > File "/home/mybandsite/django-trunk/django/core/files/images.py", line 39, > in > get_image_dimensions >data = file.re

Using a subset of a queryset in a template

2009-05-13 Thread Alex Rades
Hi, in one of my templates I'd like to show the last images taken from a queryset. So the equivalent of: images.all()[:5] in a template. Is there a simple way to do this? Do i need a templatetag? --~--~-~--~~~---~--~~ You received this message because you are su

Re: Using a subset of a queryset in a template

2009-05-13 Thread Alex Koshelev
On Wed, May 13, 2009 at 2:56 PM, Alex Rades wrote: > > Hi, > in one of my templates I'd like to show the last images taken from > a queryset. So the equivalent of: > > images.all()[:5] > > in a template. > Is there a simple way to do this? Do i need a templa

Re: Aggregation of field properties?

2009-05-13 Thread Alex Gaynor
t; and I'm getting what I expect. But I just hit a roadblock with the > size, since it is an attribute of file_system_object. > > Can I aggregate over a field property? > > Best regards, > Carlos. > > > > No, since the size isn't stored in the database you n

Re: has date template filter been fixed?

2009-05-14 Thread Alex Gaynor
gt; > Using 1.0. Has this been fixed? > > > This was fixed in the 1.1 development branch and the 1.0.X devel branch. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law.

Re: get current logged user from manager

2009-05-15 Thread Alex Gaynor
the currently logged in user there, you'll need to pass it in from the view. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~

Re: ForeignKey with null=True

2009-05-15 Thread Alex Gaynor
eign key isn't nullable the only option is to actually delete the object, which isn't exactly the same as what you specifified (since its destructive). Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's

Re: abstract classes in models

2009-05-15 Thread Alex Gaynor
y what is expected > > from python code, class1.abstractthing_set.all gives me an AttributeError > > 'class1' object has no attribute 'abstractthing_set' > > > class1.thingtype1_set.all returns exactly what is expected > > i was hoping that the abstr

Re: ForeignKey with null=True

2009-05-15 Thread Alex Gaynor
On Fri, May 15, 2009 at 12:11 PM, aa56280 wrote: > > So to be clear then, yes, I want to delete the object from the > database entirely. How to go about doing that using location_set? > > On May 15, 12:07 pm, Alex Gaynor wrote: > > On Fri, May 15, 2009 at 12:04 PM, aa56280

Re: Ordering a query by comments connected to model

2009-05-15 Thread Alex Gaynor
gt; How do I order a query by comments connected to a model? > > -Martin > > > If you are using the latest development version you can do this using aggregates: http://docs.djangoproject.com/en/dev/topics/db/aggregation/#order-by Alex -- "I disapprove of what you say, but I will defe

Re: abstract classes in models

2009-05-15 Thread Alex Gaynor
On Fri, May 15, 2009 at 1:38 PM, Rusty Greer wrote: > > > On Fri, May 15, 2009 at 10:10 AM, Alex Gaynor wrote: > >> >> >> On Fri, May 15, 2009 at 12:08 PM, Rusty Greer wrote: >> >>> >>> >>> On Fri, May 15, 2009 at 9:57 AM, Geor

Re: Ordering a query by comments connected to model

2009-05-15 Thread Alex Gaynor
="object_pk") > > However, denormalization would still be better in most cases. > > > Any aggregation over generic relations is currently unsupported, it was hoped this would make it into 1.1, but unfortunately some of the way SQL works prevented this (since it requires us t

Re: Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Alex Gaynor
)) > > > > AttributeError: 'NoneType' object has no attribute 'cursor' > > > > running syncdb works fine and updates my database. > > > I don't believe you are correctly running r10790, as that code no longer exists in it, this was a bug fixe

additional data on ManyToManyField and symmetrical

2009-05-16 Thread Alex Rades
Hi, I have a model which looks like: class Person(models.Model): friends = models.ManyToManyField("self", through="Friendship") class Friendship(models.Model): person_a = models.ForeignKey(Person) person_b = models.ForeignKey(Person, related_name="_unused_") Now, as mentioned in: htt

Re: Ordering a query by comments connected to model

2009-05-16 Thread Alex Gaynor
underlying Query > to > > allow support for additional conditions on a join clause). > > Alex, thanks for your comment. > However, this code works for me with Django 1.1 beta1 (rev10793). > I understand that one should not rely on undocumented behaviour, but > does this case

<    5   6   7   8   9   10   11   12   13   14   >