Re: unknown column in field list
On Sat, 2009-04-11 at 18:56 -0700, nixon66 wrote: > I have a legacy database that I used inspectdb to create the models. > I cleaned up the models, set primary keys, foriegn keys etc. But when > I tried to create a view I get an "unknown column activity.fp_id_id > in field list". I'm not sure why its appending an extra id to the end > of a foriegnkey field. Here are the two models in question: [...] > class Activity(models.Model): > activity_id = models.CharField(max_length=10, primary_key=True) > fp_id = models.ForeignKey(Clients, max_length=10, blank=True) This is where the problem is arising. ForeignKey objects at the Python level store an object. At the database level, they obviously don't do that and store a reference to the primary key (or some other unique field) in the related table. The normal way to convert the Python-level attribute to a database column name for related fields is to append an "_id" suffix. You have two choices here, one is to use the db_column attribute on the field to specify the column name. The probably better method is to name the attribute "fp" in the Django model. After all, it's *not* an id value, it's an object, so the current name, suggesting it's an id is a bit misleading. Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
unknown column in field list
Forgot to add the view I'm using. def country_detail(request, country): c = Country.objects.get(slug=country) lobbyists = Activity.objects.filter(country=c) return render_to_response('country/country_detail.html', {'country':c, 'lobbyists':lobbyists}) --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: unknown column in field list
oh, forgot to add the view I'm using. Here is the view. def country_detail(request, country): c = Country.objects.get(slug=country) lobbyists = Activity.objects.filter(country=c) return render_to_response('country/country_detail.html', {'country':c, 'lobbyists':lobbyists}) On Apr 11, 9:56 pm, nixon66wrote: > I have a legacy database that I used inspectdb to create the models. > I cleaned up the models, set primary keys, foriegn keys etc. But when > I tried to create a view I get an "unknown column activity.fp_id_id > in field list". I'm not sure why its appending an extra id to the end > of a foriegnkey field. Here are the two models in question: > > class Clients(models.Model): > fp_id = models.CharField(max_length=10, primary_key=True) > fp_name = models.CharField(max_length=200, blank=True) > slug = models.CharField(max_length=200, blank=True) > reg_date = models.CharField(max_length=20, blank=True) > termination_date = models.CharField(max_length=20, blank=True) > address_is_foreign = models.CharField(max_length=2, blank=True) > address_1 = models.CharField(max_length=100, blank=True) > city = models.CharField(max_length=50, blank=True) > state = models.CharField(max_length=10, blank=True) > country = models.CharField(max_length=2, blank=True) > zipcode = models.CharField(max_length=10, blank=True) > foreign_cntry_represented = models.ForeignKey(Country, > max_length=2, blank=True) > class Meta: > db_table = u'clients' > > def __unicode__(self): > return self.country > > def get_absolute_url(self): > return 'lobby/client/%s/' % self.slug > > class Activity(models.Model): > activity_id = models.CharField(max_length=10, primary_key=True) > fp_id = models.ForeignKey(Clients, max_length=10, blank=True) > reg_id = models.ForeignKey(Lobbyist, max_length=10, blank=True) > supp_id = models.CharField(max_length=10, blank=True) > period_start_date = models.DateTimeField(null=True, blank=True) > period_end_date = models.DateTimeField(null=True, blank=True) > activity_type=models.ForeignKey > (Lobbytype,max_length=50,related_name="activity_type", blank=True) > slug = models.CharField(max_length=765, blank=True) > activity_desc = models.TextField(blank=True) > financial_amount = models.FloatField(null=True, blank=True) > financial_desc = models.TextField(blank=True) > country = models.CharField(max_length=2, primary_key=True) > year = models.CharField(max_length=5, blank=True) > class Meta: > db_table = u'activity' --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
unknown column in field list
I have a legacy database that I used inspectdb to create the models. I cleaned up the models, set primary keys, foriegn keys etc. But when I tried to create a view I get an "unknown column activity.fp_id_id in field list". I'm not sure why its appending an extra id to the end of a foriegnkey field. Here are the two models in question: class Clients(models.Model): fp_id = models.CharField(max_length=10, primary_key=True) fp_name = models.CharField(max_length=200, blank=True) slug = models.CharField(max_length=200, blank=True) reg_date = models.CharField(max_length=20, blank=True) termination_date = models.CharField(max_length=20, blank=True) address_is_foreign = models.CharField(max_length=2, blank=True) address_1 = models.CharField(max_length=100, blank=True) city = models.CharField(max_length=50, blank=True) state = models.CharField(max_length=10, blank=True) country = models.CharField(max_length=2, blank=True) zipcode = models.CharField(max_length=10, blank=True) foreign_cntry_represented = models.ForeignKey(Country, max_length=2, blank=True) class Meta: db_table = u'clients' def __unicode__(self): return self.country def get_absolute_url(self): return 'lobby/client/%s/' % self.slug class Activity(models.Model): activity_id = models.CharField(max_length=10, primary_key=True) fp_id = models.ForeignKey(Clients, max_length=10, blank=True) reg_id = models.ForeignKey(Lobbyist, max_length=10, blank=True) supp_id = models.CharField(max_length=10, blank=True) period_start_date = models.DateTimeField(null=True, blank=True) period_end_date = models.DateTimeField(null=True, blank=True) activity_type=models.ForeignKey (Lobbytype,max_length=50,related_name="activity_type", blank=True) slug = models.CharField(max_length=765, blank=True) activity_desc = models.TextField(blank=True) financial_amount = models.FloatField(null=True, blank=True) financial_desc = models.TextField(blank=True) country = models.CharField(max_length=2, primary_key=True) year = models.CharField(max_length=5, blank=True) class Meta: db_table = u'activity' --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: UnpickleableError when sessions are saved
On Sat, Apr 11, 2009 at 9:45 PM, Iqbal Abdullahwrote: > > Hi guys, > > In one of our views, we're getting the error below: > > Traceback (most recent call last): > File "/usr/lib/python2.5/site-packages/django/core/servers/ > basehttp.py", line 278, in run >self.result = application(self.environ, self.start_response) > File "/usr/lib/python2.5/site-packages/django/core/servers/ > basehttp.py", line 635, in __call__ >return self.application(environ, start_response) > File "/usr/lib/python2.5/site-packages/django/core/handlers/ > wsgi.py", line 243, in __call__ >response = middleware_method(request, response) > File "/usr/lib/python2.5/site-packages/django/contrib/sessions/ > middleware.py", line 35, in process_response >request.session.save() > File "/usr/lib/python2.5/site-packages/django/contrib/sessions/ > backends/db.py", line 53, in save >session_data = self.encode(self._get_session > (no_load=must_create)), > File "/usr/lib/python2.5/site-packages/django/contrib/sessions/ > backends/base.py", line 88, in encode >pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL) > UnpickleableError: Cannot pickle objects > > By outputting debug strings, I've found out that this error occurs > after the view gets read and before the output to the browser. > > 'ImagingCore' here might be referencing to PIL (Python Imaging > Library) images which are stored in memory which are in turn are > stored in one of the objects which are stored into request.session in > this particular view. > > I can confirm that the other parts of the view which does not process > the images are ok. > > Versions used: > Django-1.0.2-final > we're using the development server that comes with django > > So my question is: I'm wodering if there are any restrictions to the > data types which we can store in request.sessions? > > > > As the error message indicates(sort of), the only things that can be put in request.session are things that can be pickled, most things in Django itself can be(things like Querysets). When you have your own objects(or other 3rd party libs) you'll have to make sure those objs can be pickled. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
UnpickleableError when sessions are saved
Hi guys, In one of our views, we're getting the error below: Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 278, in run self.result = application(self.environ, self.start_response) File "/usr/lib/python2.5/site-packages/django/core/servers/ basehttp.py", line 635, in __call__ return self.application(environ, start_response) File "/usr/lib/python2.5/site-packages/django/core/handlers/ wsgi.py", line 243, in __call__ response = middleware_method(request, response) File "/usr/lib/python2.5/site-packages/django/contrib/sessions/ middleware.py", line 35, in process_response request.session.save() File "/usr/lib/python2.5/site-packages/django/contrib/sessions/ backends/db.py", line 53, in save session_data = self.encode(self._get_session (no_load=must_create)), File "/usr/lib/python2.5/site-packages/django/contrib/sessions/ backends/base.py", line 88, in encode pickled = pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL) UnpickleableError: Cannot pickle objects By outputting debug strings, I've found out that this error occurs after the view gets read and before the output to the browser. 'ImagingCore' here might be referencing to PIL (Python Imaging Library) images which are stored in memory which are in turn are stored in one of the objects which are stored into request.session in this particular view. I can confirm that the other parts of the view which does not process the images are ok. Versions used: Django-1.0.2-final we're using the development server that comes with django So my question is: I'm wodering if there are any restrictions to the data types which we can store in request.sessions? --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django admin page hangs in django server - where is web server error log?
On Sat, 2009-04-11 at 17:40 -0700, adelein wrote: > Hi Zain, > > The thing is that I was able to access the main page before I changed > the urls.py file, so I think that means that the port isnt being > blocked. Something to do with the urls.py file is messed up : ( Then go back and try things out slowly. Firstly, don't try to work on an external IP address. Just test on localhost, since that removes one variable that isn't necessary. Make sure that removing the admin line from urls.py does make things go back to working again when you're accessing on localhost. Then compare your urls.py to what is in the tutorial very carefully (I can't see anything's that different just from looking at it quickly). If the admin url template was broken, we'd hear about it very quickly. I worked through the tutorial yesterday from beginning to end and encountered no problems with access, so you're right in thinking it's something different about your particular setup. If all else fails, go back to the start and try again in a different directory. You already have the Poll model, so you won't have to type that in again. Start from "django-admin.py startproject", set up settings.py, run "startapp polls" and copy in your existing models.py file. Test things on localhost and it should work. Then you have two versions to compare. Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django admin page hangs in django server - where is web server error log?
Hi Zain, The thing is that I was able to access the main page before I changed the urls.py file, so I think that means that the port isnt being blocked. Something to do with the urls.py file is messed up : ( Thanks On Apr 11, 5:35 pm, Zain Memonwrote: > Since no messages are shown in the log, the connection is most likely being > blocked somewhere upstream. Check that you've allowed port 8001 through any > firewalls or routers you have set up. > Zain > > On Sat, Apr 11, 2009 at 5:23 PM, adelein wrote: > > > This is the server output: > > > [r...@bellatrix djangoblog]# python manage.py runserver > > 93.186.171.54:8001 > > Validating models... > > 0 errors found > > > Django version 1.1 beta 1 SVN-10504, using settings > > 'djangoblog.settings' > > Development server is running athttp://93.186.171.54:8001/ > > Quit the server with CONTROL-C. > > > So no errors. Yet admin page is blank as you can see if you go to > >http://93.186.171.54:8001/admin. > > > On Apr 11, 5:21 pm, adelein wrote: > > > Yes, and I see no errors there. Still the admin page does not load at > > > all. I cant find any similar problems through google. > > > > On Apr 11, 5:17 pm, Malcolm Tredinnick > > > wrote: > > > > > On Sat, 2009-04-11 at 17:09 -0700, adelein wrote: > > > > > > Hi, > > > > > > Sorry, I meant to say urls.py of course. So, given I did put the code > > > > > in the right file, the problem still remains. > > > > > If you're following the tutorial, then you will be running the > > > > development server. So all "server log" style output will be printed to > > > > the terminal that you used to start the server. > > > > > Regards, > > > > Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin in frontend
OK Malcom Thanks again... I will play some more with it. Marcello On 4/11/09, Malcolm Tredinnickwrote: > > On Sat, 2009-04-11 at 21:10 -0300, Marcello Parra wrote: >> Hello Malcom, >> >> Thanks for your help... >> I think of a frontend as the user part of the site... where I will >> provide users pages with proper layout and the admin site, is the one >> provided by django admin where I would manage some tables, with >> default django layout... >> >> You must consider that I very new to Django and there is a chance that >> I miss something here... > > I think what you're missing is that the division you are talking about > doesn't really exist. You can think of it that way for documentation or > social organisation purposes if you like, but it's not any kind of > technical, functional or usability division. You access the admin pages > through your web browser in exactly the same way as any other part of > the site. There is no difference between the admin application and any > other applications in Django (in that respect). > > Regards, > Malcolm > > > > > > --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django admin page hangs in django server - where is web server error log?
Since no messages are shown in the log, the connection is most likely being blocked somewhere upstream. Check that you've allowed port 8001 through any firewalls or routers you have set up. Zain On Sat, Apr 11, 2009 at 5:23 PM, adeleinwrote: > > This is the server output: > > > [r...@bellatrix djangoblog]# python manage.py runserver > 93.186.171.54:8001 > Validating models... > 0 errors found > > Django version 1.1 beta 1 SVN-10504, using settings > 'djangoblog.settings' > Development server is running at http://93.186.171.54:8001/ > Quit the server with CONTROL-C. > > > So no errors. Yet admin page is blank as you can see if you go to > http://93.186.171.54:8001/admin. > > On Apr 11, 5:21 pm, adelein wrote: > > Yes, and I see no errors there. Still the admin page does not load at > > all. I cant find any similar problems through google. > > > > On Apr 11, 5:17 pm, Malcolm Tredinnick > > wrote: > > > > > On Sat, 2009-04-11 at 17:09 -0700, adelein wrote: > > > > > > Hi, > > > > > > Sorry, I meant to say urls.py of course. So, given I did put the code > > > > in the right file, the problem still remains. > > > > > If you're following the tutorial, then you will be running the > > > development server. So all "server log" style output will be printed to > > > the terminal that you used to start the server. > > > > > Regards, > > > Malcolm > > > --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django admin page hangs in django server - where is web server error log?
This is the server output: [r...@bellatrix djangoblog]# python manage.py runserver 93.186.171.54:8001 Validating models... 0 errors found Django version 1.1 beta 1 SVN-10504, using settings 'djangoblog.settings' Development server is running at http://93.186.171.54:8001/ Quit the server with CONTROL-C. So no errors. Yet admin page is blank as you can see if you go to http://93.186.171.54:8001/admin. On Apr 11, 5:21 pm, adeleinwrote: > Yes, and I see no errors there. Still the admin page does not load at > all. I cant find any similar problems through google. > > On Apr 11, 5:17 pm, Malcolm Tredinnick > wrote: > > > On Sat, 2009-04-11 at 17:09 -0700, adelein wrote: > > > > Hi, > > > > Sorry, I meant to say urls.py of course. So, given I did put the code > > > in the right file, the problem still remains. > > > If you're following the tutorial, then you will be running the > > development server. So all "server log" style output will be printed to > > the terminal that you used to start the server. > > > Regards, > > Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django admin page hangs in django server - where is web server error log?
Yes, and I see no errors there. Still the admin page does not load at all. I cant find any similar problems through google. On Apr 11, 5:17 pm, Malcolm Tredinnickwrote: > On Sat, 2009-04-11 at 17:09 -0700, adelein wrote: > > > Hi, > > > Sorry, I meant to say urls.py of course. So, given I did put the code > > in the right file, the problem still remains. > > If you're following the tutorial, then you will be running the > development server. So all "server log" style output will be printed to > the terminal that you used to start the server. > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django admin page hangs in django server - where is web server error log?
On Sat, 2009-04-11 at 17:09 -0700, adelein wrote: > > Hi, > > Sorry, I meant to say urls.py of course. So, given I did put the code > in the right file, the problem still remains. If you're following the tutorial, then you will be running the development server. So all "server log" style output will be printed to the terminal that you used to start the server. Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin in frontend
On Sat, 2009-04-11 at 21:10 -0300, Marcello Parra wrote: > Hello Malcom, > > Thanks for your help... > I think of a frontend as the user part of the site... where I will > provide users pages with proper layout and the admin site, is the one > provided by django admin where I would manage some tables, with > default django layout... > > You must consider that I very new to Django and there is a chance that > I miss something here... I think what you're missing is that the division you are talking about doesn't really exist. You can think of it that way for documentation or social organisation purposes if you like, but it's not any kind of technical, functional or usability division. You access the admin pages through your web browser in exactly the same way as any other part of the site. There is no difference between the admin application and any other applications in Django (in that respect). Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin in frontend
Hello Malcom, Thanks for your help... I think of a frontend as the user part of the site... where I will provide users pages with proper layout and the admin site, is the one provided by django admin where I would manage some tables, with default django layout... You must consider that I very new to Django and there is a chance that I miss something here... Marcello On 4/11/09, Malcolm Tredinnickwrote: > > On Sat, 2009-04-11 at 11:51 -0300, Marcello Parra wrote: >> Hello, >> >> I'm planning a site with django. >> It need to have some functionalities that are very similar to Django's >> admin (like CRUD in some tables, with validations, etc...). But I >> would not like to have two sections (frontend and admin) in it >> So, my question is: is there a way to use already made admin's >> funcionalities in my frontend without having to rewrite them ?? >> > > What do you mean by "frontend"? The admin site is just a set of > webpages. It's not special in any way. > > Regards, > Malcolm > > > > > > --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django admin page hangs in django server - where is web server error log?
Hi, Sorry, I meant to say urls.py of course. So, given I did put the code in the right file, the problem still remains. -Adelein On Apr 11, 1:58 pm, Daniel Rosemanwrote: > On Apr 11, 8:42 pm, adelein wrote: > > > > > Hi, > > > Myhttp://localhost:8000/adminpageis hanging in the django server > > and I get "Error 320 (net::ERR_INVALID_RESPONSE): Unknown error." > > after a while. > > > I am running on fedora 7. > > > I am following the django tutorial and I am using the latest svn > > django version. > > > After I set this in the settings.py and go to thehttp://localhost:8000/admin > > page it just hangs: > > > from django.conf.urls.defaults import * > > > # Uncomment the next two lines to enable the admin: > > from django.contrib import admin > > admin.autodiscover() > > > urlpatterns = patterns('', > > # Example: > > # (r'^mysite/', include('mysite.foo.urls')), > > > # Uncomment the admin/doc line below and add > > 'django.contrib.admindocs' > > # to INSTALLED_APPS to enable admin documentation: > > # (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > > # Uncomment the next line to enable the admin: > > (r'^admin/', include(admin.site.urls)), > > ) > > > First, I dont know how to access the web server error log? > > > Anyone has any idea? > > > Thanks! > > > -Adelein > > If that's your settings.py, you should go back and read the tutorial > again. That code should go in your urls.py. > > I assume by 'the Django server' you mean the built-in development > server. As the name implies, this is only for development, and doesn't > have an 'error log'. All errors are displayed in the console. > -- > 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-users@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: every time that I load a form page, i have to reload the page to make errors go away
On Sat, Apr 11, 2009 at 7:24 PM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > > On Sat, 2009-04-11 at 19:23 -0400, Alex Gaynor wrote: > [...] > > > > > > Even if your application is exclusively for your own usage, it's not > > uncommon for the pointy haired boss to come in with requests to change > > a URL hierarchy, and there's no reason to create more work for > > yourself. > > Which is what James wrote, right? > > Malcolm > > > > > > Well talked about the generic, "change the URL it's deployed at" case, you mentioned that for an application you distribute this is especially important. I just wanted to note that it's very true even if that's not the case. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: every time that I load a form page, i have to reload the page to make errors go away
On Sat, 2009-04-11 at 19:23 -0400, Alex Gaynor wrote: [...] > > > Even if your application is exclusively for your own usage, it's not > uncommon for the pointy haired boss to come in with requests to change > a URL hierarchy, and there's no reason to create more work for > yourself. Which is what James wrote, right? Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: every time that I load a form page, i have to reload the page to make errors go away
On Sat, Apr 11, 2009 at 7:21 PM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > > On Sat, 2009-04-11 at 17:49 -0500, James Bennett wrote: > > On Sat, Apr 11, 2009 at 5:13 PM, codecowboywrote: > > > I've followed some examples from around the Django community and that > > > is why I use the reverse() method at all. What is the point of using > > > the reverse() method? > > > > Well, there's a problem you'll run into fairly often. > > > > Suppose, for example, that you set up a weblog, and you have it at the > > URL "/weblog/". So in your templates you have links to "/weblog/", in > > your code the get_absolute_url() method of entries returns a string > > containing "/weblog/", any redirects involved have to have "/weblog/" > > in the URL, etc. > > > > And then one day you suddenly need to deploy another copy of the > > appliation, but on a site which wants the weblog at "/blog/". > > As James is well aware, but I'd like to make it explicit: This is > particularly true if you're writing an application that is going to be > distributed and used by a broader audience. You have absolutely no idea > where the end-users are going to install your application in the their > URL hierarchy. Tying your application to some particular URLs is simply > poor design practice in those cases. > > Regards, > Malcolm > > > > > Even if your application is exclusively for your own usage, it's not uncommon for the pointy haired boss to come in with requests to change a URL hierarchy, and there's no reason to create more work for yourself. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: every time that I load a form page, i have to reload the page to make errors go away
On Sat, 2009-04-11 at 17:49 -0500, James Bennett wrote: > On Sat, Apr 11, 2009 at 5:13 PM, codecowboywrote: > > I've followed some examples from around the Django community and that > > is why I use the reverse() method at all. What is the point of using > > the reverse() method? > > Well, there's a problem you'll run into fairly often. > > Suppose, for example, that you set up a weblog, and you have it at the > URL "/weblog/". So in your templates you have links to "/weblog/", in > your code the get_absolute_url() method of entries returns a string > containing "/weblog/", any redirects involved have to have "/weblog/" > in the URL, etc. > > And then one day you suddenly need to deploy another copy of the > appliation, but on a site which wants the weblog at "/blog/". As James is well aware, but I'd like to make it explicit: This is particularly true if you're writing an application that is going to be distributed and used by a broader audience. You have absolutely no idea where the end-users are going to install your application in the their URL hierarchy. Tying your application to some particular URLs is simply poor design practice in those cases. Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template filter with plural tag [Solved]
Thanks! It works as charm. On 11 abr, 22:54, Malcolm Tredinnickwrote: > Indeed, this is possible. You need to use a number for the counting > portion of the blocktrans-plural combination, so that gettext can use > the number to determine the plural form. The trick is that you use the > same variable again, combined with a filter as another alias inside the > translation block to represent the content you want. Like this: > > {% blocktrans count list as number and list|apnumber as word %} > There is {{ word }} object. > {% plural %} > There are {{ word }} objects. > {% endblocktrans %} --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to use email instead of username for user authentication?
On Sat, 2009-04-11 at 07:52 -0700, pkenjora wrote: > Malcom, Well, I'm not "Malcom" (sic), but I'll reply anyway. >Google, FaceBook, and LinkedIn have been using email authentication > for how long now? With the default constraints you've put on Django a > developer would have to "work around" the out of the box code to make > the project behave like the big 3 names on the web. There's some assumption there that what they're doing is a good idea. Their systems have the usability problems I've mentioned. It's also not clear their authentication methods are the best around. In any case, as I note below (and have written elsewhere), you're simply not restricted from using this system and can do so without patching Django, if that's the way you want to go. There's no restriction in place here! The combined size of forums and social networking sites not pretending that my "handle" is an email address is, I'll wager, larger than Facebook or LinkedIn, certainly. Which has precisely the same small weight as your examples. The point being that there are valid use-cases in both directions and you'll notice that that's never been disputed. [...] > As far as your reasons go, I'm fairly sure its just as easy to > change the email as it is the username, I'm sorry you feel that way. It's patently false. The username is only used on the site you are creating an account for. Your email address has much wider usage and creating a new one isn't always possible or desirable (signing up to one of the hosted services requires agreeing to T that are often unpleasant). The username when creating a new account on a site has much less currency. > I would even argue that my > username (display name) could change but my login credentials should > stay the same. You are assuming that the username is the display name. That might be a secondary use for it and it sometimes works well for that. However, the username is primarily the unique identifier for the user within the system. It's the thing that won't change. Having a display name, particularly one that can change is also quite common and it's for extensions like that that user profile exist for. Login credentials are not the same as identifier within the system. The login credentials should definitely be permitted to change. Having an account tied to an email address is tragic when that email address is no longer accessible to you (for example, it was a company address and you've since left the company). Allowing the email address to change -- and hence not making it the entity identifier -- is a good thing. > You are correct, username authentication has always been around. > However, the explicit banning and obfuscating of email authentication > in the default module has not. I'm sorry, but that's simply not correct. I pointed that out earlier in the thread. You have the version control history, please feel free to find the released version of Django where this wasn't the case and correct me if you really feel this is not the case. > That is the part that worries me, that > is where things are going wrong. > > We're all professionals here, we all take the time to leave feedback > in the hopes of improving Django. Which is a given. Not a partricularly relevant comment for this thread, unless you're trying to imply something sinister, since there's no indication that feedback isn't being listened to. In fact, in this case, it's being answered with both technical and usability reasons for the current behaviour. > I have a sneaking suspicion that > project specific requirements crept into the trunk because it was > easier than patching every time. Whereas, I have a sneaking suspicion that you've forgotten your history. Now we both have sneaking suspicions. It's all very suspicous. :-) Part of the problem with threads like this is the built-in assumptions people are bringing to the table. The username field in the User model is just the unique identifier in the system. If you want to use the email address for login, it's fairly easy to do so: writing auth backends is supported and encouraged. You never have to show the username to users (so you could generate a more-or-less random identifier when creating the account) and that's fairly standard practice in a bunch of projects I've seen. It's also not uncommon to add a user-editable display name in a user profile class, etc, etc. You're argument is about a bit of a red herring because it's assigning more import to the username field than it deserves. That field simply isn't intrinsic to a user's experience on the site because you are in complete control as to what information you show and what information you authenticate against on your site. Before complaining that "oh, no, now I have to write my own login method", yes, big deal! You have to write half a dozen lines once, or use somebody else's. Just like you do when supporting OpenID or Facebook Connect or other authentication systems. Django
Re: Template filter with plural tag
On Sat, 2009-04-11 at 12:40 -0700, Kless wrote: > I would to pluralize into a translation block [1] but I also want to > apply the 'apnumber' template filter [2] > --- > {% load humanize %} > {% load i18n %} > > {% blocktrans count list|apnumber as number %} > There is {{ number }} object. > {% plural %} > There are {{ number }} objects. > {% endblocktrans %} > --- > > The problem is that if the filter is used then the 'plural' tag > doesn't works. > > Is there any way to solve it? Indeed, this is possible. You need to use a number for the counting portion of the blocktrans-plural combination, so that gettext can use the number to determine the plural form. The trick is that you use the same variable again, combined with a filter as another alias inside the translation block to represent the content you want. Like this: {% blocktrans count list as number and list|apnumber as word %} There is {{ word }} object. {% plural %} There are {{ word }} objects. {% endblocktrans %} Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: every time that I load a form page, i have to reload the page to make errors go away
On Sat, Apr 11, 2009 at 5:13 PM, codecowboywrote: > I've followed some examples from around the Django community and that > is why I use the reverse() method at all. What is the point of using > the reverse() method? Well, there's a problem you'll run into fairly often. Suppose, for example, that you set up a weblog, and you have it at the URL "/weblog/". So in your templates you have links to "/weblog/", in your code the get_absolute_url() method of entries returns a string containing "/weblog/", any redirects involved have to have "/weblog/" in the URL, etc. And then one day you suddenly need to deploy another copy of the appliation, but on a site which wants the weblog at "/blog/". Reverse URL resolution lets you easily make this kind of change, or have an application reused on different sites without changing the code, by looking up the correct URL in your actual URL configuration instead of hard-coding it all over the place. But in order to work, all your URL patterns have to point to views which actually exist and which live in files that don't raise any kind of import or syntax errors, since the reverse resolution system has to scan through your URL patterns to find the right one. If you have any errors in a view file, or have a URL pattern pointing to a view that doesn't actually exist in your code, reverse resolution won't work. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: every time that I load a form page, i have to reload the page to make errors go away
On Saturday 11 April 2009 03:13:18 pm codecowboy wrote: > What is the point of using the reverse() method? > I'm answering this because I want to make sure that my idea of it is the same as the rest of the community and would definately like feedback on it. Using this example: urlpatterns = patterns ('fun', url(r'^fun/$', 'views.place', name="fun_place"), ) reverse('fun_place') will return the url, in this case, 'fun/'. I use reverse in various view functions and other places, such as http redirects. To me it's a lot like the models.permalink decorator on non-model based urls and fits in with the DRY philosophy. Using this style in your code allows you to edit the the url pattern, or the funciton call, or any other part of the url pattern without ever having to change anything else in your code, unless you edit the name parameter. Mike -- Mark's Dental-Chair Discovery: Dentists are incapable of asking questions that require a simple yes or no answer. signature.asc Description: This is a digitally signed message part.
Re: Admin in frontend
On Sat, 2009-04-11 at 11:51 -0300, Marcello Parra wrote: > Hello, > > I'm planning a site with django. > It need to have some functionalities that are very similar to Django's > admin (like CRUD in some tables, with validations, etc...). But I > would not like to have two sections (frontend and admin) in it > So, my question is: is there a way to use already made admin's > funcionalities in my frontend without having to rewrite them ?? > What do you mean by "frontend"? The admin site is just a set of webpages. It's not special in any way. Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: every time that I load a form page, i have to reload the page to make errors go away
I've followed some examples from around the Django community and that is why I use the reverse() method at all. What is the point of using the reverse() method? On Apr 11, 5:03 pm, Daniel Rosemanwrote: > On Apr 11, 7:57 pm, codecowboy wrote: > > > > > Every time that a load a form on my site, I see the following errors. > > If I reload the page, they go away and everything works just fine. > > Does anyone know why? Thank you in advance. > > > TemplateSyntaxError at /eaccounts/register/ > > > Caught an exception while rendering: Tried edit in module > > conferences.views. Error was: 'module' object has no attribute 'edit' > > > Original Traceback (most recent call last): > > File "/usr/lib/python2.5/site-packages/django/template/debug.py", > > line 71, in render_node > > result = node.render(context) > > File "/usr/lib/python2.5/site-packages/django/template/ > > defaulttags.py", line 373, in render > > url = reverse(self.view_name, args=args, kwargs=kwargs) > > File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", > > line 254, in reverse > > *args, **kwargs))) > > File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", > > line 227, in reverse > > possibilities = self.reverse_dict.getlist(lookup_view) > > File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", > > line 169, in _get_reverse_dict > > self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern)) > > File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", > > line 136, in _get_callback > > raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % > > (func_name, mod_name, str(e)) > > ViewDoesNotExist: Tried edit in module conferences.views. Error was: > > 'module' object has no attribute 'edit' > > The page you are trying to load has either a reverse() call in the > view, or a {% url %} tag in the template. In order to resolve the > reverse lookup, Django is trying to load all the views in your urlconf > - and it looks like one of them has an error. Fix the error in the > conferences.views.edit function, and the message should go away. > -- > 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-users@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: Port in use Error
Hi, I'm in the exact same situation " Validating models... 0 errors found Django version 1.0.2 final, using settings 'mylu.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Error: That port is already in use. " but the solution above doesn't solve my problem ./manage.py runserver 127.0.0.1:8001 gives me Permission denied (tho' I'm admin) sudo netstat -np | grep 8000 -> tcp 511 0 127.0.0.1:8000 127.0.0.1:56853 CLOSE_WAIT - tcp 443 0 127.0.0.1:8000 127.0.0.1:44749 CLOSE_WAIT - tcp 438 0 127.0.0.1:8000 127.0.0.1:44746 CLOSE_WAIT - tcp 438 0 127.0.0.1:8000 127.0.0.1:44748 CLOSE_WAIT - tcp 443 0 127.0.0.1:8000 127.0.0.1:47211 CLOSE_WAIT - tcp 524 0 127.0.0.1:8000 127.0.0.1:60170 CLOSE_WAIT - On Mar 17, 9:17 am, TPwrote: > gordyt > > Thanks this does help, I managed to overcome this problem yesterday, > but was still slightly confused as to > why I had the error in the first place, this helps me understand! > > Thanks On Mar 26, 12:25 pm, pcastellazzi wrote: > The python uuid library use libuuid from e2fsprogs (at least in > ubuntu). This particular uuid library spanws a daemon called uuidd to > help with concurrent uuid generation. As far as i know the only way to > disable this behaviour is to compile libuuid with --disable-uuidd > option. > > When you run ./manage.py runserver the first time, libuuid launch > uuidd with fork(2). This cause uuidd to inherit all open file > descriptors from the parent process. In this case the parent process > is the python interpreter running manage.py and the open file > descriptors are among other things the open tcp connections. After > that manage.py will (probably) hang whiel serving a request, and if it > is restarted by hand or by changing a file in your application it will > keep saying port already in use until you kill uuidd. > > The most simple workaround is to launch uuidd without parameters. This > will make the daemon start without open tcp ports and the library will > not try to run uuidd by it self, then do your normal django > development stuff and when you are done you can kill uuidd with uuidd - > k. > > On Mar 17, 1:17 pm, TP wrote: > > > gordyt > > > Thanks this does help, I managed to overcome this problem yesterday, > > but was still slightly confused as to > > why I had the error in the first place, this helps me understand! > > > 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-users@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: Cannot call a custom model method in my view
Thank you Daniel. I got it working. That link that you gave me helped me to figure it out. I'm curious though, is there ever a reason in Django to define a method in a model class or would I always use a custom manager method? I'm going to post my code here for anyone who has the same question down the road. Thanks a lot and I hope that this helps someone else. - conferences/models.py - In this file I create a custom manager (ConferenceManager) class with a custom function (def upcoming(self)). Notice in the Conference model that I create a class variable named objects and set it equal to the custom manager that I created. This is all that you have to do in order to access the custom function in your manager. from django.db import models from datetime import datetime from scinet.scientists.models import Scientist class ConferenceManager(models.Manager): def upcoming(self): today = datetime.today() return super(ConferenceManager, self).get_query_set().filter (date__gte=(today)) class Conference(models.Model): title = models.CharField(max_length=200) description = models.TextField() date = models.DateTimeField() scientists = models.ManyToManyField(Scientist, through='ConferenceAttendee') created = models.DateTimeField() modified = models.DateTimeField() objects = ConferenceManager() - conferences/views.py - As you can see, once you create the model the way that I did above, you will be able to call the upcoming() function like I did. "uc = Conference.objects.upcoming()". def detail(request, conference_id): c = get_object_or_404(Conference, pk=conference_id) # Get all upcoming conferences uc = Conference.objects.upcoming() return render_to_response('conferences/detail.html', {'conference': c, 'upcoming_conferences' : uc}) - templates/conferences/details.html - The template is not relevant here but I will include it just for the sake of providing a complete. Upcoming Conferences {% for conference in upcoming_conferences %} {{ conference.date|date:"F d"}}: {{ conference.title }} {% endfor %} On Apr 11, 4:49 pm, Daniel Rosemanwrote: > On Apr 11, 9:25 pm, codecowboy wrote: > > > > > I've read some other posts regarding this issue as well as the > > following article:http://www.b-list.org/weblog/2007/nov/03/working-models/. > > I cannot seem to get this thing to work. Thank you in advance for any > > help. Here is my code. > > > -- view -- > > from django.db.models import get_model > > > def blah(): > > c = get_model('conferences', 'conference') > > uc = c.upcoming() > > > -- model -- > > class Conference(models.Model): > > . > > . > > . > > > def upcoming(self): > > today = datetime.today() > > return self.objects.filter(date__gte=(today)) > > > I've also tried the following in my view code: > > > def blah(): > > c = Conference() > > uc = c.upcoming() > > > I cannot stop the following error from displaying: > > > TypeError at /scientists/portal > > > unbound method upcoming() must be called with Conference instance as > > first argument (got nothing instead) > > > Request Method: GET > > Request URL: http://127.0.0.1:8000/scientists/portal > > Exception Type: TypeError > > Exception Value: > > > unbound method upcoming() must be called with Conference instance as > > first argument (got nothing instead) > > > Exception Location: /home/guy/DjangoApps/scinet/scientists/views.py > > in portal, line 20 > > You are confused between class and instance methods. upcoming as you > have defined it is an instance method - ie you call it on an instance > of Conference. However, the content of the method looks like it should > be a class method - that is, you call it on the Conference class > itself - and, indeed, that is what you are trying to do in your blah > view. > > There are two solutions to this: the first is to tell Python that this > is a class method by simply using the @classmethod decorator - and, by > convention, using cls as the parameter to the method rather than > self. > > However, looking at what you're actually trying to do - return a > custom queryset of Conference objects - the idiomatic way of achieving > this in Django is actually to define a custom manager. Again, two ways > of doing this: you can define an additional manager and put your > method in it as get_query_set - so you would call it as > Conference.upcoming.all(); or override the default manager and put > your method as upcoming - so you would call it as > Conference.objects.upcoming(). Your choice. > > See here for information on custom >
Re: Tutorial - include question
2009/4/11 Alex Gaynor: > mysite/urls.py needs to have the full urlpatterns = thing like the > polls/urls.py has so it would look like: > > from django.conf.urls.defaults import * > > admin.autodiscover() > > urlpatterns = patterns('', > (r'^polls/', include('mysite.polls.urls')), > ) Thanks! Regards Johann --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to use email instead of username for user authentication?
On Sat, Apr 11, 2009 at 10:52 AM, pkenjorawrote: > > You are correct, username authentication has always been around. > However, the explicit banning and obfuscating of email authentication > in the default module has not. That is the part that worries me, that > is where things are going wrong. > I can't figure out what you are talking about here. You mention an '@' filter elsewhere, and all I can think you mean is the fact that '@' is not an allowed character in the auth's username field? If so, near as I can tell that has been there since the earliest official Django release, you can see in the 0.90 source code that there's an isAlphaNumeric validator on that field: http://code.djangoproject.com/browser/django/tags/releases/0.90/django/models/auth.py#L33 so as far back as 0.90, near as I can tell, you were not allowed to have '@' in a username. Yet you seem to be saying you need to work around the 'new' restriction as you upgrade to 1.0.2 -- so I'm confused. Are you upgrading from some level (what one?) which allowed '@' in usernames? Are you talking about some other restriction? Karen --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: every time that I load a form page, i have to reload the page to make errors go away
On Apr 11, 7:57 pm, codecowboywrote: > Every time that a load a form on my site, I see the following errors. > If I reload the page, they go away and everything works just fine. > Does anyone know why? Thank you in advance. > > TemplateSyntaxError at /eaccounts/register/ > > Caught an exception while rendering: Tried edit in module > conferences.views. Error was: 'module' object has no attribute 'edit' > > Original Traceback (most recent call last): > File "/usr/lib/python2.5/site-packages/django/template/debug.py", > line 71, in render_node > result = node.render(context) > File "/usr/lib/python2.5/site-packages/django/template/ > defaulttags.py", line 373, in render > url = reverse(self.view_name, args=args, kwargs=kwargs) > File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", > line 254, in reverse > *args, **kwargs))) > File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", > line 227, in reverse > possibilities = self.reverse_dict.getlist(lookup_view) > File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", > line 169, in _get_reverse_dict > self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern)) > File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", > line 136, in _get_callback > raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % > (func_name, mod_name, str(e)) > ViewDoesNotExist: Tried edit in module conferences.views. Error was: > 'module' object has no attribute 'edit' The page you are trying to load has either a reverse() call in the view, or a {% url %} tag in the template. In order to resolve the reverse lookup, Django is trying to load all the views in your urlconf - and it looks like one of them has an error. Fix the error in the conferences.views.edit function, and the message should go away. -- 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-users@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 admin page hangs in django server - where is web server error log?
On Apr 11, 8:42 pm, adeleinwrote: > Hi, > > Myhttp://localhost:8000/adminpage is hanging in the django server > and I get "Error 320 (net::ERR_INVALID_RESPONSE): Unknown error." > after a while. > > I am running on fedora 7. > > I am following the django tutorial and I am using the latest svn > django version. > > After I set this in the settings.py and go to thehttp://localhost:8000/admin > page it just hangs: > > from django.conf.urls.defaults import * > > # Uncomment the next two lines to enable the admin: > from django.contrib import admin > admin.autodiscover() > > urlpatterns = patterns('', > # Example: > # (r'^mysite/', include('mysite.foo.urls')), > > # Uncomment the admin/doc line below and add > 'django.contrib.admindocs' > # to INSTALLED_APPS to enable admin documentation: > # (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > # Uncomment the next line to enable the admin: > (r'^admin/', include(admin.site.urls)), > ) > > First, I dont know how to access the web server error log? > > Anyone has any idea? > > Thanks! > > -Adelein If that's your settings.py, you should go back and read the tutorial again. That code should go in your urls.py. I assume by 'the Django server' you mean the built-in development server. As the name implies, this is only for development, and doesn't have an 'error log'. All errors are displayed in the console. -- 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-users@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: Cannot call a custom model method in my view
On Apr 11, 9:25 pm, codecowboywrote: > I've read some other posts regarding this issue as well as the > following article:http://www.b-list.org/weblog/2007/nov/03/working-models/. > I cannot seem to get this thing to work. Thank you in advance for any > help. Here is my code. > > -- view -- > from django.db.models import get_model > > def blah(): > c = get_model('conferences', 'conference') > uc = c.upcoming() > > -- model -- > class Conference(models.Model): > . > . > . > > def upcoming(self): > today = datetime.today() > return self.objects.filter(date__gte=(today)) > > I've also tried the following in my view code: > > def blah(): > c = Conference() > uc = c.upcoming() > > I cannot stop the following error from displaying: > > TypeError at /scientists/portal > > unbound method upcoming() must be called with Conference instance as > first argument (got nothing instead) > > Request Method: GET > Request URL: http://127.0.0.1:8000/scientists/portal > Exception Type: TypeError > Exception Value: > > unbound method upcoming() must be called with Conference instance as > first argument (got nothing instead) > > Exception Location: /home/guy/DjangoApps/scinet/scientists/views.py > in portal, line 20 You are confused between class and instance methods. upcoming as you have defined it is an instance method - ie you call it on an instance of Conference. However, the content of the method looks like it should be a class method - that is, you call it on the Conference class itself - and, indeed, that is what you are trying to do in your blah view. There are two solutions to this: the first is to tell Python that this is a class method by simply using the @classmethod decorator - and, by convention, using cls as the parameter to the method rather than self. However, looking at what you're actually trying to do - return a custom queryset of Conference objects - the idiomatic way of achieving this in Django is actually to define a custom manager. Again, two ways of doing this: you can define an additional manager and put your method in it as get_query_set - so you would call it as Conference.upcoming.all(); or override the default manager and put your method as upcoming - so you would call it as Conference.objects.upcoming(). Your choice. See here for information on custom managers: http://docs.djangoproject.com/en/dev/topics/db/managers/ -- 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-users@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: Tutorial - include question
On Sat, Apr 11, 2009 at 4:16 PM, Johann Spieswrote: > > Working through the tutorial everything went well until I came to the > section "Decoupling the URLconfs" where > the "include" option for urls in a subdirectory is not working as > advertised. > > What did I do wrong? > > > In mysite/urls.py I have: > > == > from django.conf.urls.defaults import * > > (r'^polls/', include('mysite.polls.urls')), > > # Uncomment the next two lines to enable the admin: > from django.contrib import admin > admin.autodiscover() > = > And in mysite/polls/urls.py have > = > from django.conf.urls.defaults import * > > urlpatterns = patterns('mysite.polls.views', >(r'^$', 'index'), >(r'^(?P\d+)/$', 'detail'), >(r'^(?P\d+)/results/$', 'results'), >(r'^(?P\d+)/vote/$', 'vote'), > ) > = > But this results in: > > Traceback (most recent call last): > > File "/var/lib/python-support/python2.6/django/core/servers/basehttp.py", > line 278, in run >self.result = application(self.environ, self.start_response) > > File "/var/lib/python-support/python2.6/django/core/servers/basehttp.py", > line 635, in __call__ >return self.application(environ, start_response) > > File "/var/lib/python-support/python2.6/django/core/handlers/wsgi.py", > line 239, in __call__ >response = self.get_response(request) > > File "/var/lib/python-support/python2.6/django/core/handlers/base.py", > line 67, in get_response >response = middleware_method(request) > > File "/var/lib/python-support/python2.6/django/middleware/common.py", > line 56, in process_request >if (not _is_valid_path(request.path_info) and > > File "/var/lib/python-support/python2.6/django/middleware/common.py", > line 142, in _is_valid_path >urlresolvers.resolve(path) > > File "/var/lib/python-support/python2.6/django/core/urlresolvers.py", > line 246, in resolve >return get_resolver(urlconf).resolve(path) > > File "/var/lib/python-support/python2.6/django/core/urlresolvers.py", > line 179, in resolve >for pattern in self.urlconf_module.urlpatterns: > > AttributeError: 'module' object has no attribute 'urlpatterns' > > > Regards. > > Johann > > > > mysite/urls.py needs to have the full urlpatterns = thing like the polls/urls.py has so it would look like: from django.conf.urls.defaults import * admin.autodiscover() urlpatterns = patterns('', (r'^polls/', include('mysite.polls.urls')), ) Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Tutorial - include question
Working through the tutorial everything went well until I came to the section "Decoupling the URLconfs" where the "include" option for urls in a subdirectory is not working as advertised. What did I do wrong? In mysite/urls.py I have: == from django.conf.urls.defaults import * (r'^polls/', include('mysite.polls.urls')), # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() = And in mysite/polls/urls.py have = from django.conf.urls.defaults import * urlpatterns = patterns('mysite.polls.views', (r'^$', 'index'), (r'^(?P\d+)/$', 'detail'), (r'^(?P\d+)/results/$', 'results'), (r'^(?P\d+)/vote/$', 'vote'), ) = But this results in: Traceback (most recent call last): File "/var/lib/python-support/python2.6/django/core/servers/basehttp.py", line 278, in run self.result = application(self.environ, self.start_response) File "/var/lib/python-support/python2.6/django/core/servers/basehttp.py", line 635, in __call__ return self.application(environ, start_response) File "/var/lib/python-support/python2.6/django/core/handlers/wsgi.py", line 239, in __call__ response = self.get_response(request) File "/var/lib/python-support/python2.6/django/core/handlers/base.py", line 67, in get_response response = middleware_method(request) File "/var/lib/python-support/python2.6/django/middleware/common.py", line 56, in process_request if (not _is_valid_path(request.path_info) and File "/var/lib/python-support/python2.6/django/middleware/common.py", line 142, in _is_valid_path urlresolvers.resolve(path) File "/var/lib/python-support/python2.6/django/core/urlresolvers.py", line 246, in resolve return get_resolver(urlconf).resolve(path) File "/var/lib/python-support/python2.6/django/core/urlresolvers.py", line 179, in resolve for pattern in self.urlconf_module.urlpatterns: AttributeError: 'module' object has no attribute 'urlpatterns' Regards. Johann --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django admin page hangs in django server - where is web server error log?
Hi, My http://localhost:8000/admin page is hanging in the django server and I get "Error 320 (net::ERR_INVALID_RESPONSE): Unknown error." after a while. I am running on fedora 7. I am following the django tutorial and I am using the latest svn django version. After I set this in the settings.py and go to the http://localhost:8000/admin page it just hangs: from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^mysite/', include('mysite.foo.urls')), # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), ) First, I dont know how to access the web server error log? Anyone has any idea? Thanks! -Adelein --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Cannot call a custom model method in my view
I've read some other posts regarding this issue as well as the following article: http://www.b-list.org/weblog/2007/nov/03/working-models/. I cannot seem to get this thing to work. Thank you in advance for any help. Here is my code. -- view -- from django.db.models import get_model def blah(): c = get_model('conferences', 'conference') uc = c.upcoming() -- model -- class Conference(models.Model): . . . def upcoming(self): today = datetime.today() return self.objects.filter(date__gte=(today)) I've also tried the following in my view code: def blah(): c = Conference() uc = c.upcoming() I cannot stop the following error from displaying: TypeError at /scientists/portal unbound method upcoming() must be called with Conference instance as first argument (got nothing instead) Request Method: GET Request URL:http://127.0.0.1:8000/scientists/portal Exception Type: TypeError Exception Value: unbound method upcoming() must be called with Conference instance as first argument (got nothing instead) Exception Location: /home/guy/DjangoApps/scinet/scientists/views.py in portal, line 20 --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin Inlines astray
fixed after trying all sorts of approaches I finally got it to work by chmod'ing o+r to the files under the django/contrib/admin directory. Most of them already had read permissions but I could see that a few didn't. a On Sat, 2009-04-11 at 19:58 +0100, Andy Wilson wrote: > ps. I used the 'song' and 'recording' models as an example, in fact I > have several apps that use inlines, and on the one installation they are > missing in every case. No errors are thrown and I can see nothing > relevant in the logs. > > On Sat, 2009-04-11 at 19:50 +0100, Andy Wilson wrote: > > has anyone any idea why the inlines might go missing? > > > > I have a model 'song' and a model 'recording'. I've created a > > recordingInline class, and in the modelAdmin I set: > > inlines = [recordingInline] > > > > this all works fine on my Ubuntu installation running python 2.5.2 and > > django 1.0.2, but on another installation on freebsd, using python 2.5.4 > > and django 1.0.2 and the same source, the inlines simply don't appear in > > the form (ie. only the form for the song model appears) but if I try to > > submit this I get an error 'ManagementForm data is missing or has been > > tampered with', presumably because the admin app knows that it is > > expecting the form data for the recording model too, so it knows about > > the inlines. > > > > What would stop the inlines appearing in one context when they work fine > > in the other? > > > > tia > > > > andy > > > > > > > > > > > > > > > --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Template filter with plural tag
I would to pluralize into a translation block [1] but I also want to apply the 'apnumber' template filter [2] --- {% load humanize %} {% load i18n %} {% blocktrans count list|apnumber as number %} There is {{ number }} object. {% plural %} There are {{ number }} objects. {% endblocktrans %} --- The problem is that if the filter is used then the 'plural' tag doesn't works. Is there any way to solve it? [1] http://docs.djangoproject.com/en/dev/topics/i18n/#in-template-code [2] http://docs.djangoproject.com/en/dev/ref/contrib/humanize/#apnumber --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "python2.5 manage.py syncdb" ...No module named _sqlite3
There is an explanation below, having to do with management dependencies and dates the versions and packages became available. But for the record, the solution is to install the py-sqlite3 package in addition to py-djangoi (with sqlite enabled). --George On Sat 11 Apr 2009 at 08:25:04 PM +0200, Joerg Sonnenberger wrote: >On Sat, Apr 11, 2009 at 11:18:19AM -0700, George Georgalis wrote: >> it seems sqlite is an option in pkgsrc py25-django, and >> default upstream... I'm not suggesting it should be one way >> or another, but why does the pkgsrc version have different >> default options than the source? > >To have a sane dependency set. The errors for missing dependencies are >even more mysterious. You are most likely hitten by the ironic situation >of py-sqlite2 being newer than the py-sqlite3 (the builtin)... On Sat 11 Apr 2009 at 09:07:43 PM +0200, Joerg Sonnenberger wrote: >On Sat, Apr 11, 2009 at 11:55:24AM -0700, George Georgalis wrote: >> ( cd /usr/pkgsrc/www/py-django/ && bmake deinstall clean ) >> ( cd /usr/pkgsrc/databases/py-sqlite2 && bmake deinstall clean ) >> ( cd /usr/pkgsrc/databases/py-sqlite3 && bmake install ) >> ( cd /usr/pkgsrc/www/py-django/ && bmake install PKG_OPTIONS.django=sqlite ) >> >> but py-django still installs py-sqlite2: > >Yes, that is expected. The question is: does it work for you after you >installed py-sqlite3? --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generic relations swamp
I realise im kind of spamming here, but does nobody really has encountered similar problem? Alan. On Apr 11, 12:07 am, zayatzzwrote: > Ok, I did some search on web and i took closer look at the > errormessage. : > > Request information > GET > > No GET data > POST > Variable Value > poll-trans-content_type-object_id-0-keel > u'1' > poll-trans-content_type-object_id-0-id > u'' > poll-trans-content_type-object_id-1-keel > u'2' > poll-trans-content_type-object_id-TOTAL_FORMS > u'2' > _save > u'Save' > poll-trans-content_type-object_id-1-name > u'Pollname in russian' > pub_date_1 > u'23:45:15' > pub_date_0 > u'2009-04-10' > poll-trans-content_type-object_id-1-id > u'' > active > u'on' > poll-trans-content_type-object_id-0-name > u'Pollname in estonian' > poll-trans-content_type-object_id-INITIAL_FORMS > u'0' > > If i understand this correctly then the content object id is not > beeing saved - it does not save the id of the poll with the > translations. Is this correct? And how can i fix this? > > I found many threads about incomplete generic relations support in > admin - they were from '07 or so, so the things could be different. > And i found this :http://djangoplugables.com/projects/django-genericadmin/ > > Could this be of any use? > > Would anything else help? > > Thanks! > Alan --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple sites, single application in Django
Hello Russell, I can't say this is best practice but my approach to a similar goal has been to create projects for each website. These projects/websites are unrelated to each other as far as content goes but all install a common set of apps, some off the shelf, some custom. I have sites installed for each project but not all of my apps are fully site aware so I only use sites minimally at this time. On Apr 11, 8:23 am, Russell McConnachiewrote: > I still have not come up with a creative way to design a site > which hosts multiple sites - providing different html layouts, style sheets. > > I am looking for someone to kind of explain to me some best practices on > doing this Toodle-looo. creecode --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin Inlines astray
ps. I used the 'song' and 'recording' models as an example, in fact I have several apps that use inlines, and on the one installation they are missing in every case. No errors are thrown and I can see nothing relevant in the logs. On Sat, 2009-04-11 at 19:50 +0100, Andy Wilson wrote: > has anyone any idea why the inlines might go missing? > > I have a model 'song' and a model 'recording'. I've created a > recordingInline class, and in the modelAdmin I set: > inlines = [recordingInline] > > this all works fine on my Ubuntu installation running python 2.5.2 and > django 1.0.2, but on another installation on freebsd, using python 2.5.4 > and django 1.0.2 and the same source, the inlines simply don't appear in > the form (ie. only the form for the song model appears) but if I try to > submit this I get an error 'ManagementForm data is missing or has been > tampered with', presumably because the admin app knows that it is > expecting the form data for the recording model too, so it knows about > the inlines. > > What would stop the inlines appearing in one context when they work fine > in the other? > > tia > > andy > > > > > > --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
every time that I load a form page, i have to reload the page to make errors go away
Every time that a load a form on my site, I see the following errors. If I reload the page, they go away and everything works just fine. Does anyone know why? Thank you in advance. TemplateSyntaxError at /eaccounts/register/ Caught an exception while rendering: Tried edit in module conferences.views. Error was: 'module' object has no attribute 'edit' Original Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/python2.5/site-packages/django/template/ defaulttags.py", line 373, in render url = reverse(self.view_name, args=args, kwargs=kwargs) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 254, in reverse *args, **kwargs))) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 227, in reverse possibilities = self.reverse_dict.getlist(lookup_view) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 169, in _get_reverse_dict self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern)) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 136, in _get_callback raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)) ViewDoesNotExist: Tried edit in module conferences.views. Error was: 'module' object has no attribute 'edit' Request Method: GET Request URL:http://127.0.0.1:8000/eaccounts/register/ Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: Tried edit in module conferences.views. Error was: 'module' object has no attribute 'edit' Original Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/python2.5/site-packages/django/template/ defaulttags.py", line 373, in render url = reverse(self.view_name, args=args, kwargs=kwargs) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 254, in reverse *args, **kwargs))) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 227, in reverse possibilities = self.reverse_dict.getlist(lookup_view) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 169, in _get_reverse_dict self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern)) File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py", line 136, in _get_callback raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)) ViewDoesNotExist: Tried edit in module conferences.views. Error was: 'module' object has no attribute 'edit' Exception Location: /usr/lib/python2.5/site-packages/django/template/ debug.py in render_node, line 81 Python Executable: /usr/bin/python Python Version: 2.5.2 Python Path:['/home/guy/DjangoApps/scinet', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/ python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/ python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/ lib/python2.5/site-packages/Numeric', '/usr/lib/python2.5/site- packages/PIL', '/usr/lib/python2.5/site-packages/gst-0.10', '/var/lib/ python-support/python2.5', '/usr/lib/python2.5/site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0'] Server time:Sat, 11 Apr 2009 13:54:58 -0500 --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin Inlines astray
has anyone any idea why the inlines might go missing? I have a model 'song' and a model 'recording'. I've created a recordingInline class, and in the modelAdmin I set: inlines = [recordingInline] this all works fine on my Ubuntu installation running python 2.5.2 and django 1.0.2, but on another installation on freebsd, using python 2.5.4 and django 1.0.2 and the same source, the inlines simply don't appear in the form (ie. only the form for the song model appears) but if I try to submit this I get an error 'ManagementForm data is missing or has been tampered with', presumably because the admin app knows that it is expecting the form data for the recording model too, so it knows about the inlines. What would stop the inlines appearing in one context when they work fine in the other? tia andy --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "python2.5 manage.py syncdb" ...No module named _sqlite3
Hi Karen, On Apr 8, 2:33 am, Karen Traceywrote: > On Tue, Apr 7, 2009 at 8:39 PM, George wrote: > > > I'm pretty sure this shouldn't happen; but the error is no doubt my > > fault. Maybe something about the doc doesn't apply to my system? I > > have pkgsrc python2.5 and Django 1.0.2 > > What sort of a system is this? I'm not familiar with pkgsrc but it seems to > have provided you with an incomplete Python package, or your source build > produced an incomplete result. Thanks for the confirmation, http://pkgsrc.org is a package manager framework. It is native to NetBSD and designed for easy maintenance and portability across all/most unix like environments. It looks like sqlite is not enabled by default in pkgsrc python 2.5; I'm looking into getting that option worked out. I'm sure to have more questions after that :) --George --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Fewer columns in admin popups
Hello, In the Django admin site, I find myself going back and forth between adding more columns to list_display to enhance the list view and then removing them when I realize that they make the list view too big for the popup version displayed when clicking on the add button or the raw_id_fields magnifying glass. I've contemplated making the popup window a little bigger, but I think it would be better if I could just hide certain columns for the popup. That way I could optimize the main list view for a minimum of 1024x768 resolution (and most of my users have wide screens now) but keep the popups smaller than that. Is it possible to exclude columns from the popup list view? Thanks, Dave --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generic relations and unit tests.
I agree with you on this, but it is often impractical due to the volume of the data required. I have this data already in my database, I shouldn't have to spend a few days moving it to the tests file... Fixtures are a quick way to import your data to the test DB without having to recreate everything... I'd really like a better solution to this, as I can use either tests or contenttype at the moment and I'd like to use both... Thanks, Stavros On Apr 11, 3:54 am, Malcolm Tredinnickwrote: > On Sat, 2009-04-11 at 08:47 +0800, Russell Keith-Magee wrote: > > On Sat, Apr 11, 2009 at 5:53 AM, Poromenos wrote: > > > > Hello, > > > I created a model that has a ForeignKey to ContentType, but now I > > > can't use my test fixtures, since the IDs they point to are random > > > every time the test database is created. I can't dump the contenttypes > > > data because then I get many duplicate inserts, since Django rebuilds > > > them every time it sets up the test DB. Is there any way for me to use > > > both ContentType and unit tests? > > > The IDs won't be completely random, but they certainly will be fragile > > and subject to change. > > > You have discovered ticket #7052; unfortunately, there isn't any easy > > fix at the moment. > > > 1) Don't use fixtures - create your test objects in the setUp() method > > of your test using normal Python code. > > > 2) Use the fixture to define the basic data in your objects, and then > > use the setUp() method to modify the contenttypes at runtime, based on > > the current values in the database. This means you don't serialize the > > contenttype objects themselves in your fixture, and you use and > > foreignkey reference to a contenttype as a temporary placeholder for > > the real value that will be inserted at runtime. > > > Obviously, neither of these are ideal solutions. This bug is something > > I want to look at for Django v1.2. > > Well, I'd argue (1) is the ideal solution. Creating objects > programmatically is robust, self-documenting and encourages testers to > think about the minimum requirements needed for a self-contained > unittest. It's also fairly easy. Tends to be my normal practice. > > So opinions clearly differ there. Which doesn't invalidate Russell's > opinion, but I wouldn't want people to think it's all horrible when > there's already a perfectly standard and supported way of doing this > (the setUp() method exists to set things up for unittests). > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Registration form and Profile form is not saving
On Apr 11, 3:55 pm, Praveenwrote: > Hi all, i am really fed up and have tried number of way. Please read > my last line which really describe where i am facing problem. > First Attempt. > Problem:Data is saving for register and contact but for profile i get > error > ValueError > Exception Value: > > Cannot assign " 0x916b0cc>": "UserProfile.user" must be a "User" instance. > > Please look in to regview.py this line > I am trying to get the user = form.data['title'] which is currently > created and with that user the profile would saved. > I will be very thankful for your suggestion Well, it looks like request.user is an instance of AnonymousUser - ie the current user is not logged in. So try logging in first. -- 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-users@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 -~--~~~~--~~--~--~---
Multiple sites, single application in Django
Hello, I am new to Django, I've been reading over the Django "Sites" Model framework but I still have not come up with a creative way to design a site which hosts multiple sites - providing different html layouts, style sheets. I am looking for someone to kind of explain to me some best practices on doing this, I have read the Django tutorial parts #1 through #4 and feel quite comforable with what I have seen in the framework so far. I basically need to look at the request.get_host() website and display content on behalf of it. I'm not exactly sure if this is what the sites framework is for. Thanks for the help. --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Registration form and Profile form is not saving
Hi all, i am really fed up and have tried number of way. Please read my last line which really describe where i am facing problem. First Attempt. models.py - class UserProfile(models.Model): user = models.ForeignKey(User, unique=True, verbose_name=_ ('user')) gender = models.CharField(_('gender'), max_length=1, choices=GENDER_CHOICES, blank=True) dob = models.DateField(_('dob'), max_length=10, help_text=_ ("Should be in date format"), null=True, blank=True) city = models.CharField(_('res_city'), max_length=30, choices=CITY_CHOICES, blank=True) class RegistrationForm(forms.Form): """The basic account registration form.""" title = forms.CharField(max_length=30, label=_('Title'), required=False) email = forms.EmailField(label=_('Email address'), max_length=75, required=True) password2 = forms.CharField(label=_('Password (again)'), max_length=30, widget=forms.PasswordInput(), required=True) password1 = forms.CharField(label=_('Password'), max_length=30, widget=forms.PasswordInput(), required=True) first_name = forms.CharField(label=_('First name'), max_length=30, required=True) last_name = forms.CharField(label=_('Last name'), max_length=30, required=True) #gender = forms.CharField(label = _('Gender'), widget = forms.Select(choices=GENDER_CHOICES,attrs=attrs_dict)) #dob = forms.DateTimeField(widget=forms.DateTimeInput(attrs=dict (attrs_dict, max_length=75)), label=_(u'date of birth')) #city = forms.CharField(label = _('res_city'), widget = forms.Select(choices=CITY_CHOICES,attrs=attrs_dict)) def __init__(self, *args, **kwargs): self.contact = None super(RegistrationForm, self).__init__(*args, **kwargs) newsletter = forms.BooleanField(label=_('Newsletter'), widget=forms.CheckboxInput(), required=False) def clean_password1(self): """Enforce that password and password2 are the same.""" p1 = self.cleaned_data.get('password1') p2 = self.cleaned_data.get('password2') if not (p1 and p2 and p1 == p2): raise forms.ValidationError( ugettext("The two passwords do not match.")) # note, here is where we'd put some kind of custom # validator to enforce "hard" passwords. return p1 def clean_email(self): """Prevent account hijacking by disallowing duplicate emails.""" email = self.cleaned_data.get('email', None) if email and User.objects.filter(email=email).count() > 0: raise forms.ValidationError( ugettext("That email address is already in use.")) return email def save(self, request=None, **kwargs): """Create the contact and user described on the form. Returns the `contact`. """ if self.contact: log.debug('skipping save, already done') else: self.save_contact(request) return self.contact def save_contact(self, request): print " i am in save_contact " log.debug("Saving contact") data = self.cleaned_data password = data['password1'] email = data['email'] first_name = data['first_name'] last_name = data['last_name'] username = data['title'] #dob = data['dob'] #gender = data['gender'] #city = data['city'] verify = (config_value('SHOP', 'ACCOUNT_VERIFICATION') == 'EMAIL') if verify: from registration.models import RegistrationProfile user = RegistrationProfile.objects.create_inactive_user( username, password, email, send_email=True) else: user = User.objects.create_user(username, email, password) user.first_name = first_name user.last_name = last_name user.save() # If the user already has a contact, retrieve it. # Otherwise, create a new one. try: contact = Contact.objects.from_request(request, create=False) #profile = UserProfile.objects.form_request(request, create=False) except Contact.DoesNotExist: contact = Contact() contact.user = user contact.first_name = first_name contact.last_name = last_name contact.email = email contact.role = 'Customer' contact.title = data.get('title', '') contact.save() if 'newsletter' not in data: subscribed = False else: subscribed = data['newsletter'] signals.satchmo_registration.send(self, contact=contact, subscribed=subscribed, data=data) def save_profile(self, request): user_obj = User.objects.get(pk=request.user.id) #user_obj.first_name = self.cleaned_data['first_name'] #user_obj.last_name = self.cleaned_data['last_name'] try: profile_obj = request.user.get_profile()
Re: how to use email instead of username for user authentication?
Malcom, Google, FaceBook, and LinkedIn have been using email authentication for how long now? With the default constraints you've put on Django a developer would have to "work around" the out of the box code to make the project behave like the big 3 names on the web. In this light it sounds like the constraint is too tight and needs to be moved into an optional module not a default one. Again these sound like project specific requirements not general framework properties. As far as your reasons go, I'm fairly sure its just as easy to change the email as it is the username, I would even argue that my username (display name) could change but my login credentials should stay the same. I currently use the same email address for multiple accounts on many Django projects using the code I pasted above, I simply use what almost every email engine today supports email[+-._] vari...@domain.com. Looking at this objectively, I would argue the case for email authentication is strongest. I think changing the default auth module to allow both and making the current one optional would leave in place the flexibility of DJango out of the box and allow developers to constrain it on their own. Email authentication is catching on, Django should not fight the tide. You are correct, username authentication has always been around. However, the explicit banning and obfuscating of email authentication in the default module has not. That is the part that worries me, that is where things are going wrong. We're all professionals here, we all take the time to leave feedback in the hopes of improving Django. I have a sneaking suspicion that project specific requirements crept into the trunk because it was easier than patching every time. Now there is a hesitation to modify because it would affect the original project. That's not a good reason to start justifying weak requirements to the community. I would recommend re-opening the ticket and getting feedback on it from the community. -Paul On Apr 7, 5:10 pm, Malcolm Tredinnickwrote: > On Tue, 2009-04-07 at 10:16 -0700, pkenjora wrote: > > Hi, > > > Why not remove the '@' filter and allow the specific project > > developer the freedom to use email as username? What was the > > reasoning behind this? > > One reason is that usernames can be made to be unique, since you're > selecting a new username and if the one you choose is already taken, you > can choose another one. You cannot, however, easily change your email > address and there are cases of different people sharing a single email > address or the same person needing/wanting to create multiple accounts. > > Another reason is likely simply historical; usernames that *aren't* > email addresses are much more readable and traditional in social-based > sites and that was what was used in the initial implementation. The > uniqueness problem mentioned above is very real, however, so Django is > protecting people from doing dumb things here. If you want to work > around that, it's possible and fairly easy, but not heavily advisable. > > > I always like Django because it didn't try to force development down > > a specific path. All developers have their own way and every project > > is unique, for a long time Django accommodated that. I'm a bit > > worried about where this is going... > > It's not "going" anywhere. The username requirements have been the same > since the very first day you used Django. Don't frame this as something > slipping out of control, please. > > > > > I'm worried that the workarounds just introduce unnecessary > > complexity. > > Almost as if you shouldn't workaround a valid constraint, isn't it? :-) > > Regards, > Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin in frontend
Hello, I'm planning a site with django. It need to have some functionalities that are very similar to Django's admin (like CRUD in some tables, with validations, etc...). But I would not like to have two sections (frontend and admin) in it So, my question is: is there a way to use already made admin's funcionalities in my frontend without having to rewrite them ?? Thanks for any help... Marcello --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
[ANN] Falcon - powering innovation
If anybody is interesed in new technologies, you'll love this new language called Falcon [1], which has been open sourced ago little time. Falcon is a scripting engine ready to empower mission-critical multithreaded applications. It provides six integrated programming paradigms: procedural, object oriented, prototype oriented, functional, tabular and message oriented. You use what you prefer. To know more about its design, read the interview to the Falcon author that has published ComputerWorld Australia [2]. [1] http://www.falconpl.org/ [2] http://www.computerworld.com.au/article/298655/-z_programming_languages_falcon?fp=2= --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Schema-less models
In the project I'm working on it makes a lot of sense to store pretty much everything in 1-2 models, as there are a lot of common operations being done on any object or property - moderation, versioning, etc. I wanted to have something similar to this approach: http://bret.appspot.com/entry/how-friendfeed-uses-mysql in Django. Original models don't fit there, so I started to write "meta" models, first stage is done and I'll be glad to read some critics - or maybe there's already a solution that I've missed? http://dpaste.com/hold/31803/ --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Default mimetype
On Fri, 2009-04-10 at 23:40 -0700, Roman Timushev wrote: > Hello, > > My application serves content with different mimetypes: 'application/ > xhtml+xml', 'application/xml', 'application/json'. Specifying mimetype > for every view is not DRY. Is it possible to define default mimetype > for url groups? It should be easy to write a decorator for the appropriate view functions. Each function returns an HttpResponse object, so call the view then modify the mimetype on the returned object. Mimetypes on URL groups isn't possible. It's also not really the right level, since the URL doesn't really determine the mimetype, in general, so it's not something that would be particularly common to use. It requires more knowledge about the request to determine the MIME type (e.g. the "accept" headers). Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Easy way to create pretty pages with nav?
Hi I think a 'problem' of Django is that it is produced by programmers and doesn`t mention that programming is the minor important part of a successfull site. Far more important is content and the visual way content is presented in a brain catching way to the customer. Both isn`t comprised in Django. So looking from outward Django's main task may by to get rid of nasty programming details that a layouter can concentrate more on important tasks - in Django speak 'templates' the production of not beeing part of Django. The same with the app engine patch project (AEP) dedicated to run native Django on Google appEngine (GAE) http://code.google.com/p/app-engine-patch/wiki/Documentation http://groups.google.com/group/app-engine-patch In my view both Django and appEnginePatch exist to make life easier for layouters and journalists. Konrad --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Foreign Key query question
On Apr 11, 12:32 pm, Malcolm Tredinnickwrote: > That's definitely a small bug, then. I've opened ticket #10790 so that > it gets fixed eventually. Since it's not a functionality bug (the answer > is still correct), it will be fixed after 1.1 now, but we will fix it. I > understand why it's occurring (the comparison to NULL is a very special > case in this situation). Thanks Malcolm! --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Default mimetype
There is no such capabilities. Write your own set of decorators that will be path response object with needed mimetype - almost DRY solution. On Sat, Apr 11, 2009 at 10:40 AM, Roman Timushevwrote: > > Hello, > > My application serves content with different mimetypes: 'application/ > xhtml+xml', 'application/xml', 'application/json'. Specifying mimetype > for every view is not DRY. Is it possible to define default mimetype > for url groups? > > Roman > > > > --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Modifying the User model
That's the workaround we were about to implement. But what I was searching for, was a more consistent way to modify the **model** itself (which will be reflected into the database structure and consequently in the forms), not the way Django handles the forms. I think Django choice isn't so silly, as we have to remember it is a general purpose user class (in some applications you won't even need email adress). Thanks anyway for your help ;) Davide On Apr 10, 8:12 pm, soniiicwrote: > The way I achieved this was to make my own registration form and use > this: > > email = forms.EmailField(widget=forms.TextInput(attrs=dict > (attrs_dict,maxlength=75)),label=_(u'Email address')) > > where attrs_dict was earlier defined as: > attrs_dict = { 'class': 'required' } > > also, the email address isn't checked for uniqueness (which i think is > silly) so I added this: > > def clean_email(self): > """ > Validate that the email is not already in use. > > """ > try: > user = > User.objects.get(email__iexact=self.cleaned_data['email']) > except User.DoesNotExist: > return self.cleaned_data['email'] > raise forms.ValidationError(_(u'This email is already taken. > Please > choose another.')) > > On Apr 10, 6:51 pm, Davide wrote: > > > > > Hi all, > > we've been using the django User model from contrib.auth.models > > As we want to re-use as much code as possible, is there a way to edit > > the class properties, making the "email" field required? As a default > > this is not a required field. Gooogled for some answers but didn't > > find one, but if I missed something please let me know. > > Thanks in advance, > > Davide --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Default mimetype
Hello, My application serves content with different mimetypes: 'application/ xhtml+xml', 'application/xml', 'application/json'. Specifying mimetype for every view is not DRY. Is it possible to define default mimetype for url groups? Roman --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Foreign Key query question
On Sat, 2009-04-11 at 01:02 -0700, nikita kozlovsky wrote: > On Apr 11, 3:11 am, Malcolm Tredinnick> wrote: > > > > Django's SQL is going exactly what you suspect and not using any outer > > join here. Using a simplified version of the original two models: > > > > class Student(models.Model): > >... > > > > class Message(models.Model): > >title = models.CharField(max_length=50) > >student = models.ForeignKey(Student) > > > > ... the SQL that is generated for Message.objects.filter(student=None) > > is: > > > > SELECT `outer_message`.`id`, `outer_message`.`title`, > > `outer_message`.`student_id` FROM `outer_message` WHERE > > `outer_message`.`student_id` IS NULL > > Yes, this correctly if student = models.ForeignKey(Student). > I use this simplified models with student = models.ForeignKey > (Student, null=True), sql that is generated for Message.objects.filter > (student=None) is: > > SELECT "messages_message"."id", "messages_message"."title", > "messages_message"."student_id" FROM "messages_message" LEFT OUTER > JOIN "messages_student" ON ("messages_message"."student_id" = > "messages_student"."id") WHERE "messages_student"."id" IS NULL That's definitely a small bug, then. I've opened ticket #10790 so that it gets fixed eventually. Since it's not a functionality bug (the answer is still correct), it will be fixed after 1.1 now, but we will fix it. I understand why it's occurring (the comparison to NULL is a very special case in this situation). Regards, Malcolm --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to keep the translations for the templates from different applications separately?
for those who is interested, the issue is solved: http://groups.google.com/group/pinax-users/browse_thread/thread/58d45dab96840ee5/0f62760ab5223b2e regards valery On Apr 7, 8:27 pm, Valerywrote: > Hi > > no answers... does it mean that it is impossible in Django to separate > the template translations from different applications?.. > > regards,Valery > > On Apr 4, 7:07 pm,Valery wrote: > > > Hi > > > How could one keep the translations for the templates from different > > apps separately? According to Django docs (http://www.djangobook.com/ > > en/2.0/chapter19/) one could put the application's translations in a > > correspondent application folder, but it has a few to do with > > templates whereas the very templates carry the larger part of texts to > > be translated. I am puzzled. > > > there are two ways that look for me somewhat feasible: > > > 1. keep all applications outside of project tree and try to attach > > them in some "pluggable" way, e.g. like middleware (sounds odd to me) > > > 2. use LOCALE_PATHS to point to myproject/templates/application-N/ > > locale/ where the translations are stored (this didn't work for me) > > > P.S. In fact I have cross-posted this question from pinax-user group > > > regardsValery --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Foreign Key query question
On Apr 11, 3:11 am, Malcolm Tredinnickwrote: > Django's SQL is going exactly what you suspect and not using any outer > join here. Using a simplified version of the original two models: > > class Student(models.Model): > ... > > class Message(models.Model): > title = models.CharField(max_length=50) > student = models.ForeignKey(Student) > > ... the SQL that is generated for Message.objects.filter(student=None) > is: > > SELECT `outer_message`.`id`, `outer_message`.`title`, > `outer_message`.`student_id` FROM `outer_message` WHERE > `outer_message`.`student_id` IS NULL Yes, this correctly if student = models.ForeignKey(Student). I use this simplified models with student = models.ForeignKey (Student, null=True), sql that is generated for Message.objects.filter (student=None) is: SELECT "messages_message"."id", "messages_message"."title", "messages_message"."student_id" FROM "messages_message" LEFT OUTER JOIN "messages_student" ON ("messages_message"."student_id" = "messages_student"."id") WHERE "messages_student"."id" IS NULL i use django svn-10510 --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: SQL Between query in sqlite3
On Sat, Apr 11, 2009 at 2:44 AM, Kenneth Gonsalveswrote: > > On Saturday 11 April 2009 11:16:52 Nalini wrote: > > select * from Table where dates BETWEEN '2009-01-01' AND '2009-01-31' > > Can any one help me? > > Model.objects.filter(mydate__gte='2009-01-01' > ).filter(mydate__lte='2009-01-31') > -- > regards > kg > http://lawgon.livejournal.com > > > > You can also do mydate__range=(datetime_obj1, datetime_obj2). Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: SQL Between query in sqlite3
On Saturday 11 April 2009 11:16:52 Nalini wrote: > select * from Table where dates BETWEEN '2009-01-01' AND '2009-01-31' > Can any one help me? Model.objects.filter(mydate__gte='2009-01-01' ).filter(mydate__lte='2009-01-31') -- regards kg http://lawgon.livejournal.com --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
SQL Between query in sqlite3
Hi, I am using django, python and sqlite3 for my web page. I want the datas from the database between two dates. how do i handle it in django. i want the query for this select * from Table where dates BETWEEN '2009-01-01' AND '2009-01-31' Can any one help me? --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dereferencing One-to-Many Relationships in Templates
Ahh...never mind! I tried doing a {% for S.M %} that didn't work, but {% for S.M.all %} did thanks for being my sounding board... On Apr 10, 10:38 pm, Anthonywrote: > Hello, > > I'm passing queryset 'S' to a template. S has several attributes, M, > N and O. > > M has a one-to-many relationship with T. I need to display: > > N, O, T^1, T^2 through T^n, etc. (the T list would be a filtered > subset) > > Can this be done via template tags? (Will I have to make custom > ones?) At the moment, I'm considering breaking out the T^x values in > the view, then building a dictionary of tuples to pass them into the > template. However, it would seem more natural to me to be able to de- > reference the T values directly from the template. > > Thanks, > Anthony --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---