Re: Controlling File Downloads.

2010-12-15 Thread euan.godd...@googlemail.com
If you're using apache you might want to consider wiring your app to generate mod_auth_token URLs and have apache receive these. On Dec 15, 8:29 am, NoviceSortOf wrote: > What is the best way to allow authorized downloads > to specific users in Django. > > We have 2 possible scenarios that could

Re: Jquery-ui in admin: c is undefined

2010-08-05 Thread euan.godd...@googlemail.com
It looks like order is important. I don't think there's much you can do other than declare it twice in this case. On Aug 5, 8:59 am, Alessandro Ronchi wrote: > If I load jquery-ui (a custom full download) in my admin I get this script > error: > c is undefined > > If I load 2 times jquery with >

Re: django mail_admins source code

2010-08-05 Thread euan.godd...@googlemail.com
AFAIK mail_admins is designed to send error messages to the site administrator, not for the purpose you are proposing, so you won't get the original email. Your proposal seems reasonable enough to me since you're not using mail_admins as designed. Why take only the second admin email address? On

Re: django.contrib.auth

2010-08-03 Thread euan.godd...@googlemail.com
Why would you want to do such a thing? md5 is very week compared to sha1 and has known vulnerabilities, e.g. http://searchsecurity.techtarget.com/news/article/0,289142,sid14_gci1430587,00.html On Aug 3, 2:45 pm, Seaky wrote: > Hi, > > I want to modify type of hash by default in auth (sha1 -> md5)

Re: ModelChoiceField Question

2010-07-28 Thread euan.godd...@googlemail.com
I believe ModelChoiceField is meant to be used with ModelForm. I'd stick to one or the other. Either use ModelForm and let it do the work, or use Form and do the work yourself rather than trying to get ModelChoiceField to work. Euan On 29 July, 05:23, Carlos Daniel Ruvalcaba Valenzuela wrote: >

Re: User Registration: Looking for tips

2010-07-28 Thread euan.godd...@googlemail.com
For the UserProfle model you've provided you won't be able to user the UserCreationForm as there are a load of extra fields. Moreover because User is a foreign key from that model it isn't a straight- forward matter of using a model form. To get a single model form to split the work to two underly

Re: Plese guide to solve this

2010-07-21 Thread euan.godd...@googlemail.com
The traceback tells you exactly what the problem is. The correct kwarg is max_length On Jul 21, 2:00 pm, balu wrote: > Respected sir > > This is balu studying B.Tech third year. I started working on django > in order to create dynamic website. My Python version is 2.6.5. While > I'm using creati

Re: iPython and Django issue

2010-07-21 Thread euan.godd...@googlemail.com
I think you need to install readline before you compile python. iPython doesn't work properly without it, although I've never seen it give a traceback - it usually just looks a bit forlorn. On Jul 21, 2:02 pm, Ingo86 wrote: > Hello all, > i'm on MacOSX Snow Leopard and I have an issue with iPytho

Re: update least syntax?

2010-07-11 Thread euan.godd...@googlemail.com
Django doesn't support the query type you're trying to do. You've already discovered F which is about as complicated as it gets, bt the update syntax is pretty much limited to setting a field's value to a consant. Looping over the minimum set of things and calling save on each one if your only opt

Re: How to pass a GET param that contains multiple items

2010-07-11 Thread euan.godd...@googlemail.com
This is a standard encode/decode situation you are descibing. Django automatically decodes the GET string the the browser encodes. If you need spaces, then they wil be encoded and decoded appropriately, so don't worry about that. If you want to pass a list in the GET string, do: url?var=1&var=2&v

Re: Error in Admin - can't seem to chain __unicode__'s for ForeignKeys

2010-07-08 Thread euan.godd...@googlemail.com
I think the problem you're facing is that you're trying to concatenate a string and an object together. Before I dive into the explanation, you might want to bear a couple of things in mind: 1) Your unicode method doesn't explicitly return a unicode object which will be a problem if any of the var

Re: Passing argument to Template loader

2010-07-08 Thread euan.godd...@googlemail.com
I'm not sure I understand exactly what the problem is. The post you cite seems to have the exact solution you are looking for. I appreciate that you don't want to violate DRY, but pretty much every Django view I've written ends with render_to_response. In your situation you just give the "templates

Re: Log errors to file

2010-07-08 Thread euan.godd...@googlemail.com
I have created a decorator for Django views which handles AJAX tracebacks and sends the traceback back to the AJAX application as JSON, e.g. {'status':'error', 'message': } It uses the traceback module to output the full traceback. Obviously you need to have a handler that receives this data and

Re: get_model()

2010-07-08 Thread euan.godd...@googlemail.com
I've never found any documentation. It's pretty useful if you're having import issues. On Jul 8, 7:25 am, Kenneth Gonsalves wrote: > hi, > > any reason why get_model() in django.db.models is not documented? Or is it > just that I cannot find it? > -- > Regards > Kenneth Gonsalves > Senior Associa

Re: Is Django admin's "delete confirmation" considered RESTful?

2010-07-07 Thread euan.godd...@googlemail.com
eplacing the url that the user sees?  IE, > instead of showing ://admin/auth/user, show ://admin/auth/ > user_delete_confirmation?  And if so, how does one do this?  I don't > think you can replace the url with render_to_response, right?  I could > do a redirect, but if I did that,

Re: New tutorial added to Django by Example

2010-07-07 Thread euan.godd...@googlemail.com
Hi again, I've had a read over your blog tutorial and have the following suggestions: 1) Make it PEP-8 (http://www.python.org/dev/peps/pep-0008/) compliant - it's a lot easier to read. 2) Except only the error that might occur in the paginatior example. Bare excepts are BAD. 3) Maybe consider ena

Re: Filter based on result of model method

2010-07-07 Thread euan.godd...@googlemail.com
As stated there is no way to filter on any non-field attribute, property or method. However, don't despair. If the result of your permission check can be expressed as another Django query then it should be possible to construct something in the ORM that uses this. That said, we have had trouble wi

Re: Is Django admin's "delete confirmation" considered RESTful?

2010-07-07 Thread euan.godd...@googlemail.com
I'm not entirely sure whether you're asking one question or two here. Firstly, I think that in the RESTful sense, there's nothing wrong with having a confirmation page that uses the same URL to perform an action *providing* the HTTP verb is different. In this case the confirmation page is accessed

Re: Calling some javascript for new visitors only

2010-07-07 Thread euan.godd...@googlemail.com
You'll need to do the test in the view and then pass the result of the test into the template. On Jul 7, 10:13 am, grimmus wrote: > Hi, > > I need to show a javascript lightbox popup for new visitors to my > site. > > I presume using a cookie is the best way to achieve this. But how can > i check

Re: Jumping from Django to php : maintaining session variables..

2010-07-06 Thread euan.godd...@googlemail.com
I think the solution is pretty self-explanatory. Could you give details of the specific problem you're encountering, because, as far as I can see, the snippet given in the referenced post is excellent, although I fail to see why any one would want to support a cross-PHP/ python application out of c

Re: GROUP BY and ORDER BY using the ORM

2010-07-05 Thread euan.godd...@googlemail.com
tra() clause or perhaps look at using a property bound to a > method however at this point you're outside the scope of the ORM. > > Any ideas on how I can best acheive this? > > I'm trying to stay away from using a foreach and looping over a > potentially large number of r

Re: break/continue for templates

2010-07-05 Thread euan.godd...@googlemail.com
The link to your snippet doesn't work for me. It sounds like a neat idea. However, I've never come across a situation where I've needed to do that in 2.5 years of developing Django templates, and, whilst I agree that we don't want to get into a holy war about whether stuff should be done in templa

Re: manage.py ignores DJANGO_SETTINGS_MODULE

2010-07-05 Thread euan.godd...@googlemail.com
a bit about startup steps. > > Graham > > On Jul 5, 4:25 pm, "euan.godd...@googlemail.com" > > > > wrote: > > If you read the source for django.core.management.__init__ you'll find > > a function called "setup_environ. This is called by all

Re: New Django tutorial

2010-07-04 Thread euan.godd...@googlemail.com
Glad to be of assistance. Let me know when it's finished or if you want another look over, Euan On 3 July, 15:22, Rainy wrote: > Thanks for great feedback, Euan. I've added some comments below. > > On Jul 3, 8:26 am, "euan.godd...@googlemail.com" > > wrote:

Re: GROUP BY and ORDER BY using the ORM

2010-07-04 Thread euan.godd...@googlemail.com
Erm. You don't seem to have specified what to order by. In this case, surely you want ... .order_by('date_time') However, this field doesn't seem to appear in your models. One thing I've found handy for debugging Django's ORM to SQL is something which I don't think is documented in django docs at

Re: manage.py ignores DJANGO_SETTINGS_MODULE

2010-07-04 Thread euan.godd...@googlemail.com
If you read the source for django.core.management.__init__ you'll find a function called "setup_environ. This is called by all management commands (i.e. manage.py). If you note here the os.environ is set unconditionally. I suppose for your setup to work correctly django should be doing: if not "DJ

Re: New Django tutorial

2010-07-03 Thread euan.godd...@googlemail.com
I had a look over your tutorial and it looks pretty sweet. Definitely gets down into explaining how to use the admin interface and taught me things I hadn't realized. I have a few suggestions for you (feel free to ignore :)): 1) I'm not sure how good an idea it is to call the attribute on your Dat

Re: Django Personalization and Preferences?

2010-07-03 Thread euan.godd...@googlemail.com
Seems good to me. You could have a preferences model which has a one- to-one relationship to a User. Your method is sound that it saves an additional SQL query to get the extra info, but if you have the auth context processor enabled you can always do: {{ user.preferences.employee }} # where emplo

Re: Valid objects are returning an http 404 response

2010-07-01 Thread euan.godd...@googlemail.com
When you say "an apache 404 error" do you mean a non-Django styled one? If so, I think there's something wrong with your apache configuration and not your Django app. What mechanism are you using to serve the application? I have seen issues like with this mod_wsgi when the reload mechanism isn't tr

Re: Managing the balance between SSL and impact on the server

2010-07-01 Thread euan.godd...@googlemail.com
We have a Django solution that blends both SSL and none SSL. We did it by creating a decorator for views that adds an attribute to the view function and then some middleware that ensures these views are always server over SSL (with a permanent redirect to the SSL equivalent if necessary). We also r

Re: LAMPP + Django on Fedora 13 Linux

2010-06-30 Thread euan.godd...@googlemail.com
I think you're maybe a bit confused about what exactly LAMPP provides. If you're going to use phpmyadmin, you might want to re-think going for Django in the first place. Django provides a much more tailored admin interface than phpmyadmin will give you (although the latter is great for custom SQL,

Re: Should I start to use Mako from beginning?

2010-06-30 Thread euan.godd...@googlemail.com
If you're going to use Mako and SQLAlchemy I'd use Pylons or repoze.bfg rather than trying to crowbar them into Django. Django's templating engine and ORM are used on many high volume sites without any issues of scalability, so if you're keen to learn the rest of Django I'd stick to that. On the

Re: Proper approach to updating model object with 100 attributes.

2010-06-30 Thread euan.godd...@googlemail.com
The frozenset wasn't any commentary on your approach or speed of parsing, I just like to use them where-ever possible. My only concern with your approach was that you were expecting every field on the model to be in the dictionary. Looping over the dictionary's items and ignoring any fields that a

Re: Proper approach to updating model object with 100 attributes.

2010-06-30 Thread euan.godd...@googlemail.com
, value in dictionary_of_field_values.iteritems(): if field in allowed_fields: setattr(obj, field, value) Euan On Jun 30, 1:36 pm, Tim Chase wrote: > On 06/30/2010 02:10 AM, euan.godd...@googlemail.com wrote: > > > I think you need to be careful messing with __dict__ as Django tu

Re: Proper approach to updating model object with 100 attributes.

2010-06-30 Thread euan.godd...@googlemail.com
I think you need to be careful messing with __dict__ as Django turns most fields in descriptors behind the scenes so setting them in the __dict__ could break these. I'd stick to setattr and maybe verify that the key in the dictionary is one of the model's fields. I think there is a method on _meta

Re: Disabling the use of certain template tags

2010-06-30 Thread euan.godd...@googlemail.com
I'm not sure whether you could define tags with these names yourself that do nothing (or a safe version of what Django allows). I suspect Django might not allow this and give a name clash. Alternatively you could parse any such tags out of the user defined templates before passing them to the temp

Re: Admin Search Engline

2010-06-29 Thread euan.godd...@googlemail.com
the admin files is responsible > for the search engine so that I can extend it? > > On Mon, Jun 28, 2010 at 10:27, euan.godd...@googlemail.com > > wrote: > > I think that would be quite an undertaking as you would need to write > > an expression parser and monkey around w

Re: None field : Admin save setting it to empty value instead of NULL during save

2010-06-29 Thread euan.godd...@googlemail.com
Django admin can't differentiate between empty string and None and picks empty string which makes sense in most cases. If you don't like the idea of empty string override the save method and coerce empty string to None before calling the super classes save, e.g. class YourModel(models.Model):

Re: Admin Search Engline

2010-06-28 Thread euan.godd...@googlemail.com
I think that would be quite an undertaking as you would need to write an expression parser and monkey around with the search code in admin. If you succeed, I'd be interested to see the result. Euan On Jun 28, 8:36 am, Massimiliano della Rovere wrote: > I'd like to modify the default search engi

Re: Why is ModelAdmin to Model a 1-1 relationship?

2010-06-28 Thread euan.godd...@googlemail.com
That's a great solution. Much better than messing around with the metaclass :) On Jun 27, 5:47 am, Lee Hinde wrote: > On Fri, Jun 25, 2010 at 2:54 PM, patjenk wrote: > > In our application, we have a Model that has a boolean field named > > "deleted". When the delete() method is called, we set t

Re: Why is ModelAdmin to Model a 1-1 relationship?

2010-06-26 Thread euan.godd...@googlemail.com
It may be possible to sub-class admin.ModelAdmin so that when your two instances are registered the code won't throw an exception. I suspect it might be a bit nasty as many such things in Django are often fraught when you stray off the beaten path. If I get a chance I'll take a look at the source

Re: Rendering the Admin app list?

2010-06-26 Thread euan.godd...@googlemail.com
There is no reason why all views should pass that variable to the template. It is more efficient to only pass the minimal variable necessary to render the template Even the list is lazily evaluated there is still unnecessary overhead in passing it when not needed. Euan On 26 June, 08:50, derek w

Re: reloading in shell

2010-06-25 Thread euan.godd...@googlemail.com
LOL. Yeah bpython is interesting. Some of the features were pretty nice last time i tried it, but it was a bit flaky so I stuck with iPython. Could have well improved since then though. On Jun 25, 12:26 pm, Kenneth Gonsalves wrote: > On Friday 25 June 2010 16:48:49 euan.godd...@googlemail.

Re: reloading in shell

2010-06-25 Thread euan.godd...@googlemail.com
> The latter, as I don't have to do at across 200 different boxes, I > just edit one file in my NFS home directory? That was joke btw. But for one person running on a single machine with plenty of resources, I honestly think that iPython is the best option. I had a read of the link you posted and

Re: reloading in shell

2010-06-25 Thread euan.godd...@googlemail.com
> To be a bit pedantic, python itself supports many of these features > (tab completion, history) if you tell it to. What's easier, sudo easy_install iPython, or making alterations to the existing python interpreter and still not having colour :) ? -- You received this message because you are su

Re: Admin Media output order?

2010-06-25 Thread euan.godd...@googlemail.com
You could possibly alter the metaclass for the media for your model, but I suspect this would lead to a whole world of hurt. On 24 June, 20:18, ringemup wrote: > Is there any way to change the order in which admin media are output > (e.g. outputting a ModelAdmin-level javascript after a widget-le

Re: Rendering the Admin app list?

2010-06-25 Thread euan.godd...@googlemail.com
Do you mean that you want to include this code in your own app or want to alter the structure of the admin app? Either of these actions will require the view that renders the page to pass the variable app_list into the context as }% if app_list %} will always be False as Django's templating system

Re: reloading in shell

2010-06-25 Thread euan.godd...@googlemail.com
iPython is great for this sort of thing, especially the code completion with tab. You could also use the reload statement. This only works when you do: import foo.bar.MyClass and doesn't always work correctly, but it might save a bit of typing. On 25 June, 06:24, Kenneth Gonsalves wrote: > On

Re: Django Sphinx or haystack Xapian

2010-06-24 Thread euan.godd...@googlemail.com
We are in the process of switching from a custom Xapain installation to Solr as we found Xapian quite limited in its ability to do faceting, spelling suggestions, or highlighting. If you don't need any of those things, I would recommend Xapian (although I've not used it through Haystack). I have us

Re: Generate image and send to template

2010-06-24 Thread euan.godd...@googlemail.com
I can't understand the comments in your code, but it looks like some graph generating software. I think the problem you're having is that the first function returns a HttpResponse half way through (line 53), but then there is some further processing which will never be accessed. The second functi

Re: noob syntax question

2010-06-24 Thread euan.godd...@googlemail.com
I'd add to Michael's comment that if you're unhappy with this syntax (I personally find it a bit odd in some cases), you can customize exactly what word is used there in your model definition. If you alter the choice model and add the "related_name" keyword to the foreign key definition, e.g.: cl

Re: trying to do console testing of my models, "no module named X"

2010-06-24 Thread euan.godd...@googlemail.com
If you do: python manage.py shell you will get a python shell with all the necessary paths set up so that you can do your testing. You may also want to consider some sort of automated testing as it makes this sort of thing a lot easier and quicker. Euan On 24 June, 05:04, robinne wrote: > I ha

Re: How to options by limited_choices_to ?

2010-06-23 Thread euan.godd...@googlemail.com
First of all you might want to reconsider not using the name "type" for one of your fields as it is a builtin in python. I guess what you could do it limit the choices using the choices keyword in the field constructor. However, since this appears to be dynamic you would need to set it in the mode

Re: Forms - Widget - Radioselect - how to set initial value on a static form

2010-06-23 Thread euan.godd...@googlemail.com
Karen's suggestion is great. You can also pass initial data into the form constructor. So using the example above if you do (in your view): my_form = F1(initial=dict(rs_field='N')) you'll achieve the same result. Don't think there's much to be said for either way other the way I just suggest migh

Re: outer join in orm

2010-06-22 Thread euan.godd...@googlemail.com
er be more pythonic than eg running raw sql. Nonetheless, I > view this as a weakness in Django's ORM, and would plead with TPTB to > provide a solution, not that it would affect my current problem. > > On Jun 21, 11:46 am, "euan.godd...@googlemail.com" > > wrot

Re: Django-Mysql

2010-06-22 Thread euan.godd...@googlemail.com
Do you absolutely need to use MySQL? I've found for development that sqlite is the most hassle-free. I use OS X for development at home and it is the easiest option. The only drawback is that if you have multiple clients accessing the DB you can get locking issues. If it's just you, then you're sor

Re: Django c _imaging module not installed

2010-06-22 Thread euan.godd...@googlemail.com
Are you doing some image related work in Django admin? We have had lots of trouble with libjpeg and PIL. We use PIL 1.1.6 and libjpeg 6. Our install process requires using apt to install the libjpeg62-dev package before installing PIL 1.1.6. If you're using a Debian based OS, I'd remove your cust

Re: automatic documentation (docutils) does not pull in class methods?

2010-06-22 Thread euan.godd...@googlemail.com
You could try using Spinhx if you don't think docutils gives you enough flexibility. The autodoc extension is great. On Jun 22, 5:24 am, pk wrote: > Answering my own question -- it is django.contrib.admindocs.view that > limits the admindocs view to only list methods on a model that has a > singl

Re: One to many django pagination

2010-06-22 Thread euan.godd...@googlemail.com
If i understand you correctly you've got a couple of solutions. You can define a "through" relationship between Student and Teacher usinf Techer_profile as the "through" table (http://docs.djangoproject.com/ en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships). Then you should be ab

Re: outer join in orm

2010-06-21 Thread euan.godd...@googlemail.com
AFAIK there is no direct way to do this sort of thing in a single query. select_related will only get foreign key relations into the query so the ORM will always do an SQL query for each row in your many to many. In these types of situations I tend to select everything I need and then run some sort

Re: File upload from python client to Django app

2010-06-21 Thread euan.godd...@googlemail.com
urllib2 can handle cookies and therefore you should be able to handle the login. It will probably be a fair bit of work to get the client to submit the various parts, but I'm sure I've seen some examples around on how to do such a thing. Euan On Jun 21, 3:52 pm, srn wrote: > Hello to all, > > I'

Re: optional ForeignKey

2010-06-21 Thread euan.godd...@googlemail.com
You want: parent = models.ForeignKey('self', null=True, blank=True) On Jun 21, 3:37 pm, Magnus Valle wrote: > Hi, > I'm trying to make model that has itself as a foreign key, in an > attempt to store a reverse tree in Django. > However, I can't find a way to set a default value to > models.Forei

Re: How much would you charge for this? £5k? £15k? £50k?

2010-06-21 Thread euan.godd...@googlemail.com
It sounds like your project is pretty fully featured and if you claim to be "inexperienced" in Django development this much work is pretty impressive on a part-time basis over 6 months! Currently the Django project I am working on has taken over 2.5 years (and is ongoing). Although we don't just d

Re: Django Template Hyphenated Keys

2009-02-17 Thread euan.godd...@googlemail.com
Why can't you change the dictionary? Can't you just create a copy of the dict and rename the keys in your copy using _ rather than - like so: >>> bad = {'var-1':'Apples', 'var-2':'Pears'} >>> good = dict() >>> for k,v in bad.items(): >>>good[k.replace('-','_')] = v >>> good {'var_1': 'Apples