Re: dictionaries in template

2009-07-30 Thread Malcolm Tredinnick
On Thu, 2009-07-30 at 11:14 +0200, Salvatore Leone wrote: > Hi, > > I pass to my template a dictionary of answer -> [attach_list] > > so the data structure is > > answers_list[answer] = attach_list > > > Inside the template I actually can read the answers: > > {% for answer in answers_list.

Re: how to use the url tag with optional arguments?

2009-07-27 Thread Malcolm Tredinnick
On Mon, 2009-07-27 at 16:30 +0530, Kenneth Gonsalves wrote: > hi > latest trunk. > in my urls.py I have a url: > > url(r'^addlandmark/((?P\d+)/)?$', 'addlandmark', name='add_landmark'), You have nested capturing groups here, which is almost always an error. You have also mixed positional and nam

Re: get_or_create not atomic?

2009-05-12 Thread Malcolm Tredinnick
On Tue, 2009-05-12 at 10:47 -0700, Phil Mocek wrote: > On Tue, May 12, 2009 at 02:25:41AM -0700, Daniel Roseman wrote: > > No, [get_or_create is] not atomic. By the way, that depends on what grained-ness of atomicity you're after, which hasn't been defined in this thread. The guarantee is that af

Re: two models, 1 table

2009-05-11 Thread Malcolm Tredinnick
On Mon, 2009-05-11 at 22:19 -0700, George Song wrote: > On 5/11/2009 8:55 PM, rpupkin77 wrote: > > Hi, can I use the same table in two different models and surface > > different data in each, model, particularly in the admin panel? > > Sounds like a job for proxy models[1], each with its own defa

Re: Quoting in extra(select=...) expression

2009-05-11 Thread Malcolm Tredinnick
On Mon, 2009-05-11 at 12:09 -0700, lemming110 wrote: [...] > But using extra(select={'comment_count': sql,}) where > > sql = '''select count(*) > from django_comments > where django_comments.content_type_id=12 and > django_comments.object_pk= > %s''' > > gives me an error every way that I have t

Re: Recursive ManyToMany?

2009-05-11 Thread Malcolm Tredinnick
On Sun, 2009-05-10 at 20:36 -0700, nek4life wrote: > I'm trying to create a record label website and I'm modeling the music > data. I have artists, albums, tracks so far. What I'd like to do is > use the artists model for both individual recording artists and groups > of recording artists. Pro

Re: Overwrite send_mail

2009-05-11 Thread Malcolm Tredinnick
On Sun, 2009-05-10 at 13:54 +0100, Dougal Matthews wrote: > Thanks Will, > Found it > here; > http://code.djangoproject.com/browser/django/trunk/django/test/utils.py#L50 > > > That does look about what I am hoping to do, not so sure about monkey > patching the core though. > > > Basically, as

Re: exclude subquery executed twice?

2009-05-11 Thread Malcolm Tredinnick
On Sat, 2009-05-09 at 20:18 -0700, Henry Andrews wrote: > Hi folks, > When excluding using a subquery, I'm seeing the subquery being > executed first as its own query, then seeing the correct query being > run, including the subquery. Using filter instead of exclude, this > does not happen. Ju

Re: URLField verify_exists fails

2009-05-11 Thread Malcolm Tredinnick
On Mon, 2009-05-11 at 11:47 -0700, Roodie wrote: > Now that's interesting. Must be some mis-configuration on the > server side, since I can see the URL just fine, both in my bowser > and from the python console: What do you mean by "see", especially for the browser case? Sure, it returns somethin

Re: URLField verify_exists fails

2009-05-11 Thread Malcolm Tredinnick
On Mon, 2009-05-11 at 11:35 -0700, Roodie wrote: > Hello, > > One of our testers reported a strange issue - sometimes thr URLField > does not accept a valid, existing URL. I verified it on my local > developer laptop also. The mentioned URL is: > > http://www.harmat.hu/ > > The site exists, I e

Re: using id as a model field name ?

2009-05-08 Thread Malcolm Tredinnick
On Fri, 2009-05-08 at 16:31 -0700, paul wisehart wrote: > I didn't realize that id was a python builtin function. > > I have a large pre-existing database that I wrote a bunch of models > for. > > I used 'id' as the primary key field for all of them. > > """ > class SalesQuoteItemDetail(models.

Re: 'NoneType' object is not iterable

2009-05-08 Thread Malcolm Tredinnick
On Fri, 2009-05-08 at 11:24 -0700, Kalle wrote: > Hi, > > I'm just started to play with Django, and ran into this problem right > away. > > * I'm using the python script at the bottom to POST to the url. > * I'm using "manage.py runserver" to run my app > * Everything works fine when I'll run my

Re: self unique symmetrical relation

2009-05-08 Thread Malcolm Tredinnick
On Thu, 2009-05-07 at 07:12 -0700, Aldo wrote: > Hello, > > I have a problem for a quite simple model. > I would like to model a person marriage relation. > > example : > > class Person(models.Model): > name=models.CharField(max_length=100) > married_to=models.OneToOneField('sel

Re: Django and a basic SQL join

2009-05-08 Thread Malcolm Tredinnick
On Wed, 2009-05-06 at 13:14 -0700, jrs_66 wrote: > Thanks! This is a great starting point. My real queryset requires me > to go a few joins deeper, however. I will try nesting loops to get > there, but this seems frightfully like querying in a loop (maybe I'm > wrong, I'll check the end query t

Re: select_related works with sqlite but not mysql?

2009-05-08 Thread Malcolm Tredinnick
On Tue, 2009-05-05 at 21:59 -0500, Keith Pettit wrote: > I'm trying to display a list on a page that is a combination of two > different models. In development I use sqlite and the list works > great, but when I go to MySQL I don't get any results. It's odd > because I use pagination and I can s

Re: please help with FileField(upload_to='foo')

2009-05-05 Thread Malcolm Tredinnick
On Tue, 2009-05-05 at 21:42 -0300, Gabriel wrote: > djangomax escribió: > > According to the Django Book for version 1.0, the following should > > work: > > > > fileField = forms.FileField(upload_to='foo') > > > > However, I get an error saying there was an unexpected argument. Any > > idea why?

Re: To run manage.py syncdb without being prompted to create a superuser

2009-05-05 Thread Malcolm Tredinnick
On Tue, 2009-05-05 at 10:21 -0700, bconnors wrote: > I'm looking at How to run manage.py syncdb without being prompted to > create a superuser > > at > http://code.djangoproject.com/wiki/CookBookScriptsNoSuperUserSyncdb > > >>> from django.core import management > >>> from django.dispatch import

Re: default input format for dates that will work for ModelForm?

2009-05-05 Thread Malcolm Tredinnick
On Tue, 2009-05-05 at 09:23 -0700, klaasvanschel...@gmail.com wrote: > Hi, > > I would like to present the user with dates in their particular locale > (Dutch). Both when presenting the date and when parsing it. > > As I understand, for individual form's fields this should be possible > like so:

Re: Separation of apps

2009-05-05 Thread Malcolm Tredinnick
On Tue, 2009-05-05 at 06:48 -0700, eric.frederich wrote: > So the solution you recommend, "Have the foreign key point to the > auth.User model and then use person.get_profile() if you need to > access the profile object"... is that a "best practice" for dealing > with users and profiles? Never li

Re: Help with schema

2009-05-05 Thread Malcolm Tredinnick
On Tue, 2009-05-05 at 06:02 -0700, Chris McComas wrote: > I have a site/database that tracks baseball players and their agents. > Players can have multiple agents at one time, they also can fire > agents and hire new ones at anytime, and I'd like to track all of > their agents, current, or previou

Re: Problem with cookie on development server

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 15:47 -0700, Andrew Se. Fefelov wrote: > Hello guys! > > I'v got such problem with development server. I run any app on my dev > server and it is stuck on Set Cookie response: Define "stuck". What happens? The request and response headers you posted look reasonable to me,

Re: How to add non-model field in admin

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 12:07 -0700, Tomáš Ehrlich wrote: > Hi there, > I wonder if is there any way to add extra input field in admin, which > I don't want to define in model. > > For example, I want to import external files. I have simple blog model > (title, content, pub_date), but in admin I wa

Re: How to handle view/url situation (Newbie)

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 15:41 +0200, Masklinn wrote: > On 4 May 2009, at 14:55 , pbzRPA wrote: > > On May 4, 1:24 pm, Masklinn wrote: [...] > >> FWIW the `'app.views.showItems'` isn't even necessary, you can just > >> pass the view function and reverse will figure out the rest, so > >> > >>

Re: Separation of apps

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 12:51 -0700, eric.frederich wrote: > Thanks for the reply. > > You're right that auth.User is not a replacement for a profile. > Maybe I will make the training app require only that a profile model > exists and has a particular set of fields like cost-center, manager's > e-m

Re: fail silently: "NoneType object has no attribute...." errors?

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 11:52 -0700, hotani wrote: > Most of the errors I'm seeing these days in my application are of the > "NoneType object has no attribute" variety. While this may be > helpful on occasion on the development server, I really don't want it > creeping up on production. > > "We

Re: data too long in a CharField column

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 08:46 -0700, MS wrote: > Hi, > > I have a problem with django+postgresql: > I have a model with a CharField(max_length=255) field, and I'm > assigning some much longer value to this field, like: > > m = MyModel() > m.myfield = 'very long text - say 400 chars' > m.save() >

Re: Separation of apps

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 11:35 -0700, eric.frederich wrote: > I wrote an app that consist of an authentication backend and a single > model "Profile" (extension of auth.User). It also has a function > which queries ldap to get user information like their manager. We'll > call this app my_custom_bac

Re: Custom SQL with a variable issue.

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 10:31 -0700, MikeL wrote: > I figured it out. I had to run cursor.execute for the SET and the > SELECT line and it managed to remember the @row being 0 between them. > Though it would be nice if a django solution exists. You found the Django solution already: use cursor.exec

Re: Custom SQL with a variable issue.

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 11:31 -0700, pbzRPA wrote: > Hi, > > Could you provide the code of your model and why you would want to use > a custom sql instead of the django model object. For the type of query that Mike is asking about, custom SQL is a reasonable solution. Django cannot really provide

Re: ManyToManyField and Manager.exclude()

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 09:18 -0700, Riccardo Pelizzi wrote: > Hello, > > I have a model which looks kinda like this: > > class Host(model): > ip = IPAddressField() > > class Domain(model): > hosts = ManyToManyField(Host) > > If i want to get all the domains without hosts: > Domain.objects.f

Re: Split models.py to smaller parts.

2009-05-03 Thread Malcolm Tredinnick
On Sun, 2009-05-03 at 10:01 -0700, Rick Wagner wrote: > > > Thank you for the explanation. I think this trick is not in the > > > Documentation yet > > > > That's because it's pretty basic Python knowledge. I'm sure I've read > > on this list that basic Python knowledge isn't supposed to be >

Re: How do I set a foreign key as a primary key?

2009-05-03 Thread Malcolm Tredinnick
On Sun, 2009-05-03 at 09:03 -0700, Thierry wrote: > I have the following model: > > class Person(models.Model): > person = models.ForeignKey(User) > age = models.IntegerField() > > How can I set the above foreign key to be my primary key so that my > Person table only contains two column

Re: django setting problem on windows

2009-05-02 Thread Malcolm Tredinnick
On Sat, 2009-05-02 at 22:24 -0700, online wrote: > I have mod_python set working fine with apache. > > I have django setting as following at apache > > > ServerAdmin webmas...@dummy-host2.li > Do

Re: passing current datetime to generic view archive_year in a decoupled url

2009-05-02 Thread Malcolm Tredinnick
On Sat, 2009-05-02 at 21:00 -0700, josebrwn wrote: > Hi, I'm trying to pass the current year the date based view > archive_year using the "url" template tag, and I'm stuck trying to get > the current time to resolve. this works just fine: > > {% now > "Y" %} > > but this (as well as many variat

Re: print_r() in Django & SQL debug output

2009-05-02 Thread Malcolm Tredinnick
On Sun, 2009-05-03 at 09:48 +0700, Okto Silaban wrote: > On Sun, May 3, 2009 at 9:27 AM, Malcolm Tredinnick > wrote: > > > > How are you rendering that template? The only thing I can > think of that > will go wrong here

Re: print_r() in Django & SQL debug output

2009-05-02 Thread Malcolm Tredinnick
On Sun, 2009-05-03 at 07:47 +0700, Okto Silaban wrote: > > > On Sun, May 3, 2009 at 7:04 AM, George Song wrote: > > > Django has extensive documentation. It's advisable that you > look it up > first before asking: > > >

Re: Avatars in comments

2009-05-02 Thread Malcolm Tredinnick
On Sat, 2009-05-02 at 15:22 -0700, trancos123 wrote: > [Sorry for my poor english] > Hi > I'm using a django.contrib.comments for my application (with django- > profile), and i want to add the user avatar > in every comment. > How can i do this? > I'm searching for a tutorial about this, but i can

Re: Help beginner again: templatetags.

2009-05-02 Thread Malcolm Tredinnick
On Sat, 2009-05-02 at 10:30 -0700, zayatzz wrote: > > > Start without the extends for a little while. > > I did - the outcome is still the same - stuff from index.html gets > loaded. > > >I still think that is the > > problem. If it isn't that, than there is a CSS or some other styling that is

Re: offline population of django auth user table

2009-05-02 Thread Malcolm Tredinnick
On Sat, 2009-05-02 at 09:09 -0700, Jeff wrote: > I'm using Django's authentication. I would like to add several users > through a command-line script (not through code executed via the > website). Something like manage.py createsuperuser but for normal > users and not interactive. I want to be

Re: Proper way to rescue transaction after IntegrityError using postgres?

2009-05-02 Thread Malcolm Tredinnick
On Sat, 2009-05-02 at 06:57 -0700, Charlie DeTar wrote: > Karen Tracey wrote: > > Thing is, a side-effect of dealing with a test that raises an > > IntegrityError, using PostgreSQL, is you need a working rollback in > > order to recover. So, even though you may not be interested in actually > > t

Re: Debug middleware

2009-05-02 Thread Malcolm Tredinnick
On Sat, 2009-05-02 at 04:11 -0700, Kless wrote: > How to debug a middleware? I would print any variables for a > middleware that I'm building > > Is there any way to make it? In any sensible web server setup, printing to sys.stderr will send the output the server's error log. With Django's devel

Re: Django equivalent to a SQL CASE statement?

2009-05-01 Thread Malcolm Tredinnick
On Fri, 2009-05-01 at 13:49 -0700, jrs_66 wrote: > Thanks! Very helpful! > > Any idea where a very experienced SQL coder can find a few details > beyond the three pages of model/queryset documentation? Such as > information on a) SQL CASE statements (or equivalent), b) performing > LEFT JOINs (

Re: "DeprecationWarning: the sets module is deprecated"

2009-05-01 Thread Malcolm Tredinnick
On Fri, 2009-05-01 at 14:59 -0700, nbv4 wrote: > Whenever I run the syncdb command, I get this error: > > ch...@chris-desktop:~/Websites/jobmap$ python manage.py syncdb > /var/lib/python-support/python2.6/MySQLdb/__init__.py:34: > DeprecationWarning: the sets module is deprecated > from sets im

Re: Django equivalent to a SQL CASE statement?

2009-05-01 Thread Malcolm Tredinnick
On Fri, 2009-05-01 at 14:27 -0700, Malcolm Tredinnick wrote: [...] > Again, provide some details about the problem(s) you're trying to solve > and we can help. Email is always hard to interpret, since it doesn't include body language. If there's any confusion about the in

Re: Help beginner again: templatetags.

2009-05-01 Thread Malcolm Tredinnick
Probably not necessary to start each title with "help" (which is pretty much implicit in the fact that there's a question asked on the list) or "beginner" (which isn't particularly helpful to us, as it could mean antyhing). Just a note for the future. :-) On Fri, 2009-05-01 at 12:16 -0700, zayatz

Re: url template tag help

2009-05-01 Thread Malcolm Tredinnick
On Fri, 2009-05-01 at 11:28 -0700, Malcolm Tredinnick wrote: [...] > Certainly the error reporting from some of the URL resolving is a little > weak and that's something we're going to fix at some point. Hopefully > before 1.1 comes out. So bear with us for a little while lon

Re: url template tag help

2009-05-01 Thread Malcolm Tredinnick
On Fri, 2009-05-01 at 11:13 -0700, Kevin Audleman wrote: > > > I can't explain any of this, but I've been thinking about your > > question since you posted it beause I know this type of error happens > > to me a lot (and indeed has been hard to debug), but I couldn't put my > > finger on remember

Re: Django equivalent to a SQL CASE statement?

2009-05-01 Thread Malcolm Tredinnick
On Fri, 2009-05-01 at 10:48 -0700, jrs_66 wrote: > Hi, > > Any pointers as to where I could find any info about performing a SQL > CASE statement using Django? Even more fundamental... is there really > no way of doing a LEFT OUTER JOIN in Django (other than terribly > sloppy role your own hacks

Re: slug field not populated on form save

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 23:46 -0300, Gabriel wrote: > I have a model with a custom field: [...] > class AutoSlugField(fields.SlugField): > def __init__(self, prepopulate_from, force_update = False, *args, > **kwargs): > self.prepopulate_from = prepopulate_from > self.force_updat

Re: ManyToMany query on all()?

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 19:26 -0700, jeff wrote: > This seems like it should be easy, but it's got me stumped. > > Here's a model from the Django examples: > > class Entry(models.Model): > blog = models.ForeignKey(Blog) > headline = models.CharField(max_length=255) > body_text = models

Re: Allow only specified HTML tags.

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 15:35 -0700, Brandon wrote: > I want to have a message board type program which will only allow html > tags which are in a specified list. How can I accomplish such a feat > with the django template system? I want to find a way before trying to > write my own template tags.

Re: managing templates(html pages)

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 15:14 -0700, Frutoso wrote: > Hello all - I am new to Django development and I have a question about > templates. > > I have many templates(html pages) and want to know the best way to > manage them all. For example: > I have business_form.html: to get data > I have business

Re: I'm having some trouble with signals.

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 15:03 -0700, Brian McKeever wrote: > I'm sure I made some dumb mistake, but I just can't see it. > Basically, I'm having difficulty connecting to the signal with my > model. Don't have time to look into this deeply at the moment, but I suspect I know the problem. The signal

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

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 12:42 -0700, Bro wrote: > class SentenceText(models.Model): > language = models.ForeignKey(Language) > text_id = models.IntegerField() > text = models.TextField() > def __unicode__(self): > return self.id + ' ' + self.text > > class Box(models.Model):

Re: Template tags and variables overlapping

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 12:22 -0700, Julián C. Pérez wrote: > jajaja i know > that what just a stupid example to make my point... Well, the details are important for something like this, since the complexity of what you're after dictates which solution approach might be most appropriate. > i plan

Re: help needed: apache httpd.conf and urls

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 12:27 -0700, zayatzz wrote: > Hello > > I have this in my template : > > > settings file is following: > MEDIA_ROOT = '/var/www/media/' > MEDIA_URL = "http://localhost/media/"; > > when i go to the webpage then the stuff that i get from server says > > > Even when i rep

Re: Configuration help. Multiple projects.

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 11:33 -0700, eric.frederich wrote: > Malcom, > > That helped. > > I think I understand what you're saying. > > I could have two projects, projectA that has appA1 and appA2 installed > and projectB that has appB1 and appB2 installed. > If projectA and projectB's settings.py

Re: Configuration help. Multiple projects.

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 10:53 -0700, eric.frederich wrote: > Malcom, > > Thanks for replying. > > Let me try to explain a little more. > > When I said "get a list of XYZ training courses" I did mean getting > the Course objects back and doing a little logic with them. > Something I'd want on the

Re: How to include session data in traceback

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 09:47 -0700, Brian Morton wrote: > Thanks. That makes perfect sense. Since my session data is persisted > in the db (and I don't have a cleanup script active at the moment), I > can retrieve the pickled session data based on the session id in the > cookie (that is in the tr

Re: Configuration help. Multiple projects.

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 07:47 -0700, eric.frederich wrote: > So, I have been tasked with creating a new website within my company > for a new project. Lets call the project XYZ (because just calling it > 'the project' is confusing since Django already has a concept of > projects). > > The website

Re: How to include session data in traceback

2009-04-30 Thread Malcolm Tredinnick
On Thu, 2009-04-30 at 04:58 -0700, Brian Morton wrote: > I am considering filing an enhancement request but I want to check > first to make sure this functionality doesn't already exist. > > Is there some way to make Django include the contents of session in > the traceback email received from a

Re: Custom primary key

2009-04-29 Thread Malcolm Tredinnick
On Wed, 2009-04-29 at 15:37 -0700, Timboy wrote: > I am trying to make a pk for an object that starts with the year > followed by seven additional digits. YYXXX I want the digits to > automatically increase like normal. > > I'm guessing I need to pass force_insert=True to my save if not > sel

Re: Displaying content in different styles.

2009-04-29 Thread Malcolm Tredinnick
On Wed, 2009-04-29 at 21:11 +0300, Oleg Oltar wrote: [...] > Is there a way to check in the loop if it's a first item. And if so to > process it in a different way? Or do I have pass first article to > template separately? Inside a for-loop you have access to a the counter for the loop and there

Re: How to deal with problem about ForeignKey

2009-04-29 Thread Malcolm Tredinnick
On Wed, 2009-04-29 at 01:36 -0700, Margie wrote: [...] > Would love to hear a summary of where this might be going from any > developers! I realize it is a tough problem - not complaining here. > Just trying to get a grip on what do do in my own app and whether > there are any changes coming and

Re: url template tag help

2009-04-29 Thread Malcolm Tredinnick
On Wed, 2009-04-29 at 08:10 -0700, Julián C. Pérez wrote: > actually... i don't use underscores into my url or views names... > that 'view_aboutPage' was actually just a made up example name Sounds like you need to provide more accurate information then. Provide the actual data that is failing. I

Re: url template tag help

2009-04-29 Thread Malcolm Tredinnick
On Wed, 2009-04-29 at 03:17 -0700, Christian Berg wrote: > it also helps to rename the URL to view-about-page. Dashed do work. > It seems that URL Namen are bound to slug resitrictions. Slugs have nothing to do with it. If you can't use underscores in URL pattern names, it's a bug. Create a small

Re: Login redirect url truncated

2009-04-29 Thread Malcolm Tredinnick
On Wed, 2009-04-29 at 07:43 -0700, Bastien wrote: > Hi, > > I'm trying to get Django to do the following: > > A user must be logged in to comment on a content. If the user is not > logged in then I provide a link to the login page and use the 'next' > function to take her back to the content pag

Re: After upgrade from .96 to 1.0.2 -- 'NoneType' object has no attribute '_meta'

2009-04-28 Thread Malcolm Tredinnick
On Tue, 2009-04-28 at 15:00 -0700, thebigape wrote: > Okay... this is a Macbook running apache2/osx 10.4.11 The Django > Admin interface worked fine with my app prior to the failed port. > Since my upgrade the only thing I've found that doesn't work is the > Admin interface. I've uninstalled

Re: link to a local file for download?

2009-04-28 Thread Malcolm Tredinnick
On Tue, 2009-04-28 at 15:24 -0500, Danny Brown wrote: > check your file permissions. Must be readable by www-data Not for a file link, no. Since it won't go back to the web-server. The file:// schema tells the browser that this is a local file. The http:// and https:// protocol, on the other hand

Re: link to a local file for download?

2009-04-28 Thread Malcolm Tredinnick
On Tue, 2009-04-28 at 12:24 -0400, Cai Yizhi wrote: > Hello, > > I am a new comer to Django. I want to create hyper link pointing to a > local text file (say ~/a.txt). I am wondering how to do this in > Django? > > I have tried: > Download > > But it doesn't work. That's because "~" doesn't m

Re: Template does not work as it should

2009-04-28 Thread Malcolm Tredinnick
On Tue, 2009-04-28 at 05:02 -0700, 83nini wrote: > Hi, > > I'm trying to display a form in the following way: > 1. creating a form > 2. writing a view method that looks like this: >def contact(request): > if request.method == 'POST': > form = ContactForm(request.POST) >

Re: Finding Reason for Form.is_valid()

2009-04-28 Thread Malcolm Tredinnick
On Tue, 2009-04-28 at 04:22 -0700, Chris wrote: > What's the easiest way to get a quick synopsis of why form.is_valid() > returns false? I'm trying to unittest a form, and whenever is_valid() > fails, it takes me forever to find out why. The "form" object will have an attribute called "errors" th

Re: Django beta slower with some queries?

2009-04-27 Thread Malcolm Tredinnick
On Mon, 2009-04-27 at 13:11 -0700, julianb wrote: [...] > In my code, I just used a queryset as parameter for __in and in > previous Django versions it would evaluate to a list of numbers > whereas now it does a subselect. I don't think that's very backwards > compatible. It's fully backwards com

Re: ignore urls

2009-04-27 Thread Malcolm Tredinnick
On Mon, 2009-04-27 at 12:25 -0700, keegan3d wrote: > I'm having trouble getting django to ignore my blog urls. > > I run wordpress from /blog, and django from /. /blog is working, but > if I try to navigate to anything deeper django takes over. > > http://inscopeapps.com/blog/ - works > http://i

Re: Replacing the standard User class with a custom one

2009-04-27 Thread Malcolm Tredinnick
On Mon, 2009-04-27 at 21:11 +0200, Emmanuel Surleau wrote: > On Monday 27 April 2009 20:12:13 karl wrote: > > > Apologies in advance, I'm sure this query pops up regularly. > > > > > > I'd like to replace the default User class which comes with Django's > > > authentication system (for my applicat

Re: Replacing the standard User class with a custom one

2009-04-27 Thread Malcolm Tredinnick
On Mon, 2009-04-27 at 08:09 +0200, Emmanuel Surleau wrote: > Hello, > > Apologies in advance, I'm sure this query pops up regularly. > > I'd like to replace the default User class which comes with Django's > authentication system (for my application, users login via email/password, > not > lo

Re: Is there a bug in queryset distinct() filtration in Postgre SQL?

2009-04-27 Thread Malcolm Tredinnick
On Mon, 2009-04-27 at 08:51 -0700, NoviceSortOf wrote: > > Thanks for the as_sql() function as can now can > see the SQL detail. Which reveals a problem in > getting DISTINCT to draw from a fields or fields that can in fact > return the unique result of the query. Perhaps it is my usage > of the

Re: Disabling PRG Pattern

2009-04-26 Thread Malcolm Tredinnick
On Sun, 2009-04-26 at 19:41 -0700, Chris wrote: > On Apr 26, 7:40 pm, Alex Gaynor wrote: > > On Sun, Apr 26, 2009 at 7:39 PM, Chris wrote: > > > > > I've noticed a Redirect/Get is issued automatically after every Post > > > made. Is there any way to disable this feature? I can't find anything >

Re: Google Appengine patch and Apengine Helper

2009-04-26 Thread Malcolm Tredinnick
On Sun, 2009-04-26 at 19:35 -0700, dartdog wrote: > Well,, both have issues,, but there has not been any visible activity > on 1)app-engine Django since about August 08. While the lone developer > on 2)App engine patch is working hard daily.. > > I have seen a few posts that others have abandoned

Re: Creating an object with a FileField programmatically

2009-04-26 Thread Malcolm Tredinnick
On Sun, 2009-04-26 at 17:21 -0700, chachra wrote: > I am trying something similar and getting: > > Cannot create a consistent method resolution > order (MRO) for bases File, FieldFile Then you're not doing something too similar, because that's quite different to the error in the post you quote.

Re: Blocking multiple form submissions from the same IP address

2009-04-26 Thread Malcolm Tredinnick
On Sun, 2009-04-26 at 12:44 -0700, Rex wrote: > On my Django site, I have an HTML form survey split across a few > consecutive pages. I want to make sure that if a user gets to the last > page and clicks "submit", they can't go back to the first page of the > form and repeat the whole process. (I

Re: instancemethod expected at least 2 arguments, got 0

2009-04-26 Thread Malcolm Tredinnick
On Sun, 2009-04-26 at 11:24 -0700, bobhaugen wrote: > Malcolm, thanks a lot for replying, and for the suggestions. > > But it looks like it wasn't a django problem or a problem with the > quoted code. Adds emphasis to the requirement to reduce things to a self-contained demonstration. Always. :-

Re: Getting data post from input with multiple name

2009-04-26 Thread Malcolm Tredinnick
On Sun, 2009-04-26 at 10:20 -0700, eli wrote: > Hi, > > I have problem: > In my template, I have some inputs with multiple name like: > value="{{ data.name }}" /> > > How to get this data from request.POST in view method? > > I tried: > - request.POST.get('values', None) > - request.POST.get

Re: instancemethod expected at least 2 arguments, got 0

2009-04-26 Thread Malcolm Tredinnick
On Sun, 2009-04-26 at 07:52 -0700, bobhaugen wrote: > Here's the traceback: > http://dpaste.com/38000/ > > Here's the code that triggered the error: > > swaps = Swap.objects.filter( > Q(state=2, proposing_offer__offerer=request.user) | > Q(state=2, responding_offer__offerer=r

Re: Help with templates

2009-04-26 Thread Malcolm Tredinnick
On Sat, 2009-04-25 at 23:45 -0700, Prtamma wrote: [...] > I am using the following code > > {% if object.album_set.all %} > > {% for album in object.album_set.all %} > {{ album.title }} li> > {% endfor %} > > {% endif %} > > but nothing shows up, can anyone please correct m

Re: could not load custom filter

2009-04-26 Thread Malcolm Tredinnick
On Sun, 2009-04-26 at 06:09 -0700, tekion wrote: > Hi, > I have tried to load my customer filter, but getting an error which > indicates it's not in the path. I saw a similar post, one of the > suggested things to check was to make sure the project was listed in > the setting.py file. My project

Re: Manipulating ManyToManyField in Model.save()

2009-04-25 Thread Malcolm Tredinnick
On Sat, 2009-04-25 at 04:37 -0700, medhat wrote: > Here is a small example: > > class Item(models.Model): > title = models.CharField(max_length=25) > other = models.TextField(null=True, blank=True) > items = models.ManyToManyField('self', null=True, blank=True) > > def __unicode_

Re: ManyToMany relationship being 'lost'?

2009-04-25 Thread Malcolm Tredinnick
On Fri, 2009-04-24 at 15:32 -0300, Rubens Altimari wrote: > Hello, > > > Sorry if this is a known issue, but I didn't find anything elsewhere. > > > I have these two models related by a many-to-many relationship. I'm > using the 'default' admin application to edit data, and in order to be > ab

Re: Offtopic: MySQL or PostgreSQL for a limited VPS ?

2009-04-25 Thread Malcolm Tredinnick
On Fri, 2009-04-24 at 16:18 -0700, Joshua Partogi wrote: > > > On Apr 25, 8:20 am, Konstantin S wrote: > > Hello! > > > > I am planning to deploy django based site on a limited VPS and want to > > know which database is more suitable for this ? If I've had a 'normal' > > hardware I'd vote for t

Re: limit number of many to one relationships for an entity

2009-04-25 Thread Malcolm Tredinnick
On Thu, 2009-04-23 at 22:05 -0700, Avi wrote: > is there a neat way to inform the admin interface that you want to > limit hte number of one to many relationships ? (i..e. only allow 3 > addresse entires per person) ? If "neat" means "just a simple option", then no, since that's not really a prop

Re: Prolem dealing with json post data

2009-04-25 Thread Malcolm Tredinnick
On Thu, 2009-04-23 at 21:23 -0700, Francis wrote: > Hi, I'm using dojo (also tried with jquery) to send json data to my > django application. > > But I can't get it working properly. The trick to understanding is to think how are you sending the data? In particular, what MIME type is being used?

Re: Is there a bug in queryset distinct() filtration in Postgre SQL?

2009-04-25 Thread Malcolm Tredinnick
On Thu, 2009-04-23 at 13:22 -0700, Tyler Erickson wrote: > I seem to be encountering the same or similar issue. The distinct() > method seems to have no affect on my queryset. Both this post and the original one don't contain enough information for anybody to replicate the problem (since we can p

Re: [Querysets] Trying to determine status of an order based on the properties of its order items

2009-04-25 Thread Malcolm Tredinnick
On Thu, 2009-04-23 at 11:00 +0100, Andrew Ingram wrote: > Hi All, > > I'm looking for an efficient way to solve the following problem, I'm > happy to use custom sql if necessary. > > Basically I have an Order model and an OrderItem model (ecommerce > site), structured as follows: > > Order(mode

Re: inclusion tag optional argument

2009-04-25 Thread Malcolm Tredinnick
On Tue, 2009-04-21 at 11:51 -0700, adrian wrote: > > I want to have an inclusion tag that builds a menu system, which has a > default config. > > default_config = [list of dicts here] > > @register.inclusion_tag('_nav_leftmenu.html') > def nav_leftmenu(menu_config=default_config): > # build

Re: dynamic creation of models

2009-04-25 Thread Malcolm Tredinnick
On Tue, 2009-04-21 at 09:52 -0700, David De Sousa wrote: > Hi! in a new project, I have the necessity of creating new models on > the fly, and then interact with them (including writing to a new table > in the database), is there any way of doing this? Yes. > I'm guessing that with a little intr

Re: How to relate child instance to Parent?

2009-04-25 Thread Malcolm Tredinnick
On Mon, 2009-04-20 at 22:39 +1000, Joshua Partogi wrote: > Dear all, > > I have an inheritance model as such: > > class User(models.Model) > > class Staff(User) > > Now I already have the instance of User inside view: > > user = User.objects.create(name="Joe") > > now how do I relate this us

Re: Database Error

2009-04-25 Thread Malcolm Tredinnick
On Sun, 2009-04-19 at 22:24 -0700, Adrián Ribao wrote: > Hello, > I have a model using extra fields in M2M relationships as described > in: > http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships > > When I try to do something I get this: > > "psycopg2

Re: Block delete

2009-04-25 Thread Malcolm Tredinnick
On Fri, 2009-04-17 at 21:36 -0700, koranthala wrote: [...] > I understand it is done because all backends does not support it - but > can it be supported for backends which actually support it? I am using > postgresql - and now I have to do many non-optimal things to decrease > this query count.

Re: how to create some application variable for django

2009-04-25 Thread Malcolm Tredinnick
On Fri, 2009-04-17 at 03:02 -0700, forrest yang wrote: > session would be created esaily, but could django create some > application variable like asp.net , or provide some special function > for the different period of server, on_server_start() > on_application_start() or something like that? Th

Re: Strange inconsistency between SQL and ORM with SQLite.

2009-04-25 Thread Malcolm Tredinnick
On Thu, 2009-04-16 at 23:11 -0700, Tai Lee wrote: > I'm trying to add an extra selection to a queryset, `featured`, which > should be True (or 1) if the primary key matches a number of known > values. > > It appears to work as expected both in SQL and the ORM when matching > against a single valu

<    1   2   3   4   5   6   7   8   9   10   >