Re: Open source CMS (if based on Django better)
On Wed, May 5, 2010 at 9:52 PM, Jonatan.mv wrote: > What would be you recommended CMS?. Could you please give some reasons > (pro and cons)?. > > I'm investigating on these: > > - PyLucid v0.8.x stable, v0.9 alpha > - FeinCMS v1.1.0 stable > - django-simplecms > - django-cms-2.0 2.0.2 stable , 2.1 alpha > - google-sites > Disclaimer: I'm the primary author of FeinCMS, so my view is obviously biased. I won't give a recommendation and will let others speak up. That being said, there's still some advice I'd like to give. Some of these packages have different goals than other: FeinCMS and Django-CMS are primarily page oriented CMS. Both have plugins, which can be used to integrate other types of content than only rich text / plain text content snippets. On the other hand, simplecms and PyLucid offer more modules for structured content (like articles, blog entries etc) and therefore do more, but you might not need all functionality they offer. Using those might give you a head start compared to Django-CMS or FeinCMS though, but I'm not sure about that because I've never taken a deeper look at them. google-sites ... this is a list concerning Django, so google sites is off-topic, and I'm not sure whether you can use google sites for your own webpages at all, at least if you have requirements for styling, functionality which do not align well with what google sites is currently offering. Btw, did you take a look at the following page on the Django wiki? http://code.djangoproject.com/wiki/CMSAppsComparison Thanks, Matthias -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.2 release candidate available
I've been using the beta for a while and it works pretty good for what I've seen. On May 6, 6:40 am, James Bennett wrote: > Tonight we're proud to announce, finally, the first Django 1.2 release > candidate. If all goes well, it will also be the *only* release > candidate, and Django 1.2 final will release one week from today. > > For more information, consult: > > * The Django project > weblog:http://www.djangoproject.com/weblog/2010/may/05/12-rc-1/ > * The release notes:http://docs.djangoproject.com/en/dev/releases/1.2-rc-1/ > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
where can I find good unit test examples?
Hi All, Where can I find good examples of django unit tests? I currently just want to test my models and some helper functions, but they will do a .save() on a bunch of model instances. Any help gratefully recieved! Chris -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Syntax for displaying field values from parent model(s) in a template?
On May 5, 9:15 pm, Daniel Roseman wrote: > On May 5, 6:27 pm, Derek wrote: > > > > > I have set of models, with relationships D -> C -> B -> A, where the > > "->" indicates a "many to one" relationship. > > > I have been able to create a filtered queryset on child model D, based > > on a value in a parent model A, using the following syntax: > > > my_query = D.objects.filter(C__B__A__name__icontains = "foo") > > > where model A has a field called "name". > > > I need to be able to display the value of the "name" field from A, > > along with the field attribute data from D in a template. > > > I have therefore added the following to the end of my_query: > > > .select_related('C__B__A__name') > > > Assuming the template is called with the context containing: > > > 'results': my_query > > > then I can use {{ results.name }}, for example, to retrieve the value > > of the "name" field from model D. > > > However I am unable to figure out the correct syntax for retrieving > > the value of the "name" field from related model A. > > > I have tried {{ results.C.B.A.name }} with no effect? > > > What is the correct way to do this? > > > Thanks > > Derek > > Firstly, your select_related syntax is wrong. You don't need it to > access related objects, but it does help cut down on db queries. > However, it doesn't go down to field level, so you just want > 'C__B__A'. > > Secondly, your 'results' object is a queryset, so you *can't* do > 'results.name' as you claim. A queryset is a collection of items, not > a single one, so 'results' as a whole doesn't have either 'name' or > 'C' attributes. However, once you iterate through the queryset, each > individual item inside it does have both 'name' and 'C' attributes. So > this will work: > > {% for result in results %} > {{ result.name }} : {{ result.C.B.A.name }} > {% endfor %} > > An easy way of exploring all this is via the shell - you could have > seen the result of your query there, and accessed the individual > objects and their attributes. > -- > DR. Daniel Thanks for the heads-up about working in the shell. I have found out more useful commands and syntax in doing so (e.g. showing the SQL from the query via my_query.query.as_sql() ). I had the right idea (e.g. I was working with the {% for result in results %} loop, even though I did not indicate that to the original question) . The root of the problem was that my model relationships were incorrect i.e. D <- C -> B -> A and so I had to restructure the query. Derek -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
MacPorts installation, Django $PATH issue
Hi everybody I just got Django installed (to test it) via Macports and I have Python 2.5 and 2.6 installed on a MacBook running 10.6.3. I did everything the installation guide told me, but after typing: python manage.py runserver I get this error: File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management I believe the solution would be this comment on the installation site: To avoid a command not found issue with Snow Leopard 10.6.2 and various other OSX (Django installed using MacPorts?) here a tip that might help. There might be a $PATH issue. Adding the proper PATH to ~/.Profile: export PATH=/opt/local/bin:opt/local/sbin:/opt/local/lib/ python2.4/site-packages/django/bin:$PATH should help. NB Could be that one needs to change the Python version in the PATH. But I dont now what a $PATH issue is and where I could paste this code to fix it. Or if you know another possible reason please tell me. Any help would be greatly appreciated. Thanks a lot Best Z. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
access value from request.GET.get in request.method == 'POST
Hi to everybody. I am a django and python newbie and I hope that someone can help me here. This is my first post here. I will first explain my problem very abstractly to confine myself to only the bare necessities. I define a function "process" in a views.py file. BEGIN Code def process(request, template_name) token = request.GET.get('token', ' ') ... if request.method == 'GET': some_details = getDetails(token) if 'Success' in some_details['ACK'] email_adress = some_details['EMAIL'][0] first_name = some_details['FIRSTNAME'][0] ... return render_to_response(template_name, ---> locals(), context_instance=RequestContext(request)) if request.method == 'POST': details_response = doSomething(token = token) # everytime I enter this, I get empty token if 'Success' in details_respone['ACK']: ... else: error_code = details_response['L_ERRORCODE0'] return render_to_response(template_name, ---> locals(), context_instance=RequestContext(request)) END Code My question is: how can I access the value for token when polling the if request.method == 'POST' I would appreciate 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: QuerySet.distinct and aggregates
> The actual call I had tried was > Payment.objects.filter(appliedpayment__invoice__location=loc).distinct().ag > gregate(Sum('amount')) > (where amount is a field on Payment). I could do > AppliedPayment...aggregate(...), but unfortunately the AppliedPayment > splits the 'amount' into several values (based on revenue type), which > would mean doing several aggregate calls and summing them, which I've > already done when it seemed appropriate (and I just discovered while > writing this that aggregate can take more than one argument, but I > don't know if that results in a single query). Multiple aggregates within the same aggregate(), I'm 99% sure, are put into a single query, at least if they're simple and not spanning complex relationships themselves. > For now, when I know > there's generally going to be less than a dozen instances, I've just > done the processing in python, which I'm sure will work fine. > > I was hoping for an elegant solution for when I know there's going to > be several thousand plus instances (or hundreds of thousands after a > year or two of deployment). So in the end, I guess I can work with it, > but mostly I was hoping to find out whether the whole respecting > distinct() thing could be made to happen. Yeah, that's a tricky use case no matter what. I don't think there's a way out of *something* doing some heavy lifting, whether it be python or the db. But as I've seen mentioned many times (often by Malcolm...where's a Malcolm bat-signal when you need one? I'd love to hear his thoughts on this) the ORM isn't designed and can't be expected to handle 100% of cases. This may indeed be a situation where a simple extra() actually *is* the elegant solution. > Dunno if it's worthwhile filing a ticket for it, or if there is one. > Or maybe just a doc ticket for mentioning explicitly that aggregate > ignores distinct. Certainly agree with this. Sorry I couldn't be more help! Regards Scott -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: access value from request.GET.get in request.method == 'POST
First thing would be to ensure that when you submit the form back to itself, the querystring remains. It's all well and good to visit a form like this: /someapp/myform/?token=blah But if your HTML form tag is: Then you'll lose the "?token=blah" part when you submit. Other than that, nothing I can spot in there that would case token to be blank. In other words, a request made with POST still has any arguments in the querystring accessible via request.GET. I'd break the code right after you extract the token: token = request.GET.get('token', ' ') assert False ...and inspect the value of token in the state output. If it looks fine there, just keep moving that "assert False" down till you find where the value is getting lost. Regards Scott > Hi to everybody. I am a django and python newbie and I hope that > someone can help me here. > This is my first post here. > > I will first explain my problem very abstractly to confine myself to > only the bare necessities. > > I define a function "process" in a views.py file. > > BEGIN Code > > def process(request, template_name) > token = request.GET.get('token', ' ') > ... > if request.method == 'GET': > some_details = getDetails(token) > > if 'Success' in some_details['ACK'] > email_adress = some_details['EMAIL'][0] > first_name = some_details['FIRSTNAME'][0] > ... > return render_to_response(template_name, ---> > locals(), context_instance=RequestContext(request)) > > if request.method == 'POST': > details_response = doSomething(token = token) # everytime I > enter this, I get empty token > if 'Success' in details_respone['ACK']: > ... > else: > error_code = details_response['L_ERRORCODE0'] > return render_to_response(template_name, ---> > locals(), context_instance=RequestContext(request)) > > END Code > > My question is: how can I access the value for token when polling the > if request.method == 'POST' > > I would appreciate 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Grappelli - TinyMCE only works in Firefox
Hi All, We're using Grappelli in the admin of a Django site we're building. Weirdly, the TinyMCE text editor only shows up in Firefox. Has anyone else run into this? I've been scouring the Net and the TinyMCE wiki for clues but so far no luck. Any help would be greatly appreciated. TIA -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: access value from request.GET.get in request.method == 'POST
On 6 Mai, 14:35, zinckiwi wrote: > First thing would be to ensure that when you submit the form back to > itself, the querystring remains. It's all well and good to visit a > form like this: > > /someapp/myform/?token=blah > > But if your HTML form tag is: > > > > Then you'll lose the "?token=blah" part when you submit. my HTML form tag is as follows: How can I avoid losing the "?token=blah" part? I think this could be the problem. > > Other than that, nothing I can spot in there that would case token to > be blank. In other words, a request made with POST still has any > arguments in the querystring accessible via request.GET. > > I'd break the code right after you extract the token: > > token = request.GET.get('token', ' ') > assert False I don't konow exactly what you mean with this. Is this some kind of debug possibility? > > ...and inspect the value of token in the state output. If it looks > fine there, just keep moving that "assert False" down till you find > where the value is getting lost. > > Regards > Scott > > > > > Hi to everybody. I am a django and python newbie and I hope that > > someone can help me here. > > This is my first post here. > > > I will first explain my problem very abstractly to confine myself to > > only the bare necessities. > > > I define a function "process" in a views.py file. > > > BEGIN Code > > > def process(request, template_name) > > token = request.GET.get('token', ' ') > > ... > > if request.method == 'GET': > > some_details = getDetails(token) > > > > if 'Success' in some_details['ACK'] > > email_adress = some_details['EMAIL'][0] > > first_name = some_details['FIRSTNAME'][0] > > ... > > return render_to_response(template_name, ---> > > locals(), context_instance=RequestContext(request)) > > > if request.method == 'POST': > > details_response = doSomething(token = token) # everytime I > > enter this, I get empty token > > if 'Success' in details_respone['ACK']: > > ... > > else: > > error_code = details_response['L_ERRORCODE0'] > > return render_to_response(template_name, ---> > > locals(), context_instance=RequestContext(request)) > > > END Code > > > My question is: how can I access the value for token when polling the > > if request.method == 'POST' > > > I would appreciate 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Grappelli - TinyMCE only works in Firefox
TinyMCE works in every browser ... you just need to change the setup- file, see http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/browsers regards, patrick On 6 Mai, 14:53, django_jedi wrote: > Hi All, > > We're using Grappelli in the admin of a Django site we're building. > Weirdly, the TinyMCE text editor only shows up in Firefox. Has anyone > else run into this? > > I've been scouring the Net and the TinyMCE wiki for clues but so far > no luck. > > Any help would be greatly appreciated. > > TIA > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: where can I find good unit test examples?
Hi Chris, First of all, I never had much luck writing reproducible tests for Django models with the fixture system that comes built into Django as I never got consistent results and found the XML a pain to maintain. I came across Fixture - http://code.google.com/p/fixture/ We have this running with our Django installation for all our unittests and it works a treat. There are some examples of unittests in the source for that. I've used that in an open source project called Django audit to test some model related bits and pieces, but I wouldn't necessarily attest to their being "good tests" as it's a work in progress. Have a look at https://launchpad.net/django-audit/ in the tests section. For good unittesting in general in a Django type manner (but not specifically model related) have a look at http://pypi.python.org/pypi/twod.wsgi/ Hope this helps, Euan On May 6, 9:23 am, Chris Withers wrote: > Hi All, > > Where can I find good examples of django unit tests? > > I currently just want to test my models and some helper functions, but > they will do a .save() on a bunch of model instances. > > Any help gratefully recieved! > > Chris > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Converting a urlib2 response to a django one
Hello everyone, I'm trying to make a django-view that proxies the contents of a file from another URL. This mostly works (I realize some error handling is still needed): def digitalObject(request, id): import base64 import urllib2 url="http://some.url.com/somefile"; req = urllib2.Request(url) resp = urllib2.urlopen(req) objfile = resp.read() response = HttpResponse(objfile) return response but I'd like to avoid copying one by one the header elements of the original response (resp) to the HttpResponse (response). I mean, elements like, the mimetype, the Content-Disposition, etc. Is there a better way to convert a urlib2 response to a django one? Thanks, Filipe -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Disabling (or find a workaround for) the comment security checks
Disclaimer: Disabling the security stuff makes it really likely you'll get comment spammed. You should set up some kind of akismet protection on the backend if you disable the security. If you don't want the checking then you probably want a custom comment form. You can use this method to setup a new form: http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#django.contrib.comments.get_form Then use the form base classes with the functionality you want. (You'll probably want to exclude the CommentSecurityForm, and include the generic foreign key information some other way.) http://docs.djangoproject.com/en/dev/ref/contrib/comments/forms/ Hope that helps! Alex On May 5, 5:59 pm, Federico Capoano wrote: > Hello to all, > > I've just launched my new web-site powered by django and i'm very > satisfied. > > I've implemented StaticGenerator to improve the performance and > loading speed and I have to admit is brilliant. > > Unfortunately i've noticed the comment system doesn't work. This > happens because the pages of the blog are saved as static html pages, > so the timestamp and csfr security stuff are the one saved when the > page was generated. > > I gotta find a fix for this, because I really want my blog pages to be > saved as static html cos this is the best solution to obtain fast > loading speed without overloading my little VPS. > > I think I can generate the timestamp with javascript, but what about > the other two fields (csrfmiddlewaretoken and security hash)? > > If you want to take a look closely this is the > url:http://nemesisdesign.net/blog/ > I hope i'm not breaching any rule by posting the url. > > Thanks > Federico > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Converting a urlib2 response to a django one
You could do it quite easily with twod.wsgi and Paste: """ from paste.proxy import Proxy from twod.wsgi import make_wsgi_view class ProxyRemoteFile(Proxy): def __call__(self, environ, start_response): environ['PATH_INFO'] = "/fixed/path/to/file" return super(ProxyRemoteFile, self).__call__(environ, start_response) proxy_app = ProxyRemoteFile("some.url.com", ["GET"]) # This is the Django view that you can attach to any URLConf: proxy_view = make_wsgi_view(proxy_app) """ More info here: http://packages.python.org/twod.wsgi/ http://pythonpaste.org/modules/proxy.html On May 6, 2:34 pm, Filipe Correia wrote: > Hello everyone, > > I'm trying to make a django-view that proxies the contents of a file > from another URL. > > This mostly works (I realize some error handling is still needed): > > def digitalObject(request, id): > import base64 > import urllib2 > url="http://some.url.com/somefile"; > req = urllib2.Request(url) > resp = urllib2.urlopen(req) > objfile = resp.read() > response = HttpResponse(objfile) > return response > > but I'd like to avoid copying one by one the header elements of the > original response (resp) to the HttpResponse (response). I mean, > elements like, the mimetype, the Content-Disposition, etc. > Is there a better way to convert a urlib2 response to a django one? > > Thanks, > Filipe > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
customizing emailed error messages
When I get an unexpected error in my mod_wsgi/Django application, I'm emailed a very nice error message with a stack trace and all the HTTP environment variables (GET, POST, META, etc.) That's great, but it does not include the name of the logged-in user. Is there a way for me to add that information (or other useful stuff) to the error message that is emailed? I'm guessing it's a template somewhere, but I can't find it -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Converting a urlib2 response to a django one
On May 6, 3:35 pm, Gustavo Narea wrote: > More info here: > http://packages.python.org/twod.wsgi/ Sorry, I meant: http://packages.python.org/twod.wsgi/manual/embedded-apps.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Disabling (or find a workaround for) the comment security checks
Also, as I think more about this, are you sure you need static generator? You might get sufficient speed just by using cache. Premature optimization is bad On May 6, 8:37 am, Alex Robbins wrote: > Disclaimer: > Disabling the security stuff makes it really likely you'll get comment > spammed. You should set up some kind of akismet protection on the > backend if you disable the security. > > If you don't want the checking then you probably want a custom comment > form. > You can use this method to setup a new > form:http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#dja... > > Then use the form base classes with the functionality you want. > (You'll probably want to exclude the CommentSecurityForm, and include > the generic foreign key information some other > way.)http://docs.djangoproject.com/en/dev/ref/contrib/comments/forms/ > > Hope that helps! > Alex > > On May 5, 5:59 pm, Federico Capoano wrote: > > > > > Hello to all, > > > I've just launched my new web-site powered by django and i'm very > > satisfied. > > > I've implemented StaticGenerator to improve the performance and > > loading speed and I have to admit is brilliant. > > > Unfortunately i've noticed the comment system doesn't work. This > > happens because the pages of the blog are saved as static html pages, > > so the timestamp and csfr security stuff are the one saved when the > > page was generated. > > > I gotta find a fix for this, because I really want my blog pages to be > > saved as static html cos this is the best solution to obtain fast > > loading speed without overloading my little VPS. > > > I think I can generate the timestamp with javascript, but what about > > the other two fields (csrfmiddlewaretoken and security hash)? > > > If you want to take a look closely this is the > > url:http://nemesisdesign.net/blog/ > > I hope i'm not breaching any rule by posting the url. > > > Thanks > > Federico > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: access value from request.GET.get in request.method == 'POST
> my HTML form tag is as follows: > > > > How can I avoid losing the "?token=blah" part? I think this could be > the problem. You'll want to replace it with this: As explained here: http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_full_path > > assert False > > I don't konow exactly what you mean with this. Is this some kind of > debug possibility? An "assert" immediately stops execution if the expression evaluates to false. So "assert False" just stops the view dead in its tracks. You can then inspect the state of your view, including all the variables, providing you have settings.DEBUG set to true. Regards Scott -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: access value from request.GET.get in request.method == 'POST
Thank you Scott. Now I can access the "?token=blah" part. This was a very fast and painless help. I will learn more about Post and Get requests. Best regards Said PS: How can I vote for you? On 6 Mai, 17:04, zinckiwi wrote: > > my HTML form tag is as follows: > > > > > > How can I avoid losing the "?token=blah" part? I think this could be > > the problem. > > You'll want to replace it with this: > > > > As explained here: > > http://docs.djangoproject.com/en/dev/ref/request-response/#django.htt... > > > > assert False > > > I don't konow exactly what you mean with this. Is this some kind of > > debug possibility? > > An "assert" immediately stops execution if the expression evaluates to > false. So "assert False" just stops the view dead in its tracks. You > can then inspect the state of your view, including all the variables, > providing you have settings.DEBUG set to true. > > Regards > Scott > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to adapt some code provided by friend
Hey Frank, Thanks for the advice. I'm gonna do that as well ;-) Cheers, 2010/5/5 Frank > I hate to chime in here but I recently started using Django, quite > successfully. I'm also a consent-student. I fear that you are going to > have a lot of trouble using Django (or anything like it) if you don't > build some basics. > > To successfully use a product like Django, basic knowledge of at least > database administration will go along way. I'd also highly suggest you > go though a Intro-to-python book. (The book Dive In To python is > online: http://diveintopython.org/toc/index.html) > > Don't get me wrong, you don't need to be an expert -- or even close -- > of anything to use these tools. But, some basic knowledge will take > you a long way when trying to determine what a problem might be or how > to go about something. > > Regards, > Frank (tOSU) > > On May 5, 7:05 am, Etienne Python wrote: > > Well actually, I copied all of the data (including the database), not > only > > the code. But indeed, like you say, the problem is not solved yet just by > > installing mysql. > > > > So I followed the alternative solution you suggested. Now I get another > > error actually: when I run ./manage.py syncdb like you suggested I get > the > > following message in the cmd: > > > > Error: No module named redis_cache.cache > > > > I must admit I'm lost ;-) > > > > 2010/5/5 Daniel Roseman > > > > > > > > > On May 5, 12:23 pm, Etienne Python wrote: > > > > > > File > "c:\python26\lib\site-packages\django\db\backends\mysql\base.py", > > > > line 13, in > > > >raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) > > > > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb > > > > module: No module named MySQLdb > > > > > As Georg says, you need to install MySQLdb. However I suspect that > > > that won't solve your problem: if all you've done is copied the Django > > > code from the server, there'll be a whole stack of things you don't > > > have, starting with the database itself. If you need the actual data > > > from the server, you'll need to install MySQL itself as well, then > > > back up the data from the server and restore it to your local > > > database. > > > > > If you don't, you can probably shortcut this whole process by simply > > > using sqlite - in your settings.py, change DATABASE_ENGINE to > > > 'sqlite3' and your DATABASE_HOST to a filename, something like > > > 'data.db'. Then run ./manage.py syncdb to create the empty database. > > > -- > > > DR. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com > > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > > For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Converting a urlib2 response to a django one
Hi, Thanks for the reply! This looks neat. Although, right now I would rather not depend on two additional packages if I can :\ I think I'll settle with copying a few headers manually for now: def digitalObject(request, id): import base64 import urllib2 url="http://some.url.com/somefile"; req = urllib2.Request(url) resp = urllib2.urlopen(req) objfile = resp.read() response["Expires"] = resp.info().getheader("Expires") response["Content-Disposition"] = resp.info().getheader("Content- Disposition") response["Date"] = resp.info().getheader("Date") response["Content-Type"] = resp.info().getheader("Content-Type") return response Filipe On May 6, 3:35 pm, Gustavo Narea wrote: > You could do it quite easily with twod.wsgi and Paste: > > """ > from paste.proxy import Proxy > from twod.wsgi import make_wsgi_view > > class ProxyRemoteFile(Proxy): > def __call__(self, environ, start_response): > environ['PATH_INFO'] = "/fixed/path/to/file" > return super(ProxyRemoteFile, self).__call__(environ, > start_response) > > proxy_app = ProxyRemoteFile("some.url.com", ["GET"]) > > # This is the Django view that you can attach to any URLConf: > proxy_view = make_wsgi_view(proxy_app) > """ > > More info > here:http://packages.python.org/twod.wsgi/http://pythonpaste.org/modules/proxy.html > > On May 6, 2:34 pm, Filipe Correia wrote: > > > > > > > Hello everyone, > > > I'm trying to make a django-view that proxies the contents of a file > > from another URL. > > > This mostly works (I realize some error handling is still needed): > > > def digitalObject(request, id): > > import base64 > > import urllib2 > > url="http://some.url.com/somefile"; > > req = urllib2.Request(url) > > resp = urllib2.urlopen(req) > > objfile = resp.read() > > response = HttpResponse(objfile) > > return response > > > but I'd like to avoid copying one by one the header elements of the > > original response (resp) to the HttpResponse (response). I mean, > > elements like, the mimetype, the Content-Disposition, etc. > > Is there a better way to convert a urlib2 response to a django one? > > > Thanks, > > Filipe > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Working out some custom API stuff
Thanks for the help on that portion, it is working wonderfully. I've been able to power through most of the requests for this project but there is one outstanding element in regards to pagination. Here is my view: def QandAAPI(request, site): quest = entry.objects.filter(site__name__icontains=site) if 'id' in request.GET: ids = request.GET.getlist('id') quest = quest.filter(id__in=ids) if 'sect' in request.GET: sect = request.GET.getlist('sect') quest = TaggedItem.objects.get_by_model(quest, sect) if 's' in request.GET: s = request.GET['s'] search_query = ( Q(question__icontains=s) | Q(answer__icontains=s) | Q(answerer__icontains=s) ) quest = quest.filter(search_query) if 'count' in request.GET and not 'page' in request.GET: count = request.GET['count'] quest = quest[:count] if 'count' in request.GET and 'page' in request.GET: page = int(request.GET['page']) count = request.GET['count'] paginator = Paginator(quest, count) try: page = paginator.page(page) except ValueError: page = 1 json = serializers.serialize("json", quest) return HttpResponse(json) I am getting the following error when I try to plug a page=1 into the URL coercing to Unicode: need string or buffer, int found I'm not entirely sure how to fix this error, I've tried many times. The final view should do the following: Check to see if 'page' and 'coutn' are part of the url. If they are, then pull up the results of that page with the count declared in the URL. There will be another component that will skip the 'count' if it isn't declared but I haven't got there yet. On May 5, 4:11 am, Daniel Roseman wrote: > On May 5, 4:46 am, Nick wrote: > > > > > Here's the deal. I'm working on a customAPIfor moving information > > about. I am stuck at a point in creating my view. > > It might be best just to get into the details. > > > Here is the model: > > > class entry(models.Model): > > question = models.CharField('Question', max_length=200, > > blank=False) > > answer = models.TextField('Answer', blank=False) > > answerer = models.CharField("Expert's Name", max_length=100, > > blank=False) > > credentials = models.CharField ("Expert's Credentials", > > max_length=100, blank=False) > > published = models.DateTimeField(auto_now_add=True) > > updated = models.DateTimeField(auto_now=True) > > site = models.ForeignKey(Site) > > section = TagField() > > > Once a site is picked the feed is narrowed down by id (whether single > > id, list or range), then by section (single or multiple) and finally > > some pagination and count params (I'm not worried about that right > > now). Currently, I am stuck on the section portion. I may be going > > about this all wrong. What I would like is for some URL like: > > >http://mysite.com/qanda/SITENAME/?sect=THESECTIONNAME > > > to produce a JSON output of Questions and Answers under that site with > > that section name. Here is my view: > > > def QandAAPI(request, site): > > quest = entry.objects.filter(site__name__icontains=site) > > if 'id' in request.GET: > > id = request.GET.get('id','') > > id = id.split(',') > > else: > > id = quest.values_list('id', flat=True) > > if 'sect' in request.GET: > > sect = request.GET.get('sect','') > > else: > > sect = '' > > quest = quest.filter(id__in=id, section=sect) > > object = serializers.serialize("json", quest) > > json = "%s" % object > > return HttpResponse(json) > > > Basically, I would like the "else: sect=" to be a WILDCARD so if the > > sect portion of theAPIisn't explicitly stated then it just pulls > > everything. > > > What do you think? Raw SQL? I'm a complete bonehead? All opinions/ > > advice are welcome. > > I wouldn't call you a bonehead, but the method you're using to get all > the objects when no id is passed in is... well... special. > > The key to doing this sort of filtering is to remember that QuerySets > are lazy, and successive filters can be applied to them without > hitting the database, until the time comes to actually evaluate them. > So what you want to do is to set up the base query at the start of the > method, then further filter it depending on the GET parameters. Then, > if a particular parameter isn't passed in, you simply don't filter on > it. Something like: > > def QandAAPI(request, site): > quest = entry.objects.filter(site__name__icontains=site) > if 'id' in request.GET: > ids = request.GET.getlist('id') > quest = quest.filter(id__in=ids) > if 'sect' in request.GET: > sect = request.GET['sect'] > quest = quest.filter(section=sect) > json = serializers.serialize("json", quest) > return HttpResponse(json) > > (Also note that I'm using getlist for the 'id' parameter - that > enables you to g
Re: where can I find good unit test examples?
Perhaps I'm missing something, but when I run "manage.py test", the system sets up a test database So you should be able to create all the model elements you need, and save them and change them -- whatever. In fact, what I do is during the setUp(...) routine, I add my "stock" test data. It'll create 1000ish records with proper references. This is all done within the confines of the Django framework. Then, in tearDown(), I delete all the data and the next unit test re-setups... My implementation actually uses a base class. In this way, I can have multiple base unittest classes that setup data in a particular way. This design not particular efficient -- it's contently creating and deleting data. But it does satisfy the standard unit test requirement that each test is independent of other tests. Either order or expected data. While I'm sure it has it's down falls, it works very well for my system. Frank [tOSU] http://blog.theOpenSourceU.com/ On May 6, 3:23 am, Chris Withers wrote: > Hi All, > > Where can I find good examples of django unit tests? > > I currently just want to test my models and some helper functions, but > they will do a .save() on a bunch of model instances. > > Any help gratefully recieved! > > Chris > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django App and Memory Mgmt
I have a Django app that selects one of many possible XML documents, parses it with minidom.parse(), finds all elements of a certain tag with getElementsByTagName() then it sends a small subset of those elements off to a client browser. So I typically have to parse many thousands of elements to make the DOM object to then get the appropriate 50 or 100 element portion that will be sent off to the user as a smaller XML file where it is parsed at the client side with javascript. My memory performance with Apache and mod_wsgi isn't very good, and I assume that's because I parse the whole file into memory, and also because getElements creates another large object before I can extract my desired elements. I do a bit of scrutinizing and massaging of them before they get wrapped up and sent on. I'd like to call unlink() on the big objects, but I don't know that I can do that somewhere, as I 'return' the small subset, and I don't have control after that is returned by Django to the requestor. Any thoughts on a) is this a big contributor to my memory footprint? b) wouldn't this all be garbage collected after the response is handled anyway? c) would I be better off with a SAX parsing of the XML file to avoid building the whole DOM tree to get my small subset of objects? Your thoughts appreciated. Is there a better way? I wouldn't want to stuff the XML-file resident content into a database and rebuild the XML element subsets because there are tons of files arriving and disappearing and it would become a huge background activity for another program. Ross. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.2 release candidate available
Awesome! Thanks so much! On May 6, 3:32 am, Federico Capoano wrote: > I've been using the beta for a while and it works pretty good for what > I've seen. > > On May 6, 6:40 am, James Bennett wrote: > > > > > > > Tonight we're proud to announce, finally, the first Django 1.2 release > > candidate. If all goes well, it will also be the *only* release > > candidate, and Django 1.2 final will release one week from today. > > > For more information, consult: > > > * The Django project > > weblog:http://www.djangoproject.com/weblog/2010/may/05/12-rc-1/ > > * The release notes:http://docs.djangoproject.com/en/dev/releases/1.2-rc-1/ > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > > correct." > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django App and Memory Mgmt
On Thu, May 6, 2010 at 1:40 PM, Ross wrote: > Your thoughts appreciated. Is there a better way? I wouldn't want to > stuff the XML-file resident content into a database and rebuild the > XML element subsets because there are tons of files arriving and > disappearing and it would become a huge background activity for > another program. if your XML docs are too transient, then it's not a job for a database. if you're getting repeated queries, or if several queries need some xml elements repeatedly, you could simply use a cache to avoid the repeats. If each xml element is used very few times, but you think a good proportion of them is going to be required before becoming outdated, then you could preprocess them as they arrive, instead of waiting for the request. i guess that processing a whole document would produce several results much faster than searching each individually. to avoid the load on a RDBMS, you might find better to store the preprocessed results on a key/value store, maybe even a memory-resident one, like redis. -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ERROR: Caught UnicodeEncodeError while rendering: 'ascii' codec
Sorry for the delayed response - And yeah, I'm using cmemcached - looks like the django docs have been updated in the past month to show it's deprecated. Thanks! On Apr 19, 9:08 am, Karen Tracey wrote: > On Sun, Apr 18, 2010 at 3:54 AM, Michael Strickland > wrote: > > > > > > > Temporary fix: > > > It appears to be a result of changeset [12637] in memcached.py: > >http://code.djangoproject.com/changeset/12637 > > > # memcached.py, lines 53-54 removed in def set() > > 53: if isinstance(value, unicode): > > 54: value = value.encode('utf-8') > > > In my templates at least, this means that before 12637, memcached.py > > converted the data from > > to before saving it. It no > > longer does this conversion, which appears to be necessary at least > > for some users. > > > I was able to fix it by adding those two lines back in to > > memcached.py, so the data is converted before the cache attempts to > > save it. > > > Not to familiar with memcached - any reason it wouldn't be able to > > digest the unconverted data? I can't tell if this is something that > > was overlooked when 12637 was adopted, or whether Willem and I have > > something wrong with our caches... > > Which Python memcached bindings are you using -- cmemcached or > python-memcached? > > Karen > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.2 release candidate available
Awesome Job, thanks everyone. Vitaly Babiy On Thu, May 6, 2010 at 2:53 PM, Nick Serra wrote: > Awesome! Thanks so much! > > On May 6, 3:32 am, Federico Capoano wrote: > > I've been using the beta for a while and it works pretty good for what > > I've seen. > > > > On May 6, 6:40 am, James Bennett wrote: > > > > > > > > > > > > > Tonight we're proud to announce, finally, the first Django 1.2 release > > > candidate. If all goes well, it will also be the *only* release > > > candidate, and Django 1.2 final will release one week from today. > > > > > For more information, consult: > > > > > * The Django project weblog: > http://www.djangoproject.com/weblog/2010/may/05/12-rc-1/ > > > * The release notes: > http://docs.djangoproject.com/en/dev/releases/1.2-rc-1/ > > > > > -- > > > "Bureaucrat Conrad, you are technically correct -- the best kind of > correct." > > > > > -- > > > You received this message because you are subscribed to the Google > Groups "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > > > For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > > For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django App and Memory Mgmt
Reading more it sounds like the memory usage issue, particularly for those exploring Webfaction, is a typical rite of passage, and probably has more to do with httpdconf and mod_wsgi setup than it does with Django practices. Lots of discussion here. (I hope this forum allows html, otherwise that's a messy link :) On May 6, 3:14 pm, Javier Guerra Giraldez wrote: > On Thu, May 6, 2010 at 1:40 PM, Ross wrote: > > Your thoughts appreciated. Is there a better way? I wouldn't want to > > stuff the XML-file resident content into a database and rebuild the > > XML element subsets because there are tons of files arriving and > > disappearing and it would become a huge background activity for > > another program. > > if your XML docs are too transient, then it's not a job for a > database. if you're getting repeated queries, or if several queries > need some xml elements repeatedly, you could simply use a cache to > avoid the repeats. > Thanks for the concurrence. You're prob right. I'll have to look into caching, but the recurrence of the same slice of the XML file could be fairly infrequent. But it's worth looking into. > If each xml element is used very few times, but you think a good > proportion of them is going to be required before becoming outdated, > then you could preprocess them as they arrive, instead of waiting for > the request. i guess that processing a whole document would produce > several results much faster than searching each individually. to > avoid the load on a RDBMS, you might find better to store the > preprocessed results on a key/value store, maybe even a > memory-resident one, like redis. > Yes, there might be some opportunity to pre-process as a backend process. Will keep that in mind as an option. > -- > Javier > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.2 release candidate available
I need to say thanks and congrats! I'm watching development community just at short time ago and I'm happy and motivated to contribute more and more as I can! 2010/5/6 Vitaly Babiy > Awesome Job, thanks everyone. > Vitaly Babiy > > > > On Thu, May 6, 2010 at 2:53 PM, Nick Serra wrote: > >> Awesome! Thanks so much! >> >> On May 6, 3:32 am, Federico Capoano wrote: >> > I've been using the beta for a while and it works pretty good for what >> > I've seen. >> > >> > On May 6, 6:40 am, James Bennett wrote: >> > >> > >> > >> > >> > >> > > Tonight we're proud to announce, finally, the first Django 1.2 release >> > > candidate. If all goes well, it will also be the *only* release >> > > candidate, and Django 1.2 final will release one week from today. >> > >> > > For more information, consult: >> > >> > > * The Django project weblog: >> http://www.djangoproject.com/weblog/2010/may/05/12-rc-1/ >> > > * The release notes: >> http://docs.djangoproject.com/en/dev/releases/1.2-rc-1/ >> > >> > > -- >> > > "Bureaucrat Conrad, you are technically correct -- the best kind of >> correct." >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> Groups "Django users" group. >> > > To post to this group, send email to django-us...@googlegroups.com. >> > > To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com >> . >> > > For more options, visit this group athttp:// >> groups.google.com/group/django-users?hl=en. >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "Django users" group. >> > To post to this group, send email to django-us...@googlegroups.com. >> > To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com >> . >> > For more options, visit this group athttp:// >> groups.google.com/group/django-users?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Felipe 'chronos' Prenholato. Linux User nº 405489 Home page: http://chronosbox.org/blog Twitter: http://twitter.com/chronossc -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django App and Memory Mgmt
You may want to consider using a sax based parsing. It works by calling you back for beginning of tag (has the attributes), text content, and end of tag, from which you can keep state and just keep the, you say small. subset of the element data that you need, which you can either stick in a dom, or have your own object structure that you know how to render for the requester. Much more coding than the dom, but you don't need the whole document in memory at once. Bill On Thu, May 6, 2010 at 3:34 PM, Ross wrote: > Reading more it sounds like the memory usage issue, particularly for > those exploring Webfaction, is a typical rite of passage, and probably > has more to do with httpdconf and mod_wsgi setup than it does with > Django practices. Lots of discussion here. (I hope this forum allows html, > otherwise that's a messy link :) > > > > On May 6, 3:14 pm, Javier Guerra Giraldez wrote: >> On Thu, May 6, 2010 at 1:40 PM, Ross wrote: >> > Your thoughts appreciated. Is there a better way? I wouldn't want to >> > stuff the XML-file resident content into a database and rebuild the >> > XML element subsets because there are tons of files arriving and >> > disappearing and it would become a huge background activity for >> > another program. >> >> if your XML docs are too transient, then it's not a job for a >> database. if you're getting repeated queries, or if several queries >> need some xml elements repeatedly, you could simply use a cache to >> avoid the repeats. >> > > Thanks for the concurrence. You're prob right. I'll have to look into > caching, but the recurrence of the same slice of the XML file could be > fairly infrequent. But it's worth looking into. > >> If each xml element is used very few times, but you think a good >> proportion of them is going to be required before becoming outdated, >> then you could preprocess them as they arrive, instead of waiting for >> the request. i guess that processing a whole document would produce >> several results much faster than searching each individually. to >> avoid the load on a RDBMS, you might find better to store the >> preprocessed results on a key/value store, maybe even a >> memory-resident one, like redis. >> > > Yes, there might be some opportunity to pre-process as a backend > process. Will keep that in mind as an option. > >> -- >> Javier >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
need help with custom authorization Backend
I am writing an authorization backend to get some permissions from custom tables. I added it to settings.py, It does not appear Django is calling get_group_permissions(self) from this backend. I had print statements and nothing got printed in Please help. class MyBackend(object): supports_object_permissions = False supports_anonymous_user = True def authenticate(self, username, password): return None def get_group_permissions(self): """ Returns a set of permission strings that this user has through his/her groups self. """ print " in my backend group perm" role = Role.objects.filter(user__exact = self.id) if role is not None: perms = role.permissions.values_list('content_type__app_label', 'codename') return set(["%s.%s" % (ct, name) for ct, name in perms]) Models.py class Role(models.Model): group= models.ForeignKey(Group) name = models.CharField(max_length=80, unique=True) permissions = models.ManyToManyField(Permission, verbose_name='permissions', blank=True def __unicode__(self): return self.name -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Password reset email sent several times
You have five different users in your database with the same e-mail address. If you look at the e-mail messages, you'll notice that each one specifies a different value for username. Just make sure you click the right one for the password you want to reset. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Working out some custom API stuff
Never mind this, I got it figured out. Thanks again On May 6, 12:51 pm, Nick wrote: > Thanks for the help on that portion, it is working wonderfully. > > I've been able to power through most of the requests for this project > but there is one outstanding element in regards to pagination. > > Here is my view: > > def QandAAPI(request, site): > quest = entry.objects.filter(site__name__icontains=site) > if 'id' in request.GET: > ids = request.GET.getlist('id') > quest = quest.filter(id__in=ids) > if 'sect' in request.GET: > sect = request.GET.getlist('sect') > quest = TaggedItem.objects.get_by_model(quest, sect) > if 's' in request.GET: > s = request.GET['s'] > search_query = ( > Q(question__icontains=s) | Q(answer__icontains=s) | > Q(answerer__icontains=s) > ) > quest = quest.filter(search_query) > if 'count' in request.GET and not 'page' in request.GET: > count = request.GET['count'] > quest = quest[:count] > if 'count' in request.GET and 'page' in request.GET: > page = int(request.GET['page']) > count = request.GET['count'] > paginator = Paginator(quest, count) > try: > page = paginator.page(page) > except ValueError: > page = 1 > json = serializers.serialize("json", quest) > return HttpResponse(json) > > I am getting the following error when I try to plug a page=1 into the > URL > > coercing to Unicode: need string or buffer, int found > > I'm not entirely sure how to fix this error, I've tried many times. > > The final view should do the following: > > Check to see if 'page' and 'coutn' are part of the url. If they are, > then pull up the results of that page with the count declared in the > URL. > > There will be another component that will skip the 'count' if it isn't > declared but I haven't got there yet. > > On May 5, 4:11 am, Daniel Roseman wrote: > > > > > On May 5, 4:46 am, Nick wrote: > > > > Here's the deal. I'm working on a customAPIfor moving information > > > about. I am stuck at a point in creating my view. > > > It might be best just to get into the details. > > > > Here is the model: > > > > class entry(models.Model): > > > question = models.CharField('Question', max_length=200, > > > blank=False) > > > answer = models.TextField('Answer', blank=False) > > > answerer = models.CharField("Expert's Name", max_length=100, > > > blank=False) > > > credentials = models.CharField ("Expert's Credentials", > > > max_length=100, blank=False) > > > published = models.DateTimeField(auto_now_add=True) > > > updated = models.DateTimeField(auto_now=True) > > > site = models.ForeignKey(Site) > > > section = TagField() > > > > Once a site is picked the feed is narrowed down by id (whether single > > > id, list or range), then by section (single or multiple) and finally > > > some pagination and count params (I'm not worried about that right > > > now). Currently, I am stuck on the section portion. I may be going > > > about this all wrong. What I would like is for some URL like: > > > >http://mysite.com/qanda/SITENAME/?sect=THESECTIONNAME > > > > to produce a JSON output of Questions and Answers under that site with > > > that section name. Here is my view: > > > > def QandAAPI(request, site): > > > quest = entry.objects.filter(site__name__icontains=site) > > > if 'id' in request.GET: > > > id = request.GET.get('id','') > > > id = id.split(',') > > > else: > > > id = quest.values_list('id', flat=True) > > > if 'sect' in request.GET: > > > sect = request.GET.get('sect','') > > > else: > > > sect = '' > > > quest = quest.filter(id__in=id, section=sect) > > > object = serializers.serialize("json", quest) > > > json = "%s" % object > > > return HttpResponse(json) > > > > Basically, I would like the "else: sect=" to be a WILDCARD so if the > > > sect portion of theAPIisn't explicitly stated then it just pulls > > > everything. > > > > What do you think? Raw SQL? I'm a complete bonehead? All opinions/ > > > advice are welcome. > > > I wouldn't call you a bonehead, but the method you're using to get all > > the objects when no id is passed in is... well... special. > > > The key to doing this sort of filtering is to remember that QuerySets > > are lazy, and successive filters can be applied to them without > > hitting the database, until the time comes to actually evaluate them. > > So what you want to do is to set up the base query at the start of the > > method, then further filter it depending on the GET parameters. Then, > > if a particular parameter isn't passed in, you simply don't filter on > > it. Something like: > > > def QandAAPI(request, site): > > quest = entry.objects.filter(site__name__icontains=site) > > if 'id' in request.GET: > > ids = request.GET.getlist('id') > > quest = quest.f
Mod_WSGI and lib python
Hi, I have been trying to setup mod_wsgi with apache 2 but when I do: sudo a2enmod mod-wsgi sudo /etc/init.d/apache2 restart I get this error message: Restarting web server: apache2apache2: Syntax error on line 185 of / etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods- enabled/mod-wsgi.load: Cannot load /usr/lib/apache2/modules/ mod_wsgi.so into server: libpython2.7.so.1.0: cannot open shared object file: No such file or directory failed! but I have that file here: /usr/local/lib/libpython2.7.so.1.0 and i can do: echo $LD_LIBRARY_PATH :/usr/local/ lib I imangine I have misunderstood something here, and its trying to find the libpython file somewhere else. Could somebody please help me, thanks Andrew -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: MacPorts installation, Django $PATH issue
Type "which python" at the command line as your regular user. Then, look at /usr/bin/python*, /usr/lib, /usr/local/bin/python* and /usr/local/lib. Find where the site-packages for Django are located. Make sure that "which python" is pointing to the correct version. Sounds like Django is not installed in the same version of Python that you are actually using. Also, if you type python -V (I think it's a capital "V") at the command line, it should tell you which version you are using. On Thu, May 6, 2010 at 3:47 AM, HelloWorld wrote: > Hi everybody > > I just got Django installed (to test it) via Macports and I have > Python 2.5 and 2.6 installed on a MacBook running 10.6.3. > > I did everything the installation guide told me, but after typing: > > python manage.py runserver > > I get this error: > > File "manage.py", line 2, in >from django.core.management import execute_manager > ImportError: No module named django.core.management > > I believe the solution would be this comment on the installation > site: > > To avoid a command not found issue with Snow Leopard 10.6.2 and > various other OSX (Django installed using MacPorts?) here a tip that > might help. There might be a $PATH issue. Adding the proper PATH to > ~/.Profile: export PATH=/opt/local/bin:opt/local/sbin:/opt/local/lib/ > python2.4/site-packages/django/bin:$PATH should help. NB Could be that > one needs to change the Python version in the PATH. > > But I dont now what a $PATH issue is and where I could paste this code > to fix it. > > Or if you know another possible reason please tell me. > > Any help would be greatly appreciated. > > Thanks a lot > > Best > > Z. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Mod_WSGI and lib python
On May 7, 7:34 am, When ideas fail wrote: > Hi, I have been trying to setup mod_wsgi with apache 2 > > but when I do: > > sudo a2enmod mod-wsgi > sudo /etc/init.d/apache2 restart > > I get this error message: > > Restarting web server: apache2apache2: Syntax error on line 185 of / > etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods- > enabled/mod-wsgi.load: Cannot load /usr/lib/apache2/modules/ > mod_wsgi.so into server: libpython2.7.so.1.0: cannot open shared > object file: No such file or directory > failed! > > but I have that file here: > > /usr/local/lib/libpython2.7.so.1.0 > > and i can do: > > echo $LD_LIBRARY_PATH :/usr/local/ > lib > > I imangine I have misunderstood something here, and its trying to find > the libpython file somewhere else. > Could somebody please help me, thanks Go back and reinstall mod_wsgi and this time do the following: make distclean ./configure --with-python=/usr/local/bin/python2.7 LD_RUN_PATH=/usr/local/lib make sudo make install Setting LD_RUN_PATH like that will force the directory '/usr/local/ lib' into the shared library search path of mod_wsgi.so file itself so not dependent on your operating system knowing it should look in /usr/ local/lib. Also read: http://code.google.com/p/modwsgi/wiki/WhereToGetHelp This question has nothing to do with Django and so you should really have asked on the mod_wsgi mailing list. 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django App and Memory Mgmt
On May 7, 4:40 am, Ross wrote: > I have a Django app that selects one of many possible XML documents, > parses it with minidom.parse(), finds all elements of a certain tag > with getElementsByTagName() then it sends a small subset of those > elements off to a client browser. So I typically have to parse many > thousands of elements to make the DOM object to then get the > appropriate 50 or 100 element portion that will be sent off to the > user as a smaller XML file where it is parsed at the client side with > javascript. > > My memory performance with Apache and mod_wsgi isn't very good, Is that for a single process, or across the whole of Apache. Make sure your read: http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html That issue applies to mod_wsgi as well. You usually should not use embedded mode, use daemon mode of mod_wsgi instead. Graham > and I > assume that's because I parse the whole file into memory, and also > because getElements creates another large object before I can extract > my desired elements. I do a bit of scrutinizing and massaging of them > before they get wrapped up and sent on. > > I'd like to call unlink() on the big objects, but I don't know that I > can do that somewhere, as I 'return' the small subset, and I don't > have control after that is returned by Django to the requestor. > > Any thoughts on a) is this a big contributor to my memory footprint? > b) wouldn't this all be garbage collected after the response is > handled anyway? c) would I be better off with a SAX parsing of the > XML file to avoid building the whole DOM tree to get my small subset > of objects? > > Your thoughts appreciated. Is there a better way? I wouldn't want to > stuff the XML-file resident content into a database and rebuild the > XML element subsets because there are tons of files arriving and > disappearing and it would become a huge background activity for > another program. > > Ross. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Password reset email sent several times
True...Thanks man..I didnt realise that. I was just checking by entering users with the same email address...so found it weird when there were 5-6 mails sent for password reset. But is there anything that I can do to restrict users using same email address more then once.. Cheers On May 7, 6:21 am, Shawn Milochik wrote: > You have five different users in your database with the same e-mail address. > > If you look at the e-mail messages, you'll notice that each one specifies a > different value for username. Just make sure you click the right one for > thepasswordyou want to reset. > > Shawn > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, sendemailto django-us...@googlegroups.com. > To unsubscribe from this group, sendemailto > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: need help with custom authorization Backend
resolved by adding has_perm and get_all_permisions methods to my backend class. Looks all methods should defined in backend, not just the one I want to change. On May 6, 1:53 pm, lray wrote: > I am writing an authorization backend to get some permissions from > custom tables. I added it to settings.py, > > It does not appear Django is calling get_group_permissions(self) from > this backend. I had print statements and nothing got printed in > Please help. > > class MyBackend(object): > supports_object_permissions = False > supports_anonymous_user = True > > def authenticate(self, username, password): > return None > > def get_group_permissions(self): > """ > Returns a set of permission strings that this user has through > his/her > groups self. > """ > print " in my backend group perm" > role = Role.objects.filter(user__exact = self.id) > if role is not None: > perms = > role.permissions.values_list('content_type__app_label', 'codename') > return set(["%s.%s" % (ct, name) for ct, name in perms]) > > Models.py > > class Role(models.Model): > group= models.ForeignKey(Group) > name = models.CharField(max_length=80, unique=True) > permissions = models.ManyToManyField(Permission, > verbose_name='permissions', blank=True > > def __unicode__(self): > return self.name > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Close window after download
I have code that generates a file for download. I want to close the window after the user selects the download or even redirect them. Here is my code: response = HttpResponse(cal.as_string(), mimetype='text/calendar') response['Content-Disposition'] = 'attachment; filename=schedule.ics' return response I can't close the window before the download using because I get an error that the window closed. So after the form download the window is hanging in limbo. If anyone knows how to close the window I'd appreciate it. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No module name error
hi all, i am a newbie in django and have been trying to get this django- registration app working with few extra fields. now i am getting his module error http://dpaste.com/191756/ please help fixing me this error.. Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
how to initial data for inlineformset
docfset=inlineformset_factory(document, documentOnline, form=documentOnlineForm, extra=1, can_delete=False) c = RequestContext( request, { 'docfset':docfset(instance=tdoc,initial=[{'actor':request.user},]), 'documentform':documentForm(initial={'tSUser':getEDSByUObj(request.user, []),'documentType':'Online','status':'Enabled'}), } ) when runing,i got following errors: __init__() got an unexpected keyword argument 'initial' so,how to initial data for inlineformset?thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: No module name error
Hi, I don't know which version of django-registration you use, but the source on views.py doesn't have any profiles.utils see :http://bitbucket.org/ubernostrum/django-registration/src/tip/registration/views.py -adji- On Fri, May 7, 2010 at 9:19 AM, newbiedjango wrote: > hi all, > i am a newbie in django and have been trying to get this django- > registration app working with few extra fields. > > now i am getting his module error > > http://dpaste.com/191756/ > > please help fixing me this error.. > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- -- http://www.tumbletooth.org my linkedin profile : http://www.linkedin.com/in/bayuadji -- -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to initial data for inlineformset
if i changed to following: 'docfset':docfset({'actor':request.user}, instance=tdoc), i got: ValidationError On May 7, 10:21 am, victor wrote: > docfset=inlineformset_factory(document, documentOnline, > form=documentOnlineForm, extra=1, can_delete=False) > c = RequestContext( > request, > { > > 'docfset':docfset(instance=tdoc,initial=[{'actor':request.user},]), > > 'documentform':documentForm(initial={'tSUser':getEDSByUObj(request.user, > []),'documentType':'Online','status':'Enabled'}), > } > ) > when runing,i got following errors: > __init__() got an unexpected keyword argument 'initial' > so,how to initial data for inlineformset?thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Insert model data into every page (base.html)
If you use the context processors, you can include the data on every page. The template should be rendered from the view or in your case a generic view. Cheers On May 5, 9:06 am, Martin Tiršel wrote: > Hello, > > I need to insert some data from database onto every page, so I inserted > them into base.html. Until now, I was using generic views but it doesn't > seems to be ideal for this case. Is there a way how to achieve this > behaviour with generic views or I have to insert needed model into every > custom view? > > I tried it this way, but update() returns None, so it doesn't work, but it > demonstrates what I am looking for: > > currency_by_date = { > "queryset": Currency.objects.all().order_by('-date', 'currency')[:2], > "template_name": "home.html", > "template_object_name": "currency", > > } > > urlpatterns = patterns('', > (r'^$', 'django.views.generic.list_detail.object_list', > currency_by_date), > (r'^profil_spolocnosti/$', > 'django.views.generic.list_detail.object_list', > currency_by_date.update({"template_name": > "profil_spolocnosti.html"})), > ... > > If I have to use custom views what is the best way to include above > queryset result into templates without repeating it over every view? > > Thank you for your help, > Martin > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No module name error
hi all, i am a newbie in django and have been trying to get this django- registration app working with few extra fields. now i am getting his module error http://dpaste.com/191756/ please help fixing me this error.. Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: No module name error
my views.py is down here which is an extension of http://bitbucket.org/ubernostrum/django-registration/src/tip/registration/views.py I am a total newbie here and don't know much about this..kindly help... from django.shortcuts import redirect from django.shortcuts import render_to_response from django.template import RequestContext import profiles.utils from registration.backends import get_backend def activate(request, backend, template_name='registration/activate.html', success_url=None, extra_context=None, **kwargs): backend = get_backend(backend) account = backend.activate(request, **kwargs) if account: if success_url is None: to, args, kwargs = backend.post_activation_redirect(request, account) return redirect(to, *args, **kwargs) else: return redirect(success_url) if extra_context is None: extra_context = {} context = RequestContext(request) for key, value in extra_context.items(): context[key] = callable(value) and value() or value return render_to_response(template_name, kwargs, context_instance=context) def ug_zero_suffix(form_data): return form_data['username'] + '0' username_generators = [ug_zero_suffix] # Not a view function (helper function) def generate_username_suggestions(form_data): MAX_SUGGESTIONS = 5 suggestions = [] for gen in username_generators: for suggestion in gen(form_data): if (suggestion != None): suggestions.append(suggestion) if (length(suggestions) >= MAX_SUGGESTIONS): return suggestions # TODO make sure that we handle not generating enough suggestions return suggestions def register(request, backend, success_url=None, form_class=RegistrationForm, profile_callback=None, template_name='registration/registration_form.html', extra_context=None): pform_class = profiles.utils.get_profile_form() if request.method =='POST': profileform = pform_class(data=request.POST, files=request.FILES) form = form_class(data=request.POST, files=request.FILES) if form.is_valid(): new_user = form.save() profile_obj = profileform.save(commit=False) profile_obj.user = new_user profile_obj.save() return HttpResponseRedirect('/accounts/ register/complete/') else: form = form_class() profileform = pform_class() if exra_context is None: extra_context = {} context = RequestContext(request) for key, value in extra_context.items(): context[key] = callable(value) and value() or value return render_to_response(template_name, {'form':form,'profileform':profileform,'context_instance':context}) def register(request, backend, success_url=None, form_class=None, disallowed_url='registration_disallowed', template_name='registration/registration_form.html', extra_context=None): backend = get_backend(backend) if not backend.registration_allowed(request): return redirect(disallowed_url) if form_class is None: form_class = backend.get_form_class(request) if request.method == 'POST': form = form_class(data=request.POST, files=request.FILES) if form.is_valid(): new_user = backend.register(request, **form.cleaned_data) if success_url is None: to, args, kwargs = backend.post_registration_redirect(request, new_user) return redirect(to, *args, **kwargs) else: return redirect(success_url) #else: # generate suggestions which can be passed into the template else: form = form_class() if extra_context is None: extra_context = {} context = RequestContext(request) for key, value in extra_context.items(): context[key] = callable(value) and value() or value return render_to_response(template_name, { 'form': form }, context_instance=context) On May 7, 11:25 am, Bayuadji wrote: > Hi, > > I don't know which version of django-registration you use, > but the source on views.py doesn't have any profiles.utils > > see :http://bitbucket.org/ubernostrum/django-registration/src/tip/registra... > > -adji- > > > > On Fri, May 7, 2010 at 9:19 AM, newbiedjango wrote: > > hi all, > > i am a newbie in django and have been trying to get this django- > > registration app working with few extra fields. > > > now i am getting his module error > > >http://dp
Re: No module name error
see this line import profiles.utils in views.py on django registration doesn't have that line. so I think you or someone already customized the registration apps -adji- On Fri, May 7, 2010 at 9:57 AM, newbiedjango wrote: > my views.py is > down here which is an extension of > http://bitbucket.org/ubernostrum/django-registration/src/tip/registration/views.py > I am a total newbie here and don't know much about this..kindly > help... > > from django.shortcuts import redirect > from django.shortcuts import render_to_response > from django.template import RequestContext > import profiles.utils > from registration.backends import get_backend > > > def activate(request, backend, > template_name='registration/activate.html', > success_url=None, extra_context=None, **kwargs): > > backend = get_backend(backend) > account = backend.activate(request, **kwargs) > > if account: > if success_url is None: > to, args, kwargs = > backend.post_activation_redirect(request, account) > return redirect(to, *args, **kwargs) > else: > return redirect(success_url) > > if extra_context is None: > extra_context = {} > context = RequestContext(request) > for key, value in extra_context.items(): > context[key] = callable(value) and value() or value > > return render_to_response(template_name, > kwargs, > context_instance=context) > > def ug_zero_suffix(form_data): > return form_data['username'] + '0' > > username_generators = [ug_zero_suffix] > > # Not a view function (helper function) > def generate_username_suggestions(form_data): > > MAX_SUGGESTIONS = 5 > suggestions = [] > > for gen in username_generators: > for suggestion in gen(form_data): > if (suggestion != None): > suggestions.append(suggestion) > if (length(suggestions) >= MAX_SUGGESTIONS): > return suggestions > > # TODO make sure that we handle not generating enough > suggestions > return suggestions > > def register(request, backend, success_url=None, > form_class=RegistrationForm, profile_callback=None, > template_name='registration/registration_form.html', > extra_context=None): > pform_class = profiles.utils.get_profile_form() > if request.method =='POST': > profileform = pform_class(data=request.POST, > files=request.FILES) > form = form_class(data=request.POST, > files=request.FILES) > if form.is_valid(): > new_user = form.save() > profile_obj = profileform.save(commit=False) > profile_obj.user = new_user > profile_obj.save() > return HttpResponseRedirect('/accounts/ > register/complete/') > else: > form = form_class() > profileform = pform_class() > if exra_context is None: > extra_context = {} > context = RequestContext(request) > for key, value in extra_context.items(): > context[key] = callable(value) and value() or > value > return render_to_response(template_name, > {'form':form,'profileform':profileform,'context_instance':context}) > > def register(request, backend, success_url=None, form_class=None, > disallowed_url='registration_disallowed', > template_name='registration/registration_form.html', > extra_context=None): > backend = get_backend(backend) > if not backend.registration_allowed(request): > return redirect(disallowed_url) > if form_class is None: > form_class = backend.get_form_class(request) > > if request.method == 'POST': > form = form_class(data=request.POST, files=request.FILES) > if form.is_valid(): > new_user = backend.register(request, **form.cleaned_data) > if success_url is None: > to, args, kwargs = > backend.post_registration_redirect(request, new_user) > return redirect(to, *args, **kwargs) > else: > return redirect(success_url) > #else: > # generate suggestions which can be passed into the > template > else: > form = form_class() > > if extra_context is None: > extra_context = {} > context = RequestContext(request) > for key, value in extra_context.items(): > context[key] = callable(value) and value() or value > > return render_to_response(template_name, > { 'form': form }, > context_instance=context) > > > On May 7, 11:25 am, Bayuadji wrote: >> Hi, >> >> I don't know which version of django-registration you use, >> but the source o
Re: No module name error
yes that import statement was done by me but im not sure if that is the correct way to do it or not. On May 7, 12:01 pm, Bayuadji wrote: > see this line > import profiles.utils > > in views.py on django registration doesn't have that line. so I think > you or someone already customized the registration apps > > -adji- > > > > On Fri, May 7, 2010 at 9:57 AM, newbiedjango wrote: > > my views.py is > > down here which is an extension of > >http://bitbucket.org/ubernostrum/django-registration/src/tip/registra... > > I am a total newbie here and don't know much about this..kindly > > help... > > > from django.shortcuts import redirect > > from django.shortcuts import render_to_response > > from django.template import RequestContext > > import profiles.utils > > from registration.backends import get_backend > > > def activate(request, backend, > > template_name='registration/activate.html', > > success_url=None, extra_context=None, **kwargs): > > > backend = get_backend(backend) > > account = backend.activate(request, **kwargs) > > > if account: > > if success_url is None: > > to, args, kwargs = > > backend.post_activation_redirect(request, account) > > return redirect(to, *args, **kwargs) > > else: > > return redirect(success_url) > > > if extra_context is None: > > extra_context = {} > > context = RequestContext(request) > > for key, value in extra_context.items(): > > context[key] = callable(value) and value() or value > > > return render_to_response(template_name, > > kwargs, > > context_instance=context) > > > def ug_zero_suffix(form_data): > > return form_data['username'] + '0' > > > username_generators = [ug_zero_suffix] > > > # Not a view function (helper function) > > def generate_username_suggestions(form_data): > > > MAX_SUGGESTIONS = 5 > > suggestions = [] > > > for gen in username_generators: > > for suggestion in gen(form_data): > > if (suggestion != None): > > suggestions.append(suggestion) > > if (length(suggestions) >= MAX_SUGGESTIONS): > > return suggestions > > > # TODO make sure that we handle not generating enough > > suggestions > > return suggestions > > > def register(request, backend, success_url=None, > > form_class=RegistrationForm, profile_callback=None, > > template_name='registration/registration_form.html', > > extra_context=None): > > pform_class = profiles.utils.get_profile_form() > > if request.method =='POST': > > profileform = pform_class(data=request.POST, > > files=request.FILES) > > form = form_class(data=request.POST, > > files=request.FILES) > > if form.is_valid(): > > new_user = form.save() > > profile_obj = profileform.save(commit=False) > > profile_obj.user = new_user > > profile_obj.save() > > return HttpResponseRedirect('/accounts/ > > register/complete/') > > else: > > form = form_class() > > profileform = pform_class() > > if exra_context is None: > > extra_context = {} > > context = RequestContext(request) > > for key, value in extra_context.items(): > > context[key] = callable(value) and value() or > > value > > return render_to_response(template_name, > > {'form':form,'profileform':profileform,'context_instance':context}) > > > def register(request, backend, success_url=None, form_class=None, > > disallowed_url='registration_disallowed', > > template_name='registration/registration_form.html', > > extra_context=None): > > backend = get_backend(backend) > > if not backend.registration_allowed(request): > > return redirect(disallowed_url) > > if form_class is None: > > form_class = backend.get_form_class(request) > > > if request.method == 'POST': > > form = form_class(data=request.POST, files=request.FILES) > > if form.is_valid(): > > new_user = backend.register(request, **form.cleaned_data) > > if success_url is None: > > to, args, kwargs = > > backend.post_registration_redirect(request, new_user) > > return redirect(to, *args, **kwargs) > > else: > > return redirect(success_url) > > #else: > > # generate suggestions which can be passed into the > > template > > else: > > form = form_class() > > > if extra_context is None: > > extra_context = {} > > context = RequestContext(request) > > for key, value in extra_context.items():
Error with passing 'form_class' arg with Django Contact Form
Hi All, Bashing my head against a wall trying to understand this issue. Playing around with Django-Contact-Form app, and trying to use my own subclassed Form in the views. From the code in views, it looks like it just takes an optional arg, form_class, which can be your Form subclassed from ContactForm. Here is my Form class: from contact_form.forms import ContactForm from django import forms attrs_dict = { 'class': 'required' } class EnhancedContactForm(ContactForm): def __init__(self, data=None, files=None, request=None, *args, **kwargs): super(EnhancedContactForm, self).__init__(request, *args, **kwargs) I know it doesn't do anything, was just trying to get the simplest form to work first. Here is my urls.py: urlpatterns += patterns('', url(r'^contact/$', contact_form, {'form_class':EnhancedContactForm}, name='contact_form'), url(r'^contact/sent/$', direct_to_template, { 'template': 'contact_form/ contact_form_sent.html' }, name='contact_form_sent'), ) It fails with the stack: TemplateSyntaxError: Caught an exception while rendering: unbound method __unicode__() must be called with EnhancedContactForm instance as first argument (got nothing instead) Original Traceback (most recent call last): File "/Library/Python/2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/Library/Python/2.5/site-packages/django/template/ defaulttags.py", line 155, in render nodelist.append(node.render(context)) File "/Library/Python/2.5/site-packages/django/template/debug.py", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File "/Library/Python/2.5/site-packages/django/utils/encoding.py", line 71, in force_unicode s = unicode(s) TypeError: unbound method __unicode__() must be called with EnhancedContactForm instance as first argument (got nothing instead) If you substitute the standard ContactForm in urls.py, it fails the same way. Anyone seen this before? What am I doing wrong? Cheers Ricko -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
values() and GenericRelation
Hello, I need to put into a template some fields of my model, but not all the fields, it is better to specify which fields to pass. Then, I use something like: MyModel.objects.values('id', 'field1__name', 'field2', 'field3__value', 'my_custom_set') But, 'my_custom_field' is a GenericRelation field, and I can't specify it as parameter of the QuerySet values() method. The error is: Exception Type: FieldError Exception Value: Invalid field name: 'my_custom_set' Note I've already read that values() method doesn't return anything for M2M fields attributes, but not sure if a GenericRelation is really a m2m field relationship. (http://docs.djangoproject.com/en/1.1/ref/models/querysets/#values-fields) However, if I give to the template the full list of fields, it works, for example, using: MyModel.objects.all() I could use all() result, but I must use the ForeingKey values of the field1 and field3, so I don't know how to get its values if it not the way I said before. How can I resolve this? Thanks your comments, and if it's not clear, please tell me, i'll try to clarify my problem. Regards, Caio -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Errors while attempting to enable admin
Django newbie here. I am learning by following the Django book. All is good until I try to enable the admin interface (on v1.1.1) and I get the following error: TemplateDoesNotExist at /admin/ admin/login.html So I did some poking around and changed my TEMPLATE_DIRS to the following (which I don't think was the right way to do it anyway): import os.path #import so we can use magic for the template import TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates').replace('\ \','/'), '/usr/lib/pymodules/python2.6/django/contrib/admin/templates/', ) When I do that I get: TemplateSyntaxError at /admin/ 'adminmedia' is not a valid tag library: Could not load template library from django.templatetags.adminmedia, No module named adminmedia This is a 'vanilla' ubuntu django install (I didn't pull from SVN) so I am hoping that this is a well-known issue, I read the comments on the book site and none appeared to be this issue. Can someone give me some pointers? 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.