Directory indexes are not allowed here. for Grappilli
Did you try changing your settings.py file from DEBUG=True to DEBUG=False? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/_xGLm2OIgFIJ. 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.
initializing virtualenvwrapper on Mac (10.6.8) for Django
This guide worked perfectly for me when setting up my dev environment on Mountain Lion. (Virtualenv, Virtualwrapper, Homebrew, Xcode, Postgres, Python, Django, etc.) https://gist.github.com/1852087 -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/EgU7B_dAnDsJ. 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.
How to crop image ?
Have you looked at easy-thumbnails? It depends on PIL or Pillow and works great for cropping amount other image manipulations. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/-8PoiC9kdKYJ. 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.
Can't get /admin/ or any page to load
When I go to 127.0.0.1:8000/admin/ I receive this error: Caught ViewDoesNotExist while rendering: Tried base in module django.views.generic. Error was: 'django.views.generic.base' is not a callable. I followed the django tutorial here: https://docs.djangoproject.com/en/dev/intro/tutorial01/ and it worked fine, but I want to restructure my directories. I moved a bunch of files around, and I updated the new changes in settings.py and some other files. But it still won't work. I've spent several hours on this, so it would be very appreciated if someone could tell me where to look to fix this. Thanks in advance. -- 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.
Extending User model with Inheritance - Attribute Error
Hi all, I am attempting to follow this tutorial: http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/ But I am receiving this error: AttributeError at /login/ 'NoneType' object has no attribute 'DoesNotExist' Here is my stack trace: http://dpaste.com/565795/ I tried changing the CUSTOM_USER_MODEL field to every permutation of paths that could possibly lead to my CustomUser class, but they all gave the same error. Thanks in advance. -- 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: Extending User model with Inheritance - Attribute Error
Thanks for the responses. How do I use a foreign key, though? In other words, how do I tell my code to look at UserProfile rather than just user? On Jul 10, 5:08 am, Jonas Geiregat wrote: > Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven: > > > > > This is not good design. If you want to store some extra fields for a User > > - i would define just another model called ProfileDetails, FK it to User > > and use it as such. > > That's also how I would do it, some example code to make it even more clear: > > from django.db import models > from django.contrib.auth.models import User > > class UserProfile(models.Model): > user = models.ForeignKey(User, unique=True) > url = models.URLField("Website", blank=True) > company = models.CharField(max_length=50, blank=True) -- 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: Extending User model with Inheritance - Attribute Error
I am having trouble with this line of the tutorial: "You need to register a handler for the signal django.db.models.signals.post_save on the User model, and, in the handler, if created=True, create the associated user profile." It seems I need to edit the User model. I am confused, though, because I am using the User model included in django.contrib, and I am very hesitant to edit files that are not in my project directory. Is this bad design to be using a mix of things I've written on my own, and things that were already included in Django? (i.e. should I write everything from scratch?) Thanks. On Jul 11, 9:54 am, Michał Sawicz wrote: > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze: > > > How do I use a foreign key, though? In other words, how do I tell my > > code to look at UserProfile rather than just user? > > https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional... > > -- > Michał (Saviq) Sawicz > > signature.asc > < 1KViewDownload -- 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: Extending User model with Inheritance - Attribute Error
Okay, thanks. This is really helpful. I am having trouble calling get_profile() from within my profile.html template, though. Here is my stack trace: http://dpaste.com/566583/ I tried calling get_profile without the (), which got rid of the error, but no data showed up. On Jul 11, 10:15 am, Andre Terra wrote: > All you have to do is add the following code to your models.py (or any other > module that gets loaded by django, for that matter): > > # models.py > from django.db.models import signals > > def create_user_profile(sender, instance, created, **kwargs): > if created: > UserProfile.objects.create(user=instance) > > signals.post_save.connect(create_user_profile, sender=User) > > (assuming your profile model is called UserProfile, of course). > > When django loads models.py, it will call that connect() method which in > turn makes create_user_profile get called every time the sender model (User) > is saved (hence the 'post_save'). > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/ > > Cheers, > André Terra > > > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent wrote: > > I am having trouble with this line of the tutorial: "You need to > > register a handler for the signal django.db.models.signals.post_save > > on the User model, and, in the handler, if created=True, create the > > associated user profile." > > > It seems I need to edit the User model. I am confused, though, because > > I am using the User model included in django.contrib, and I am very > > hesitant to edit files that are not in my project directory. > > > Is this bad design to be using a mix of things I've written on my own, > > and things that were already included in Django? (i.e. should I write > > everything from scratch?) > > > Thanks. > > > On Jul 11, 9:54 am, Michał Sawicz wrote: > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze: > > > > > How do I use a foreign key, though? In other words, how do I tell my > > > > code to look at UserProfile rather than just user? > > > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional... > > > > -- > > > Michał (Saviq) Sawicz > > > > signature.asc > > > < 1KViewDownload > > > -- > > 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. -- 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: Extending User model with Inheritance - Attribute Error
Is this done in urls.py? On Jul 11, 10:55 am, Andre Terra wrote: > Pass user.get_profile() as a template variable instead by adding it to the > template context. > > Cheers, > André > > > > > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent wrote: > > Okay, thanks. This is really helpful. > > > I am having trouble calling get_profile() from within my profile.html > > template, though. Here is my stack trace: > > >http://dpaste.com/566583/ > > > I tried calling get_profile without the (), which got rid of the > > error, but no data showed up. > > > On Jul 11, 10:15 am, Andre Terra wrote: > > > All you have to do is add the following code to your models.py (or any > > other > > > module that gets loaded by django, for that matter): > > > > # models.py > > > from django.db.models import signals > > > > def create_user_profile(sender, instance, created, **kwargs): > > > if created: > > > UserProfile.objects.create(user=instance) > > > > signals.post_save.connect(create_user_profile, sender=User) > > > > (assuming your profile model is called UserProfile, of course). > > > > When django loads models.py, it will call that connect() method which in > > > turn makes create_user_profile get called every time the sender model > > (User) > > > is saved (hence the 'post_save'). > > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/ > > > > Cheers, > > > André Terra > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent wrote: > > > > I am having trouble with this line of the tutorial: "You need to > > > > register a handler for the signal django.db.models.signals.post_save > > > > on the User model, and, in the handler, if created=True, create the > > > > associated user profile." > > > > > It seems I need to edit the User model. I am confused, though, because > > > > I am using the User model included in django.contrib, and I am very > > > > hesitant to edit files that are not in my project directory. > > > > > Is this bad design to be using a mix of things I've written on my own, > > > > and things that were already included in Django? (i.e. should I write > > > > everything from scratch?) > > > > > Thanks. > > > > > On Jul 11, 9:54 am, Michał Sawicz wrote: > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze: > > > > > > > How do I use a foreign key, though? In other words, how do I tell > > my > > > > > > code to look at UserProfile rather than just user? > > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional... > > > > > > -- > > > > > Michał (Saviq) Sawicz > > > > > > signature.asc > > > > > < 1KViewDownload > > > > > -- > > > > 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. > > > -- > > 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. -- 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: Extending User model with Inheritance - Attribute Error
So I need to create a custom view? (I can't use an existing view)? I was hoping to avoid diving into templates until later, after I've become a little more familiar with the python/html code. On Jul 11, 11:48 am, Andre Terra wrote: > This is done in your view: > > https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-... > > Cheers > > > > > > > > On Mon, Jul 11, 2011 at 3:12 PM, Brent wrote: > > Is this done in urls.py? > > > On Jul 11, 10:55 am, Andre Terra wrote: > > > Pass user.get_profile() as a template variable instead by adding it to > > the > > > template context. > > > > Cheers, > > > André > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent wrote: > > > > Okay, thanks. This is really helpful. > > > > > I am having trouble calling get_profile() from within my profile.html > > > > template, though. Here is my stack trace: > > > > >http://dpaste.com/566583/ > > > > > I tried calling get_profile without the (), which got rid of the > > > > error, but no data showed up. > > > > > On Jul 11, 10:15 am, Andre Terra wrote: > > > > > All you have to do is add the following code to your models.py (or > > any > > > > other > > > > > module that gets loaded by django, for that matter): > > > > > > # models.py > > > > > from django.db.models import signals > > > > > > def create_user_profile(sender, instance, created, **kwargs): > > > > > if created: > > > > > UserProfile.objects.create(user=instance) > > > > > > signals.post_save.connect(create_user_profile, sender=User) > > > > > > (assuming your profile model is called UserProfile, of course). > > > > > > When django loads models.py, it will call that connect() method which > > in > > > > > turn makes create_user_profile get called every time the sender model > > > > (User) > > > > > is saved (hence the 'post_save'). > > > > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/ > > > > > > Cheers, > > > > > André Terra > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent wrote: > > > > > > I am having trouble with this line of the tutorial: "You need to > > > > > > register a handler for the signal > > django.db.models.signals.post_save > > > > > > on the User model, and, in the handler, if created=True, create the > > > > > > associated user profile." > > > > > > > It seems I need to edit the User model. I am confused, though, > > because > > > > > > I am using the User model included in django.contrib, and I am very > > > > > > hesitant to edit files that are not in my project directory. > > > > > > > Is this bad design to be using a mix of things I've written on my > > own, > > > > > > and things that were already included in Django? (i.e. should I > > write > > > > > > everything from scratch?) > > > > > > > Thanks. > > > > > > > On Jul 11, 9:54 am, Michał Sawicz wrote: > > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze: > > > > > > > > > How do I use a foreign key, though? In other words, how do I > > tell > > > > my > > > > > > > > code to look at UserProfile rather than just user? > > > > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional. > > .. > > > > > > > > -- > > > > > > > Michał (Saviq) Sawicz > > > > > > > > signature.asc > > > > > > > < 1KViewDownload > > > > > > > -- > > > > > > 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. > > > > > -- > > > > 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. > > > -- > > 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. -- 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: Extending User model with Inheritance - Attribute Error
Sorry, I meant I was hoping to avoid diving into defining my own views until later. On Jul 11, 1:08 pm, Brent wrote: > So I need to create a custom view? (I can't use an existing view)? I > was hoping to avoid diving into templates until later, after I've > become a little more familiar with the python/html code. > > On Jul 11, 11:48 am, Andre Terra wrote: > > > > > > > > > This is done in your view: > > >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-... > > > Cheers > > > On Mon, Jul 11, 2011 at 3:12 PM, Brent wrote: > > > Is this done in urls.py? > > > > On Jul 11, 10:55 am, Andre Terra wrote: > > > > Pass user.get_profile() as a template variable instead by adding it to > > > the > > > > template context. > > > > > Cheers, > > > > André > > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent wrote: > > > > > Okay, thanks. This is really helpful. > > > > > > I am having trouble calling get_profile() from within my profile.html > > > > > template, though. Here is my stack trace: > > > > > >http://dpaste.com/566583/ > > > > > > I tried calling get_profile without the (), which got rid of the > > > > > error, but no data showed up. > > > > > > On Jul 11, 10:15 am, Andre Terra wrote: > > > > > > All you have to do is add the following code to your models.py (or > > > any > > > > > other > > > > > > module that gets loaded by django, for that matter): > > > > > > > # models.py > > > > > > from django.db.models import signals > > > > > > > def create_user_profile(sender, instance, created, **kwargs): > > > > > > if created: > > > > > > UserProfile.objects.create(user=instance) > > > > > > > signals.post_save.connect(create_user_profile, sender=User) > > > > > > > (assuming your profile model is called UserProfile, of course). > > > > > > > When django loads models.py, it will call that connect() method > > > > > > which > > > in > > > > > > turn makes create_user_profile get called every time the sender > > > > > > model > > > > > (User) > > > > > > is saved (hence the 'post_save'). > > > > > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/ > > > > > > > Cheers, > > > > > > André Terra > > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent wrote: > > > > > > > I am having trouble with this line of the tutorial: "You need to > > > > > > > register a handler for the signal > > > django.db.models.signals.post_save > > > > > > > on the User model, and, in the handler, if created=True, create > > > > > > > the > > > > > > > associated user profile." > > > > > > > > It seems I need to edit the User model. I am confused, though, > > > because > > > > > > > I am using the User model included in django.contrib, and I am > > > > > > > very > > > > > > > hesitant to edit files that are not in my project directory. > > > > > > > > Is this bad design to be using a mix of things I've written on my > > > own, > > > > > > > and things that were already included in Django? (i.e. should I > > > write > > > > > > > everything from scratch?) > > > > > > > > Thanks. > > > > > > > > On Jul 11, 9:54 am, Micha³ Sawicz wrote: > > > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze: > > > > > > > > > > How do I use a foreign key, though? In other words, how do I > > > tell > > > > > my > > > > > > > > > code to look at UserProfile rather than just user? > > > > > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional. > > > .. > > > > > > > > > -- > > > > > > > > Micha³ (Saviq) Sawicz > > > > > > > > > signature.asc > > > > > > > > < 1KViewDownload > > > > > > > > -- > > > > > > > You received this message because you are subscr
Re: Extending User model with Inheritance - Attribute Error
Hmm...I see. How do you choose what variables are available to which view? It seems like anything I put in context_processors is available anywhere, and I'm not sure I want that. I think I am getting closer, but I am now getting a SiteProfileNotAvailable error. Here is my stack trace: http://dpaste.com/566744/ Thanks for the help. On Jul 11, 2:01 pm, Andre Terra wrote: > You could use a context processor, which is basically a function that adds > variables to *every* template that gets called from a properly setup view. I > assume the view you are using does apply context processors, and defining > one is as easy as: > > http://stackoverflow.com/questions/3722174/django-template-inheritanc... > > You can try step #3 once you feel confident enough to write views (they are > very simple!) > > Cheers, > André Terra (airstrike) > > > > > > > > On Mon, Jul 11, 2011 at 5:12 PM, Brent wrote: > > Sorry, I meant I was hoping to avoid diving into defining my own views > > until later. > > > On Jul 11, 1:08 pm, Brent wrote: > > > So I need to create a custom view? (I can't use an existing view)? I > > > was hoping to avoid diving into templates until later, after I've > > > become a little more familiar with the python/html code. > > > > On Jul 11, 11:48 am, Andre Terra wrote: > > > > > This is done in your view: > > > > >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-. > > .. > > > > > Cheers > > > > > On Mon, Jul 11, 2011 at 3:12 PM, Brent wrote: > > > > > Is this done in urls.py? > > > > > > On Jul 11, 10:55 am, Andre Terra wrote: > > > > > > Pass user.get_profile() as a template variable instead by adding it > > to > > > > > the > > > > > > template context. > > > > > > > Cheers, > > > > > > André > > > > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent > > wrote: > > > > > > > Okay, thanks. This is really helpful. > > > > > > > > I am having trouble calling get_profile() from within my > > profile.html > > > > > > > template, though. Here is my stack trace: > > > > > > > >http://dpaste.com/566583/ > > > > > > > > I tried calling get_profile without the (), which got rid of the > > > > > > > error, but no data showed up. > > > > > > > > On Jul 11, 10:15 am, Andre Terra wrote: > > > > > > > > All you have to do is add the following code to your models.py > > (or > > > > > any > > > > > > > other > > > > > > > > module that gets loaded by django, for that matter): > > > > > > > > > # models.py > > > > > > > > from django.db.models import signals > > > > > > > > > def create_user_profile(sender, instance, created, **kwargs): > > > > > > > > if created: > > > > > > > > UserProfile.objects.create(user=instance) > > > > > > > > > signals.post_save.connect(create_user_profile, sender=User) > > > > > > > > > (assuming your profile model is called UserProfile, of course). > > > > > > > > > When django loads models.py, it will call that connect() method > > which > > > > > in > > > > > > > > turn makes create_user_profile get called every time the sender > > model > > > > > > > (User) > > > > > > > > is saved (hence the 'post_save'). > > > > > > > > > More on this athttps:// > > docs.djangoproject.com/en/dev/ref/signals/ > > > > > > > > > Cheers, > > > > > > > > André Terra > > > > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent > > wrote: > > > > > > > > > I am having trouble with this line of the tutorial: "You need > > to > > > > > > > > > register a handler for the signal > > > > > django.db.models.signals.post_save > > > > > > > > > on the User model, and, in the handler, if created=True, > > create the > > > > > > > > > associated user profile." > > > > > > > > > > It seems I need to edit the User model. I am confused, > > though, > > > > > because &g
Simple example of custom user profile fields?
Hi, Does anyone know of a simple, working example of custom user profile fields? I want to have a custom field, say, "favorite color," which is unique to each user. Then I want users to be able to login, and be taken to a page called "profile" that displays that custom field. So far, I have logging in working, and I can display built-in fields like username and email, but I am not able to get the custom fields working. Following tutorials have been informative, but after reading every tutorial I could get my hands on, I still receive errors like "no such table" or "SiteProfileNotAvailable" or just syntax errors. I've invested a significant amount of time into learning Django, but I am starting to consider switching to another product. Thanks in advance. -- 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: Simple example of custom user profile fields?
Thanks for the help guys. Micky, that tutorial looks very good. I think I almost have it working. Just one more error: http://dpaste.com/567361/ Andre, thanks for mentioning Pinax. I'll give it a shot if this doesn't work out. I have a year of python experience, but I haven't written anything web/database related. On Jul 12, 11:34 am, Micky Hulse wrote: > This tutorial helped me: > > http://www.turnkeylinux.org/blog/django-profile > > Note: The above tutorial uses an FK to User model... The Django docs > suggest a OneToOne field. > > Hope that helps. > > Micky -- 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: Simple example of custom user profile fields?
Running syncdb again didn't seem to fix it. I tried deleting the database entirely, and starting from a new database, but that also didn't work. On Jul 12, 2:28 pm, Shawn Milochik wrote: > On Tue, Jul 12, 2011 at 5:26 PM, Brent wrote: > > Thanks for the help guys. > > > Micky, that tutorial looks very good. I think I almost have it > > working. Just one more error: > > >http://dpaste.com/567361/ > > Looks like maybe you didn't run syncdb after adding something to > INSTALLED_APPS. -- 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: Simple example of custom user profile fields?
Good idea. Unfortunately, I tried that, but it results in a SiteProfileNotAvailable error: http://dpaste.com/567421/ On Jul 12, 3:15 pm, Andre Terra wrote: > Instead of using get or create, why not setting up a post_save signal > for the User model so that users always have a profile associated with > them? > > Cheers, > Andre > > On 7/12/11, Brent wrote: > > > > > > > > > > > Thanks for the help guys. > > > Micky, that tutorial looks very good. I think I almost have it > > working. Just one more error: > > >http://dpaste.com/567361/ > > > Andre, thanks for mentioning Pinax. I'll give it a shot if this > > doesn't work out. I have a year of python experience, but I haven't > > written anything web/database related. > > > On Jul 12, 11:34 am, Micky Hulse wrote: > >> This tutorial helped me: > > >>http://www.turnkeylinux.org/blog/django-profile > > >> Note: The above tutorial uses an FK to User model... The Django docs > >> suggest a OneToOne field. > > >> Hope that helps. > > >> Micky > > > -- > > 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. > > -- > Sent from my mobile device -- 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: Simple example of custom user profile fields?
Unfortunately, no matter what kind of path I put for AUTH_PROFILE_MODULE, the same error appears. On Jul 12, 5:51 pm, Andre Terra wrote: > As the traceback helpfully states, > > Exception Type: SiteProfileNotAvailable at /profile/Exception Value: > Unable to load the profile model, check AUTH_PROFILE_MODULE in your > project settings > > http://www.google.com/search?&q=django+Unable+to+load+the+profile+mod... > > check out the first result. > > Cheers, > André > > On Tue, Jul 12, 2011 at 8:09 PM, Brent wrote: > > Good idea. Unfortunately, I tried that, but it results in a > > SiteProfileNotAvailable error: > > >http://dpaste.com/567421/ > > > On Jul 12, 3:15 pm, Andre Terra wrote: > > > Instead of using get or create, why not setting up a post_save signal > > > for the User model so that users always have a profile associated with > > > them? > > > > Cheers, > > > Andre > > > > On 7/12/11, Brent wrote: > > > > > Thanks for the help guys. > > > > > Micky, that tutorial looks very good. I think I almost have it > > > > working. Just one more error: > > > > >http://dpaste.com/567361/ > > > > > Andre, thanks for mentioning Pinax. I'll give it a shot if this > > > > doesn't work out. I have a year of python experience, but I haven't > > > > written anything web/database related. > > > > > On Jul 12, 11:34 am, Micky Hulse wrote: > > > >> This tutorial helped me: > > > > >>http://www.turnkeylinux.org/blog/django-profile > > > > >> Note: The above tutorial uses an FK to User model... The Django docs > > > >> suggest a OneToOne field. > > > > >> Hope that helps. > > > > >> Micky > > > > > -- > > > > 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. > > > > -- > > > Sent from my mobile device > > > -- > > 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. -- 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: Simple example of custom user profile fields?
I'm using python manage.py runserver, and I have restarted it dozens of times. On Jul 12, 8:58 pm, Micky Hulse wrote: > On Tue, Jul 12, 2011 at 7:57 PM, Brent wrote: > > Unfortunately, no matter what kind of path I put for > > AUTH_PROFILE_MODULE, the same error appears. > > I don't know your setup, but have your tried restating Apache? That's > probably a stupid question/suggestion, but maybe worth a shot? -- 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 inline adding one too many extra rows to the form
I'm having the same issue. Will post if I discover the solution. On Dec 14 2010, 12:09 pm, Nick wrote: > I have three models. Two are inlines of another model in the Admin. I > have their extra parameters set to 0 so: > > class model1(admin.StackedInline): > model = Model1 > extra = 0 > > class model2(admin.StackedInline): > model = Model1 > extra = 0 > > class model3(admin.ModelAdmin): > inline = [ > model1, > model2, > ] > > everything renders properly except there is a blank model form below > each of the inlines in model 3's admin. How do i get rid of these > orphans? I can't teach them to pick pockets in 19th century London > (little Charles Dickens humor there). -- 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.
Pseudo OneToOneFields
Hi there. I'm not looking for a fully definite answer here necessarily, but I am searching for input on the best way to attack this problem. Here it is, somewhat abstracted so that you don't have to wrap your head around my problem domain: Let's say I've got two models - ModelOne(models.Model): some_field = models.CharField(max_length=10) ModelTwo(models.Model): f_key = models.ForeignKey(ModelOne) is_current = models.BooleanField(default=True) I didn't bother reproducing a custom manager I've written that ensures that only one ModelTwo has is_current = True for each set of ModelTwos that all refer to the same ModelOne. So, take it as a given that ModelTwo.objects.filter(f_key=some_int, is_current=True) will return no more than one ModelTwo every time. Now, what this means is that ModelOne has a *conceptual* one-to-one relationship with ModelTwo, because I almost never want ModelTwos that have is_current=False (I keep them around because I need the history at unpredictable times). I'd like to be able to express this in the code somehow, both for a cleaner, more intuitive interface, and because I'd like to access ModelTwos (with is_current=True) through ModelOnes without doing an extra query. I have a few ideas about how to go about this, but I'm relatively new at this level of Django customization, and I find myself running in circles. Here are my general ideas for implementing what I want (and no guarantees that these are even possible): 1. A PseudoOneToOneField. The call would look something like: modeltwo = PseudoOneToOneField("ModelTwo", conditions={'is_current': True}). I kind of like this one because it's very generic, and can be used in many situations (and I have more than one situation in my app). However, I know next to nothing about subclassing fields. 2. Subclass QuerySet. I don't know exactly how, but I feel as though it should be possible to make a QuerySet that will do this in one query. I think this might require a new QuerySet for each model I want to modify, though. 3. A custom Manager. I've made one custom manager, but I don't know the limits of their capabilities. Can they modify a query deeply enough for this? 4. Custom SQL. Not a real problem, but I just try to avoid this, if it's possible, and I've been successful so far. Plus, my dev and prod environments are on different backends (not my choice). Opinions and educational rants welcome. 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: Pseudo OneToOneFields
Happily, my copy of Pro Django by Marty Alchin came a few days ago, and the history app that Marty explains near the end of the book is perfect for what I need. A completely different approach to the problem, but I'm sure it's much better than anything I would have come up with. So, if you read this list, thanks Gul. On Dec 21, 11:30 pm, Brent Hagany wrote: > Hi there. I'm not looking for a fully definite answer here > necessarily, but I am searching for input on the best way to attack > this problem. Here it is, somewhat abstracted so that you don't have > to wrap your head around my problem domain: > > Let's say I've got two models - > > ModelOne(models.Model): > some_field = models.CharField(max_length=10) > > ModelTwo(models.Model): > f_key = models.ForeignKey(ModelOne) > is_current = models.BooleanField(default=True) > > I didn't bother reproducing a custom manager I've written that ensures > that only one ModelTwo has is_current = True for each set of ModelTwos > that all refer to the same ModelOne. So, take it as a given that > ModelTwo.objects.filter(f_key=some_int, is_current=True) will return > no more than one ModelTwo every time. > > Now, what this means is that ModelOne has a *conceptual* one-to-one > relationship with ModelTwo, because I almost never want ModelTwos that > have is_current=False (I keep them around because I need the history > at unpredictable times). I'd like to be able to express this in the > code somehow, both for a cleaner, more intuitive interface, and > because I'd like to access ModelTwos (with is_current=True) through > ModelOnes without doing an extra query. > > I have a few ideas about how to go about this, but I'm relatively new > at this level of Django customization, and I find myself running in > circles. Here are my general ideas for implementing what I want (and > no guarantees that these are even possible): > > 1. A PseudoOneToOneField. The call would look something like: > modeltwo = PseudoOneToOneField("ModelTwo", conditions={'is_current': > True}). I kind of like this one because it's very generic, and can be > used in many situations (and I have more than one situation in my > app). However, I know next to nothing about subclassing fields. > > 2. Subclass QuerySet. I don't know exactly how, but I feel as though > it should be possible to make a QuerySet that will do this in one > query. I think this might require a new QuerySet for each model I > want to modify, though. > > 3. A custom Manager. I've made one custom manager, but I don't know > the limits of their capabilities. Can they modify a query deeply > enough for this? > > 4. Custom SQL. Not a real problem, but I just try to avoid this, if > it's possible, and I've been successful so far. Plus, my dev and prod > environments are on different backends (not my choice). > > Opinions and educational rants welcome. 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 -~--~~~~--~~--~--~---
Organizing apps without using projects
My apologies if this has been brought up before on this group - my searching did not turn up anything, but my search skills are notoriously suspect. I have been reorganizing my code so that it does not depend on the project (mostly with success) after watching James Bennet's talk at Djangocon about reusable apps. I've chosen to follow the model James talks about with respect to Ellington - that is, I have a bunch of interdependent apps that are all under the umbrella of one python module. Right now, I actually have one umbrella "app", with a bunch of proper apps underneath it, so that I only have to put the umbrella module in INSTALLED_APPS, rather than each sub-app. I'm not quite sure if that's the best way to do this, but more on that in a bit. The only things I don't have working again are my unit tests, and I'd like to get some feedback on what would be the best way to get them to work with this sort of setup. The problem is that my tests and models are currently in umbrella.app.tests/models, but the test runner expects them to be in umbrella.tests/models. Here are a few ways to get this done, that I can see: 1. Move all my models and tests from umbrella.app to umbrella. This almost completely undoes the benefits of breaking the application into small apps. 2. Rather than just putting umbrella in INSTALLED_APPS, put every umbrella.app in. This just seems silly to me, since these apps are too interdependent to be very useful apart from each other. 3. Write a new test runner that looks in the correct places. This makes it harder than just "manage.py test" for other people to test the app themselves. If you've dealt with this kind of thing before, or have a good idea/ recommendation, please let me know. I doubt that there is a completely satisfactory solution (to me), but I'd like some opinions on what sucks less. Thanks, Brent --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Organizing apps without using projects
I'm not in front of my code at the moment, but I'm pretty sure there's no magic involved, and it works just fine. When I do a runserver from my (completely decoupled) project, the root urlconf sends everything to umbrella.urls, which then delegates once again to umbrella.app.urls, which knows where to find the views, and the views know where to find the models. Everything just looks for the parts they need, relative to umbrella. That's not magic, is it? Seems to me, it's pretty much just like it used to work before, just with one more layer of indirection in the url resolution. And it's still decoupled, because any user can just bypass the default urlconf that I provide, and go directly to umbrella.app.urls from their project urlconf, if they wish. In any case, I will try the umbrella.* thing. Will that try to put things like umbrella.urls and umbrella.templates into INSTALLED_APPS, too? On Oct 8, 7:38 am, Carl Meyer <[EMAIL PROTECTED]> wrote: > On Oct 7, 10:28 pm, Brent Hagany <[EMAIL PROTECTED]> wrote: > > > My apologies if this has been brought up before on this group - my > > searching did not turn up anything, but my search skills are > > notoriously suspect. > > > I have been reorganizing my code so that it does not depend on the > > project (mostly with success) after watching James Bennet's talk at > > Djangocon about reusable apps. I've chosen to follow the model James > > talks about with respect to Ellington - that is, I have a bunch of > > interdependent apps that are all under the umbrella of one python > > module. Right now, I actually have one umbrella "app", with a bunch > > of proper apps underneath it, so that I only have to put the umbrella > > module in INSTALLED_APPS, rather than each sub-app. I'm not quite > > sure if that's the best way to do this, but more on that in a bit. > > This can't be working as you describe it, unless you're doing some > other magic you aren't telling us about to get your models loaded. > The same problem you're having with tests you should be having with > models as well; Django will look for your models in umbrella.models, > not umbrella.app.models, because you just have "umbrella" in > INSTALLED_APPS. > > The solution to both problems is to include "umbrella.*" in > INSTALLED_APPS. This will include every app inside the umbrella > package, without you having to list them all separately. > > Carl --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Organizing apps without using projects
I haven't tried a syncdb (which, now that you mention it, probably does not work), but the admin does work. This is probably because I don't do an autodiscover - I register each app manually. As for coupling, the apps in question do depend on each other, but not at a very deep level. My reason for separating things like this is that I may want to take one app out and plug in another that exposes the same functionality to the other apps, but is different internally. Besides that, I just find it easier to have chunks of functionality separated in this way. Brent On Oct 8, 9:20 am, Carl Meyer <[EMAIL PROTECTED]> wrote: > On Oct 8, 9:51 am, Brent Hagany <[EMAIL PROTECTED]> wrote: > > > I'm not in front of my code at the moment, but I'm pretty sure there's > > no magic involved, and it works just fine. When I do a runserver from > > my (completely decoupled) project, the root urlconf sends everything > > to umbrella.urls, which then delegates once again to > > umbrella.app.urls, which knows where to find the views, and the views > > know where to find the models. Everything just looks for the parts > > they need, relative to umbrella. That's not magic, is it? > > No, but it's only half- working. Ever try a "syncdb" since you did > this rearrangement? It won't find your models. And if you try to use > the admin, it won't find them either. Bottom line is, it's not > correctly configured. A properly configured app needs to have a > models module, and needs to be in INSTALLED_APPS. "umbrella" is not > an app, and your other apps aren't actually installed because they > aren't in INSTALLED_APPS. > > > In any case, I will try the umbrella.* thing. Will that try to put > > things like umbrella.urls and umbrella.templates into INSTALLED_APPS, > > too? > > Assuming umbrella.urls is a urls.py file, not a urls/ package > directory, it won't try to load that (it only loads subdirectories). > I haven't tested, but it probably will try to load your templates > directory, and may fail somewhere down the line because it isn't a > Python module. If you use umbrella.*, it's really not advisable to > have anything but the apps themselves in the umbrella directory. > > Also, if the apps are really so tightly coupled that they could never > be used apart from each other, I'd question the value of having them > be separate apps at all. It sounds more like you have one app. If it > has too many e.g. models to want to put them all in one models.py, you > could look at splitting up your models.py into a models/ package. The > point of splitting out separate reusable apps is that they address a > single well-defined concern, and you can actually reuse them > independently of each other. > > Carl --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
F() expression order of operations
I'm having some trouble getting F() expressions to obey my parentheses when I don't want the default order of operations. For example, given the model: class MyModel(models.Model): wins = models.DecimalField(max_digits=1, decimal_places=0) losses = models.DecimalField(max_digits=1, decimal_places=0) win_percentage = models.DecimalField(max_digits=4, decimal_places=3, default=Decimal('0.000')) I get the following results when trying to calculate the win_percentage: In [1]: MyModel.objects.create(wins=2, losses=4) Out[1]: In [2]: MyModel.objects.all().update(win_percentage=F('wins') / (F ('wins') + F('losses'))) Out[2]: 1 # I expect this to return Decimal("0.333") In [3]: MyModel.objects.get(pk=1).win_percentage Out[3]: Decimal("5.000") It appears to be ignoring the parentheses around F('wins') + F ('losses'), and so instead of 2 / (2 + 4) = .333, I'm getting 2 / 2 + 4 = 5. Am I doing this wrong, or is this by design, or is it a bug? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
get_or_create() error on synchronous calls from multiple instances
The get_or_create() or convenience method is doing this behavior: 1) try: 2) return self.get(), False 3) except self.model.DoesNotExist: 4) . . . 5) obj = self.model(...) 6) obj.save() 7) return obj, True But what if (on a heavy system with many clients) the record that did not exist at line 2 does exist by line 6 (i.e., in between the execution of these statements, some other database user has caused that record to come into existence)? In that case there will now be either two records that contain the data (if there are not unique fields), or an exception will be thrown (if there are unique fields). To handle the case of unique fields, which will throw an exception, I think the code should be changed to something like this: 1) try: 2) return self.get(), False 3) except self.model.DoesNotExist: 4) . . . 5) obj = self.model(...) try: 6) obj.save() except: return self.get(...), False 7) return obj, True Does that seem like a correct solution? or am I misunderstanding this new-to-me world of django/sql/python? If this is a potential problem (although admittedly rare) should I be concerned that the django code as a whole typically is not written to handle these worst cases? -- Salad dressings on us all, Brent --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
OnlineBook - High Performance Django
Good day Guys I got this off news.python.sc, and thought I would share in case anyone misses it. https://lincolnloop.com/high-performance-django/index.html Definitely some tidbits of information, esp to areas of securing and performance improving. HTH Regards Brent -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/351773ca-3b6a-bc04-00e4-76092eb2e841%40gmail.com.
Cleaning up redis connection after client disconnects from streaming response
I've implemented a Server Sent Event<http://www.html5rocks.com/en/tutorials/eventsource/basics/> API in my Django app to stream realtime updates from my backend to the browser. The backend is a Redis pubsub. My Django view looks like this: def event_stream(request): """ Stream worker events out to browser. """ listener = events.Listener( settings.EVENTS_PUBSUB_URL, channels=[settings.EVENTS_PUBSUB_CHANNEL], buffer_key=settings.EVENTS_BUFFER_KEY, last_event_id=request.META.get('HTTP_LAST_EVENT_ID') ) return http.HttpResponse(listener, mimetype='text/event-stream') And the events.Listener class that I'm returning as an iterator looks like this: class Listener(object): def __init__(self, rcon_or_url, channels, buffer_key=None, last_event_id=None): if isinstance(rcon_or_url, redis.StrictRedis): self.rcon = rcon_or_url elif isinstance(rcon_or_url, basestring): self.rcon = redis.StrictRedis(**utils.parse_redis_url(rcon_or_url)) self.channels = channels self.buffer_key = buffer_key self.last_event_id = last_event_id self.pubsub = self.rcon.pubsub() self.pubsub.subscribe(channels) def __iter__(self): # If we've been initted with a buffer key, then get all the events off # that and spew them out before blocking on the pubsub. if self.buffer_key: buffered_events = self.rcon.lrange(self.buffer_key, 0, -1) for msg in reversed(list(buffered_events)): if (self.last_event_id and json.loads(msg)['id'] == self.last_event_id): break yield to_sse({'data': msg}) try: for msg in self.pubsub.listen(): if msg['type'] == 'message': yield to_sse(msg) finally: logging.info('Closing pubsub') self.pubsub.close() self.rcon.connection_pool.disconnect() I'm able to successfully stream events out to the browser with this setup. However, it seems that the disconnect calls in the listener's "finally" don't ever actually get called. I assume that they're still camped out waiting for messages to come from the pubsub. As clients disconnect and reconnect, I can see the number of connections to my Redis instance climbing and never going down. Once it gets to around 1000, Redis starts freaking out and consuming all the available CPU. I would like to be able to detect when the client is no longer listening and close the Redis connection(s) at that time. Things I've tried or thought about: 1. A connection pool. But as the redis-py<https://github.com/andymccurdy/redis-py> README states, "It is not safe to pass PubSub or Pipeline objects between threads." 2. A middleware to handle the connections, or maybe just disconnections. This won't work because a middleware's process_response() method gets called too early (before http headers are even sent to the client). I need something called when the client disconnects while I'm in the middle of streaming content to them. 3. The request_finished<https://docs.djangoproject.com/en/dev/ref/signals/#request-finished> and got_request_exception<https://docs.djangoproject.com/en/dev/ref/signals/#got-request-exception> signals. The first, like process_response() in a middleware, seems to fire too soon. The second doesn't get called when a client disconnects mid-stream. Final wrinkle: In production I'm using Gevent so I can get away with keeping a lot of connections open at once. However, this connection leak issue occurs whether I'm using plain old 'manage.py runserver', or Gevent monkeypatched runserver, or Gunicorn's gevent workers. (Cross-posted at http://stackoverflow.com/questions/12853067/django-cleaning-up-redis-connection-after-client-disconnects-from-stream. Answer either here or there... I'll make sure the other gets updated for posterity's sake.) Any help would be greatly appreciated! Thanks, Brent -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/_GhEn_UBHI8J. 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: Cleaning up redis connection after client disconnects from streaming response
After a lot of banging on things and reading framework code, I've found what I think is the right answer to this question. 1. According to the WSGI PEP, if your application returns an iterator with a close() method, it should be called by the WSGI server once the response has finished. Django supports this too. That's a natural place to do the Redis connection cleanup that I need. 2. There's a bug in Python's wsgiref implementation, and by extension in Django's 'runserver', that causes close() to be skipped if the client disconnects from the server mid-stream. See http://bugs.python.org/issue16220. I've submitted a patch. 3. Even if the server honors close(), it won't be called until a write to the client actually fails. If your iterator is blocked waiting on the pubsub and not sending anything, close() won't be called. I've worked around this by sending a no-op message into the pubsub each time a client connects. That way when a browser does a normal reconnect, the now-defunct threads will try to write to their closed connections, throw an exception, then get cleaned up when the server calls close(). The SSE spec says that any line beginning with a colon is a comment that should be ignored, so I'm just sending ":\n" as my no-op message to flush out stale clients. Sample code for doing this is posted on the Stack Overflow page where I also posted this question. See http://stackoverflow.com/questions/12853067/django-cleaning-up-redis-connection-after-client-disconnects-from-stream -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ggFglXbVqdYJ. 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.
new to Django and Python
I get an error message when I run the "$ python manage.py syncdb" Command. 70 SyntaxError: Non-ASCII character '\xe2' in file /Users/bmregister/djangoLocal/myFirstSite/myFirstSite/settings.py on line 70, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details I can’t find any characters ‘/xe2’ anywhere in the settings.py file, line 70 or other wise? I am editing the file in the Xcode IDE. The pep article really doesn’t help me much. Any suggestions or ideas on what needs to be edited in my settings.py file? Brent. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CEE1FF56.48C0%25Brent.Register%40coxinc.com. For more options, visit https://groups.google.com/groups/opt_out.