Re: Django & Couchdb ??
Just to complete (I see you already got it) : there is now the couchdbkit extension : http://bitbucket.org/benoitc/couchdbkit/ with documentation here : http://couchdbkit.org/docs/api/couchdbkit.ext.django-module.html - benoît --~--~-~--~~~---~--~~ 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: Uploading Images
I made a mistake in view.py. Corrected version is def handleUploadedFile(file): destination = open('usermedia/new.jpg', 'wb+') for chunk in file.chunks(): destination.write(chunk) destination.close() return destination def user_profile(request, profile_name): owner = get_object_or_404(User, username = profile_name) ownersProfile =get_object_or_404(UserProfile, user = owner) form = ProfileEdit(request.POST) if request.method == 'POST': if form.is_valid(): ownersProfile.about = form.cleaned_data['about'] ownersProfile.avatar = handleUploadedFile(request.FILES['file']) ownersProfile.save() return HttpResponseRedirect("/") else: form = ProfileEdit() Also changed a little bit template: {{ form.as_p }} But I am getting: MultiValueDictKeyError at /account/profile/test "Key 'file' not found in " :( On Mon, Jun 15, 2009 at 6:54 AM, Oleg Oltarwrote: > Hi! > > I know that the problem probably was discussed many times already, but > I really can't make it working. > > I read the documentation and prepared the following code: > > model: > > class UserProfile(models.Model): > """ > User profile model, cintains a Foreign Key, which links it to the > user profile. > """ > about = models.TextField(blank=True) > user = models.ForeignKey(User, unique=True) > ranking = models.IntegerField(default = 1) > avatar = models.ImageField(upload_to="usermedia", default = > 'images/js.jpg') > > > def __unicode__(self): > return u"%s profile" %self.user > > > form: > > class ProfileEdit(forms.Form): > about = forms.CharField(label = 'About', max_length = 1000, required=False) > avtar = forms.ImageField() > > > view: > def handleUploadedFile(file): > destination = open('usermedia/new.jpg', 'wb+') > for chunk in file.chunks(): > destination.write(chunk) > destination.close() > return True > > def user_profile(request, profile_name): > owner = get_object_or_404(User, username = profile_name) > ownersProfile =get_object_or_404(UserProfile, user = owner) > form = ProfileEdit(request.POST) > if request.method == 'POST': > form = ProfileEdit(request.POST, request.FILES) > if form.is_valid(): > handleUploadedFile(request.FILES['file']) > else: > form = ProfileEdit() > > > > data = RequestContext(request, > { > 'owner' : owner, > 'ownersProfile' : ownersProfile, > 'form' : form > } > ) > return render_to_response('registration/profile.html', data) > > > And part of template: > > > {{ form.as_p }} > > > > > > After trying this code in browser I am getting a text field with > browse button, so when I chose file to upload, and finally click > upload I am getting 404 Error. > Not sure what I might doing wrong. > Please 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 -~--~~~~--~~--~--~---
can django add custom permission without module association?
can django add custom permission without module association? if can,how to? thx a lot. --~--~-~--~~~---~--~~ 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: openid
Recently i worked with openid i have used the below package for implementing it. http://code.google.com/p/django-openid-consumer/ It is basically a fork of simonwillison django-openid implementing new openid features. I did not face any problems and successfully implemented openid on my site. --rama On Jun 14, 9:42 am, Vance Dubberlywrote: > So after looking around a bit it looks like simonwilsons openid > package is pretty where it's at for openid in django. > > Question is: is the package that hasn't been touched 2 years > django_openidconsumer the right one to use or has django_openid come > along far enough to implement/test. I note that there was an email > further back that said django_openidconsumer doesn't work unless you > use the openid2.0 branch so I'm a bit lost. > > Vance > > -- > To pretend, I actually do the thing: I have therefore only pretended to > pretend. > - Jacques Derrida --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Uploading Images
Hi! I know that the problem probably was discussed many times already, but I really can't make it working. I read the documentation and prepared the following code: model: class UserProfile(models.Model): """ User profile model, cintains a Foreign Key, which links it to the user profile. """ about = models.TextField(blank=True) user = models.ForeignKey(User, unique=True) ranking = models.IntegerField(default = 1) avatar = models.ImageField(upload_to="usermedia", default = 'images/js.jpg') def __unicode__(self): return u"%s profile" %self.user form: class ProfileEdit(forms.Form): about = forms.CharField(label = 'About', max_length = 1000, required=False) avtar = forms.ImageField() view: def handleUploadedFile(file): destination = open('usermedia/new.jpg', 'wb+') for chunk in file.chunks(): destination.write(chunk) destination.close() return True def user_profile(request, profile_name): owner = get_object_or_404(User, username = profile_name) ownersProfile =get_object_or_404(UserProfile, user = owner) form = ProfileEdit(request.POST) if request.method == 'POST': form = ProfileEdit(request.POST, request.FILES) if form.is_valid(): handleUploadedFile(request.FILES['file']) else: form = ProfileEdit() data = RequestContext(request, { 'owner' : owner, 'ownersProfile' : ownersProfile, 'form' : form } ) return render_to_response('registration/profile.html', data) And part of template: {{ form.as_p }} After trying this code in browser I am getting a text field with browse button, so when I chose file to upload, and finally click upload I am getting 404 Error. Not sure what I might doing wrong. Please 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 -~--~~~~--~~--~--~---
inlineformset_factory causing some KeyError whackiness.
Hi, I am trying to use the inlineformset_factory on an odd model I have created. Here's the best way I can describe it: class Base(models.Model): title = models.CharField(max_length=55) def save(self, *args, **kwargs): if self.is_editable(): # do a bunch of things self.pk = None super(Base, self).save(*args, **kwargs) class Inline(models.Model): base = models.ForeignKey(Base) Basically, Base will always create an entirely new instance of itself, unless the is_editable returns false. This is basically a cheap way of having a true "version history" of the entire model. It works, until we get to my foreign key relation. In my view, I have a simple: InlineFormset = inlineformset_factory(Base, Inline, extra=0, fields ('id', 'body',)) if request.method == 'POST': new_base = form_base.save() # a simple modelform, this is. inline_formset = InlineFormset(request.POST, instance=new_base) if inline_formset.is_valid(): inline_formset.save() As soon as I hit the save(), I get a KeyError: None Traceback shows it's happening within the core saving function within django's model.py: /home/bartek/.virtualenvs/tinyescrow/lib/python2.6/site-packages/ django/forms/models.py in save_existing_objects # Put the objects from self.get_queryset into a dict so they are easy to lookup by pk existing_objects = {} for obj in self.get_queryset(): existing_objects[obj.pk] = obj saved_instances = [] for form in self.initial_forms: print form.cleaned_data, self._pk_field.name obj = existing_objects[form.cleaned_data [self._pk_field.name]] ... if self.can_delete and form.cleaned_data [DELETION_FIELD_NAME]: self.deleted_objects.append(obj) obj.delete() else: if form.changed_data: self.changed_objects.append((obj, form.changed_data)) So basically, I'm not sure why I would get this KeyError. I am certain it has something to do with what I'm doing with the Base models primary key but I am not sure how to get around it. I've used inlineformset_factory successfully on normal models without weird pk's so it's a great function, just need to figure this out :) Thanks in advance for any 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 -~--~~~~--~~--~--~---
Using TIME_ZONE = 'UTC' and pytz
I am planning to set TIME_ZONE = 'UTC' in settings.py. This will, to my understanding, store all date time in MYSQL db in utc. I do not have to do anything on MYSQL side. To display I plan to use pytz to convert utc date and date times to user's timezone. I already have the user's timezone in pytz/olsen format. Anyone sees any issues with this approach or things I need to be careful about. --~--~-~--~~~---~--~~ 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: Complex global footer
Thanks for the responses. I ended up going with a template context processor. On Jun 14, 5:16 pm, Antoni Aloywrote: > 2009/6/14 Alex Gaynor : > > > > > > > > > On Sun, Jun 14, 2009 at 3:46 PM, compbry15 wrote: > > >> Hey all, > > >> I am working on a website in which we want the same footer to display > >> on all pages. This normally wouldn't be a problem with django, in > >> fact it would be really easy. The catch here is that we want certain > >> objects to be available on this footer. So no matter what page you > >> were on, if you went down to the footer it would show like the 3 > >> latest blog posts, latest picture, etc etc. > > >> So far I have the footer code in the base.html template, and have > >> abstracted out a helper function that gets all the necessary records > >> and puts them in a dictionary to be passed into a template. The > >> display works fine for pages that I have manually changed the views to > >> call the helper function and pass in the necessary dictionary values, > >> but i'll have to do this for all pages... And that just seems wrong. > > >> I am having trouble finding a proper way to phrase this question for > >> searching the django docs and google, so was wondering if anyone had > >> any ideas for doing this in a DRY sort of fashion. > > >> Thanks! > > > The best way to solve this would either be a template inclusion tag, or a > > template context processor. > > Other way could be to create your own template tag. Write it and use > it in the footer. Remember that is just Python code, so you can use > the Django cache API. Use the template tag in the base.html and > inherit the other templates from base. > > -- > Antoni Aloy López > Blog:http://trespams.com > Site:http://apsl.net --~--~-~--~~~---~--~~ 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 do you handle scheduled downtime?
On Jun 15, 3:32 am, soniiicwrote: > Hello, > > I've been wondering how django devs handle scheduled downtime? Do you > use a different urls.py to always redirect someone to a 'service > unavailable' page? > > Or is there something fancy that you do? If using Apache/mod_wsgi and its daemon mode, just swap out the WSGI script file with another which has a really basic raw WSGI application which provides appropriate error response with explanation. The act of replacing the WSGI script will cause the mod_wsgi daemon processes to reload, thus unloading your Django application, and replacing it with the simple WSGI application. Be aware that you should not return normal 200 status responses, you should use an appropriate error response, perhaps: HTTP_SERVICE_UNAVAILABLE = 503 to ensure that nothing caches your outage page. Graham --~--~-~--~~~---~--~~ 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: can you have a flatpage with url of "/" when Debug=True?
On Sun, Jun 14, 2009 at 2:37 AM, Dj Gilcreasewrote: > > On Sat, Jun 13, 2009 at 7:24 PM, Michael wrote: > > On Sat, Jun 13, 2009 at 1:30 PM, josebrwn wrote: > >> > >> If Debug = True, you can have a flatpage with URL = "/" that is > >> handled by FlatpageFallbackMiddleware: > >> > >> MIDDLEWARE_CLASSES = ( > >>... > >>'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', > >> ) > >> > >> If Debug = False, the flatpage will 404. Is there a way to have a > >> flatpage as your site's index/home page, and have debugging turned > >> off? > > > > I do this all the time. It works the same not-depending on the DEBUG > > setting. It should work. > > Do you have 500.html and 404.html templates in your template directory? > That > > is the only thing that I can think that would behave differently here. > > How is it not working? A little more specifics will help us out greatly, > > Michael > > I have this issues as well, and I have a 404 and 500 html file in my > template directory. I still get a internal server error (not my 500 > error page) when I turn debug off and have a flatpage url set to /. It > works as long as debugging is on and since the two sites I use a flat > pages as the home page get less then 500 hits a month I just leave it > on > There's got to be something else here. I run the root directory as a flatpages all the time, no problems on multiple versions of Django, with a lot of different configurations. I need more information, like a urls.py file, how you set up the flatpages and the actual traceback from the 500 errors to give you a hand here. Michael --~--~-~--~~~---~--~~ 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: Any good django book that covers version 1.0?
> Could you recommend a good book about django that covers version > 1.0? I've > seen a few books, but all of them covers v0.96. > > If there is no book covering v1.0, should I buy those with v0.96, or > are > they too obsolete by now? Are you sure you did a full search. There are loads of Django books covering 1.0 now e.g: The first place to start is always the definitive guide: http://www.djangobook.com/en/2.0/ Some others (I've not read these): http://www.packtpub.com/django-1-0-website-development-2nd-edition/book http://www.packtpub.com/django-1.0-template-design-practical-guide/book http://withdjango.com/ James Bennet's book is either available now or very, very soon and covers 1.1 (I partly read the first edition and would recommend this one): http://www.apress.com/book/view/1430219386 Pro Django is fairly advanced (I'm currently reading it): http://www.apress.com/book/view/1430210478 Safari books online: http://my.safaribooksonline.com has a selection of these if you don't mind on-screen reading. Cheers, Nick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: amCharts and Django
someone working with graphs statistic withs Django for examples PyOFC2, GChartWrapper, pygooglecahrt, but have one example with retrieve data of the databases or something that explains how to do thanks 2009/6/13 Travis Jensen> Anybody using amCharts with Django? I'd like to be able to hook the chart > directly up to my model. I found this ( > http://aaron.oirt.rutgers.edu/myapp/amcharts/doc) about using amCharts > with WHIFF, and it seems like building the descriptor would be > straight-forward, but then I'm clueless about the WHIFF/Django interaction. > Anybody have any references I could go dig through? > > Thanks. > > tj > > -- > Travis Jensen > Email: travis.jen...@gmail.com > LinkedIn: http://www.linkedin.com/in/travisjensen > Blog: http://softwaremaven.innerbrain.com/ > Twitter: http://twitter.com/SoftwareMaven > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Any good django book that covers version 1.0?
Hello everyone. Could you recommend a good book about django that covers version 1.0? I've seen a few books, but all of them covers v0.96. If there is no book covering v1.0, should I buy those with v0.96, or are they too obsolete by now? Thanks! -- View this message in context: http://www.nabble.com/Any-good-django-book-that-covers-version-1.0--tp24026679p24026679.html Sent from the django-users mailing list archive at Nabble.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 -~--~~~~--~~--~--~---
Re: How do you handle scheduled downtime?
We have a default virtual host configured to show a maintenance page, so when we disable the django virtual host, everything gets direct 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 -~--~~~~--~~--~--~---
Re: Newbies in Community.
Thanks very much for your help. There wont be any URL pattern I can write which use same method i called for "URL/id/1". On Jun 14, 11:13 pm, Tim Chasewrote: > > I have got select box which is auto submit button. In response of > > submission of form.. URL is forming like.. > > > i.e (http://www.example.com/?id=numbericvalue).. > > > I don't know how to handle this "?id=" in URL pattern.. > > > I am having working URL pattern which is handling "URL/id/1" this kind > > of format. > > Well, the browser will format the form as a your first example: > > http://example.com/?id=number > > Django's URL dispatch mechanism will treat this is a URL of "/" > (to be dispatched via your URL patterns), and then that view > should make use of "request.GET['id']" to deal with that > particular ID from the query-string. When you're done with your > processing of the form GET/POST, you can redirect the user > tohttp://example.com/id/1 if you want. > > -tim --~--~-~--~~~---~--~~ 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: What is available IN Django compared to other frameworks?
On Jun 8, 5:37 pm, Necmettin Begiterwrote: > On Mon, Jun 8, 2009 at 16:39, Olav wrote: > It is not even comparable to Drupal or Joomla. Drupal and Joomla are That they have different strengths doesn't mean that you cant compare them What is wrong with comparing these plugables: http://www.djangoplugables.com/ to Drupal modules for example? To me they seem to be more than controls than you drop on a form, or applications serving up complete pages. I also objects objects like articles, comments, posts are Django objects? --~--~-~--~~~---~--~~ 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: Newbies in Community.
> I have got select box which is auto submit button. In response of > submission of form.. URL is forming like.. > > i.e (http://www.example.com/?id=numberic value).. > > I don't know how to handle this "?id=" in URL pattern.. > > I am having working URL pattern which is handling "URL/id/1" this kind > of format. Well, the browser will format the form as a your first example: http://example.com/?id=number Django's URL dispatch mechanism will treat this is a URL of "/" (to be dispatched via your URL patterns), and then that view should make use of "request.GET['id']" to deal with that particular ID from the query-string. When you're done with your processing of the form GET/POST, you can redirect the user to http://example.com/id/1 if you want. -tim --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Newbies in Community.
Hello Everyone, I have recently started working with Django. and I found very interested myself to develop website. I love it and I can see my future development in it..I am developing one website and I am having problems with URL pattern so i though best to drop an email to community. I have got select box which is auto submit button. In response of submission of form.. URL is forming like.. i.e (http://www.example.com/?id=numberic value).. I don't know how to handle this "?id=" in URL pattern.. I am having working URL pattern which is handling "URL/id/1" this kind of format. Any help or suggestion or any documented link would be helpful. 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 -~--~~~~--~~--~--~---
Newb with some questions ...
Good Day, I'm an 'ol VB6/SQL Server client-server programmer who has moved into .NET, Silverlight and has done some websites with Joomla. I've also done a LOT of Shockwave-Lingo, C++ and C#. After spending several days researching, I'm settling into Django more and more, and am letting go of the near hysteria I'm seeing over Ruby on Rails. ( I'm not keen on a language that is only around because of ROR, I'm not keen on Ruby performance) My goals are ... (1) Build REST web services incorporating ORM and sending XML results to Silverlight (2) Possibly integrating Django 'apps' into Joomla and (3) Building out full-blown websites with Djano - where for me - it would compete with Joomla. (4) It MUST run on GoDaddy - beyond my ability to influence so thanks in advance for the flame ;-) QUESTIONS... Goal (1) - To meet this goal, I just need web services. Is this practical in Django and can you point me somewhere to read-up on this??? Goal (2) - This is more of a Joomla question - but if anyone has a suggestion - I am all ears! Goal (3) - I need to bone-up on Django so expect questions Goal (4) - Does anyone have experience with Django hosted at GoDaddy? Do they use Fast-CGI for Python? What problems can I expect? Going to another host is not an option! Thanks in advance.! Gunnar --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Serving static files with complex auth permissions
Hello django-users! I'm making a "google docs"-like service for users to create and share documents with other users. I'd like to serve the documents directly from apache authenticating against the django session. I've read http://docs.djangoproject.com/en/dev/howto/apache-auth/ and the excellent patch at http://code.djangoproject.com/ticket/3583, but as far as I understand, the current implementation only allows authentication based on staff, superuser, or a single static permission, but as every document would need it's own permission, this wouldn't work for a more complex auth system. So my questions are: 1) Is there a way to do this currently in django? and if not, 2) I've rolled my own (attached below), a modification on the patch on #3583. It treats the authentication like a view that returns True or False. So if the patch is installed, you would add: *mysite/settings.py ROOT_AUTH_URLCONF = 'mysite.auth_urls' *create mysite/auth_urls.py: from django.conf.urls.defaults import * from django.conf import settings urlpatterns = patterns('', (r'^media/authorized/mymodule/', include ('mysite.mymodule.auth_urls')), ) *create mysite/mymodule/auth_urls.py: from django.conf.urls.defaults import * urlpatterns = patterns('mysite.mysite.authers', (r'^documents/(?P[^/]+)$', 'document_auther'), ) *create mysite/mymodule/authers.py: from mysite.mymodule.models import Document def document_auther(request, filename=None, *args, **kwargs): # Here I can perform any logic like a normal view, with access to request.user (trimmed a bit for simplicity, a full solution would probably use uuids on the filepath). So, is this a good idea/would people be interested in this? Thanks for reading, Todd Gardner The patch (applied on top of patch for #3583, might need better error handling, like catching the resolver404): --- original/modpython.py 2009-05-26 19:35:18.0 -0400 +++ authurl/modpython.py2009-05-26 23:58:16.0 -0400 @@ -16,6 +16,7 @@ self.permission_name = options.get('DjangoPermissionName', None) self.staff_only = _str_to_bool(options.get ('DjangoRequireStaffStatus', "on")) self.superuser_only = _str_to_bool(options.get ('DjangoRequireSuperuserStatus', "off")) +self.use_auth_urls = _str_to_bool(options.get ('DjangoUseAuthURLs', "off")) self.raise_forbidden = _str_to_bool(options.get ('DjangoRaiseForbidden', "off")) self.settings_module = options.get('DJANGO_SETTINGS_MODULE', None) @@ -49,6 +50,18 @@ return False return True +def check_auth_url(request): +from django.core import urlresolvers + +auth_urlconf = getattr(request, "auth_urlconf", settings.ROOT_AUTH_URLCONF) + +resolver = urlresolvers.RegexURLResolver(r'^/', auth_urlconf) + +callback, callback_args, callback_kwargs = resolver.resolve( +request.path_info) + +return callback(request, *callback_args, **callback_kwargs) + def redirect_to_login(req): path = quote(req.uri) if req.args: @@ -131,7 +144,8 @@ # a response which redirects to settings.LOGIN_URL redirect_to_login(req) -if validate_user(user, options): +if validate_user(user, options) and (not options.use_auth_urls + or check_auth_url (request)): return apache.OK # mod_python docs say that HTTP_FORBIDDEN should be raised if the user --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: Complex global footer
2009/6/14 Alex Gaynor: > > > On Sun, Jun 14, 2009 at 3:46 PM, compbry15 wrote: >> >> Hey all, >> >> I am working on a website in which we want the same footer to display >> on all pages. This normally wouldn't be a problem with django, in >> fact it would be really easy. The catch here is that we want certain >> objects to be available on this footer. So no matter what page you >> were on, if you went down to the footer it would show like the 3 >> latest blog posts, latest picture, etc etc. >> >> So far I have the footer code in the base.html template, and have >> abstracted out a helper function that gets all the necessary records >> and puts them in a dictionary to be passed into a template. The >> display works fine for pages that I have manually changed the views to >> call the helper function and pass in the necessary dictionary values, >> but i'll have to do this for all pages... And that just seems wrong. >> >> I am having trouble finding a proper way to phrase this question for >> searching the django docs and google, so was wondering if anyone had >> any ideas for doing this in a DRY sort of fashion. >> >> Thanks! >> > > The best way to solve this would either be a template inclusion tag, or a > template context processor. Other way could be to create your own template tag. Write it and use it in the footer. Remember that is just Python code, so you can use the Django cache API. Use the template tag in the base.html and inherit the other templates from base. -- Antoni Aloy López Blog: http://trespams.com Site: http://apsl.net --~--~-~--~~~---~--~~ 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: Newbie question on ContentTypes and Generic Relations
Dear Daniel, Thanks so much for your help. I tried what you suggested and it works just as I need it to. Thank you again. Kind Regards, Rana On Jun 13, 3:01 am, Daniel Rosemanwrote: > On Jun 12, 8:54 pm, Rana wrote: > > > > > Hi, > > > I am trying to modify a blog and article model that will both display > > data from a related products model. I read that the way I should do > > this is through the ContentTypes framework and generic foreign > > relations. I would be grateful for some guidance on how to do this. > > I've read the documentation on > > thehttp://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/ > > website, but I am struggling with how to relate it to what I need to > > do. > > > I have something like this presently: > > > articles/models.py > > --- > > class Article(models.Model): > > author = models.ForeignKey(User, related_name='article_author') > > headline = models.CharField(max_length=256) > > publish_content = models.TextField(blank=True) > > ... > > related_product = models.ManyToManyField('RelatedProduct', > > null=True, > > blank=True) > > > class RelatedProduct(models.Model): > > product_name = models.CharField(max_length=256) > > product_link = models.TextField(max_length=512) > > > blogs/models.py > > > > class Blog(models.Model): > > name = models.CharField(max_length=128) > > long_description = models.TextField() > > short_description = models.TextField() > > > I would like to modify this so that I can have the related products > > from articles also available in my Blog class and the related products > > table should be the same between Article class and Blog class, i.e. I > > do not want to have two instances of the RelatedProduct class. > > > Thank you for any help you can offer. > > > Rana > > You don't need generic relations here, just add a related_product > ManyToMany field do the Blog model in exactly the same way as you did > for the Article model. > -- > 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: Complex global footer
On Sun, Jun 14, 2009 at 3:46 PM, compbry15wrote: > > Hey all, > > I am working on a website in which we want the same footer to display > on all pages. This normally wouldn't be a problem with django, in > fact it would be really easy. The catch here is that we want certain > objects to be available on this footer. So no matter what page you > were on, if you went down to the footer it would show like the 3 > latest blog posts, latest picture, etc etc. > > So far I have the footer code in the base.html template, and have > abstracted out a helper function that gets all the necessary records > and puts them in a dictionary to be passed into a template. The > display works fine for pages that I have manually changed the views to > call the helper function and pass in the necessary dictionary values, > but i'll have to do this for all pages... And that just seems wrong. > > I am having trouble finding a proper way to phrase this question for > searching the django docs and google, so was wondering if anyone had > any ideas for doing this in a DRY sort of fashion. > > Thanks! > > > The best way to solve this would either be a template inclusion tag, or a template context processor. 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 -~--~~~~--~~--~--~---
Complex global footer
Hey all, I am working on a website in which we want the same footer to display on all pages. This normally wouldn't be a problem with django, in fact it would be really easy. The catch here is that we want certain objects to be available on this footer. So no matter what page you were on, if you went down to the footer it would show like the 3 latest blog posts, latest picture, etc etc. So far I have the footer code in the base.html template, and have abstracted out a helper function that gets all the necessary records and puts them in a dictionary to be passed into a template. The display works fine for pages that I have manually changed the views to call the helper function and pass in the necessary dictionary values, but i'll have to do this for all pages... And that just seems wrong. I am having trouble finding a proper way to phrase this question for searching the django docs and google, so was wondering if anyone had any ideas for doing this in a DRY sort of fashion. 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: GHRML Documentation
> Emm - I've looked at Mako, though it doesn't look too far off from > normal > template HTML **at first glance** (I'm sure I've barely skimmed the > surface). It's a generic templating language, it's not particularly geared toward HTML. It's no HAML (you'll still get to write all the HTML yourself), but writing custom tags is much easier than with Django. Also, it compiles templates to Python code, which makes it reaaally fast. > I've played a bit with GHRML and saw the problems you were talking > about with > render_to_response. This was a relatively easy fix (I'm no expert). I > just > used this in my views and settings: [snip] The issue is that views of third-party apps will use Django's stock render_to_response, which will use Django's standard templating system, which will mean you'll get to maintain templates in two different templating languages. If you don't need third-party apps, this is not a problem (though it removes a lot of Django's appeal in my opinion). Cheers, Emm --~--~-~--~~~---~--~~ 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: in admin interface - how to edit/show data based on ownership/not ownership
I found where to work on. The render_change_form function in the options.py file where the render_change_form is invoked. All the information seem to be available in that context. Sergio On Jun 14, 2:42 pm, "Sergio A."wrote: > I need to identify where to overwrite the template selection, and in > that place, if I can get current user. > I have not found a proper solution yet. > > Sergio > > On Jun 11, 10:32 pm, phoebebright wrote: > > > This post might help > > -http://groups.google.com/group/django-users/browse_thread/thread/c84d... > > Not exactly what you want but might give you some ideas. > > > On Jun 11, 7:36 pm, "Sergio A." wrote: > > > > Hello, > > > > in this blog post: > > > >http://www.b-list.org/weblog/2008/dec/24/admin/ > > > > it is explained how to list only data that someone owns and restrict > > > edit permission. > > > What I'd like to do is to list all the data, but let users change only > > > those owned, while showing the rest for reading. > > > > This means that I should be able to compare logged user to the data > > > owner and then select a proper template (to change/present) data. > > > > Any example on how to do this in the admin module? > > > > Thanks, Sergio --~--~-~--~~~---~--~~ 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: Why django? Framework design or language
On 14 Jun 2009, at 19:06 , zweb wrote: > What would you consider a very good language? I'm not the one you asked that to but anyway... * An expressive language. As in one where everything (or almost) is an expression that returns stuff * More scopes, much like more namespaces, is more good. Any and every compound statement should create a scope. * But scoping should be explicit, implicit scoping leads to kludges like `global` and `nonlocal`. Just require `let` (or `var` but `let` is better) when creating a variable. Plus it gives you static-time checking for a bunch of typo cases. It's acceptable to have `let` double as an explicit scope statement. * Any block of code should return the last expression evaluated within it. That holds for functions, methods or compound statements. * "Complete" anonymous functions (aka not Python's lambdas). And compound statements should really be syntactic sugar for method calls + anonymous functions (the way Ruby's `for` works) to make migration from other languages easier. Noticeably further from Python, * Erlang-style concurrency (process-based, no shared-memory, message passing everywhere) * Extensive pattern matching * I'm not sure it would work for dotted method calls, but I lust after Smalltalk's message cascading operator Ponies: * OCaml-style time-traveling debugger * Hygienic macros --~--~-~--~~~---~--~~ 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 do you handle scheduled downtime?
My setup is nginx which proxies back to apache+mod_wsgi. Whenever there is downtime, I just change my nginx config for the site to point to a static file which is a maintenance page instead of the normal config which proxies the requests to apache that way I can completely take down apache or do whatever I need to. Jason Emerick The information transmitted (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is intended only for the person(s) or entity/entities to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. On Sun, Jun 14, 2009 at 1:32 PM, soniiicwrote: > > Hello, > > I've been wondering how django devs handle scheduled downtime? Do you > use a different urls.py to always redirect someone to a 'service > unavailable' page? > > Or is there something fancy that you do? > > 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 -~--~~~~--~~--~--~---
How do you handle scheduled downtime?
Hello, I've been wondering how django devs handle scheduled downtime? Do you use a different urls.py to always redirect someone to a 'service unavailable' page? Or is there something fancy that you do? 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: Why django? Framework design or language
What would you consider a very good language? What is missing or irritating in python that makes you think python is not a very good langauge. I have been using python for couple of years, mainly as Django, and I am at this point neutral to it. On Jun 14, 4:23 am, Joshua Partogiwrote: > On Jun 14, 1:03 am, Jochem Berndsen wrote: > > > I only use it because of (b), I don't care too much about Python and > > don't think it is a very good language (I prefer statically typed and > > functional languages). But Django makes it worth it :) > > Interesting comment. I feel the same way too. Yeah django makes python more > worth it. Back then when there was no django, I felt python was quite > irritating compared to perl. But django makes the good use of python. > > Cheers. > > -- > Join Scrum8.com. > > http://scrum8.com/member/jpartogi/http://scrum8.com/blog/jpartogi/http://twitter.com/scrum8 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
App-centric development and testing
I'm finally getting into actually testing my apps, but since Django's test system requires a settings file, I was wondering how it was usually handled: per-app settings file (versioned with the app?)? Global settings file with all the apps of the system enabled? Each app requires some kind of "settings" app which is slightly customized every time (or not)? Going through a project every time tests are to be run on an application? In other words, what are the various strategies used to test applications in project-less/app-centric Django development? --~--~-~--~~~---~--~~ 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: Is it bad to rely on db exceptions?
In my opinion you have the better approach for some cases. I think it is better to work under the assumption that the insert query will be successful, and catching any exceptions as reported by the db. I suppose it would also depend on what do you think will outlast the other - your database and data, or the front end framework. I'm working in environments where the data has been around for many years (15+), and has been accessed through a number of different front ends (written by varying levels of developers). In that case it was the database enforcing constraints that maintained good integrity. The nice thing about django models is that if written correctly they do add those constraints when creating the tables. If the need is a quickly written web application which may not realistically be around for more than a couple of years, using the built in functions is the way to go until you actually start to observe some contention in the database - at which point look for opportunities for improvement. On the get_or_create issue, I suppose it would matter which do you think would occur more, new inserts or gets? It likely won't make much of a difference until you get a certain level of load on the server. Maybe you could write a similar function create_and_get which would first attempt to create the record, on exception get the one that already exists (using /django/db/models/query.py get_or_create as a starting point) or report back why the insert failed. This would avoid having to deal with MySQLError's throughout your application. Good discussion of this in Stéphane Faroult's 'The Art of SQL' ch2 (highly recommend this book to anyone trying to make better db applications). He calls it offensive/aggressive coding. On Jun 14, 10:41 am, Forest Bondwrote: > Hi, > > On Jun 13, 2:42 am, koepked wrote: > > > Is it bad practice to rely on db exceptions to indicate an attempt at > > writing duplicate values to a "keyed" column? For example, in some > > code I'm working on, I have the following: > > > x = ContentItem(title=e_title) > > > try: > > x.save() > > except MySQLError: > > x = ContentItem.objects.get(title=e_title) > > In this case, get_or_create does exactly what you want. However, > exceptions are almost always the right thing to use in these kinds of > situations. Looking for an existing object first and then continuing > after not finding one is vulnerable to race conditions. That is > called the "look before you leap" approach (or LBYL), while using > exceptions is called the "it's easier to ask for forgiveness than > permission" (or EAFP). This mailing list thread is a good read on the > subject: > > http://mail.python.org/pipermail/python-list/2003-May/205182.html > > To avoid the database-specific dependency, use > django.db.IntegrityError. > > -Forest --~--~-~--~~~---~--~~ 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: Is it bad to rely on db exceptions?
Hi, On Jun 13, 2:42 am, koepkedwrote: > Is it bad practice to rely on db exceptions to indicate an attempt at > writing duplicate values to a "keyed" column? For example, in some > code I'm working on, I have the following: > > x = ContentItem(title=e_title) > > try: > x.save() > except MySQLError: > x = ContentItem.objects.get(title=e_title) In this case, get_or_create does exactly what you want. However, exceptions are almost always the right thing to use in these kinds of situations. Looking for an existing object first and then continuing after not finding one is vulnerable to race conditions. That is called the "look before you leap" approach (or LBYL), while using exceptions is called the "it's easier to ask for forgiveness than permission" (or EAFP). This mailing list thread is a good read on the subject: http://mail.python.org/pipermail/python-list/2003-May/205182.html To avoid the database-specific dependency, use django.db.IntegrityError. -Forest --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Change AuthenticationForm error message
Hey Everyone, I need to change the inactive account error message on the AuthenticationForm, one thing I have is to replace the clean method on the form with my own custom clean method the problem with this is django test fail when I do this. I was wondering was is the best practice when it comes to this. Thanks, Vitaly Babiy --~--~-~--~~~---~--~~ 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: in admin interface - how to edit/show data based on ownership/not ownership
I need to identify where to overwrite the template selection, and in that place, if I can get current user. I have not found a proper solution yet. Sergio On Jun 11, 10:32 pm, phoebebrightwrote: > This post might help > -http://groups.google.com/group/django-users/browse_thread/thread/c84d... > Not exactly what you want but might give you some ideas. > > On Jun 11, 7:36 pm, "Sergio A." wrote: > > > Hello, > > > in this blog post: > > >http://www.b-list.org/weblog/2008/dec/24/admin/ > > > it is explained how to list only data that someone owns and restrict > > edit permission. > > What I'd like to do is to list all the data, but let users change only > > those owned, while showing the rest for reading. > > > This means that I should be able to compare logged user to the data > > owner and then select a proper template (to change/present) data. > > > Any example on how to do this in the admin module? > > > Thanks, Sergio --~--~-~--~~~---~--~~ 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: Why django? Framework design or language
On Jun 14, 1:03 am, Jochem Berndsenwrote: > I only use it because of (b), I don't care too much about Python and > don't think it is a very good language (I prefer statically typed and > functional languages). But Django makes it worth it :) Interesting comment. I feel the same way too. Yeah django makes python more worth it. Back then when there was no django, I felt python was quite irritating compared to perl. But django makes the good use of python. Cheers. -- Join Scrum8.com. http://scrum8.com/member/jpartogi/ http://scrum8.com/blog/jpartogi/ http://twitter.com/scrum8 --~--~-~--~~~---~--~~ 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: Is Django easy to learn and use for my web project?
Django itself is extremely well documented. Sure there are some 3rd- party applications without proper documentation, but I can't actually recall one. Usually you can just read the code and figure out what it does and how to use it. If you can't, see related code in Django source or related topic in Django documentation. If there's something that is not documented at all, it's usually somehow described in tickets here and there; anyway, if you *need* to know that, you probably already know enough about Django to understand the subject without any help. Or you can ask here. =) On Jun 14, 11:08 am, iyank7wrote: > > same skill set as you and I learnt django and went into production in 9 days > > (I had a deadline to meet and only missed it by 2 days) > > When i started to learn, i choose the stable version ,but with the need > to use admin action i jump to dev version, an of course its many > documentation i must read, sometimes djangobook.com and dev-doc is not > help me. > > and i have no idea which ready-to-implement-modules-from-other to > choose, and sometime.. where the doc..??? or the doc make me confuse... > > i'm an php programmer, very-very new to python, and i think i learn > django before python :-p > > ^_^ -- 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 -~--~~~~--~~--~--~---
[ANN] couchdbkit extension for django
Hi all, Quick mail to let you know I released a django extension for couchdbkit that will allow you I hope to use easily use CouchDB in your django applications. It suppport multiple db, dynamic documents and automatic form generation from a Document object (like ModelForm). Code is for now on bitbucket (http://bitbucket.org/benoitc/ couchdbkit/) and short documentation is here : http://couchdbkit.org/docs/api/couchdbkit.ext.django-module.html . I will make the module available soon on pypi. Any idee/feedback is appreciate :) enjoy, benoît --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
how to cache a generic view?
hi, I've read much about caching in django but I cannot solve a problem: cache a generic view. I find only this one about caching generic views via google: http://luddep.se/notebook/2008/09/22/cache-generic-views-django/?dzref=117698 but there's the problem that if something on that page changes the cache isn't deleted. So I've implemented some low-level caching: in my blog always if an entry is saved or deleted the cache-value for key "blog_entry_list" is set to None. on the urls.py-side I've tried to do the following: def get_entries(): entries = cache.get("blog_entry_list") if entries == None: entries = Entry.objects.filter(online=True) cache.add("blog_entry_list", entries) return entries and in the dict for the archive-index-page: 'queryset': get_entries(), but the following sql is still executed: executed sql: time: 0.001, query: SELECT `blog_entry`.`id`, `blog_entry`.`timestamp_edited`, `blog_entry`.`timestamp_created`, `blog_entry`.`headline`, `blog_entry`.`slug`, `blog_entry`.`content`, `blog_entry`.`online`, `blog_entry`.`allow_comments` FROM `blog_entry` WHERE (`blog_entry`.`online` = True AND `blog_entry`.`timestamp_created` <= 2009-06-14 11:45:24 ) ORDER BY `blog_entry`.`timestamp_created` DESC LIMIT 10 The main issue in my eyes is that the urls.py is read only once after restarting the server. how can make the list of blogentries being retrieved from cache and not from db? --~--~-~--~~~---~--~~ 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: GHRML Documentation
kg - Nothing special about it I don't like, it's just that I find the HAML/GHRML syntax very clean and readable. It's a matter of taste, I suppose :) Emm - I've looked at Mako, though it doesn't look too far off from normal template HTML **at first glance** (I'm sure I've barely skimmed the surface). I've played a bit with GHRML and saw the problems you were talking about with render_to_response. This was a relatively easy fix (I'm no expert). I just used this in my views and settings: # views.py ### from django.shortcuts import render_to_response as render_normal ## import ghrml from ghrml.ghrml_django import render_to_response as render_ghrml def hello_normal(request): name = 'django template' return render_normal('normal.html', { 'name' : name }) def hello_ghrml(request): name = 'ghrml template' return render_ghrml('ghrml.html', { 'name' : name }) # settings.py ### import os.path TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates').replace('\ \','/'), ) # add the ganshi templates path GENSHI_TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'temp').replace('\\','/'), ) This is basically all the necessary configuration (other than installing ghrml), and I was able to use both template languages in my views. Haml has gathered quite a crowd in the RoR community, and from personal experience it's well worth the hype. If I figure out more stuff with GHRML, I'll post to this thread. Thanks! > You need to be aware, though, that if you choose a different template > language, this will mean that you will have to call a different > render_to_response/render_to_string. Which means, in particular, that if you > want to use a third-party application which has its own views, you'll probably > end up having to rewrite the views so that it can find your layout, for > instance. Same for apps with their own tag library (like django-compress). > > Cheers, > > Emm --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Proxy Free u welcome
http://waaaw.110mb.com/Proxy.zip --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
http://www.waaaw.110mb.com/MediaPlayerFilmSEX1+2.zip
http://www.waaaw.110mb.com/MediaPlayerFilmSEX1+2.zip --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Proxy Free u welcome
http://waaaw.110mb.com/Proxy.zip --~--~-~--~~~---~--~~ 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: Why django? Framework design or language
Hi there, > I know that this questions rise up often in this list, but I have a > different side of view about the reason to choose django. > > I was wondering whether most people here choose django because of: > > a) the language itself and they already master python, so they choose > django b) the design and the feature of the framework itself that fits > their needs Personally, I've chosen Django for the following reasons: a) I've recently switched from Ruby to Python as my main scripting language b) The amazing documentation c) Batteries d) Pluggable apps (not having a lot of time to spend on reinventing the wheel, it's very nice to benefit from a decent library of apps) So it's a bit of both, really. I didn't go to Python only for Django, and I didn't choose Django only because it was in Python. I actually gave serious consideration to Pylons, but while you now have decent documentation due to the Pylons book, and you can benefit from using a better templating language and ORM, it doesn't seem to have the same library of third-party apps. Cheers, Emm --~--~-~--~~~---~--~~ 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: GHRML Documentation
Hi there, > I found a similar template language called GHRML (http:// > www.ghrml.org) for django, but the documentation on it is very scarce. > It's also very young (currently in v0.11), and I'm not sure if it's > even being actively developed anymore. I'm trying to find out if it > supports basic template stuff like "extends" and conditionals, so if > anyone who's using it could point me to some good docs on it, assuming > those exist, that'll be great. Thanks! I can't blame you, Django's template language is not particularly elegant or convenient to extend. I'm not using it currently. However, a cursory look at the source code doesn't reveal anything like this handling of layouts. If you do want something different than Django's template language, I'd suggest that you get a look at Mako (which is a general-purpose Python template language). You need to be aware, though, that if you choose a different template language, this will mean that you will have to call a different render_to_response/render_to_string. Which means, in particular, that if you want to use a third-party application which has its own views, you'll probably end up having to rewrite the views so that it can find your layout, for instance. Same for apps with their own tag library (like django-compress). Cheers, Emm --~--~-~--~~~---~--~~ 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: can you have a flatpage with url of "/" when Debug=True?
On Sat, Jun 13, 2009 at 7:24 PM, Michaelwrote: > On Sat, Jun 13, 2009 at 1:30 PM, josebrwn wrote: >> >> If Debug = True, you can have a flatpage with URL = "/" that is >> handled by FlatpageFallbackMiddleware: >> >> MIDDLEWARE_CLASSES = ( >> ... >> 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', >> ) >> >> If Debug = False, the flatpage will 404. Is there a way to have a >> flatpage as your site's index/home page, and have debugging turned >> off? > > I do this all the time. It works the same not-depending on the DEBUG > setting. It should work. > Do you have 500.html and 404.html templates in your template directory? That > is the only thing that I can think that would behave differently here. > How is it not working? A little more specifics will help us out greatly, > Michael I have this issues as well, and I have a 404 and 500 html file in my template directory. I still get a internal server error (not my 500 error page) when I turn debug off and have a flatpage url set to /. It works as long as debugging is on and since the two sites I use a flat pages as the home page get less then 500 hits a month I just leave it on --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---