tutorial error

2011-11-02 Thread rihad
It says at the end of part 3 of the Django tutorial: "The idea behind include() and URLconf decoupling is to make it easy to plug-and-play URLs. Now that polls are in their own URLconf, they can be placed under "/polls/", or under "/fun_polls/", or under "/ content/polls/", or any other path root,

Re: tutorial error

2011-11-02 Thread Daniel Roseman
On Wednesday, 2 November 2011 07:24:39 UTC, rihad wrote: > > It says at the end of part 3 of the Django tutorial: > > "The idea behind include() and URLconf decoupling is to make it easy > to plug-and-play URLs. Now that polls are in their own URLconf, they > can be placed under "/polls/", or un

"python manage.py runserver" creates not tables (tutorial)

2011-11-02 Thread angelika
I've started the Django tutorial and I get as far as running python manage.py runserver, but when I do, nothing happens. I get no messages and the database connected to the project is still empty. The database exists and I've made no modifications to any of the files created, accept for the info to

Re: "python manage.py runserver" creates not tables (tutorial)

2011-11-02 Thread angelika
Sorry, title is supposed to be "python manage.py runserver" creates no tables (tutorial) On Nov 2, 10:42 am, angelika wrote: > I've started the Django tutorial and I get as far as running python > manage.py runserver, but when I do, nothing happens. I get no messages > and the database connected

Re: "python manage.py runserver" creates not tables (tutorial)

2011-11-02 Thread nisa balakrishnan
did u do a syncdb ? On 02-Nov-2011, at 3:12 PM, angelika wrote: > I've started the Django tutorial and I get as far as running python > manage.py runserver, but when I do, nothing happens. I get no messages > and the database connected to the project is still empty. The database > exists and I've

Re: "python manage.py runserver" creates not tables (tutorial)

2011-11-02 Thread angelika
Christ, I totally messed up this post. I did not mean "python manage.py runserver" but "python manage.py syncdb". That is the command that does not create any tables. Sorry. On Nov 2, 10:44 am, nisa balakrishnan wrote: > did  u do a syncdb ? > On 02-Nov-2011, at 3:12 PM, angelika wrote: > > > > >

Re: No module named django after upgrade to os x Lion

2011-11-02 Thread angelika
Thanks a million, Kurtis! I followed your advice and I no longer get any errors when I run "python manage.py runserver". Hurray :) ! I'll probably give PostgreSQL a try once I've got the hang of python and django a bit more, since you were all so positive about that. My next problem is that the c

Re: "python manage.py runserver" creates not tables (tutorial)

2011-11-02 Thread kenneth gonsalves
On Wed, 2011-11-02 at 02:47 -0700, angelika wrote: > Christ, I totally messed up this post. I did not mean "python > manage.py runserver" but "python manage.py syncdb". That is the > command that does not create any tables. Sorry. > > https://code.djangoproject.com/ticket/11494 - it may be due to

Re: tutorial error

2011-11-02 Thread rihad
On Nov 2, 1:29 pm, Daniel Roseman wrote: > On Wednesday, 2 November 2011 07:24:39 UTC, rihad wrote: > > > It says at the end of part 3 of the Django tutorial: > > > "The idea behind include() and URLconf decoupling is to make it easy > > to plug-and-play URLs. Now that polls are in their own URL

Re: tutorial error

2011-11-02 Thread rihad
On Nov 2, 1:29 pm, Daniel Roseman wrote: > On Wednesday, 2 November 2011 07:24:39 UTC, rihad wrote: > > > render_to_response('polls/detail.html', {'poll': p}) Oops, of course this has no relation to URLs, it's just a filepath :) -- You received this message because you are subscribed to the

Re: "python manage.py runserver" creates not tables (tutorial)

2011-11-02 Thread angelika
Thanks, Kenneth. I'm new to both Python and Django. I'm doing the tutorial and I named the site mysite, to keep it simple. Does that mean mysite is the name of the app? And the command should be: from mysite import * I did that, but nothing happened. Same as with 'python manage.py runserver'. No

Re: Set of choices of which several can be chosen without using a ManyToManyField

2011-11-02 Thread Mark Furbee
As alluded to previously, the most "straightforward way to use a set of choices of which several can be chosen" IS to use a ManyToManyField. The syntax is slightly different, but ManyToManyFields are really easy to use with Django. Do not reinvent the wheel in this case. Thanks, Mark Furbee On

Calling Python from JavaScript

2011-11-02 Thread asif
I will explain what i'm trying to achieve, I'm using Dajaxice with Django. I created modelformset which consist of multiple forms. Each form has dropdown field on which I'm calling dajaxice function, that function will takes the value of the dropdown field and calls another python function which c

QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Thomas Guettler
Hi, I just discovered, that "if obj in queryset" can be very slow: queryset=MyModel.objects.all() obj=MyModel.objects.get(id=319526) #if obj in queryset: # This is very slow, if queryset is big: All lines from queryset get created to Python objects #print 'in' if queryset.filter(id=obj.id)

Re: "python manage.py syncdb" creates no tables (tutorial)

2011-11-02 Thread kenneth gonsalves
On Wed, 2011-11-02 at 04:37 -0700, angelika wrote: > I'm new to both Python and Django. I'm doing the tutorial and I named > the site mysite, to keep it simple. Does that mean mysite is the name > of the app? And the command should be: you must have created an app under mysite - probably named 'po

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Flavia Missi
That's because your queryset is being evaluated when you compare, maybe if you explain your problem, we can give you a better solution than the use of `in`. Take a look at the docs about when querysets are evaluated: https://docs.djangoproject.com/en/dev/ref/models/querysets/#when-querysets-are-e

Re: "python manage.py syncdb" creates no tables (tutorial)

2011-11-02 Thread angelika
I'm following the tutorial on this page: https://docs.djangoproject.com/en/1.3/intro/tutorial01/ In it, the 'python manage.py syncdb' command is supposed to be run to create tables for the apps in the INSTALLED_APPS setting, right? And this bit seems to come before you start creating an app. Or ha

Re: "python manage.py syncdb" creates no tables (tutorial)

2011-11-02 Thread kenneth gonsalves
On Wed, 2011-11-02 at 04:59 -0700, angelika wrote: > I'm following the tutorial on this page: > https://docs.djangoproject.com/en/1.3/intro/tutorial01/ > > In it, the 'python manage.py syncdb' command is supposed to be run to > create tables for the apps in the INSTALLED_APPS setting, right? And >

Re: "python manage.py syncdb" creates no tables (tutorial)

2011-11-02 Thread Flavia Missi
You do not need to run syncdb before creating your first app, syncdb search for the apps in INSTALLED_APPS and sync their models with the database, so you can run it anytime. Note that if you just change an existing model syncdb won't sync anything, you'll need migrations for that. []'s On Wed, N

Re: Set of choices of which several can be chosen without using a ManyToManyField

2011-11-02 Thread Jaroslav Dobrek
On 1 Nov., 18:54, Mark Furbee wrote: > As alluded to previously, the most "straightforward way to use a set of > choices of which several can be chosen" IS to use a ManyToManyField. The > syntax is slightly different, but ManyToManyFields are really easy to use > with Django. Do not reinvent the

Re: "python manage.py syncdb" creates no tables (tutorial)

2011-11-02 Thread angelika
Well, here I am, confessing my stupidity to the internet. Like I said, I'm new to both Python and Django. I've been trying to run the commands in the same terminal window where I ran the 'python manage.py runserver'. When I run it in a separate window, it all works as expected. The tables are creat

Django + Ajax/Javascript

2011-11-02 Thread Felix Wagner
Hi, I have the following model layout: class A(models.model): options = models.ManyToManyField(OptionSet, blank=True, null=True) values = models.ManyToManyField(Value, blank=True, null=True) class OptionSet(models.model): name = models.TextField(unique=True) values = models.ManyT

Onchange attribute for mdelformset

2011-11-02 Thread asif
How can i access the form in django views. Suppose Modelform class QuestionForm(forms.ModelForm): answer = forms.ChoiceField(choices=HAY_EVALUATION_CHOICES, widget=forms.Select(attrs={'onchange': 'this.form.submit();'})) In views.py if 'form-0-answer' in request.POST: answer

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Jirka Vejrazka
> queryset=MyModel.objects.all() > obj=MyModel.objects.get(id=319526) Thomas, if the second line works for you (i.e. does not raise MyModel.DoesNotExist exception), then obj is in queryset by definition. What are you trying to achieve? Jirka -- You received this message because you are

Re: Django aggregation does excessive GROUP BY clauses

2011-11-02 Thread christian.oudard
Opened a bug: https://code.djangoproject.com/ticket/17144 I think I might take a crack at fixing this one. On Nov 1, 9:06 pm, Karen Tracey wrote: > On Tue, Nov 1, 2011 at 6:19 PM, christian.oudard > > > > > > > > > > wrote: > > I am doing a very simple aggregation using the Django ORM, and it

Re: "python manage.py runserver" creates not tables (tutorial)

2011-11-02 Thread Martin Chiteri
What about if you do a python manage.py sqlall >From the settings file, I do not see any of your apps added in the list of installed apps, like INSTALLED_APPS = ( 'django.contrib.auth', 'mysite.news', ., ) Martin. -- You received this message because you are subscribed to the Google

Onchange event on Choicefield in django formset

2011-11-02 Thread asif.jama...@rezayat.net
How can i access the form fields in django views. Suppose i have modelform called class QuestionForm(forms.ModelForm): answer = forms.ChoiceField(choices=HAY_EVALUATION_CHOICES, widget=forms.Select(attrs={'onchange': 'this.form.submit();'})) In views.py if 'form-0-answer' in reque

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Thomas Guettler
Here is a better example: def get_special_objects(): # Some are special. But the result can still be huge! return MyModel.objects.filter() obj=MyModel.objects.get() # is this object "special?" if obj in get_special_objects(): # This is very slow if there are many rows in the res

Re: Field available via Django shell but not via web application (crossposted from StackOverFlow)

2011-11-02 Thread Jordan
Yes, it does work in runserver, as might be expected since runserver uses exact same environment as the shell. So that established, how can I fix it? On Nov 1, 9:04 pm, Andy McKay wrote: > Is this using the Django built in runserver or some other way of serving > pages? If not try using runserve

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Tom Evans
On Wed, Nov 2, 2011 at 3:25 PM, Thomas Guettler wrote: > Here is a better example: > > def get_special_objects(): >    # Some are special. But the result can still be huge! >    return MyModel.objects.filter() > > obj=MyModel.objects.get() > > # is this object "special?" > if obj in get_sp

Re: Set of choices of which several can be chosen without using a ManyToManyField

2011-11-02 Thread Tom Evans
On Wed, Nov 2, 2011 at 12:15 PM, Jaroslav Dobrek wrote: > I now use ManyToManyFields and hide certain data from administrators > by simply not importing them into admin.py. What I don't like about > this solution is that this data still is in the database and not in my > source code. In my view, i

Re: Onchange event on Choicefield in django formset

2011-11-02 Thread Kurtis Mullins
Try changing your success_url to this same page. On Wed, Nov 2, 2011 at 11:00 AM, asif.jama...@rezayat.net < asif.jama...@rezayat.net> wrote: > How can i access the form fields in django views. > > Suppose i have modelform called > > > class QuestionForm(forms.ModelForm): > > > answer = forms.Ch

Re: Django + Ajax/Javascript

2011-11-02 Thread Furbee
You could pass the values from the view to the template and use javascript (I would suggest using jQuery) if there are only a few options. I would suggest using Dajax (dajaxproject.com) for your AJAX commands. It is really easy to plug into Django, and you should get familiar with it and the jQuery

Re: Onchange event on Choicefield in django formset

2011-11-02 Thread Furbee
I think your 'answer' is going to exist in POST in either case. Perhaps change the construct of your logic to: if 'evaluation' in request.POST: return render_to_response('results.html') elif 'form-0-answer' in request.POST: answer = request.POST.get('answer','') val

Re: Field available via Django shell but not via web application (crossposted from StackOverFlow)

2011-11-02 Thread Furbee
You said you are using django.contrib.auth.models.User as your User model, but that doesn't have a "foos" property. Can you share the models that you are using? Are you creating a subclass User that extends django.contrib.auth.models.User and adds foos and a ForeignKey? Is foos a ManyToManyField, O

Re: Calling Python from JavaScript

2011-11-02 Thread Furbee
You could call the Dajaxice method that gets the result (the one that fires when the drop down changes) with window.onload, or you could pass the initial values to the template via the view. For consistency and code reuse, I would personally use the first method, calling the Dajaxice function respo

Re: Onchange event on Choicefield in django formset

2011-11-02 Thread Kurtis Mullins
Whoops, sorry -- I didn't realize you weren't using CBVs. :) On Wed, Nov 2, 2011 at 12:43 PM, Furbee wrote: > I think your 'answer' is going to exist in POST in either case. Perhaps > change the construct of your logic to: > > if 'evaluation' in request.POST: > return render_to_respo

Problems with jquery and accessing django template system

2011-11-02 Thread Kevin Miller
I have a url that I need to attach to link that is in a jquery section. It seem like the django template system is not getting the variable. For example: $.each(event,function(index,value){ var url = "{% url fiesta.views.detail "+ event[index].pk +" %}"

Re: Problems with jquery and accessing django template system

2011-11-02 Thread Tom Evans
n Wed, Nov 2, 2011 at 5:13 PM, Kevin Miller wrote: > I have a url that I need to attach to link that is in a jquery > section. It seem like the django template system is not getting the > variable. For example: > > $.each(event,function(index,value){ >                        var url = "{% url fies

Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
Hello, i'm currently doning a website where user can register (without password, without auth module of Django). They put some informations and at the end (Step5Form) do multiple choices by clicking on checkboxes. When I click on validate on the last step I've "instance needs to have a primary key

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Ian Clelland
On Wed, Nov 2, 2011 at 8:25 AM, Thomas Guettler wrote: > # This is my current solution > if get_special_objects().filter(pk=obj.pk).count(): ># yes, it is special > > I can't speak to the "why" of this situation; it seems to me that this could always be converted into a more efficient databas

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Tom Evans
On Wed, Nov 2, 2011 at 5:30 PM, Ian Clelland wrote: > On Wed, Nov 2, 2011 at 8:25 AM, Thomas Guettler wrote: >> >> # This is my current solution >> if get_special_objects().filter(pk=obj.pk).count(): >>    # yes, it is special >> > > I can't speak to the "why" of this situation; it seems to me th

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread Furbee
In your Customer model there are fields which cannot be Null, so you cannot instance.save() before setting those properties. So, you may have to check for the category field in your loop and if it is category, save the instance first. Something like the following: views.py (in clients application)

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Furbee
Thanks Tom, that's a great explanation! Furbeenator On Wed, Nov 2, 2011 at 10:46 AM, Tom Evans wrote: > On Wed, Nov 2, 2011 at 5:30 PM, Ian Clelland wrote: > > On Wed, Nov 2, 2011 at 8:25 AM, Thomas Guettler wrote: > >> > >> # This is my current solution > >> if get_special_objects().filter(p

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Ian Clelland
On Wed, Nov 2, 2011 at 10:46 AM, Tom Evans wrote: > On Wed, Nov 2, 2011 at 5:30 PM, Ian Clelland wrote: > > On Wed, Nov 2, 2011 at 8:25 AM, Thomas Guettler wrote: > >> > >> # This is my current solution > >> if get_special_objects().filter(pk=obj.pk).count(): > >># yes, it is special > >> >

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Ian Clelland
On Wed, Nov 2, 2011 at 10:46 AM, Tom Evans wrote: > OK, take this example. I have a django model table with 70 million > rows in it. Doing any kind of query on this table is slow, and > typically the query is date restrained - which mysql will use as the > optimum key, meaning any further filteri

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
Hi Furbeenator, thanks a lots, it works !!! :-))) I've use your first solution. You say that "category would have to be the first Allow Null field in your model" wich is not the case here. A "phone" field is the first step (Step0) can be empty : telephone = models.CharField(max_length=14, blank=Tr

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
Oupsss, another question in the step by step: 1 class InscriptionWizard(SessionWizardView): 2    def done(self, form_list, **kwargs): 3        instance = Customer() 4        for form in form_list: 5            for field, value in form.cleaned_data.iteritems(): 6                if field == 'categor

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread Furbee
Hi Alain, Glad that it worked out! :-) To clarify, a blank is different from a Null, or "None" in Python/Django. A blank character field is "" where a null character field is NULL. If a field does not specify null=True, and you try to save an instance of that object without specifying that field,

Re: Problems with jquery and accessing django template system

2011-11-02 Thread Kevin Miller
Thanks Tom, but I have already tried that and it didn't work. On Wed, Nov 2, 2011 at 12:25 PM, Tom Evans wrote: > n Wed, Nov 2, 2011 at 5:13 PM, Kevin Miller wrote: >> I have a url that I need to attach to link that is in a jquery >> section. It seem like the django template system is not gett

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
Hi again thanks for explanations. I've understood difference between Null and None. I've modify the code to add "instance.id == Non" and it seems to be faster. To be sure. You mean that if a customer has 1 category, there will be 2 database access (one for all informations except category and on

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread Furbee
Hi Alain, Sort of. With this code: if field == 'category': instance.save() a Customer with 50 categories would write to the database 51 times (1 INSERT, and 50 UPDATES). Including the "instance.id == None" like this: if field == 'category' and instance.id == None: instance

Abstract FormView

2011-11-02 Thread Kurtis
Hey, I have a couple of FormViews that override quite a few methods. I want to write an "Abstract View" that I can subclass for these. I'm guessing what I actually need is a custom Mixin but I'm really not sure. Any suggestions on how to go about doing this? Some methods I'm overriding: get_for

Relation not found error while dealing with foreign keys and forms

2011-11-02 Thread Tabitha Samuel
Hi, In brief here is my problem. I have two simple tables, one has a one to many relation with the other. The problem I run into is that when I try to create a form instance of the child, and try to print it or render it in a template, I run into a "relation not found" error for the parent. Simply

Re: Relation not found error while dealing with foreign keys and forms

2011-11-02 Thread Furbee
Can you try this and tell us what you see: Run a shell using python manage.py shell >>> instance = Staff.objects.using('gold').get(username='tsamuel') >>> str(instance.query) This will tell us whether or not the database, reference, and such are correctly translating into a query. The error means

Re: Suggestions on "Loading" for possible long load-times?

2011-11-02 Thread Matt Schinckel
Russ mentioned it in passing, but I'll point it out for clarity: Celery is a great framework for handling background tasks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/ms

Re: Formwizard - Many2Many field - instance needs to have a primary key value before a many-to-many relationship can be used

2011-11-02 Thread youpsla
Thanks Furbee, UNDERSTOOD. Thanks again for detailled and instructive answers. Alain On 2 nov, 21:36, Furbee wrote: > Hi Alain, > > Sort of. With this code: >     if field == 'category': >         instance.save() > a Customer with 50 categories would write to the database 51 times (1 > INSERT,

"drop table if exists" aborts

2011-11-02 Thread Brian Craft
mysql generates an informational warning when running "drop table if exists " if the table doesn't exist. Django then throws an error and aborts. Is there a good way to avoid this? b.c. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post t

Django with Codebase Database

2011-11-02 Thread Jonathan
Does anybody use Django/Python with Codebase? Can it be done? If so, how hard is it? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email t

Re: Relation not found error while dealing with foreign keys and forms

2011-11-02 Thread Tabitha Samuel
Thank you so much for your reply! So I got a "Staff object has no attribute 'query'" error when I did it with the get. I got the sql when I tried it with the filter instead (instance = Staff.objects.using('gold').filter(username='tsamuel') >> str(instance.query))this is what I'm getting: 'SELECT "

Re: Disk I/O Error

2011-11-02 Thread m1chael
I would also check the disk space On Tue, Nov 1, 2011 at 7:23 AM, Jani Tiainen wrote: > On 1.11.2011 8:23, Nicole Button wrote: >> >> I'm getting a DatabaseError, looking like this: >> >> Django Version:         1.3 >> Exception Type:         DatabaseError >> Exception Value:        disk I/O erro

Re: QuerySet: "if obj in queryset" can be very slow

2011-11-02 Thread Thomas Guettler
Hi, I created a ticket: https://code.djangoproject.com/ticket/17156 {{{ The documentation should explain what happens in this code: if obj in queryset: If queryset is huge, the above code can be very slow. If you want to run the code in the database, you should use this: if queryset