Re: Rendering a form based on partly determined model state

2009-05-21 Thread google torp
Hi, not on my computet so will keep it short. Try to google "django form trick" the top result should be a blog post by colin grady. Basically what you need to do is to override the init method. ~Jakob On May 21, 8:44 pm, Joakim Hove wrote: > Hello, > > I have just started using Django - looks

Re: need help for using counter inside for loop

2009-05-20 Thread google torp
This is probably more a python issue than a Django issue. Also I don't really know what it is you want to do, but you should consider if you really need to make all these lists? Also when dealing with dates or datetimes python can do a lot of string conversion for you. If you want to do it the way

Re: Variables between Form and views

2009-05-13 Thread google torp
Hi It seems your problem with dlist_choice is caused by an incorrect you of global vars. I've not used globals much myself, but I believe that you don't import them, but instead in every function that needs them do a global var_name. the other traceback seems irrelevant, but the problem you that

Re: change query for ModelChoiceField

2009-05-11 Thread google torp
This should fix it. def __init__(self, something, *args, **kwargs): super(ShippingMethodForm, self).__init__(*args, **kwargs) self.fields["ship_method"].queryset = ShippingMethod.objects.filter(something) when you initiate the form, you do it like this: form = ShippingMethodForm(

Re: ajax cascading select boxes

2009-05-11 Thread google torp
ake a look at that. ~Jakob On 11 Maj, 09:17, newbie wrote: > First of all, thanks for the reply :) > > On May 11, 11:59 am, google torp wrote:> So CustomUser > and UserDetails  is a model you made for your > > users? If that is the case, you probably want to hook use a &

Re: ajax cascading select boxes

2009-05-10 Thread google torp
So CustomUser and UserDetails is a model you made for your users? If that is the case, you probably want to hook use a modelform instead is it makes things a bit eaiser. Anyways in your view, the user just pops out of the blue. My guess is that you need to do something like user = CustomUser(...

Re: MySQL issues

2009-04-27 Thread google torp
Hi. I haven't used Django with mysql, but judging from your error it sounds like you haven't created the database in mysql. Django probably cannot create a db like it can when you use sqlite, as it's only a file anwyays. So you need to use your mysql tool phpmyadmin or whatever you use and create

Re: how to redirect to previous page

2009-04-21 Thread google torp
On Apr 21, 10:53 pm, Margie wrote: > Can anyone advise me on what is the best way in the views.py code to > return an HttpResponse that simply returns the user to the previous > page they were on? > > For example, let's say that multiple different pages have a button > that executes some code i

Re: Search and urls

2009-04-21 Thread google torp
if you really wanted it like that, you could setup your url like this (r'^search/q=(?P)', ...) or you could just remove the q= for prettier urls and do: (r'^search/(?P)', ...) That will give you the variable "query" to your view, you have to write it in your view function aswell. read about urlc

Re: Setting dates

2009-04-18 Thread google torp
You can do do something like this: date = date.today() while date.day != 20: date += timedelta(1) ~Jakob On 18 Apr., 21:57, Alfonso wrote: > Hi, > > I'd like to set the default date of a datefield to be 'the 20th of the > current month', if past that date the date should be set to the 20th

Re: Dynamic Form - polls

2009-04-18 Thread google torp
Hi. Normally, what you are doing would work, initializing the form with request.POST. However the way you have constructed your form, you need have a poll object as well. Not only that but it should of cause be the poll that the post data is associated to. Then you could do it like this form = Pol

Re: Unittests

2009-04-17 Thread google torp
cases was a speciel naming convention for tests after reading the docs. ~Jakob On Apr 17, 10:29 pm, Alex Gaynor wrote: > On Fri, Apr 17, 2009 at 4:26 PM, google torp wrote: > > > Hi. > > You have named your test incorectly, so django won't see it as a test. > >

Re: Queries, how to get what i want?

2009-04-17 Thread google torp
= z.name >                 return t > > Worked just fine. > > Thanks again :) > > Alan. > > On Apr 17, 3:21 am, google torp wrote: > > > Hi. > > I think the problem is that get is being run before the exclude when > > you still have two results and fail

Re: Unittests

2009-04-17 Thread google torp
Hi. You have named your test incorectly, so django won't see it as a test. You need to name testCamelCaseName. Camel cases are probably not required but that's the convention. Try renaming your test. ~Jakob On Apr 17, 9:04 pm, Daniel Joshua Worth wrote: > If I run "./manage.py tests booking" it

Re: Queries, how to get what i want?

2009-04-16 Thread google torp
Hi. I think the problem is that get is being run before the exclude when you still have two results and fails as it can only handle a single result. In this case you can't use get but should use filter().exclude()[0] to get the result. On Apr 16, 10:01 pm, zayatzz wrote: > I need help with makin

Re: can’t input @ sign on a Windows PC which I installed Portable Ubuntu -- which gives you linux on it

2009-04-15 Thread google torp
This group is for Django related subjects only, please help us keep the posts on subject. I would suggest you asked this question in a Portable Ubuntu group instead. ~Jakob On 15 Apr., 20:58, bconnors wrote: > I have a Windows PC which I installed Portable Ubuntu -- which gives > you linux on i

Re: Problem querying database

2009-04-15 Thread google torp
m the query you would need an if statement in the randrange version aswell. ~Jakob On 15 Apr., 17:54, Baxter wrote: > On Apr 15, 10:44 am, google torp wrote:> What I meant > was that you could do it like this > > > import random > > sa = Article.objects.filter(...).orde

Re: Problem querying database

2009-04-15 Thread google torp
so the first wont be selected) and number of articles -1 so there wont be in problem getting a number that is too high. This is just pure python functionality btw. ~Jakob On 15 Apr., 16:54, Baxter wrote: > On Apr 15, 9:39 am, Baxter wrote: > > > On Apr 15, 9:33 am, google torp wrote:

Re: Problem querying database

2009-04-15 Thread google torp
Hi. You can just use the python random function, I believe it's in math, and generate a random number in range of the number of articles. You could do that before the slice even, and just get a random number with min value of 2 instead. ~Jakob On 15 Apr., 16:23, "bax...@gretschpages.com" wrote:

Re: code from database in template -> <br>

2009-04-15 Thread google torp
> > safe }} > >       {% endautoescape %} > > > Data goes from the db (by but some stuff) so there is not risk. > > > Thanks again. > > > Wishes, > > > M. > > > On Apr 15, 2:15 pm, google torp wrote: > > > > Hi > > > The

Re: code from database in template -> <br>

2009-04-15 Thread google torp
Hi There is a page for all the django template tags: http://docs.djangoproject.com/en/dev/ref/templates/builtins/ Your problem is the auto escape, you can use "|safe" to mark something safe and it wont be escaped. Doing this for user submitted data is a bad idea though, so make sure you don't mak

Re: Different approach?

2009-04-15 Thread google torp
Hi. As I'm not sure exactly what your goals with this site is, I'll be guessing a bit here. Using the admin to create customers ect, can be a solution, but having access to the admin also means having access to a whole bunch of stuff that you can mess with. You could instead make some views that

Re: serving static files

2009-04-13 Thread google torp
Hi. You misunderstood the docs a bit, I c/p'ed the url-conf bit here: (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}), The problem here that is also causing the error is that the file name should be a variable and not hardcoded for every file,

Re: Use Python to parse HTML and integrating said script into Django

2009-04-12 Thread google torp
Hi. It sounds like you need to change your code structure a bit to really take advantage of Django and the possibilities it offer. If you just want to get your stuff working with Django and then nothing more, I guess you could keep it like it is, but else re factoring would be a good idea. The w

Re: Details

2009-04-09 Thread google torp
Hi. I'm guessing a bit here, not sure if it actually will make any difference, but try to delete the $ in the include so it'll become: (r'^', include('p2.front.urls')), $ marks the end of the url, so maybe that is giving you the problem. ~Jakob On 9 Apr., 11:55, zayatzz wrote: > I think it has