Re: documentation patch questions
On Fri, Dec 9, 2011 at 2:33 PM, Anniewrote: > Russ: >> Long comments aren't required; you just need to provide something >> that can be answered "OK". > > That makes perfect sense, especially now that I see how it's being > used. *g* (Hadn't gotten to that part of the python unittest docs yet. > *g*) I've updated the patch and attached it. > > Thanks for your help! I've just marked the ticket ready for checkin. As soon as a commiter has some free time, it will go into trunk. Thanks for the contribution! May this not be your last :-) Yours, Russ Magee %-) -- 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.
DateTimeField(auto_now_add=True) and admin page
Hi, I have the following lines in my model: entry_date = models.DateTimeField(auto_now_add=True) pub_date = models.DateTimeField('date published', blank=True, null=True) last_change_date = models.DateTimeField(auto_now=True) Basically, I want the entry date to be added automatically, and last change date to be updated on every save(), just as described in documentation. The problem is that those fields don't appear on the admin page. I tried with explicitly setting those fields in my admin class, per Tutorial: class EcoPointAdmin(admin.ModelAdmin): fieldsets = [ ('Details', {'fields': ['title', 'description', 'type', 'status']}), ('Geo data', {'fields': ['latitude', 'longitude']}), ('Dates', {'fields': ['entry_date', 'pub_date', 'last_change_date']}), ] But now I get the error shown below. Any chance to have those fields on admin page, without creating my custom admin? I couldn't find anything useful in the archives. Thanks, DC, Django novice The error msg: ImproperlyConfigured at /admin/ecopoint/ecopoint/3/ 'EcoPointAdmin.fieldsets[2][1]['fields']' refers to field 'entry_date' that is missing from the form. -- 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: ignore case order by in Django
On Fri, 2011-12-09 at 12:55 +, Tom Evans wrote: > On Fri, Dec 9, 2011 at 12:41 PM, kenneth gonsalves >wrote: > > On Thu, 2011-12-08 at 21:04 -0800, ziggi wrote: > >> Maybe has another way to do this? > > > > iequal, icontains ... > > OP is talking about case insensitive ordering, not querying (and he > has the simplest way). > > I know, but his query did not use the simplest way. -- regards Kenneth Gonsalves -- 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: 404 only in Chrome
Thanks for the reply but that didn't help. On Dec 9, 5:41 pm, Furbeewrote: > In urls.py: > > Change: > (r'^portfolio/', include('project.urls.web')), > > To: > (r'^portfolio/$', include('project.urls.web')), > > The dollar sign makes it the end of the regular expression string. Without > it, /portfolio/ will match with /portfolio/funstuff, > /portfolio/?my_hax_rock, etc. See if that helps. > > Furbee > > > > > > > > On Fri, Dec 9, 2011 at 5:33 PM, neridaj wrote: > > Hello, > > > For some reason I'm getting a 404 in google chrome when I visit / > > portfolio/. The url entered is /portfolio/ but it returns as a 404 at / > > portfolio/undefined/ in the chrome developer tools window. I read a > > post about some issues with chrome handling errors and to resolve it > > by unchecking "Use a web service to help resolve navigation errors" > > but this didn't help with my problem. I'm not sure why undefined is > > being appended to the url, any ideas? > > > urls.py: > > > (r'^portfolio/', include('project.urls.web')), > > > project/urls/web.py: > > > urlpatterns = patterns('django.views.generic.list_detail', > > (r'^$', 'object_list', web_project_info_dict, > > 'project_web_archive_index'), > > (r'^(?P[-\w]+)/$', 'object_detail', web_project_info_dict), > > ) > > > If it was a real 404 why isn't my error page displayed i.e., when I > > visit /portfolio/non-existent-slug, I get the proper 404 page. > > > >>> django.VERSION > > (1, 2, 0, 'alpha', 0) > > > Thanks 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. -- 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: 404 only in Chrome
In urls.py: Change: (r'^portfolio/', include('project.urls.web')), To: (r'^portfolio/$', include('project.urls.web')), The dollar sign makes it the end of the regular expression string. Without it, /portfolio/ will match with /portfolio/funstuff, /portfolio/?my_hax_rock, etc. See if that helps. Furbee On Fri, Dec 9, 2011 at 5:33 PM, neridajwrote: > Hello, > > For some reason I'm getting a 404 in google chrome when I visit / > portfolio/. The url entered is /portfolio/ but it returns as a 404 at / > portfolio/undefined/ in the chrome developer tools window. I read a > post about some issues with chrome handling errors and to resolve it > by unchecking "Use a web service to help resolve navigation errors" > but this didn't help with my problem. I'm not sure why undefined is > being appended to the url, any ideas? > > urls.py: > > (r'^portfolio/', include('project.urls.web')), > > project/urls/web.py: > > urlpatterns = patterns('django.views.generic.list_detail', >(r'^$', 'object_list', web_project_info_dict, > 'project_web_archive_index'), >(r'^(?P[-\w]+)/$', 'object_detail', web_project_info_dict), > ) > > If it was a real 404 why isn't my error page displayed i.e., when I > visit /portfolio/non-existent-slug, I get the proper 404 page. > > >>> django.VERSION > (1, 2, 0, 'alpha', 0) > > Thanks 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. > > -- 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.
404 only in Chrome
Hello, For some reason I'm getting a 404 in google chrome when I visit / portfolio/. The url entered is /portfolio/ but it returns as a 404 at / portfolio/undefined/ in the chrome developer tools window. I read a post about some issues with chrome handling errors and to resolve it by unchecking "Use a web service to help resolve navigation errors" but this didn't help with my problem. I'm not sure why undefined is being appended to the url, any ideas? urls.py: (r'^portfolio/', include('project.urls.web')), project/urls/web.py: urlpatterns = patterns('django.views.generic.list_detail', (r'^$', 'object_list', web_project_info_dict, 'project_web_archive_index'), (r'^(?P[-\w]+)/$', 'object_detail', web_project_info_dict), ) If it was a real 404 why isn't my error page displayed i.e., when I visit /portfolio/non-existent-slug, I get the proper 404 page. >>> django.VERSION (1, 2, 0, 'alpha', 0) Thanks 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.
Saving a blank OneToOne inline in the admin
How do I ensure that a blank InlineModelAdmin is saved when the parent form is submitted? Here's a simplified version of my code: class Flagset(Model): group = OneToOneField(Group) flag = BooleanField() class FlagsetInline(TabularInline): model = Flagset class GroupAdmin(ModelAdmin): inlines = [FlagsetInline] admin.site.unregister(Group) admin.site.register(Group, GroupAdmin) When I save a new Group, I want a Flagset to be created whether the Flagset.flag box is checked or not. If I leave it blank, no object is created. I tried adding a signal handler like the following to create the object: @receiver(post_save, sender=Group) def create_flagset(sender, **kwargs): if kwargs['created']: Flagset.objects.get_or_create(group=kwargs['instance']) This works when the flag is not set, but causes an error if it is (because the Flagset is created twice, it looks like). What can I do to make this scenario work whether the inline is touched or not? Thanks, Dan -- 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: rendering CSV in response; need a little help
If you have a dataset that is too large to fit in memory comfortably, the ability to pass a generator to an httpresponse means you can break it up into multiple smaller queries (outside the template system anyway): def queryset_to_csv(queryset,delimiter=',',steps=500): """ generator for large querysets """ try: # raw query set fieldmeta = queryset.model._meta.fields except AttributeError: # it's been evaluated fieldmeta = qs._meta.fields fields = [] row= [] for f in fieldmeta: fields.append(f.get_attname()) row.append('"'+f.name+'"') yield "%s\r\n" % delimiter.join(row) ids=[o["id"] for o in queryset.values("id")] count=len(ids) for n in range(steps,count+steps,steps): lo,hi=n-steps,n qs=queryset.model.objects.filter(pk__in=ids[lo:hi]) it=[] for i in qs: row = [] for f in fields: val = str(getattr(i,f)).replace('"',"'").replace(delimiter,' ') row.append('"'+val+'"') it.append(delimiter.join(row)) yield "\r\n".join(it) ... return HttpResponse(queryset_to_csv(somequeryset,',', 250),mimetype='text/csv') -- 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's the django convention for templates?
> > > As you can see the templates directory is stored inside the app directory. > > Reading the django documentation instead they says that the templates dir > should live inside the root directory of the projects. > > I'm wondering, what's is the common convention about it? > > I thought to store the templates dir inside each apps, because in this way > the apps are more pluggables...I'm going wrong? > > Thank you > Your way is right, nothing wrong wth storing templates in app directory. For this purpose django even has special app loader, wich loads templates stored in the app directory. And this way your app would be closer to "just plug in and use" As for me, i'm deciding where to store templates basing on app or project requirements. -- *Vovk Donets* python/django developer skype: suunbeeam icq: 232490857 mail:donets.vladi...@gmail.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.
What's the django convention for templates?
Hello, I'm totally new in the django universe and I'm trying out to build a little project. There are many days who I'm following many tutorial on django framework. But it's not clear for me how the convention for templates is. Following the djangobook I've build a projects who has the following strurcture: projects | --- | __init__.py | manage.py | settings.py | urls.py | app folder | -- | many files | templates | | index.php As you can see the templates directory is stored inside the app directory. Reading the django documentation instead they says that the templates dir should live inside the root directory of the projects. I'm wondering, what's is the common convention about it? I thought to store the templates dir inside each apps, because in this way the apps are more pluggables...I'm going wrong? Thank you -- 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/-/UX6fBcCAaDkJ. 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: rendering CSV in response; need a little help
https://github.com/joshourisman/django-tablib -- Kenneth Reitz On Friday, December 9, 2011 at 8:33 AM, Alen Mujezinovic wrote: > Hey > > Here's what I use to add CSV export to the admin: > > https://gist.github.com/46e6d19e6e08faefb476 > -- > 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/-/3dDsN7eCWFQJ. > To post to this group, send email to django-users@googlegroups.com > (mailto:django-users@googlegroups.com). > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > (mailto: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: rendering CSV in response; need a little help
Hey Here's what I use to add CSV export to the admin: https://gist.github.com/46e6d19e6e08faefb476 -- 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/-/3dDsN7eCWFQJ. 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: rendering CSV in response; need a little help
On Fri, Dec 9, 2011 at 4:12 PM, Sells, Fredwrote: > I'm getting an http request from another server in our system and I need > to respond using a csv format. I've seen the example in the docs where > the template looks like this: > > {% for row in data %}"{{ row.0|addslashes }}", "{{ row.1|addslashes }}", > "{{ row.2|addslashes }}", "{{ row.3|addslashes }}", "{{ row.4|addslashes > }}" > {% endfor %} > > > However I would like my template to work with a variable number of > fields. Short of doing a ",".join(arow) in my view, I'm not sure how > to do this without getting a trailing "," in my output. My view > snippet looks like this: > > results = [ (s.a, s.b, s.c, s.d, s.e) for s in today] > return render_to_response('tuples2csv.txt',{'records': results}, > mimetype='text/plain', context_instance=RequestContext(request)) > > > My template looks like this at this time: > === > {% for row in records %}{% for value in row %}{{value}},{% endfor %} > {% endfor %} > === > > The data looks like this - I've deleted much of the internal field > content since it is proprietary information > > 7:55,,, > 8:55,,, > 11:25,,, > 8:25,,xxx, > = > I guess I can always convert this to a text block in my view and respond > with that, but it seems like I should be able to use the template system > for a more generic solution. I've done a fair amount of googling on > this but keep getting to the same examples that are close but not quite > what I need. > > If someone can clarify how to eliminate the trailing ","I would really > appreciate it. > > Thanks, > Fred. > Do you have a really good reason for generating CSV in a template? It will be astonishingly slow. The python csv module simply requires a file like object to write to. A HttpResponse is a file like object. To answer your question, in a for loop there are various counters available, one of which is forloop.last, which is true the last time through the loop. https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#for Cheers Tom -- 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: Walking the template / Partial rendering
Also, here's the actual code that is used by the mixin to assemble the response: https://gist.github.com/70beb521546d59deb207 Compare this to what is going on in `ExtendsNode.render`: https://code.djangoproject.com/browser/django/trunk/django/template/loader_tags.py#L103 The code in the gist does handle `{{ block.super }}` but it comes with the cost of duplicating a big part of the render method. Having the context assembly moved out of the render method in the `ExtendsNode` would already be a big step :) Alen -- 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/-/vUL82_HQ6QIJ. 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.
rendering CSV in response; need a little help
I'm getting an http request from another server in our system and I need to respond using a csv format. I've seen the example in the docs where the template looks like this: {% for row in data %}"{{ row.0|addslashes }}", "{{ row.1|addslashes }}", "{{ row.2|addslashes }}", "{{ row.3|addslashes }}", "{{ row.4|addslashes }}" {% endfor %} However I would like my template to work with a variable number of fields. Short of doing a ",".join(arow) in my view, I'm not sure how to do this without getting a trailing "," in my output. My view snippet looks like this: results = [ (s.a, s.b, s.c, s.d, s.e) for s in today] return render_to_response('tuples2csv.txt',{'records': results}, mimetype='text/plain', context_instance=RequestContext(request)) My template looks like this at this time: === {% for row in records %}{% for value in row %}{{value}},{% endfor %} {% endfor %} === The data looks like this - I've deleted much of the internal field content since it is proprietary information 7:55,,, 8:55,,, 11:25,,, 8:25,,xxx, = I guess I can always convert this to a text block in my view and respond with that, but it seems like I should be able to use the template system for a more generic solution. I've done a fair amount of googling on this but keep getting to the same examples that are close but not quite what I need. If someone can clarify how to eliminate the trailing ","I would really appreciate it. Thanks, Fred. -- 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: Walking the template / Partial rendering
Hey Tom I've had a look through previous tickets if something similar came up and also looked at the link you posted. It's the right direction, but not quite what I'm trying. Pulling out a single block from a template and rendering is easy. It breaks and throws an `AttributeError` though as soon as you've got a `{{ block.super }}` in the block you've pulled from the template due to the context not being fully assembled: http://dpaste.com/hold/670841/ Also, say I want to pick the block "map" from the parent template will not work without first walking manually up the chain, and again, build the context: http://dpaste.com/hold/670842/ Alen -- 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/-/sbqc07PVHbcJ. 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: urls.py?
On 12/09/2011 03:06 AM, Reinout van Rees wrote: On 09-12-11 01:28, Jim Byrnes wrote: from django.conf.urls.defaults import * from mysite import views from mysite.views import hello, current_datetime, hours_ahead, display_meta from django.contrib import admin from mysite.contact import views from mysite.books import views admin.autodiscover() urlpatterns = patterns('', (r'^hello/$', hello), (r'^time/$', current_datetime), (r'^time/plus/(\d{1,2})/$', hours_ahead), (r'^admin/' , include(admin.site.urls)), (r'^contact/$',views.contact), (r'^search-form/$', views.search_form), #from mysite.books (r'^search/$', views.search), # from mysite.books ) mysite.contact.views might very well have a contact() method, but mysite.books.views probably does not. And you're importing 'views' a couple of times at the top. The last "from mysite.books import views" is winning :-) You cannot have one variable point to several things at the same time. Best thing you can do: import mysite.contact.views import mysite.books.views ... (r'^contact/$', mysite.contact.views.contact), Reinout That worked and your explanation gave me a better understanding of how the process works. Thanks, Jim -- 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: urlresolver and custom Site model?
Great thanks for that. It definitely works now. -- 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: Walking the template / Partial rendering
On Fri, Dec 9, 2011 at 3:16 PM, Alen Mujezinovicwrote: > Whoops. Editor ate the formatting. Here's the correctly formatted > version: https://gist.github.com/d7b50c7449dfd09725ea > That version is much easier to read :) This ticket renders email contents from different blocks within a template: https://code.djangoproject.com/attachment/ticket/17193/send_templated_mail.3.diff Their code for finding and rendering a block looks pretty simple, and doesn't require changes to core to achieve it. Could it be applicable to your needs? Check out _render_block_node() Cheers Tom -- 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: Walking the template / Partial rendering
Whoops. Editor ate the formatting. Here's the correctly formatted version: https://gist.github.com/d7b50c7449dfd09725ea -- 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/-/n6YA8FHUauUJ. 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.
Walking the template / Partial rendering
Hi group I considered posting this to django-dev or opening a ticket but decided to erron the side of caution. I've been looking thoroughly through django's template code the last two daysbecause I'd like to render only parts of templates. Pseudocode: tpl = Template(""" {% block someblock %}foo{% endblock %} {% block otherblock %}bar{% endblock %} """) node = tpl.get_block("someblock") result = node.render(template.Context({})) The motivation to do this is to get rid of the overhead that goes into templates when dealing with reasonably AJAX heavy and complex templates. Thinkof a template structure like this: {% block body %} {% block map %}{% endblock %} {% block content %}{% endblock %} {% endblock %} {% extends "body.html" %} {% block map %}{% endblock %} {% block content %} {{ object_list|unordered_list }} {% endblock %} {% extends "map.html" %} {% block content %}{{ object }}{% endblock %} Ideally when requesting the page that serves pin.html via AJAX we'd want to serve only the content that is in {% block content %}. One way to do this {% extends "map.html" %} {% block content %}{% include "pin-detail.html" %}{% endblock %} And the corresponding view: def pin(request, id): #... if request.is_ajax(): tpl = loader.get_template("pin-detail.html") content = json.dumps(content = tpl.render(Context({'object': pin}))) return HttpResponse(content, mimetype = 'application/json') return render_to_response('pin.html', {'object': pin}) This gets very tedious with time and isn't desireable. So I came up with a mixin that gets rid of the repetition. It checks if the request is AJAX'd and if so, renders all the blocks listed in `self.partials`and `json.dump`'s the result to the HttpResponse. It all works, except: * {{ block.super }} does not work without resolving the whole chain of parent templates and building up the quite complex corresponding context. It's basically a copy of the first half of the `django.template.loader_tags.ExtendsNode.render` method. * Rendering blocks that are part of a parent template but not the current one fails because of the complexity of how the context for the current and its parent blocks are created. I figure building up the context properly is duplicating too much of django's internals to be sane work. Ignoring these two points, it all works very well - but I'd also like to be able to render blocks that do make use of {{ block.super }} and that can bedefined at any point in the template chain. Ideally the `BlockNode`, `ExtendsNode` and `Template` classes would provide some methods to walk the chain and build the context. Are you guys interested in having similar functionality? It would involve somerefactoring of the template internals and probably some decisions of the corecomitters - I wouldn't really want to change the `Template` class because itis the interface to adopt for third party template languages. Also, here's more pseudo code to illustrutate how the partial mixin looks whenused. class PinView(PartialRenderingView): template_name = 'pin.html' # Blocks to render and dump as json when doing AJAX requests partials = ['title', 'pin', 'form'] def get(request, id): # ... return self.render_to_response(request, pin = pin, form = form) def post(request, id): # ... return self.render_to_response(request, pin = pin, form = form) Anyway. Thoughts? Alen -- http://twitter.com/flashingpumpkin http://github.com/flashingpumpkin -- 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.
Building my own `like` system
I am thinking to build my own like system, as a way of learning various technologies including Javascript; and to gain a better understanding of authentication and XSS. Most importantly though, this will provide a fun project with which to learn DJango. Use-case: 1.Unique ID generated atop a little bit of Javascript code, for embedding in any website 2.When unique user presses this like button, a +1 is triggered to the 'score' of that UID 3.On unique user's profile, display what they like'd I'm unsure as where to start... how would I go about building this system? — i.e. Should I be looking at Pinax? Thanks for all suggestions, Alec Taylor -- 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: ignore case order by in Django
On Friday, 9 December 2011 05:04:23 UTC, ziggi wrote: > > Hi! > > I found only way to ordering query results ignorecase by using : > > Spam.objects.extra(select={'eggs_upper':'uppper(eggs)',order_by['eggs_upper']}) > > Maybe has another way to do this? > In MySQL, you can set the collation of your table to be case-insensitive. This affects all queries, though. -- DR. -- 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/-/xT-661H8jyIJ. 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: ignore case order by in Django
On Fri, Dec 9, 2011 at 12:41 PM, kenneth gonsalveswrote: > On Thu, 2011-12-08 at 21:04 -0800, ziggi wrote: >> Maybe has another way to do this? > > iequal, icontains ... OP is talking about case insensitive ordering, not querying (and he has the simplest way). Cheers Tom -- 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: ignore case order by in Django
On Thu, 2011-12-08 at 21:04 -0800, ziggi wrote: > Maybe has another way to do this? iequal, icontains ... -- regards Kenneth Gonsalves -- 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.
ignore case order by in Django
Hi! I found only way to ordering query results ignorecase by using : Spam.objects.extra(select={'eggs_upper':'uppper(eggs)',order_by['eggs_upper']}) Maybe has another way to do this? -- 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 help regarding the SAAS based django-web application
I am not asking the definition here see my website architecture requirement is having all the cod base on a single application and for all application is using a single database now need to maintain and develop a application . ex- Multiple Application Users access the same database and application is on single tennat architecture. so for above scenario i am asking!!! On Fri, Dec 9, 2011 at 4:58 PM, Marc Aymerichwrote: > > > On Thu, Dec 8, 2011 at 2:25 PM, pritesh modi wrote: > >> Hi guys >> >> Any one suggest me that how saas architecture based >> application is developed in django.which pattern and architecture way whole >> application is developed? also application to be pluggable can be reusable >> and applied on saas. >> >> provide me documentation or help on this topic if anyone has already >> developed in this way > > > > you have not searched "Django saas" in google yet, isn't it? > > > >> -- > > Marc > > -- > 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. > -- Pritesh Modi -- 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 help regarding the SAAS based django-web application
On Thu, Dec 8, 2011 at 2:25 PM, pritesh modiwrote: > Hi guys > > Any one suggest me that how saas architecture based > application is developed in django.which pattern and architecture way whole > application is developed? also application to be pluggable can be reusable > and applied on saas. > > provide me documentation or help on this topic if anyone has already > developed in this way you have not searched "Django saas" in google yet, isn't it? > -- Marc -- 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: String problem about creating user
On Fri, Dec 9, 2011 at 10:54 AM, Tsung-Hsienwrote: > Hello > If I use register page to create user, the string of username and > email displays u'' on command line, and if I create user on > command line, the string of username and email display ''. the > difference is one has the 'u' and the other doesn't. > > The important thing is: > When I want to filter the User object, the object views the string as > different character. Therefore, I can't get what I want, and the > object always return [ ]. > How to let the string does not display u'xxx' but 'xxx' ? > > I have the question because the PasswordResetForm of django, and find > the User.objects.filter(email__iexact=email, is_active=True) always > return [ ] > > and my view like this: > if request.method == 'POST': > form = RegistrationForm(request.POST) > if form.is_valid(): > user = User.objects.create_user( > username=form.cleaned_data['username'], > password=form.cleaned_data['password1'], > email=form.cleaned_data['email'] > ) > > > 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. > http://stackoverflow.com/questions/4810853/what-is-this-extra-character-python-puts-before-every-field-in-an-sql-query Cheers Tom -- 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.
String problem about creating user
Hello If I use register page to create user, the string of username and email displays u'' on command line, and if I create user on command line, the string of username and email display ''. the difference is one has the 'u' and the other doesn't. The important thing is: When I want to filter the User object, the object views the string as different character. Therefore, I can't get what I want, and the object always return [ ]. How to let the string does not display u'xxx' but 'xxx' ? I have the question because the PasswordResetForm of django, and find the User.objects.filter(email__iexact=email, is_active=True) always return [ ] and my view like this: if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = User.objects.create_user( username=form.cleaned_data['username'], password=form.cleaned_data['password1'], email=form.cleaned_data['email'] ) 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: Query with no-correspondence results
On Thu, Dec 8, 2011 at 8:45 PM, wgiswrote: > Ian Clelland, it worked! Thanks a lot for your perseverance > > Tom's secret sauce it's not working, unfortunately =( > Just (Carrots, Flavour, 3.0) > I guess since some 'contexts' don't have an associated thing-vote, the > filter will cut them off. > It would be more neat with the ORM, but I must be looking for a golden > a pot. > That is strange; it wasn't supposition, it was actual results from a working project. Perhaps sqlite behaves differently to other DBs with that query, as you can see from this data and transcript, it does precisely what you asked for, using the ORM: sqlite> select * from app_thing; id name -- -- 1 carrot sqlite> select * from app_votecontext; id name -- -- 1 Flavour 2 Smell 3 Usability 4 Size sqlite> select * from app_vote; id thing_idcontext_id user_id vote -- -- -- -- -- 1 1 1 1 2 2 1 1 2 4 >>> from app.models import * >>> from django.db.models import * >>> carrot = Thing.objects.get(name='carrot') >>> u=User.objects.get(id=1) >>> f=(Q(vote__thing=carrot) | Q(vote__isnull=True))\ ...& (Q(vote__user=u) | Q(vote__isnull=True)) >>> qs = VoteContext.objects.filter(f) >>> qs = qs.annotate(vote_value=Sum('vote__vote')) >>> for ctxt in qs: print ctxt.name, ctxt.vote_value ... Flavour 2.0 Smell None Usability None Size None -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Template Renderer safe if used with URL parameters?
@Mathew ,am sorry i don't know is it safe or not,Its the one of the question I wished to ask to some one.I think most of the applications use ajax get methods ,since its faster. -- 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: urls.py?
On 09-12-11 02:23, Mario Gudelj wrote: I think you have to add "from views import *" to urls.py and make sure you have a method called contact in your view. Doing a "star import" is almost always a bad idea. You don't know what you're importing. And you can override variables by accident that way. Better to explicitly import what you need. In this case the problem was that the original poster imported 'view' a few times from different places. Doing a "*" import would only make that problem worse :-) Reinout -- Reinout van Reeshttp://reinout.vanrees.org/ rein...@vanrees.org http://www.nelen-schuurmans.nl/ "If you're not sure what to do, make something. -- Paul 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: urls.py?
On 09-12-11 01:28, Jim Byrnes wrote: from django.conf.urls.defaults import * from mysite import views from mysite.views import hello, current_datetime, hours_ahead, display_meta from django.contrib import admin from mysite.contact import views from mysite.books import views admin.autodiscover() urlpatterns = patterns('', (r'^hello/$', hello), (r'^time/$', current_datetime), (r'^time/plus/(\d{1,2})/$', hours_ahead), (r'^admin/' , include(admin.site.urls)), (r'^contact/$',views.contact), (r'^search-form/$', views.search_form), #from mysite.books (r'^search/$', views.search), # from mysite.books ) mysite.contact.views might very well have a contact() method, but mysite.books.views probably does not. And you're importing 'views' a couple of times at the top. The last "from mysite.books import views" is winning :-) You cannot have one variable point to several things at the same time. Best thing you can do: import mysite.contact.views import mysite.books.views ... (r'^contact/$', mysite.contact.views.contact), Reinout -- Reinout van Reeshttp://reinout.vanrees.org/ rein...@vanrees.org http://www.nelen-schuurmans.nl/ "If you're not sure what to do, make something. -- Paul 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.