Re: manually add objects to a QuerySet
I already have the objects in an earlier chunk of the code. I don't want to hit the database again to get something I already have in another form. That is what I mean when I say that code like my_qs = MyModel.objects.filter(pk=obj1.pk) is utterly silly. I already have the objects from earlier db queries; I just need them in a queryset. On Aug 9, 8:20 am, chefsmart wrote: > Since I already have the objects, I don't want to hit the database > again. There are not just two but multiple objects, that's why I want > to avoid unnecessary db calls. > > On Aug 8, 9:54 pm, akaariai wrote: > > > On 8 elo, 11:55, chefsmart wrote: > > > > The objects are coming from mutually exclusive querysets. I need to > > > pass aquerysetof these objects to a function. > > > "Or" the querysets together? > > In [2]: f1 = Foo1() > > In [3]: f1.save() > > In [4]: f2 = Foo1() > > In [5]: f2.save() > > In [6]: [f.pk for f in Foo1.objects.all()] > > Out[6]: [1, 2] > > In [7]: qs2 = Foo1.objects.filter(pk=1) | Foo1.objects.filter(pk=2) # > > The oring of querysets > > In [8]: [f.pk for f in qs2] > > Out[8]: [1, 2] > > > - Anssi > > > > On Aug 8, 1:25 pm, Masklinn wrote: > > > > > On 8 août 2010, at 06:15, chefsmart wrote: > > > > > > I had asked this on stackoverflow, but I guess I couldn't explain > > > > > myself clearly enough. I'll try to ask again here: > > > > > > Say I have two objects obj1 and obj2 of the same model (MyModel), now > > > > > I would like to add these objects to a newQuerySet. Can I create a > > > > >QuerySetmanuallylike the following > > > > > > my_qs =QuerySet(model=MyModel) > > > > > > and then add obj1 and obj2 to thisQuerySetlike > > > > > > my_qs.add(obj1) > > > > > my_qs.add(obj2) > > > > > > Regards, > > > > > CM. > > > > > What would the use case be, which would prevent you from using a normal > > > > list? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: HttpResponseRedirect
Dnia 07-08-2010 o 14:56:57 JeffH napisał(a): Another approach that I used recently: # urls.py (r'^ThankYou/(?P\d{4})/$', views.ThankYou), # message defs in views.py # messages for ThankYou page ty_messages = { '' : 'Invalid message specified.', '0001' : 'Pending dealer record has been re-saved, awaiting approval.', '0002' : 'Pending dealer record has been saved, awaiting approval.', ... } # function in views.py def ThankYou(request, ty_msg_id): c = Context({ 'request' : request, 'show_admin' : request.user.is_authenticated(), 'ty_message' : ty_messages.get(ty_msg_id, ty_messages['']), }) t = get_template('ThankYou.html') html = t.render(c) return HttpResponse(html) # usage example return HttpResponseRedirect('/ThankYou/0089') --Jeff I used messages subsystem, as suggested before, now i have nice, clen url, and if anybody won't be redirected from respective form, will be redirected from "thanks page" to root def kontakt(request): if request.method == 'POST': form = KontaktForm(request.POST) if form.is_valid(): #do sth messages.success(request, 'Msg was send, thnks.') return HttpResponseRedirect('/dziekujemy/') else: form = KontaktForm() return render_to_response('kontakt.html', {'form': form,}, context_instance=RequestContext(request)) def dziekujemy(request): storage = messages.get_messages(request) if storage: return render_to_response('dziekujemy.html', context_instance=RequestContext(request)) else: return HttpResponseRedirect('/') -- Linux user -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Search Field on All Pages
Thanks for everyone's advice. My final solution will be to use template inheritance to have the same form across the site and to use the action="/search" to ensure I don't have to import a search function into every single view. Thanks again Wes On 8 August 2010 19:36, kostia wrote: > Yes, somebody can use template tag, somebody content processor and the > most intuitive solution is to use template inheritance, as was > suggested. > > Thank you, Tim. Wish you good luck. I loved your musician web site. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Come on, share your django powered sites with others.//Fwd: A tornado powered site to show any project powered sites(open source)
Yes, but this site can show more powered by information. For example: A site powered by python/django/jquery/apache/memcached, the site will be listed at http://django.poweredsites.org and http://python.poweredsites.org and http://jquery.poweredsites.org etc, so it's more easy to share powered by information with other projects. On Mon, Aug 9, 2010 at 12:27 AM, shacker wrote: > On Aug 7, 9:50 pm, Stone Puzzle wrote: > > Django powered sites list http://django.poweredsites.org > > A much more complete database is at http://www.djangosites.org/ > > ./s > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: manually add objects to a QuerySet
On Aug 9, 8:13 am, chefsmart wrote: > I already have the objects in an earlier chunk of the code. I don't > want to hit the database again to get something I already have in > another form. That is what I mean when I say that code like my_qs = > MyModel.objects.filter(pk=obj1.pk) is utterly silly. I already have > the objects from earlier db queries; I just need them in a queryset. But you haven't explained why converting the querysets to a list and concatenating them, or just using itertools.chain(q1, q2), wouldn't work. What sort of code do you have that relies on a queryset, and doesn't work with anything else? Show it. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django on Mac OS X
yeah, psycopg2 On Mon, Aug 9, 2010 at 1:27 AM, Sam Lai wrote: > 2010/8/9 Daniel França : > > I tried to reinstall everything... installing python+postgres from ports > > and I get the Symbol not found: _PQbackendPID error again from psycopg. > > I guess the best solution is run Ubuntu on a virtual machine or my > project > > will be stuck forever. > > python+psycopg on mac just sux. > > I haven't really been following this thread, but you meant psycopg2, > not psycopg right? psycopg is old and unsupported as far as I know. > > > > > 2010/8/8 Daniel França > >> > >> tried, nothing :( > >> I'm getting crazy with Mac OS, I think I'll go back to Linux :S > >> > >> On Sun, Aug 8, 2010 at 4:34 AM, Xavier Ordoquy > >> wrote: > >>> > >>> It won't work by commenting the timezone field since it has been > created > >>> with a non null constraint on your db. > >>> Have you tried to get_or_create the account with timezone and language > >>> set to some value ? > >>> Regards, > >>> Xavier. > >>> > >>> Le 8 août 2010 à 04:09, Daniel França a écrit : > >>> > >>> More information. > >>> here: > >>> def create_account(sender, instance=None, **kwargs): > >>> if instance is None: > >>> return > >>> account, created = Account.objects.get_or_create(user=instance) > >>> post_save.connect(create_account, sender=User) > >>> If I comment the post_save.connect, there's no exception =) but, of > >>> course the code doesn't do what it should do. > >>> So, I don't know why, but the error is in the connect... maybe because > of > >>> timezone attribute of user > >>> anyone has any idea? > >>> 2010/8/7 Daniel França > > Xavier, I think we are almost there :P > because there's a timezone field in my account model: > class Account(models.Model): > > user = models.ForeignKey(User, unique=True, > verbose_name=_('user')) > > timezone = TimeZoneField(_('timezone')) > language = models.CharField(_('language'), max_length=10, > choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE) > > def __unicode__(self): > return self.user.username > I tried to comment the line, but then the create_user abort with an > constraint timezone error. > On Sat, Aug 7, 2010 at 2:22 PM, Xavier Ordoquy > wrote: > > > > And what's your Account model ? > > I noticed it is in its get_or_create that you get the error. > > Regards, > > Xavier. > > > > Le 7 août 2010 à 18:52, Daniel França a écrit : > > > > Same error =/ > > but now,I don't know why.. it's saving at the db. The error still > > happens, but the data is in the database > > > > On Sat, Aug 7, 2010 at 12:54 PM, Xavier Ordoquy < > xordo...@linovia.com> > > wrote: > >> > >> Sorry, I just woke up form a sleep :) > >> I notice you get-or-create a user. > >> However, did you try to call get or create with specifying the > >> arguments ? first_name = "...", and so on ? > >> Does it still give an error ? > >> Regards, > >> Xavier. > >> Le 7 août 2010 à 17:46, Xavier Ordoquy a écrit : > >> > >> I just googled your error and found: > >> http://www.nerdydork.com/django-programmingerror-cant-adapt.html > >> According to the first comment, you might do something wrong with > the > >> arguments types. > >> Unless you give a table description (\d from psql shell) and the > model > >> I'm not sure I can help you further. > >> Regards, > >> Xavier. > >> As the stack seems to have a > >> Le 7 août 2010 à 17:21, Daniel França a écrit : > >> > >> I just created my db using django manage syncdb, I think it should > >> create right. > >> or how can I see the encode of each tables? > >> I'm using postgresql 8.4 > >> maybe I'll need reinstall everything =S > >> > >> On Sat, Aug 7, 2010 at 6:49 AM, Xavier Ordoquy < > xordo...@linovia.com> > >> wrote: > >>> > >>> Le 7 août 2010 à 06:44, Daniel França a écrit : > >>> > >>> > My database is UTF-8, it's fine, doesn't?. > >>> > I'm afraid to reinstall everything from ports and start to get a > >>> > lot 64-32 bits incompatible issues like happened before =/ > >>> > >>> I think that should be fine with a utf-8 DB. > >>> Are you sure your tables are UTF-8 ? > >>> What database are you using ? mysql ? postgres ? I had no issue > with > >>> both and I have a couple of non pure ascii sites. > >>> However, when I moved to snow leopard, I recompiled mysql/postgres > >>> and the python drivers. > >>> > >>> Regards, > >>> Xavier. > >>> > >>> -- > >>> 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 to > >>> django-users+unsubsc
Re: Django on Mac OS X
I doubt it's a mac issue. I already ran in a couple of very painful issues with postgresql on Linux while having no issue with mysql on mac. My feeling is that postgresql require far more attention than mysql and is more sensitive to small changes. Regards, Xavier. Le 9 août 2010 à 05:32, Daniel França a écrit : > I tried to reinstall everything... installing python+postgres from ports > and I get the Symbol not found: _PQbackendPID error again from psycopg. > I guess the best solution is run Ubuntu on a virtual machine or my project > will be stuck forever. > python+psycopg on mac just sux. > > > 2010/8/8 Daniel França > tried, nothing :( > I'm getting crazy with Mac OS, I think I'll go back to Linux :S > > > On Sun, Aug 8, 2010 at 4:34 AM, Xavier Ordoquy wrote: > It won't work by commenting the timezone field since it has been created with > a non null constraint on your db. > Have you tried to get_or_create the account with timezone and language set to > some value ? > > Regards, > Xavier. > > Le 8 août 2010 à 04:09, Daniel França a écrit : > >> More information. >> here: >> def create_account(sender, instance=None, **kwargs): >> if instance is None: >> return >> account, created = Account.objects.get_or_create(user=instance) >> >> post_save.connect(create_account, sender=User) >> >> If I comment the post_save.connect, there's no exception =) but, of course >> the code doesn't do what it should do. >> >> So, I don't know why, but the error is in the connect... maybe because of >> timezone attribute of user >> anyone has any idea? >> >> 2010/8/7 Daniel França >> Xavier, I think we are almost there :P >> because there's a timezone field in my account model: >> >> class Account(models.Model): >> >> user = models.ForeignKey(User, unique=True, verbose_name=_('user')) >> >> timezone = TimeZoneField(_('timezone')) >> language = models.CharField(_('language'), max_length=10, >> choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE) >> >> def __unicode__(self): >> return self.user.username >> >> I tried to comment the line, but then the create_user abort with an >> constraint timezone error. >> >> On Sat, Aug 7, 2010 at 2:22 PM, Xavier Ordoquy wrote: >> And what's your Account model ? >> I noticed it is in its get_or_create that you get the error. >> >> Regards, >> Xavier. >> >> Le 7 août 2010 à 18:52, Daniel França a écrit : >> >>> Same error =/ >>> but now,I don't know why.. it's saving at the db. The error still happens, >>> but the data is in the database >>> >>> On Sat, Aug 7, 2010 at 12:54 PM, Xavier Ordoquy >>> wrote: >>> Sorry, I just woke up form a sleep :) >>> I notice you get-or-create a user. >>> However, did you try to call get or create with specifying the arguments ? >>> first_name = "...", and so on ? >>> Does it still give an error ? >>> >>> Regards, >>> Xavier. >>> >>> Le 7 août 2010 à 17:46, Xavier Ordoquy a écrit : >>> I just googled your error and found: http://www.nerdydork.com/django-programmingerror-cant-adapt.html According to the first comment, you might do something wrong with the arguments types. Unless you give a table description (\d from psql shell) and the model I'm not sure I can help you further. Regards, Xavier. As the stack seems to have a Le 7 août 2010 à 17:21, Daniel França a écrit : > I just created my db using django manage syncdb, I think it should create > right. > or how can I see the encode of each tables? > I'm using postgresql 8.4 > maybe I'll need reinstall everything =S > > On Sat, Aug 7, 2010 at 6:49 AM, Xavier Ordoquy > wrote: > > Le 7 août 2010 à 06:44, Daniel França a écrit : > > > My database is UTF-8, it's fine, doesn't?. > > I'm afraid to reinstall everything from ports and start to get a lot > > 64-32 bits incompatible issues like happened before =/ > > I think that should be fine with a utf-8 DB. > Are you sure your tables are UTF-8 ? > What database are you using ? mysql ? postgres ? I had no issue with both > and I have a couple of non pure ascii sites. > However, when I moved to snow leopard, I recompiled mysql/postgres and > the python drivers. > > Regards, > Xavier. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegrou
Web site Mail Inbox
Hi, I want to create an Inbox service for users of my django site. Can anybody point me to the right direction? Any modules or it is better to do myself? Kostia -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to handle invalid deleted forms in formsets
(Using formset_factory, if that makes a difference) If the user fills a form in formset incompletely and then marks it for deletion, my form handling dies horribly. The deleted forms prevent formset.cleaned_data from working as they don't validate and thus the form doesn't have a cleaned_data attribute. If I try to iterate over formset.deleted_forms and delete the forms from formset.forms, then formset.cleaned_data crashes due to index out of range. How should I be handling these invalid forms the user didn't want anyway? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
where is the link of password reset page on djangoproject.com ?
Hello guys, please help, I've not found the password reset page on djangoproject.com where is it? thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Registration
What is the purpose of email activation? Why can't we just use username/password on the site. The one bad fact - is when somebody uses foreign email address. This is not a reason to use activation. Show me more facts please. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Registration
On 8/9/2010 8:40 AM, kostia wrote: > What is the purpose of email activation? > > Why can't we just use username/password on the site. > > The one bad fact - is when somebody uses foreign email address. This > is not a reason to use activation. Show me more facts please. > The e-mail response serves to verify that the user who signed up does in fact have control of the email address they included in their registration details. If this step was omitted I could spam people by signing up to a web site that sent out lots of email in their names (and, more relevantly, their email addresses). What is "a foreign email address"? regards Steve -- I'm no expert. "ex" == "has-been"; "spurt" == "drip under pressure" "expert" == "has-been drip under pressure". -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: where is the link of password reset page on djangoproject.com ?
On 9 August 2010 14:30, nyambaa wrote: > Hello guys, > please help, I've not found the password reset page on > djangoproject.com > where is it? > > thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > http://www.djangoproject.com/accounts/password/reset/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django on Mac OS X
I haven't read all the comments here but if you've just started working on osx you should definitely check out http://github.com/mxcl/homebrew - it's a package manager which works like a charm most of the time. Installation is extremely simple (there is even one-liner available). If your problem is related with wrong packages installation - homebrew would most probably fix all of them, if only you can get rid of those ports/finks at the first place. Regards, Lukasz On Aug 9, 2:04 pm, Xavier Ordoquy wrote: > I doubt it's a mac issue. > I already ran in a couple of very painful issues with postgresql on Linux > while having no issue with mysql on mac. > My feeling is that postgresql require far more attention than mysql and is > more sensitive to small changes. > > Regards, > Xavier. > > Le 9 août 2010 à 05:32, Daniel França a écrit : > > > > > I tried to reinstall everything... installing python+postgres from ports > > and I get the Symbol not found: _PQbackendPID error again from psycopg. > > I guess the best solution is run Ubuntu on a virtual machine or my project > > will be stuck forever. > > python+psycopg on mac just sux. > > > 2010/8/8 Daniel França > > tried, nothing :( > > I'm getting crazy with Mac OS, I think I'll go back to Linux :S > > > On Sun, Aug 8, 2010 at 4:34 AM, Xavier Ordoquy wrote: > > It won't work by commenting the timezone field since it has been created > > with a non null constraint on your db. > > Have you tried to get_or_create the account with timezone and language set > > to some value ? > > > Regards, > > Xavier. > > > Le 8 août 2010 à 04:09, Daniel França a écrit : > > >> More information. > >> here: > >> def create_account(sender, instance=None, **kwargs): > >> if instance is None: > >> return > >> account, created = Account.objects.get_or_create(user=instance) > > >> post_save.connect(create_account, sender=User) > > >> If I comment the post_save.connect, there's no exception =) but, of course > >> the code doesn't do what it should do. > > >> So, I don't know why, but the error is in the connect... maybe because of > >> timezone attribute of user > >> anyone has any idea? > > >> 2010/8/7 Daniel França > >> Xavier, I think we are almost there :P > >> because there's a timezone field in my account model: > > >> class Account(models.Model): > > >> user = models.ForeignKey(User, unique=True, verbose_name=_('user')) > > >> timezone = TimeZoneField(_('timezone')) > >> language = models.CharField(_('language'), max_length=10, > >> choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE) > > >> def __unicode__(self): > >> return self.user.username > > >> I tried to comment the line, but then the create_user abort with an > >> constraint timezone error. > > >> On Sat, Aug 7, 2010 at 2:22 PM, Xavier Ordoquy > >> wrote: > >> And what's your Account model ? > >> I noticed it is in its get_or_create that you get the error. > > >> Regards, > >> Xavier. > > >> Le 7 août 2010 à 18:52, Daniel França a écrit : > > >>> Same error =/ > >>> but now,I don't know why.. it's saving at the db. The error still > >>> happens, but the data is in the database > > >>> On Sat, Aug 7, 2010 at 12:54 PM, Xavier Ordoquy > >>> wrote: > >>> Sorry, I just woke up form a sleep :) > >>> I notice you get-or-create a user. > >>> However, did you try to call get or create with specifying the arguments > >>> ? first_name = "...", and so on ? > >>> Does it still give an error ? > > >>> Regards, > >>> Xavier. > > >>> Le 7 août 2010 à 17:46, Xavier Ordoquy a écrit : > > I just googled your error and found: > http://www.nerdydork.com/django-programmingerror-cant-adapt.html > According to the first comment, you might do something wrong with the > arguments types. > Unless you give a table description (\d from psql shell) and the model > I'm not sure I can help you further. > > Regards, > Xavier. > > As the stack seems to have a > > Le 7 août 2010 à 17:21, Daniel França a écrit : > > > I just created my db using django manage syncdb, I think it should > > create right. > > or how can I see the encode of each tables? > > I'm using postgresql 8.4 > > maybe I'll need reinstall everything =S > > > On Sat, Aug 7, 2010 at 6:49 AM, Xavier Ordoquy > > wrote: > > > Le 7 août 2010 à 06:44, Daniel França a écrit : > > > > My database is UTF-8, it's fine, doesn't?. > > > I'm afraid to reinstall everything from ports and start to get a lot > > > 64-32 bits incompatible issues like happened before =/ > > > I think that should be fine with a utf-8 DB. > > Are you sure your tables are UTF-8 ? > > What database are you using ? mysql ? postgres ? I had no issue with > > both and I have a couple of non pure ascii sites. > > However, when I moved to snow leopard, I recompiled mysql/postgres and > > the python drivers. > > > Regards, > > Xavier.
Simple FormWizard wizard howto/example
Hi, I'm still pretty new to django and searching some simple FormWizard examples What I want to do: First step: ModelChoiceField is populated with queryset Second step: A ChoiceField needs to be populated with object.get(model__field__exact=resultfromstep1)' In the last step I want to show all values for this last model. Thx! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django on Mac OS X
Daniel, Did you manage to have the application running on sqlite3 ... ? I develop on Mac & have few issues... so may be you could first ensure everything is working without postgresql connector ... ? \T, On Aug 9, 4:24 am, Daniel França wrote: > tried, nothing :( > I'm getting crazy with Mac OS, I think I'll go back to Linux :S > > On Sun, Aug 8, 2010 at 4:34 AM, Xavier Ordoquy wrote: > > It won't work by commenting the timezone field since it has been created > > with a non null constraint on your db. > > Have you tried to get_or_create the account with timezone and language set > > to some value ? > > > Regards, > > Xavier. > > > Le 8 août 2010 à 04:09, Daniel França a écrit : > > > More information. > > here: > > def create_account(sender, instance=None, **kwargs): > > if instance is None: > > return > > account, created = Account.objects.get_or_create(user=instance) > > > post_save.connect(create_account, sender=User) > > > If I comment the *post_save.connect*, there's no exception =) but, of > > course the code doesn't do what it should do. > > > So, I don't know why, but the error is in the connect... maybe because of > > timezone attribute of user > > anyone has any idea? > > > 2010/8/7 Daniel França > > >> Xavier, I think we are almost there :P > >> because there's a timezone field in my account model: > > >> class Account(models.Model): > > >> user = models.ForeignKey(User, unique=True, verbose_name=_('user')) > > >> timezone = TimeZoneField(_('timezone')) > >> language = models.CharField(_('language'), max_length=10, > >> choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE) > > >> def __unicode__(self): > >> return self.user.username > > >> I tried to comment the line, but then the create_user abort with an > >> constraint timezone error. > > >> On Sat, Aug 7, 2010 at 2:22 PM, Xavier Ordoquy wrote: > > >>> And what's your Account model ? > >>> I noticed it is in its get_or_create that you get the error. > > >>> Regards, > >>> Xavier. > > >>> Le 7 août 2010 à 18:52, Daniel França a écrit : > > >>> Same error =/ > >>> but now,I don't know why.. it's saving at the db. The error still > >>> happens, but the data is in the database > > >>> On Sat, Aug 7, 2010 at 12:54 PM, Xavier Ordoquy > >>> wrote: > > Sorry, I just woke up form a sleep :) > I notice you get-or-create a user. > However, did you try to call get or create with specifying the arguments > ? first_name = "...", and so on ? > Does it still give an error ? > > Regards, > Xavier. > > Le 7 août 2010 à 17:46, Xavier Ordoquy a écrit : > > I just googled your error and found: > http://www.nerdydork.com/django-programmingerror-cant-adapt.html > According to the first comment, you might do something wrong with the > arguments types. > Unless you give a table description (\d from psql shell) and the model > I'm not sure I can help you further. > > Regards, > Xavier. > > As the stack seems to have a > > Le 7 août 2010 à 17:21, Daniel França a écrit : > > I just created my db using django manage syncdb, I think it should > create right. > or how can I see the encode of each tables? > I'm using postgresql 8.4 > maybe I'll need reinstall everything =S > > On Sat, Aug 7, 2010 at 6:49 AM, Xavier Ordoquy > wrote: > > > Le 7 août 2010 à 06:44, Daniel França a écrit : > > > > My database is UTF-8, it's fine, doesn't?. > > > I'm afraid to reinstall everything from ports and start to get a lot > > 64-32 bits incompatible issues like happened before =/ > > > I think that should be fine with a utf-8 DB. > > Are you sure your tables are UTF-8 ? > > What database are you using ? mysql ? postgres ? I had no issue with > > both and I have a couple of non pure ascii sites. > > However, when I moved to snow leopard, I recompiled mysql/postgres and > > the python drivers. > > > Regards, > > Xavier. > > > -- > > You received this message because you are subscribed to the Google > > Groups "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google > Groups "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google > Groups "Django users" group. > To post to this
Re: Django on Mac OS X
I use PostgreSQL on my Mac as well as MySQL, and I've had many fewer problems with PostgreSQL than I've had with MySQL. My personal opinion: Ignore all the ports/fink stuff, and get a good native PostgreSQL install: http://postgresqlformac.com The 8.4.3 installer has some known problems (easy to fix if you know what they are, but easier to avoid if this is your first time), but other than that, this is a pretty reliable source of installers and native tools. Once you've got the database installed, psycopg2 installs from source fairly cleanly. Yours, Russ Magee %-) On 8/9/10, lukaszb wrote: > I haven't read all the comments here but if you've just started > working on osx you should definitely check out > http://github.com/mxcl/homebrew > - it's a package manager which works like a charm most of the time. > > Installation is extremely simple (there is even one-liner available). > If your problem is related with wrong packages installation - homebrew > would most probably fix all of them, if only you can get rid of those > ports/finks at the first place. > > Regards, > Lukasz > > On Aug 9, 2:04 pm, Xavier Ordoquy wrote: >> I doubt it's a mac issue. >> I already ran in a couple of very painful issues with postgresql on Linux >> while having no issue with mysql on mac. >> My feeling is that postgresql require far more attention than mysql and is >> more sensitive to small changes. >> >> Regards, >> Xavier. >> >> Le 9 août 2010 à 05:32, Daniel França a écrit : >> >> >> >> > I tried to reinstall everything... installing python+postgres from ports >> > and I get the Symbol not found: _PQbackendPID error again from psycopg. >> > I guess the best solution is run Ubuntu on a virtual machine or my >> > project will be stuck forever. >> > python+psycopg on mac just sux. >> >> > 2010/8/8 Daniel França >> > tried, nothing :( >> > I'm getting crazy with Mac OS, I think I'll go back to Linux :S >> >> > On Sun, Aug 8, 2010 at 4:34 AM, Xavier Ordoquy >> > wrote: >> > It won't work by commenting the timezone field since it has been created >> > with a non null constraint on your db. >> > Have you tried to get_or_create the account with timezone and language >> > set to some value ? >> >> > Regards, >> > Xavier. >> >> > Le 8 août 2010 à 04:09, Daniel França a écrit : >> >> >> More information. >> >> here: >> >> def create_account(sender, instance=None, **kwargs): >> >> if instance is None: >> >> return >> >> account, created = Account.objects.get_or_create(user=instance) >> >> >> post_save.connect(create_account, sender=User) >> >> >> If I comment the post_save.connect, there's no exception =) but, of >> >> course the code doesn't do what it should do. >> >> >> So, I don't know why, but the error is in the connect... maybe because >> >> of timezone attribute of user >> >> anyone has any idea? >> >> >> 2010/8/7 Daniel França >> >> Xavier, I think we are almost there :P >> >> because there's a timezone field in my account model: >> >> >> class Account(models.Model): >> >> >> user = models.ForeignKey(User, unique=True, verbose_name=_('user')) >> >> >> timezone = TimeZoneField(_('timezone')) >> >> language = models.CharField(_('language'), max_length=10, >> >> choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE) >> >> >> def __unicode__(self): >> >> return self.user.username >> >> >> I tried to comment the line, but then the create_user abort with an >> >> constraint timezone error. >> >> >> On Sat, Aug 7, 2010 at 2:22 PM, Xavier Ordoquy >> >> wrote: >> >> And what's your Account model ? >> >> I noticed it is in its get_or_create that you get the error. >> >> >> Regards, >> >> Xavier. >> >> >> Le 7 août 2010 à 18:52, Daniel França a écrit : >> >> >>> Same error =/ >> >>> but now,I don't know why.. it's saving at the db. The error still >> >>> happens, but the data is in the database >> >> >>> On Sat, Aug 7, 2010 at 12:54 PM, Xavier Ordoquy >> >>> wrote: >> >>> Sorry, I just woke up form a sleep :) >> >>> I notice you get-or-create a user. >> >>> However, did you try to call get or create with specifying the >> >>> arguments ? first_name = "...", and so on ? >> >>> Does it still give an error ? >> >> >>> Regards, >> >>> Xavier. >> >> >>> Le 7 août 2010 à 17:46, Xavier Ordoquy a écrit : >> >> I just googled your error and found: >> http://www.nerdydork.com/django-programmingerror-cant-adapt.html >> According to the first comment, you might do something wrong with the >> arguments types. >> Unless you give a table description (\d from psql shell) and the >> model I'm not sure I can help you further. >> >> Regards, >> Xavier. >> >> As the stack seems to have a >> >> Le 7 août 2010 à 17:21, Daniel França a écrit : >> >> > I just created my db using django manage syncdb, I think it should >> > create right. >> > or how can I see the encode of each tables? >> > I'm using postgresql 8.4 >> > maybe I'll need rei
Re: where is the link of password reset page on djangoproject.com ?
Thanks On Aug 9, 8:55 pm, rebus_ wrote: > On 9 August 2010 14:30, nyambaa wrote: > > > Hello guys, > > please help, I've not found the password reset page on > > djangoproject.com > > where is it? > > > thanks > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > http://www.djangoproject.com/accounts/password/reset/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Web site Mail Inbox
On Mon, Aug 9, 2010 at 7:21 AM, kostia wrote: > Hi, > > I want to create an Inbox service for users of my django site. Can > anybody point me to the right direction? Any modules or it is better > to do myself? > As to whether or not it is best to do it yourself, that depends on if another module exists that does what you want, and if you thoughts on implementing it would provide anything different than the status quo. I have never used this myself so I cannot comment directly on it, but you may find http://code.google.com/p/django-messages/ of use. Sincerely, Michael Schade -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Unicode challenged
Hello, I am developing a Django application, and have some Unicode problems. I must admit I do not really understand if my problems are with Django or Python or ... ; but hopefully someone her can shed some light on the problem. Setup: 1. The application is developed for the Scandinavian countries, and will typically handle various Scandinavian letters like æåø. 2. I am developing everything on Ubuntu Linux. 3. I am using MySQL as database, currently the character_set is set to (the default) latin-1; but I can of course change that. What happens: 1. A user fills out a form containing one of the problematic characters like 'Å'. 2. Django is used to validate the form, and the form content is saved in the MySQL database. 3. I have a view fetching the content from the database, and returning it to a users browser with the render_to_response() function. 4. In addition to rendering the template as browser output I want to store the rendered output in a file (as a hardcopy). This fails with UnicodeDecodeError. The code which fails look schematically like this: template = context = string_content = render_to_string( template , context ) fileH = open( filename , "w") fileH.write( string_content ) <-- This fails. fileH.close() Now - the code which works exactly as it should, i.e. 3. above, is nearly identical but the function render_to_output() is used instead, and no file operations. How does the browser (firefox 3.??) magically get this right? I have also tried replacing the write() statement with write( string_content.encode( '' )) where I have tried the encodings 'latin-1' and 'utf-8'; then it does not fail hard, but instead of the wanted 'øåæ' characters I get '?' marks. Any tips on this greatly appreciated. Joakim -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
custom vocabularies vs translation
I want to provide customizable vocabularies for an open-source django project, where each deployer can use different terms for strings that appear in templates (e.g. field names, form field descriptions, help text, page titles, etc.) Would django language files work for this purpose? Everything will be in English (at this stage), so that would involve (if I understand correctly) customizing the English language .po file. (Right?) Does that smell like a reasonable solution? Any hidden rocks? Has anybody done anything like this, either using language files or some other solution? If so, how did you do it, and how did it work in practice? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Unicode challenged
> I have also tried replacing the write() statement with > write( string_content.encode( '' )) where I have tried the > encodings 'latin-1' and 'utf-8'; then it does not fail hard, but > instead of the wanted 'øåæ' characters I get '?' marks. Are you sure that you get '?' on the file if you write it this way, or it's just the console/editor that you're using to see the file's contents that cannot handle the text's encoding? I really think write( string_content.encode( '' )) should work fine. Nuno -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Need help with my Form.save() method. Trouble with ForeignKey and ManyToMany Fields.
> def clean_username(self): > data = self.cleaned_data['username'] > try: > User.objects.get(username=data) > except User.DoesNotExist: > return > raise forms.ValidationError('The username "%s" is already > taken.' % > data) The django docs [1] say that for the clean_ method, "Just like the general field clean() method, above, this method should return the cleaned data, regardless of whether it changed anything or not." Since you're returning nothing, self.cleaned_data['username'] will be None when saving your user hence the "auth_user.username may not be NULL" exception. [1] http://docs.djangoproject.com/en/dev/ref/forms/validation/ hth, Nuno -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Unicode challenged
Thank you for answering; > Are you sure that you get '?' on the file if you write it this way, or > it's just > the console/editor that you're using to see the file's contents that > cannot handle > the text's encoding? When it comes to Unicode and such I am not sure about anything. But you are probably right; I redid everything very carefully with 'utf-8' encoding now, and that seemed to work OK. Thanks. Joakim -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
accessing a dictionary in template
in php i can do this $some_mapping = array( "var1" : content_var1, -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
accessing a dictionary in template
in php i can do this $some_mapping = array( "var1" : content_var1, "var2" : content_var2, ) for($i =1; $i < 3; $i++){ echo $some_mapping["var"+$i]; } can i do this in django template? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
New server set up
I have installed Django in the root directory of a VPS supplied by hostagtor. My aim is to provide any domain with Django. Not that there will be many. It is running I am just not sure how to proceed to make sure it is done right Any advice help would be welcome Many Thanks Russell -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: accessing a dictionary in template
I take it that you absolutely need to dynamically access the values through generated keys? Not just a regular for loop? {% for var in some_mapping %} {{ var }} {% endfor %} - Sævar On Aug 9, 8:56 pm, owidjaya wrote: > in php i can do this > > $some_mapping = array( "var1" : content_var1, > "var2" : content_var2, > ) > for($i =1; $i < 3; $i++){ > echo $some_mapping["var"+$i]; > > } > > can i do this in django template? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New server set up
Hi, What kind of http server are you going to use? Nginx ? Apache? It somehow defines possible options. best regards, On Mon, Aug 9, 2010 at 9:04 PM, XTCHost wrote: > I have installed Django in the root directory of a VPS supplied by > hostagtor. My aim is to provide any domain with Django. Not that there > will be many. It is running > > I am just not sure how to proceed to make sure it is done right > > Any advice help would be welcome > > Many Thanks > > Russell > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Bogusław Faja tel. (+48) 691544955 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: accessing a dictionary in template
On 09/08/10 19:56, owidjaya wrote: in php i can do this $some_mapping = array( "var1" : content_var1, "var2" : content_var2, ) for($i =1; $i< 3; $i++){ echo $some_mapping["var"+$i]; } can i do this in django template? You can do this, where Venue.contests.items is a dictionary. contestname contains the keys, eventcount contains the values. {% for contestname, eventcount in Venue.contests.items %} {{contestname}} {{eventcount}} {% endfor %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Registration
A. If we have a form of registration only with password and username fields. Then the user may write some fake email (foreign). B. We use registration activation link sent into email like it is done on Facebook, Linkedin, Twitter and so on. Why B is better than A? Why A is a wrong solution? Any arguments? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Translation
And now there is a time for stupid question: how to translate my English site onto different languages? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Registration
What if the user puts in a "fake" e-mail that belongs to someone else? Then any service notifications go to the poor person who owns the e-mail address, not the person who signed up for the account. Also the user would get to take advantage of the benefits of the service. With B only the initial activation e-mail would get sent there. There is no benefit to the user to put in a fake e-mail address because they still don't have access to the service. Hope this helps, Casey On 08/09/2010 03:38 PM, kostia wrote: A. If we have a form of registration only with password and username fields. Then the user may write some fake email (foreign). B. We use registration activation link sent into email like it is done on Facebook, Linkedin, Twitter and so on. Why B is better than A? Why A is a wrong solution? Any arguments? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Registration
2010/8/9 kostia > A. If we have a form of registration only with password and username > fields. Then the user may write some fake email (foreign). > > B. We use registration activation link sent into email like it is done > on Facebook, Linkedin, Twitter and so on. > > Why B is better than A? Why A is a wrong solution? Any arguments? > DRY, django-registration: http://bit.ly/93GpfU IMHO, > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Cristian Salamea @ovnicraft -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: accessing a dictionary in template
Yes i'm trying to display a table with dynamic columns. my intention was to pass the queryset object to template and pass the column names so that the template can generate the table dynamically. On Aug 9, 12:06 pm, Sævar Öfjörð wrote: > I take it that you absolutely need to dynamically access the values > through generated keys? > Not just a regular for loop? > > {% for var in some_mapping %} > {{ var }} > {% endfor %} > > - Sævar > > On Aug 9, 8:56 pm, owidjaya wrote: > > > in php i can do this > > > $some_mapping = array( "var1" : content_var1, > > "var2" : content_var2, > > ) > > for($i =1; $i < 3; $i++){ > > echo $some_mapping["var"+$i]; > > > } > > > can i do this in django template? > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django on Mac OS X
Thanx for all the help, I tried to run on Sqlite3, and I don't if it's bad or good news, but there's error even in Sqlite3 just when I tried to create the db (syncdb) I get just after I input my users data or when I try to create a user in shell: Traceback (most recent call last): File "manage.py", line 31, in execute_from_command_line() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 429, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 218, in execute output = self.handle(*args, **options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 347, in handle return self.handle_noargs(**options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 103, in handle_noargs emit_post_sync_signal(created_models, verbosity, interactive, db) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/sql.py", line 185, in emit_post_sync_signal interactive=interactive, db=db) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 162, in send response = receiver(signal=self, sender=sender, **named) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 44, in create_superuser call_command("createsuperuser", interactive=True) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 166, in call_command return klass.execute(*args, **defaults) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 218, in execute output = self.handle(*args, **options) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 134, in handle User.objects.create_superuser(username, email, password) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", line 133, in create_superuser u = self.create_user(username, email, password) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", line 129, in create_user user.save(using=self._db) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", line 435, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", line 543, in save_base created=(not record_exists), raw=raw) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 162, in send response = receiver(signal=self, sender=sender, **named) File "/Users/danielfranca/workspace/django/view/tint/apps/account/models.py", line 61, in create_account account, created = Account.objects.get_or_create(user=instance,timezone='America/Sao_Paulo') File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", line 135, in get_or_create return self.get_query_set().get_or_create(**kwargs) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 366, in get_or_create return self.get(**kwargs), False File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 336, in get num = len(clone) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 81, in __len__ self._result_cache = list(self.iterator()) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", line 269, in iterator for row in compiler.results_iter(): File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 672, in results_iter for rows in self.execute_sql(MULTI): File "/Library/Frameworks/Python.f
Re: New server set up
Sorry, forgot to mention It is a CentOS based VPS runing Parallels Virtuozzo with apache and python 2.4 All I have done is a simple install of Django to the root and run setup.py install There seem various ways to install it but I wish to be able to set up multiple domains through WHM using CPanel Thanks On Aug 9, 8:22 pm, Boguslaw Faja wrote: > Hi, > > What kind of http server are you going to use? Nginx ? Apache? It > somehow defines possible options. > > best regards, > > > > On Mon, Aug 9, 2010 at 9:04 PM, XTCHost wrote: > > I have installed Django in the root directory of a VPS supplied by > > hostagtor. My aim is to provide any domain with Django. Not that there > > will be many. It is running > > > I am just not sure how to proceed to make sure it is done right > > > Any advice help would be welcome > > > Many Thanks > > > Russell > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > Bogusław Faja > tel. (+48) 691544955 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
I did something wrong while registered
Hi, I recently registered for the group and I must have done something wrong because I am receiving every posting twice (duplicates). Can someone fix the problem or direct me to where I can fix it. Thanks in advance Johnf -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New server set up
Hm, unfortunately I don't use apache. Nginx is better for me. But for other group members answers for something else may be important: why are you using python in version 2.4? It's a bit old. Do you have access to console (ssh) or only for some web panel (cpanel, direct)? Best regards, On Mon, Aug 9, 2010 at 11:09 PM, XTCHost wrote: > Sorry, forgot to mention > > It is a CentOS based VPS runing Parallels Virtuozzo with apache and > python 2.4 > > All I have done is a simple install of Django to the root and run > setup.py install > > There seem various ways to install it but I wish to be able to set up > multiple domains through WHM using CPanel > > Thanks > > On Aug 9, 8:22 pm, Boguslaw Faja wrote: >> Hi, >> >> What kind of http server are you going to use? Nginx ? Apache? It >> somehow defines possible options. >> >> best regards, >> >> >> >> On Mon, Aug 9, 2010 at 9:04 PM, XTCHost wrote: >> > I have installed Django in the root directory of a VPS supplied by >> > hostagtor. My aim is to provide any domain with Django. Not that there >> > will be many. It is running >> >> > I am just not sure how to proceed to make sure it is done right >> >> > Any advice help would be welcome >> >> > Many Thanks >> >> > Russell >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Django users" group. >> > To post to this group, send email to django-us...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > django-users+unsubscr...@googlegroups.com. >> > For more options, visit this group >> > athttp://groups.google.com/group/django-users?hl=en. >> >> -- >> Bogusław Faja >> tel. (+48) 691544955 > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Bogusław Faja tel. (+48) 691544955 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Translation
It's all there, you just need to implement it. http://docs.djangoproject.com/en/1.1/topics/i18n/#topics-i18n If you'd like a tool to help edit the translation files then check out one of the following: http://poedit.tomcoote.co.uk/ http://code.google.com/p/django-rosetta/ http://translate.sourceforge.net/wiki/pootle/index Good luck! On Aug 9, 8:40 pm, kostia wrote: > And now there is a time for stupid question: > > how to translate my English site onto different languages? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: custom vocabularies vs translation
Using the language files is the solution here. Even if your site only supports the English language, it still means that you can have .po files for just English. Once you understand how it all hangs together you'll be away. http://docs.djangoproject.com/en/1.1/topics/i18n/#topics-i18n I have a site that is just English but we allow the client to choose what text they want to use. The text in templates can be descriptions, for example you could type "Home page welcome message" in a template and mark it for translation. Then in the English .po file you can see what the text is used for and input the correct English for it. On Aug 9, 4:19 pm, bobhaugen wrote: > I want to provide customizable vocabularies for an open-source django > project, where each deployer can use different terms for strings that > appear in templates (e.g. field names, form field descriptions, help > text, page titles, etc.) > > Would django language files work for this purpose? Everything will be > in English (at this stage), so that would involve (if I understand > correctly) customizing the English language .po file. (Right?) > > Does that smell like a reasonable solution? Any hidden rocks? > > Has anybody done anything like this, either using language files or > some other solution? If so, how did you do it, and how did it work in > practice? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: I did something wrong while registered
On Mon, Aug 9, 2010 at 1:50 PM, John Fabiani wrote: > Hi, > I recently registered for the group and I must have done something wrong > because I am receiving every posting twice (duplicates). Can someone fix > the > problem or direct me to where I can fix it. > > Have you looked at the headers of a pair of messages to see if you are receiving them on different email addresses? If so, just unsubscribe with one of them. If not, well, you need further help! Nick -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: New server set up
Yes I do have ssh - I have just tried yum update bur nothing new was updated. How do I update On Aug 9, 10:27 pm, Boguslaw Faja wrote: > Hm, unfortunately I don't use apache. Nginx is better for me. But for > other group members answers for something else may be important: why > are you using python in version 2.4? It's a bit old. Do you have > access to console (ssh) or only for some web panel (cpanel, direct)? > > Best regards, > > > > On Mon, Aug 9, 2010 at 11:09 PM, XTCHost wrote: > > Sorry, forgot to mention > > > It is a CentOS based VPS runing Parallels Virtuozzo with apache and > > python 2.4 > > > All I have done is a simple install of Django to the root and run > > setup.py install > > > There seem various ways to install it but I wish to be able to set up > > multiple domains through WHM using CPanel > > > Thanks > > > On Aug 9, 8:22 pm, Boguslaw Faja wrote: > >> Hi, > > >> What kind of http server are you going to use? Nginx ? Apache? It > >> somehow defines possible options. > > >> best regards, > > >> On Mon, Aug 9, 2010 at 9:04 PM, XTCHost wrote: > >> > I have installed Django in the root directory of a VPS supplied by > >> > hostagtor. My aim is to provide any domain with Django. Not that there > >> > will be many. It is running > > >> > I am just not sure how to proceed to make sure it is done right > > >> > Any advice help would be welcome > > >> > Many Thanks > > >> > Russell > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups "Django users" group. > >> > To post to this group, send email to django-us...@googlegroups.com. > >> > To unsubscribe from this group, send email to > >> > django-users+unsubscr...@googlegroups.com. > >> > For more options, visit this group > >> > athttp://groups.google.com/group/django-users?hl=en. > > >> -- > >> Bogusław Faja > >> tel. (+48) 691544955 > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > Bogusław Faja > tel. (+48) 691544955 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django on Mac OS X
Please, install django_extentions, werkzeug debuger and try to see what exactly where the issue is with the runserver_plus command (in browser debugger so you'll get the variables that are missing here. Most probably, your timezone field causes the issue. Regards, Xavier. Le 9 août 2010 à 22:40, Daniel França a écrit : > Thanx for all the help, > I tried to run on Sqlite3, and I don't if it's bad or good news, but there's > error even in Sqlite3 > > just when I tried to create the db (syncdb) I get just after I input my users > data or when I try to create a user in shell: > Traceback (most recent call last): > File "manage.py", line 31, in > execute_from_command_line() > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", > line 429, in execute_from_command_line > utility.execute() > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", > line 379, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", > line 191, in run_from_argv > self.execute(*args, **options.__dict__) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", > line 218, in execute > output = self.handle(*args, **options) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", > line 347, in handle > return self.handle_noargs(**options) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", > line 103, in handle_noargs > emit_post_sync_signal(created_models, verbosity, interactive, db) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/sql.py", > line 185, in emit_post_sync_signal > interactive=interactive, db=db) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", > line 162, in send > response = receiver(signal=self, sender=sender, **named) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", > line 44, in create_superuser > call_command("createsuperuser", interactive=True) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", > line 166, in call_command > return klass.execute(*args, **defaults) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", > line 218, in execute > output = self.handle(*args, **options) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", > line 134, in handle > User.objects.create_superuser(username, email, password) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", > line 133, in create_superuser > u = self.create_user(username, email, password) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", > line 129, in create_user > user.save(using=self._db) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > line 435, in save > self.save_base(using=using, force_insert=force_insert, > force_update=force_update) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > line 543, in save_base > created=(not record_exists), raw=raw) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", > line 162, in send > response = receiver(signal=self, sender=sender, **named) > File > "/Users/danielfranca/workspace/django/view/tint/apps/account/models.py", line > 61, in create_account > account, created = > Account.objects.get_or_create(user=instance,timezone='America/Sao_Paulo') > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/manager.py", > line 135, in get_or_create > return self.get_query_set().get_or_create(**kwargs) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", > line 366, in get_or_create > return self.get(**kwargs), False > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/query.py", > line 336, in get > num = len(clone) > File > "/Libra
ManyToManyField limiting choices
Hello, I have a gallery model and an image model. First, I create some galleries, then I insert images into them. But now, I want to add multiple thumbnails feature for galleries (thumbnails representing the gallery, not thumbnails for images inside gallery), so I added ManyToManyField and I can select some images, which will be used as thumbnails. But is there a way, how can I limit these images only to images belonging to the currently editing gallery? There is the limit_choices_to option, but I would need to point to 'self', what is not possible on this place. Second problem would be that I have to create gallery first, then insert images and then select thumbnails, so there is another problem, that if there would be a solution in limiting the image list, I can not use it in create gallery page in admin. What is the best way to solve this problem? Thanks, Martin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to pass session to form and customize error_message value based on session variable
I have class NewEventForm(ModelForm): Event_name = forms.CharField(label='Event Name*',widget=forms.TextInput(attrs={'size':'82','maxlength':'100','tabindex':'1'}),error_messages={'required':'! You must enter Event Name.'}) description=forms.CharField(label='Event Description*', widget=TinyMCE(attrs={'cols': 90, 'rows': 20,'tabindex':'2'}),error_messages={'required':'! You must enter a Description.'}) class Meta: model= Event I want to 1) Pass session to the form 2) Customize a) message text as in "error_messages={'required':'! You must enter Event Name.'}" based on certain settings in session. b) value of label based on certain session settings as in - label='Event Name*', and I want to do it for all the forms in my application. What would the best and least repetitive way to do it. I have around 20 forms. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
filtering related object in template
Hello, I can do: {% for image in gallery.image_set.all %} ... {% endfor %} but my image model has: is_thumbnail = models.BooleanField() and I want to limit displaying only these images which have is_thumbnail=True. I can create a method on the image model, which returns images I want to, but is it possible in template too? Thanks, Martin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ForeignKey to_field problem
Try defining the pet model like this: class Pet(models.Model): owner = models.ForeignKey(Person) name = models.CharField(max_length=30) Than it will work. On Fri, Aug 6, 2010 at 7:25 AM, bhuztez wrote: > I have my models declared in this way: > >class Person(models.Model): >name = models.CharField(max_length=50, unique=True) > >class Pet(models.Model): >owner = models.ForeignKey(Person, to_field='name') >name = models.CharField(max_length=30) > >def __unicode__(self): >return self.name > > I got empty list when trying to get pets from its owner. > >>>> person = Person(name='A') >>>> person.save() >>>> pet = Pet(owner=person, name='B') >>>> pet.save() >>>> Pet.objects.filter(owner=person) >[] >>>> Pet.objects.filter(owner__in=Person.objects.all()) >[] > > > It works as expected with explicit id >>>> Pet.objects.filter(owner__id=person.id) >[] >>>> > Pet.objects.filter(owner__id__in=Person.objects.all().values_list('id', > flat=True)) >[] > > > Setting owner to the name of the person works also >>>> Pet.objects.filter(owner=person.name) >[] > > > I didn't find any document on this, is this a convention, or this is a > bug? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django on Mac OS X
Hi, thanks, I didn't know this werkzeug debuger. Now I can see exactly where it raises the error and can print the variables values, here's the output with some values: File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line *200*, in execute return Database.Cursor.execute(self, query, params) [console ready] >>> print params (1, , u'pt-br') >>> print self >>> print query INSERT INTO "account_account" ("user_id", "timezone", "language") VALUES (?, ?, ?) >>> print params[1] America/Sao_Paulo >>> print params[0] 1 >>> print params[2] pt-br Any idea? On Mon, Aug 9, 2010 at 8:48 PM, Xavier Ordoquy wrote: > Please, install django_extentions, werkzeug debuger and try to see what > exactly where the issue is with the runserver_plus command (in browser > debugger so you'll get the variables that are missing here. > Most probably, your timezone field causes the issue. > > Regards, > Xavier. > > Le 9 août 2010 à 22:40, Daniel França a écrit : > > Thanx for all the help, > I tried to run on Sqlite3, and I don't if it's bad or good news, but > there's error even in Sqlite3 > > just when I tried to create the db (syncdb) I get just after I input my > users data or when I try to create a user in shell: > Traceback (most recent call last): > File "manage.py", line 31, in > execute_from_command_line() > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", > line 429, in execute_from_command_line > utility.execute() > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", > line 379, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", > line 191, in run_from_argv > self.execute(*args, **options.__dict__) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", > line 218, in execute > output = self.handle(*args, **options) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", > line 347, in handle > return self.handle_noargs(**options) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", > line 103, in handle_noargs > emit_post_sync_signal(created_models, verbosity, interactive, db) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/sql.py", > line 185, in emit_post_sync_signal > interactive=interactive, db=db) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", > line 162, in send > response = receiver(signal=self, sender=sender, **named) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", > line 44, in create_superuser > call_command("createsuperuser", interactive=True) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", > line 166, in call_command > return klass.execute(*args, **defaults) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", > line 218, in execute > output = self.handle(*args, **options) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", > line 134, in handle > User.objects.create_superuser(username, email, password) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", > line 133, in create_superuser > u = self.create_user(username, email, password) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/models.py", > line 129, in create_user > user.save(using=self._db) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > line 435, in save > self.save_base(using=using, force_insert=force_insert, > force_update=force_update) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/base.py", > line 543, in save_base > created=(not record_exists), raw=raw) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/dispatch/dispatcher.py", > line 162, in send > response = receiver(signal=self, sender=sender, **named) > File > "/Users/danielfranca/workspace/django/view/tint/apps/account/models.py", > line 61, in create_account > account, cre
Re: ForeignKey to_field problem
Without to_field, it works. But, setting to_field to name, you can simply type name in the input field of django admin, instead of id. I am just wondering why the api behaves differently if to_field is set to another field other than id. We create like this: >>> pet = Pet.objects.create(owner=person, name='B') But, we have to get like this: >>> pet = Pet.objects.get(owner=person.name, name='B') Hence, we cannot get_or_create On 8月10日, 上午9时37分, Renne Rocha wrote: > Try defining the pet model like this: > > class Pet(models.Model): > owner = models.ForeignKey(Person) > name = models.CharField(max_length=30) > > Than it will work. > > On Fri, Aug 6, 2010 at 7:25 AM, bhuztez wrote: > > I have my models declared in this way: > > > class Person(models.Model): > > name = models.CharField(max_length=50, unique=True) > > > class Pet(models.Model): > > owner = models.ForeignKey(Person, to_field='name') > > name = models.CharField(max_length=30) > > > def __unicode__(self): > > return self.name > > > I got empty list when trying to get pets from its owner. > > > >>> person = Person(name='A') > > >>> person.save() > > >>> pet = Pet(owner=person, name='B') > > >>> pet.save() > > >>> Pet.objects.filter(owner=person) > > [] > > >>> Pet.objects.filter(owner__in=Person.objects.all()) > > [] > > > It works as expected with explicit id > > >>> Pet.objects.filter(owner__id=person.id) > > [] > > > Pet.objects.filter(owner__id__in=Person.objects.all().values_list('id', > > flat=True)) > > [] > > > Setting owner to the name of the person works also > > >>> Pet.objects.filter(owner=person.name) > > [] > > > I didn't find any document on this, is this a convention, or this is a > > bug? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.