Re: GUI builder for django
On Wed, Apr 21, 2010 at 5:52 PM, John Finlay wrote: > Does everyone code the html and css by hand for their templates? That seems > very time consuming and tedious. every developer i know does. > Desktop apps have the same issues with variations of languages, fonts, etc. > and resizing and the layout containers and other widgets provide for dynamic > changes. GUI builders make it easy to create the views from the basic > widgets without having to program a lot of low level code. Are you saying > there isn't an equivalent type of development tool in the web design space? as a matter of fact, i use Qt Designer only to mockup and check the general disposition. for the real app i code C++ by hand. -- 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: Increase django page timeout
On Thu, Apr 22, 2010 at 6:25 AM, ge...@aquarianhouse.com wrote: > I your case i would put this task in queue or kind of a back process. +1 Queues are the way to go. in this case, i guess a "Ghetho Queue" would be enough (just a DB table of 'pending tasks', a cron script that processes them and a view that checks when it's done). if it eventually becomes necessary, migrating to a 'real' queue manager (RabbitMQ, memcacheq, whatever) gets much easier. -- 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: Increase django page timeout
On Thu, Apr 22, 2010 at 9:26 AM, Florin wrote: > Maybe a solution would be to put more filters so the data won't be > that large and so it would eventually generate the pdf. no, the solution is to put all the heavy work _out_ of the request/response cycle. just add the parameters (not the data) to an entry in a work queue and return with a redirect to another page that shows the task state and refreshes every few seconds (or poll with AJAX). meanwhile, a background daemon picks the task from the queue, and starts processing. if possible, make it write some progress info to the task entry, so the user can see it progressing. when it's finished, the status page sees the task as 'done' and redirects to the PDF download url. -- 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: Working for a startup.
I want to state some points that should be obvious: - All three techonogies mentioned so far (Django, .NET and Rails) can work on flawlessly on big, important projects when used correctly, or can fail on medium/small deployments when used incorrectly. - .NET is a lower-level layer than Django or Rails, it's more comparable to Python, Ruby, or (more so) to Java. But, being a single-sourced technology, the framework on top is more 'obvious'. also, since most of the infrastructure associated with .NET comes from Redmond, the evolution paths are clearly defined, just like it used to be with Java, where 'a web using Java' was almost always J2EE. - Any framework scales just up to a point, and then you have to start replacing some generic parts with custom implementations that work best for your specific problem. just how long can you stretch each before you see the voids and start filling them depends somewhat on the framework itself, but much more on the skill and experience of the developers. - taking a group that's experienced and productive developing with a framework and telling them that you want them to use another one that they're not familiar with is a sure path to failure. not only because of lack of experience, but also because they might not want it to succeed, and they even have a clear excuse. in fact, failing at it makes them look better because they were suggesting the other way from the start! just don't do it. -- 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: get_next_by title?
On Fri, Apr 23, 2010 at 1:29 AM, ChrisR wrote: > def get_prev_by_title(self): > get_prev = Product.objects.order_by('- > title').filter(title__lt=self.title) > try: > return get_prev[0] > except IndexError: > return None > > > def get_next_by_title(self): > get_next = > Product.objects.order_by('title').filter(title__gt=self.title) > try: > return get_next[0] > except IndexError: > return None just a little DRYer: == take 1 def firstornone (q): try: return q[0] except IndexError: return None . def get_prev_by_title(self): return firstornone(Product.objects.order_by('-title').filter(title__lt=self.title)) def get_next_by_title(self): return firstornone(Product.objects.order_by('title').filter(title__gt=self.title)) or even: take 2 === def next_by (queryset, field, value): return firstornone (queryset.order_by(field).filter(**{'%s__gt'%field:value})) def prev_by (queryset, field, value): return firstornone (queryset.order_by('-'+field).filter(**{'%s__lt'%field:value})) . def get_prev_by_title(self): return prev_by(Product.objects.all(), 'title', self.title) def get_next_by_title(self): return next_by(Product.objects.all(), 'title', self.title) = (a slow morning, i felt the itch to code a little) -- 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: Redirect to named url pattern not working
On Mon, Apr 26, 2010 at 4:16 PM, Daniel Klein wrote: > From urls.py: > > url(r'^game/(\d+)/$', 'views.game', name='gameview'), the parameter extracted from the url doesn't have a name. change to: url(r'^game/(?P\d+)/$', 'views.game', name='gameview'), -- 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: Generic web-dev question: Best way to do a processing page?
On Sat, May 1, 2010 at 7:22 AM, Joshua Russo wrote: > This is mainly just curiosity at the moment. How do you create a > "processing" intermediate page, like you see on travel sites when they are > looking for the rates? I would always avoid this if at all possible, but > sometimes you have a process that takes longer than usual. some ideas: - a view checks if the task is done, if so, shows the result. if not, uses another template with the 'wait a sec..' message and a 'refresh' HTML header that reloads the page after a few seconds. - the 'wait' page starts with a javascript that does a periodic AJAX call to check if it's done. when it's so, redirects to the 'result' page. -- 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: Limiting a ForeignKey to a subset of values
On Thu, May 6, 2010 at 1:03 AM, Xavier Ordoquy wrote: > Hi, > > I currently have a foreign key for which the model should allow the selection > of a subset of objects depending on another object value. > > Let's say model A has a foreign key on model B. Model A & B have a field > called restriction. > For a given A object, I'd like to display B objects that have the same > restriction field value as the A object. > > I've browsed a bit about the limit_choices_to but couldn't find a decent > solution for that issue. > To me complex queries wouldn't solve the issue as I need to access the object > field value. > > Does anyone have a solution for that ? i've recently ran in to something similar. i couldn't find a clean way to do it at the models; but at the forms is relatively simple: (from memory, beware of stupid mistakes) class formA (modelForm): def __init__(self, *args, **kwargs): restriction = kwargs.pop ('restriction', None) instance = kwargs.get ('instance', None) super (modelForm, self).__init__(self, *args, **kwargs) if instance and not restriction: restriction = instance.restriction self.fields['b_set'].queryset = B.objects.filter(restriction=restriction) class Meta: model = A this is A's modelForm, but the constructor takes an optional 'restriction' value. if given, it will show only B objects with that restriction. if no restriction, but it's given an A instance, reads the restriction from there. -- 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 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: Problem_Inline_max_num
On Mon, May 10, 2010 at 11:23 AM, carlos wrote: > I'm sorry but this is a translation of google even worse, it's a google translation of a text without punctuations. -- 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: Using a variable for a field name in a filter?
On Fri, May 14, 2010 at 8:37 AM, Nuno Maltez wrote: > Sure: > http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists > > myfilter = { var_field: "found" } > Foo.objects.filter(**myfilter} or even: Foo.objects.filter (**{var_field+'__eq':'found'}) if you want to use a different operator instead of the default '__eq' -- 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: Inconsistent database results between application and shell
On Mon, May 31, 2010 at 9:56 AM, Stodge wrote: > I have a query that filters on four fields: > > res = MyModel.objects.filter(name=self.name, > type=self.type, > > last_update_time__gte=today, > > last_update_time__lte=tomorrow) > > If I enter the exact same query in the shell, I get the correct > results from the database. If I access my app through the browser and > let it run the query, I get zero results. The settings file is correct all four of these parameters need some context (the 'self' object, and those 'today' and 'tomorrow' variables). obviously, you couldn't just type that in the shell and get any result. so, the problem might lay in some other code you're not showing. just guessing: something that has bitten me before is that even if querysets are lazy, the paraemters it gets aren't. specially when they're time dependent, like 'today' and 'tomorrow'. if you're creating this queryset at startup, these values might not be correct when you finally evaluate the query. -- 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: HttpRequest.DELETE implemented?
On Mon, Jun 14, 2010 at 4:48 AM, kalinski wrote: > MyModel.objects.get(id=request.DELETE['id']).delete() request.GET is a parsing of the 'query' part of the URL. request.GET is a parsing of the content of the request. request.COOKIES is a parsing of some headers of the request. what are you expecting to show up as request.DELETE ? -- 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: static files, nginx, memcached
On Fri, Jun 18, 2010 at 12:22 PM, TheIvIaxx wrote: > My thoughts right now are for it to check memcached for the key, if > not found, then serve up the file from disk. Everything else goes to > apache. I will just have a cron job populate memcached separately. > > Is this a common practice or is there a better method for this? be sure to benchmark it. in many cases, nginx will serve from static files just as fast as from memcached. yeah sounds crazy, but if nginx give the OS some hints, it will cache the files in RAM, a lot more efficiently than memcached (less context switches, no TCP involved, can dynamically get hold and release RAM as available, etc...) -- 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: static files, nginx, memcached
On Fri, Jun 18, 2010 at 5:52 PM, TheIvIaxx wrote: > Its a lot of little files and from what i've seen, the stat call is a > bottleneck. If they are all in memcache, then it should scream. yes, this sounds like memcached territory. still, we can argue all we want but a little benchmark would tell a lot more. > Which "hints" would you be referring? the extra parameters used when opening and reading files. there are lots of small flags, each one with a different set of pros/cons on different OSses. nginx is quite good at using the best for performance in most cases -- 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: Random
On Tue, Jun 22, 2010 at 12:11 PM, Waleria wrote: > I have a system that generate graphs and files .dat. However, i'm > having a problem, when two people access the system simultaneously may > happen that the graph of a person to replace the second person, what > can I do to make it not happen? you have to get some way to keep both users separate. one approach would be to create DB records for each task, and use the record ID as part of the file name. another would be to use the session ID. -- 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: Random
On Tue, Jun 22, 2010 at 12:30 PM, Waleria wrote: > my application doesn't use DBnot able to do this without using the > Random? ... without DB? you only need some unique identifier. it can be random, or an UUID, if you can track it, maybe in a cookie, or passed on URL parameters, or if you're using sessions, try the session ID. or the IP/port of the client. anything that can be different but consistent. -- 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: urllib and writing web service clients
On Fri, Jul 9, 2010 at 10:27 AM, irum wrote: > From command prompt, I invoke. curl > http://127.0.0.1:8000/api/hb/bookings/21/rooms/ > It does not respond anything, even if left for long time. However if I > use remote url, i.e. : > req = urllib2.Request('http://www.example.com') , it returns the html > file. Where am I going wrong? are you trying to do the request from Django? to the same server? on the development server? the development server is single-request. it won't answer to a new request until the current one has been completed. if you need to do a request to yourself, use a real server. of course, if you're requesting to yourself, you shouldn't have to go through HTTP, it would far better to directly access the underlying resources. > Thirdly, how do I implement conditions in my client to invoke a > certain method of a resource, i.e. before invoking POST on a 'payment' > resource, I want to perform a GET on 'booking' and 'room' resource, > only if I get response code of 200 (i.e. booking and room resource is > created), I should be able to invoke POST on 'payment' resource else > it should set a flag to false. HATEOAS: http://blogs.sun.com/craigmcc/entry/why_hateoas in short, the server shouldn't bother with policy. you should strive to create your resources so that everything that's allowable is acceptable. in your example: when you POST a new 'payment', you have to refer to the 'booking' and 'room' resources involved. these references should be URLs in the POST data. remember that REST is not CRUD, you have to do fairly extensive validations and sanitizations on POSTed data before accepting it. so, the 'payment' resource should verify that the 'booking' and 'room' URLs referenced by the client actually exist and are in the correct state (i.e. the room isn't paid yet). if anything is wrong with the data, don't write anything and respond with a client error, like 400, 406, 409, 412 or similar (check http://en.wikipedia.org/wiki/List_of_HTTP_status_codes). only answer with a 200 (or better, with a 302 to the new resource) if everything was correctly verified and created. that way, you don't care if the client has just GET the related resources, or if that was a week ago, or if the user copied from a napkin. if the reference is valid, accept it; if it's not, don't. -- 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: What causes request.session to be erased?...When you go to different view?
On Fri, Jul 9, 2010 at 11:36 PM, Chris Seberino wrote: > elif form.is_valid(): > ... > request.session["posts"].append(form.cleaned_data) > > > I noticed that everytime I revisit this form and rerun this view, the > request.session["posts"] lists gets blown away and is empty again!?!? > > > Am I misunderstanding something about requests and sessions? from the docs (http://docs.djangoproject.com/en/1.2/topics/http/sessions/#when-sessions-are-saved): # Gotcha: Session is NOT modified, because this alters # request.session['foo'] instead of request.session. request.session['foo']['bar'] = 'baz' In the last case of the above example, we can tell the session object explicitly that it has been modified by setting the modified attribute on the session object: request.session.modified = True that's exactly your case. the session object is saved automatically only when it's marked as modified. but when you modify an object inside the session and not the session itself; it doesn't gets notified of the change, so you have to tell it explicitly. -- 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: Advice on creating apps
On Fri, Jul 16, 2010 at 4:38 AM, barun wrote: > The question am pondering over is, whether I should create separate > apps for each of these sections. I'll have different database tables > for each of those sections. Or should all the sections come under a > single app, with a single model.py file defining the related models? my 2c: separate apps according to functionality, not according to user perception. if all (or several of) these sections can be modeled by the same code, do a single generic app that allows for enough configurability to manage all the different cases. for example, there's a well-known tagging app; if you plan to have tags on, say, theory chapters, and also on references; you would use the same django-tagging app on both. similarly; if you can describe the implementation of your sections with the same code; then use one app for all of them. OTOH, if each section has different coding and modelling requirements, by all means, do separate apps. -- 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: Database systems
On Fri, Jul 16, 2010 at 7:10 AM, Doane wrote: > I'm a new Django user. Which database management system should I use > in developing Django apps, MySQL or PostgreSQL? Why? this is a religious question especially without any information about your case. so, follow your faith :-) -- 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: What is a good source code control software?
On Fri, Jul 16, 2010 at 7:09 PM, Greg Pelly wrote: > I recommend finding an external host. They are cheap and you won't have to > worry about hardware/backups/administration yourself. i second that. if you have a distributed team, this is a huge timesaver. i'm happily using repositoryhosting.com, it's very cheap bug good solid service, not only SCM (SVN, Git or Mercurial) but also unlimited Trac instances. a totally different option i really like is Fossil (http://www.fossil-scm.org/); it's a distributed SCM, wiki and ticket system on a self-contained executable, very handy, very comfortable (by the same author as SQLite). you can also set it as a centralized server with apache and two lines of bash. the only downside is that it's not as popular as SVN, Git or Mercurial. -- 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: DecimalField, how to accept $ character
On Tue, Jul 20, 2010 at 9:10 AM, reduxdj wrote: > Users on my site can't type dollar signs without a form error showing. > I'd rather allow them > to type a dollar sign then clean it away after the fact? Can i see an > example for this procedure please. just put the $ sign on the field's label, that way the users won't feel the compulsion to type it :-) -- 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: about some ideas for our very largest project
On Wed, Jul 21, 2010 at 2:24 PM, RNGLAB wrote: > thanks for your ideas > > yes django is amazing framework for daily web applications. not for > core programming. this project's is needs very powerful cores > programming. it's usually accepted that most web frameworks have a 'ceiling', and when reached you have to start tearing it apart and replacing with custom code that better handles extreme loads. in Django case it's somewhat easier than on most frameworks because of the loose coupling between components. you can replace the ORM with another one if you want, or the templates, or the wsgi server... that said, Django's 'ceiling' is much higher than immediately obvious. clever use of cache alone can get you a huge boost in efficiency at very low complexity cost. also knowing when to denormalize your data, or apply some preprocessing (like google loves to do) lets you grow by orders of magnitude. i don't think any "institutional applications" would outgrow a really appropriate design on Django (heck, even Rails could do it on the right hands!). the usual counterexample to the "my framework is better than yours!" argument is how yahoo still uses PHP on heavily accessed sites. -- 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, Rails but a cost to pay ?
On Tue, Aug 3, 2010 at 9:23 AM, Masklinn wrote: > On 2010-08-03, at 16:19 , didier rano wrote: >> What do you think about this post ? >> http://blog.skeedy.com/django-rails-but-a-cost-to-pay > That it's empty and useless, and solely written for getting hits. add to that terrible grammar and disconnected discourse. it reads like a bunch of SMS messages. -- 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.
fixtures with permissions
Hi in my system, i have a few predefined groups, and some custom permissions. the predefined groups have a strictly defined set of these permission; it's a very basic part of the specification. so, i defined these groups and the required permissions and dumped to a fixture file. after cleaning it to remove the basic tables, i set it as the 'initial_data' fixture. it worked very well. to write tests, i use the same fixture and a few more defining test data and users. so far, no problem. the problems arose when i refactored some of the tables. now the tests fail because the test users have wrong permissions. after checking a little, i found the auth_permissions records are generated in a different order, so the number-based relationship in the initial_data fixture is all wrong. even worse, it's wrong in different ways in the 'real' database and the test database, i guess because the real database has been growing with each syncdb, while the test database is generated from scratch each time. there was some work about non-pk relationships in fixtures. i don't know if it ended up in Django 1.2; but this is to be deployed on Django 1.1 is there a better way to express permissions in fixtures? or if not, can i run some python code after fixture loading to setup the relationships? -- 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: Long running process and time outs?
On Sat, Aug 14, 2010 at 1:28 PM, ydjango wrote: > I have a online user initiated synchronous process which runs anywhere > between 1-5 minutes and gives user status message at the end. It is a > very DB intensive process that reads and updates lots of mysql rows > and does many calculations. The process is run as part of a view > method. long-running tasks don't belong to the request-responce cycle, send them to a background process. one of the easiest solutions is to use "Ghetto Queues". it can look like this: - create a new 'task' table, with fields to specify how to process a task and a status field (preparing, ready, processing, done, failed), if needed a 'result' field and if possible a 'percent done' field too. - when the user initiates a task, don't process it in the view function. just add a new record to the task table, with all the info needed to process it and set in 'ready' state. then return. don't forget to note the task record ID somewhere you can relate to the user's action. - another process, separate from the Django server (can be a cron task in many cases) checks the task table and picks any record in 'ready' state to do all the needed processing, first changing it to 'processing' state. it should update the 'percent done' field, and set to 'done' or 'failed' when finished. - make some way for the user to get the status of the task, either revisiting the same URL (which should show the status if there's a task in 'processing'), or via some AJAX query. there are many variations of this strategy: you can have several 'workers' if you pay attention to the way it picks a task and sets to 'processing' (transactions make it easy to atomically pick one), if you need low latency between queuing a task and picking it by the worker process, you can replace the task table with a queue manager (check carrot and/or celery) -- 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: how to refresh a template' part
On Mon, Aug 16, 2010 at 9:29 AM, Imad Elharoussi wrote: > Hello > > In my view.py I make connection with a distant server and i have to get an > object from it every minute > how can I do that without refreshing all the page answer: AJAX hint: jQuery $('#refreshingelement').load(yoururl); -- 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: Long running process and time outs?
On Mon, Aug 16, 2010 at 1:43 PM, ydjango wrote: > Is there a way to put the process in a different thread or background > job directly from django view (without going through a queue and > cron)? sure, you could simply execute an external process; but then you have to be sure not to start too many of them (specially two of the same, when the user gets click-happy), poll status and result, etc. been there, got bored, reinvented ghetto queues (and only recently found they had a name) > I heard Python is not very good with multi threading because of GIL. I > am on Python 2.5 this is only a concern if your processing is CPU bound. if so, another reason to go off-process. -- 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: Displaying images
On Thu, Aug 19, 2010 at 10:00 AM, Bradley Hintze wrote: > you got the quotes wrong: -- 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: Displaying images
On Thu, Aug 19, 2010 at 10:28 AM, Bradley Hintze wrote: > Javier > > Unfortunately, changing the quotes as you explained did not work. likely the template isn't gettng the MEDIA_URL variable. if you show the generated HTML it would be easier to help -- 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: Displaying images
On Thu, Aug 19, 2010 at 10:49 AM, Bradley Hintze wrote: > > ... > > so it looks as if you're right, the template isn't gettng the > MEDIA_URL variable. > I thought this was taken care of in setttings.py (see previous > messages). Does something need to be done in url.py? no, it's done on a context processor: http://docs.djangoproject.com/en/1.2/ref/templates/api/#playing-with-context-objects most template-handling shortcuts and generic view automatically apply the default set of context processors; but one notable exception is render_to_response(). if you're using it, it's better to create the context yourself as shown in the note: render_to_response('my_template.html', my_data_dictionary, context_instance=RequestContext(request)) -- 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: Displaying images
On Thu, Aug 19, 2010 at 12:03 PM, Bradley Hintze wrote: > So do I create 'my_data_dictionary'? and whats in there? are you using render_to_response()? can't comment on your code if you don't show it -- 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: What's the best practice for initializing the state of the server?
On Thu, Aug 19, 2010 at 9:45 PM, buddhasystem wrote: > Thank you! I actually had something less fancy in mind, like initializing > data structures (possibly from a file), when the server is starts. > Basically, looking for "init" handle. point is, in a 'shared nothing' architecture, you don't know (nor care) how many instances of the server are running. those data structures you mention, are memory structures, reside on the database, or maybe on shared cache (like memcached)? if they have to be single instances for the whole system, they must reside on a shared resource; that is database or cache. for that, you should handle out of Django, like hcarvalhoalves suggested. if they are memory (python) structures, bear in mind that each server instance would have its own copy. if you still want these, just call the constructor function from an appropriate file, maybe urls.py or models.py by the way; if you think 'multiple servers' would only apply for a big deployment, remember that mod_wsgi and even flup can start multiple Django processes, kill them and restart them at will to better serve varying user demand. it's very seldom wise to 'hook' on that life cycle. -- 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: static files + index.html dynamic usign django
On Tue, Aug 24, 2010 at 7:33 AM, Piotr Kilczuk wrote: > P.S. Don't think about URLs as directories. +1 -- 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: Services Trade: Legal Work for help switching Django site to App Engine
On Fri, Aug 27, 2010 at 1:47 PM, Trendero.com wrote: > I have a site, trendero.com, built using Django and hosted with > RackSpace on its own server. To reduce costs, I'd like to switch the > hosting to App Engine, but I'm not a technical guy (had the site built > using contractors). just one advice, GoogleAppEngine isn't totally compatible with Django. it can run, but needs some reprogramming. exactly how much depends on the complexity of your site and (most of all) the personal programming style used by your developer. much easier, and you might still save some money, is to migrate to a cheaper VPS. rackspace are good, but expensive. migrating to another VPS might take just a couple of days (at most!) for any sysadmin. while reprogramming the app for GAE could take a significant time. -- 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: Template syntax
On Fri, Sep 3, 2010 at 11:10 AM, Bradley Hintze wrote: > -In my template I put {{ param1.0 }}, expecting to see the first list > in the list of lists. > Result: nothing was printed to the page. that zero becomes a string '0', not a numeric 0. IOW, it's not param[0], it's (among other things) param['0'], clearly not what you want. -- 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: Tools to ease template/ui development
On Tue, Sep 14, 2010 at 4:18 PM, pixelcowboy wrote: > I would really love something like pyjamas but that works with jquery > or something like that. What I would really love is to forget every > other programming language and just use python everywhere. Wouldn't > that be sweet? the problem with pyjamas (and similar 'translators') is that you use Python syntax with all the common limitations of JavaScript. for example, in JS you use 'objects' for dicts, and they can only use strings for keys. another one: when i first tried it, it didn't support yield(), so many built-in iterators just didn't work. i guess it has improved, but you could only forget about JS if they reproduce all of python standard libraries. that would be a _huge_ bloat for the browser. -- 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: Escaping text for raw SQL?
On Tue, Oct 12, 2010 at 10:46 AM, Nick Arnett wrote: > Anybody know a good way to do this? Words.objects.filter(foo__in=mylist) -- 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: How long is a model validation heavy testsuite supposed to run?
2010/10/13 Jonathan Barratt : > not being an SQLite user myself but knowing the database image is a simple > single file you'd be surprised to learn that a good single-file architecture can be waaay faster than a more complex system. (good examples include Tokyo Cabinet and Varnish and, yes, SQLite) of course, RAM based DBs can be even faster too. -- 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: What is the best way to implement time-based / cronjob actions in a Django app?
On Wed, Oct 13, 2010 at 3:43 PM, Shawn Milochik wrote: > C. The Celery daemon polls the broker regularly, looking for tasks. i hope this isn't polling, but a signal initiated by the broker. -- 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: m2m relationship management
On Thu, Oct 14, 2010 at 4:45 AM, Justinas Jaronis wrote: > There > are some objects that will have about 20+ m2m relationships not knowing anything about your system, it might be the best solution; but in the _vast_ majority of cases this is a signal of suboptimal design. maybe there's some commonality that could be abstracted with table inheritance, or generic relationships. -- 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: Newbie question: How should I structure my very simple project / app?
On Tue, Oct 19, 2010 at 6:52 AM, wawa wawawa wrote: > So, given this paucity of requirements and the horrendously unclear > explanation above, what suggestions might you lot have? (Apart from "RTFM", > of course!) first and foremost, yes, you have to read the manual, and do the tutorial. ideally, you should forget about your specific project while doing it. it's not too long, should take a few hours to do completely. the fact is, if you skip this step, you won't get useful answers here. then, you'll see that it's easy to read the rest of the documentation to find anything you need for your project. if at any point you need some pointers, just ask here, in most cases you'll get a quick answer about where to find the relevant docs, together with some extra tips. and lastly, you'll find that your Django code shouldn't wait until your backend process finishes, so you'll have to spin the task out of the request/response cycle. the ideal answer is a queue manager, like RabbitMQ + celery. but if you don't foresee hundreds of files processed daily, a ghetto queue should be enough. for that, simply save the uploaded file somewhere, and note in the database any other parameters, meanwhile your background process checks the DB for tasks ready to be processed, takes them, and updates the status in the DB record. the user would check his task in some status page, and when it reaches the 'done' state, presents the result. good luck, and welcome -- 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: Expense of django query
On Tue, Oct 19, 2010 at 9:45 AM, Ed wrote: > Why is that? Is there a way to do this that doesn't result in two > queries? check: http://docs.djangoproject.com/en/1.2/topics/db/optimization/#don-t-overuse-count-and-exists there's a tip about loading the whole query once: use {% with actor_list.all as actors %}. after that, you could use {{actors|first}} to get the first one -- 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: Expense of django query
On Tue, Oct 19, 2010 at 3:46 PM, Ed wrote: > I have 3 tables: studio, film, images. If film has a foreign key to > studio, and images has a foreign key to film. If I wanted to pull all > of the images for a particular studio, it would be more expensive to > pull: what i do is: in the view, get the images of the studio, ordered by film: images_queryset = image.objects.filter(film__studio_id==studioid).order_by('film') in the template, iterate through the images and show the film whenever it changes: {% for img in images_queryset.all %} {% ifchanged img.film %} ...show the film data {% endifchanged %} show the image... {% endfor %} -- 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: Expense of django query
On Wed, Oct 20, 2010 at 7:59 AM, Ed wrote: > what is the purpose of ifchanged? since the images are sorted by film, if you just show the film for every image it would be repeated. with {% ifchanged %} it's only shown before all the images for this film, so the result is like this: film A image a.1 image a.2 film B image b.1 image b.2 image b.3 film C without {% ifchanged %} you would get: film A image a.1 film A image a.2 film B image b.1 film B image b.2 film B image b.3 film C ... -- 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: How to aggregate values by month
2010/10/28 Rogério Carrasqueira : > Thanks for you answer. Unfortunatelly I need to output my results on a JSON > file. Do you have any other approach? if the {% regroup %} is what you need, you should know that it's an application of itertools.groupby() -- 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: Converting Django to Desktop App? (Multiple Instances)
On Fri, Oct 29, 2010 at 3:41 AM, Mike Dewhirst wrote: > That looks a bit 'under the radar' with regard to locked roadmap etc. Why > not dig the pit a bit deeper and make your own server with Apache, Django > and your Oracle db. Much cleaner than Apache/Django everywhere. also, if it's going to be a 'hidden server', no need to use Oracle. MySQL and PostgreSQL are way more than enough. heck, even SQLite should cope with such a small load. -- 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: minimum system requirements
On Sun, Oct 31, 2010 at 12:10 PM, Peter Herndon wrote: > but I would not expect that single VPS to be able to handle more than a very > small number of visitors at once. only if you consider several dozens "a very small number" -- 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: 2D map application: performance and design question
On Mon, Nov 1, 2010 at 5:55 AM, Cal Leeming [Simplicity Media Ltd] wrote: > 9 out of 10 times, the bottleneck is usually the database true, but 8.7 of those 9 are about how the database is used, and not about the engine choice. simply changing SQLite won't improve significantly the one-user case. the trick is: 1) get as few db queries as possible for each page. 2) use appropriate indices for those queries but first of all, you have to identify if it is really the DB where you're spending time. the easiest way to be sure is to install django_debug_toolbar app, it's great to tell you exactly what's going on with the time and the DB accesses. -- 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: 2D map application: performance and design question
On Tue, Nov 2, 2010 at 3:35 AM, Lars Ruoff wrote: > Ok, so having excluded SQLite and the static served files, I'd like to > test if the server matters. What would be a minimum Apache install and > config to run Django locally (on Windows)? again, that's _very_ unlikely to be the cause. why not profile a little? if you're not handy with a python profiler, just set a var 'starttime = datetime.now()' at the beginning of your view function and a few 'print(datetime.now() - starttime)' at strategic points. -- 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: Converting plain string to dictionary
On Fri, Nov 12, 2010 at 3:40 AM, Pradnya wrote: > Please let me know if there is any other way to convert the plane > text / string into json if you have data in a non-standard format, you'll have to whip up your own parser -- 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: ReportLab and Django - templates? ; FK object has no attribute split
On Thu, Nov 18, 2010 at 6:08 PM, Victor Hooi wrote: > But yeah, I'd still love if there was a separate template I could use > to generate the PDF. It just feels very weird building up the PDF line > by line in views.py. the obvious answer is "write your own"; but it doesn't have to be a full-fledged templating language capable of creating any PDF imaginable. just what you need. IOW: write a simple function for each PDF format you need, with the data as parameters, and a file-like object to write on. if you wish, you can make it very non-django, the data input could be any python sequence of data objects, that way you can feed it a list of dictionaries, or a django queryset (handy for testcases). then your Django views can be almost as usual: get parameters from the request, data from the database, filter and preprocess all you need, and feed to the relevant PDF format function. that way you get the same content/presentation separation, even if the presentation is written in procedural python instead of descriptive templates. -- 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: How do I get tracebacks printed to terminal?
On Tue, Nov 23, 2010 at 3:48 PM, Markus Barth wrote: > I am using quite a lot of asynchronous calls for updating a page. The > problem is that this way you never see a traceback. In turbogears the > development server prints all tracebacks to the terminal. Is there any > way to get a similar behaviour with django? firebug can show the content of any request/response, including AJAX ones. it also renders any HTML content, like those generated by the Django error pages -- 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: umlaut
On Mon, Nov 29, 2010 at 8:24 AM, Brian Bouterse wrote: > Yes I think a template filter is the right approach. I'd say that generating UTF-8 HTML is 'more right' -- 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: Sqlite :memory: database for production?
On Mon, Nov 29, 2010 at 10:10 AM, Subsume wrote: > Right now I've got the name :memory: but the table always seems to be > empty, despite objects being created. from the docs (http://www.sqlite.org/inmemorydb.html): > Every :memory: database is distinct from every other. So, opening two > database connections each with the filename ":memory:" will create two > independent in-memory databases. -- 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: php script in django app
On Tue, Nov 30, 2010 at 10:51 PM, vamsy krishna wrote: > I am trying to embed an Ajax call to load some RSS feeds using a PHP > script in my Django app. This does not work and it returns my actual > PHP code which is not getting executed. This works when I try the same > outside of Django in Apache. i guess that it doesn't work when using Django's dev server. - to execute PHP, you need a PHP interpreter - Django's devserver is a simple Python HTTP server that translates every request into WSGI calls to Django. so should it work? no way -- 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 in production on Windows
On Wed, Dec 1, 2010 at 6:43 AM, ashdesigner wrote: > The only undiscovered issue to us is whether we can launch a heavy > loaded website in Django under Windows (IIS) + MSSQL. Would appreciate > any comment please. a WSGI plugin for IIS would be the best answer; but there's nothing wrong with FastCGI. properly managed can sustain as high load as anybody else. unfortunately, the most common FastCGI->WSGI adapter (flup) is quite good and performant; but limited in terms of dynamic process/thread lifetime managing. a more 'modern' approach could be gunicorn or Tornado. since both of them handle HTTP->WSGI, your IIS frontend would have to proxy those requests, but i guess that's a standard feature of any webserver -- 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: Unresolved import in Eclipse
On Wed, Dec 1, 2010 at 6:54 PM, Andre Terra wrote: > I've never used it as a plugin, just the standalone version. the standalone is just an Eclipse installer with the plugin already configured (and a few relevant others) -- 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.
Fwd: Django in production on Windows
On Thu, Dec 2, 2010 at 9:22 AM, ashdesigner wrote: > maybe I just don't get the point. i guess the point is that nobody likes IIS, so there's no development specific for that platform -- Javier -- 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: Fwd: Django in production on Windows
On Thu, Dec 2, 2010 at 10:05 AM, ashdesigner wrote: > not to use Python/Django > +IIS+Windows because of lack of support and tools immaturity ("hack" > approach). not at all. there are lots of goods reasons to go the *nix route (be it Linux, BSD, Solaris, etc). but Django does work anywhere Python does. FastCGI is _not_ a 'hack'. It's a standard -- 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: Fwd: Django in production on Windows
On Thu, Dec 2, 2010 at 10:29 AM, Sithembewena Lloyd Dube wrote: > it is a web server problem? Specifically IIS? if IIS can do FastCGI (and it should!) you can do django with flup if IIS can proxy HTTP (and it would be weird if it doesnt), you can do Django with gunicorn/tornado or, you can ditch IIS and use gunicorn on its own. it's a great webserver, and i guess it won't raise as many zealot alarms on win-only admins as asking to install Apache -- 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: Fwd: Django in production on Windows
On Thu, Dec 2, 2010 at 10:57 AM, ashdesigner wrote: > browsing through techy blogs I often saw FastCGI mentioned as someway 'slow', > 'deprecated', you're reading the wrong blogs > 'IIS7-incompatible' that might be true, i have no idea. a big reason to stay far from IIS unfortunately, i've just checked that both Gunicorn and Tornado are *nix only. no big surprise, since both use modern prefork+events architectures, which are clumsy on windows (to say the least). so, i think you have few options: 1: find if IIS can do FastCGI (and it should) 2: switch to a complete webserver (apache, ligthttp, nginx) 3: switch platforms. in the long run, option 3 is the best; but dealing with management, inertia and zealotry are huge obstacles, and it would be seen as a Django limitation; so i would seriously try option 1 first. option 2 is very good also, and note that both ligthttp and nginx are growing in usage precisely because they're extremely light and fast. also, see the fact that both use FastCGI as the main method to connect with backend apps. -- 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: Fwd: Django in production on Windows
On Fri, Dec 3, 2010 at 4:04 AM, ashdesigner wrote: > Frankly, I just don't quite get the #3 option. Do you mean switching > to *nix would entail considerable support/management issues? If so, > why *nix - native to Django - as you say, could be a limitation to the > framework? Is this what you mean? No, I mean that, if you're in a windows-only organization, and your admins don't cooperate, just suggesting another platform for Django could be seen by management as a limitation of Django and not a problem of their chosen platform. -- 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 & wsgi: what is the preferred webserver?
On Sun, Mar 7, 2010 at 4:21 PM, Shawn Milochik wrote: > Have a look here: > > http://code.djangoproject.com/wiki/ServerArrangements > > In general, you should have two Web servers (e.g. Apache and nginx or > lighttpd). Apache (with mod_wsgi) to serve Django and nginx or lighttpd to > serve the static files (CSS, JavaScript, images, etc.). AFAICT, mod_wsgi can be 'separate enough', leaving Apache free to host static files. another setup is a light and fast server (lighttpd, nginx, cherokee) plus Django on FastCGI. again, it's two separate processes (web server / FastCGI server). in short, it seems that these days the main thing to avoid is mod_python and static files on the same Apache instance. -- 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 ORM
On Tue, Mar 23, 2010 at 11:04 AM, jrs wrote: > The recommendation to avoid web requests for long-chain deletes, most > of the time, makes no sense. There are frequently valid cases of long- > chain deletes being basic to web requests. those cases are best served by an off-request process -- 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: Using Mako as a templating language
On Sun, Mar 28, 2010 at 12:34 PM, Colin wrote: > Or any other templating language that's a bit looser in allowing a bit > of logic to mix in with the presentation layer? PHP -- 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: Passing context variables from template to view
On Mon, Mar 29, 2010 at 3:07 AM, derek wrote: > Is there a possibility to store longer term data in the session > variable (assuming one is dealing with logged-in users)? you should write that data to the user's profile; or to any DB record with a ForeingKey to the User model -- 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: Giving up PHP. ...Can't decide between Django & Rails
On Fri, Apr 9, 2010 at 11:13 AM, UnclaimedBaggage wrote: > Ooops - forgot one other thing: > > I'm a little concerned by django error handling. The tracer stack > seems to miss the relevant file a lot of the time, and I often find > little help from the error pages even when it does get the right page > (eg an error comes up with a useful file/line # in the debug page, but > the cause is on another page and I'm struggling for indications as to > where the bad code actually came from). This could, of course, just be > my inexperience with the language, but do more experienced developers > regularly find themselves having to "guess and hunt" exceptions/ > errors? > > Secondly, typoed template variables don't seem to throw exceptions. Is > there a way of changing this? I haven't seen much in the way of > getters/setters in example code, and I'm concerned that may make > typoed variable/list/dictionary declarations more difficult to hunt > down. > > Cheers again. ;-) this comments are mostly about Python, not Django. from this (and your mention that like Rails syntax better than Django's), i can guess you like Ruby more than Python, or at least, you're more familiar with it. if that's right, then you should first choose between learning Python or staying with Ruby. after that, your framework choice is more than obvious. of course, syntax preferences are subjective and very visceral. i'm not a big fan of Python's syntax; but there are very few languages that i find more hideous than Ruby. :-) total bliss for me would be a Django-like ORM for Lua... -- 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: how to use IPC in Django??
On Mon, Apr 12, 2010 at 5:19 AM, vishwanath b wrote: > tom i know the programming language is python but the framework is > djangoso i want to know how to use the python socket code in this > framework that is what my question is? - there's no IPC code in Django - there are lots of IPC in Python that's why you should look for Python, not Django -- 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: could i use a select?
On Wed, Feb 8, 2012 at 9:53 AM, Dennis Lee Bieber wrote: > I don't > think the slice is "present" early enough to be turned into an "offset x > limit y" query yes, it is; and yes, it does -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: About managing dependencies in a collaborative development team and good practices.
On Tue, Feb 21, 2012 at 8:24 AM, Sébastien Billion wrote: > Set a virtualenv is good thing. You can write a shell script which set the > virtualenv and install all the external module with pip -r. Use pip -r > nameofrequriementsfile.txt. In this file, put the list of module with > version. i do exactly that. just a tip: to create and maintain the pip requirements file do: pip freeze > piprequirementsfile.txt -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: About managing dependencies in a collaborative development team and good practices.
On Wed, Feb 22, 2012 at 9:17 AM, Santiago Basulto wrote: > I'm unsing virtualenvs and Pip. Seems great, is really easy that way. > > What about deployment? Will it be simple? Or should i care about the > specific webserver? on deployment there should be a 'real' webserver (as opposed to the development server) and probably some wsgi server, database, cache, queues, whatever your project needs. besides that 'platform' needs, you also have the webapp itself: your project and all the python dependencies (django, and extra apps like South, celery, tagging, etc.) for this, it's (almost) the same as for development: create a virtualenv, pull from repository, and pip-install all dependencies. the main difference is that instead of you running the dev-server, the infrastructure (including your wsgi server) will execute your app. exactly how that's done is different for each deployment architecture. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Mysql problem
On Thu, Feb 23, 2012 at 6:21 AM, kalyani ram wrote: > a backend having about 2lakh records i couldn't resist, and found this: http://en.wikipedia.org/wiki/Lakh translated, it's "about 200,000 records" -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is GeoDjango Too Much For This?
On Sat, Feb 25, 2012 at 7:50 PM, DF wrote: > Finally, > I want to provide users the ability to search for nearby posts or > within a certain boundary (from the documentation I've read, this is > what GeoDjango apparently excels at). that's the point. it seems easy, until you write some SQL to express the 'nearby' criteria... and find that you're doing a very expensive full-table scan. a GIS database handles spatial indexes, so queries like "order by distance to this point, retrieve the 20 closest" or "all points inside this polygon" are done quickly and efficiently no matter the number of points in the database. Postgres and SQLite handle these type or queries; some MySQL versions can deal a few of them. better go with Postgres, as it's far more tested (and used by core developers) -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Going crazy with WSGI
On Mon, Feb 27, 2012 at 11:19 PM, atlastorm wrote: > WSGI is a script that connects Django to > Apache. not really WSGI is just a standard, a document that says "the web server will call the app as a function with such and such parameters, the app will return such and such values with the response" armed with that, any Python developer can write a web app just following the 'app' part of the standard, and any web server that wants to call those apps do the calls following the other part. specifically, mod_wsgi is the apache plugin that launches a Python interpreter and do all the calls according to the standard, and Django is a framework that follows the WSGI standard. besides, some WSGI-compliant servers need a little extra information to specify exactly what web app to call, and in mod_wsgi case, it's done with 'the wsgi file'. but this is specific to mod_wsgi, other servers do that differently. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Going crazy with WSGI
On Tue, Feb 28, 2012 at 5:58 AM, atlastorm wrote: > Right now I'm practicing Django by running the Django server > (manage.py runserver) and everything works. Apache also runs but I > have no clue what its doing. nothing. the Django development server (the one that runs with the runserver command) is an intentionally-limited web server. you don't need Apache for development. but this server will absolutely not be appropriate for real world serving, no matter how light the load. > If I close the Django server, how do I > run my application? If I save a django.wsgi file in mysite/apache/ > django.wsgi will things happen automatically? you need the mod_wsgi docs for that. the Django page about deployment in mod_wsgi should be enough to get you running in the simplest case. > When I practiced CGI with python, I had to import the cgi module and > use that to get the inputs from an html form. Do I have to do > something similar with Django? no. Django manages everything between WSGI and your apps. you shouldn't need any extra Python code besides what you run under the development server. in fact, the development server uses WSGI too, so if your code already runs there, it should also run on Apache/mod_wsgi once you get that configured. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Filtering model searches by a property (as opposed to a field)
On Wed, Feb 29, 2012 at 3:16 PM, Tom wrote: > Is it not possible to filter based on a property? queries are compiled to SQL to be sent and processed at the database; properties are Python code, the database knows nothing about them. that's why the compiler only allows you to use database fields on a filter > What is the correct method for doing this? the generic answer is to do it in Python, something like: result = [ record in queryset if record.property == value ] but this can be very inefficient, and nowhere as flexible as Django's querysets. much better is to translate the criteria into something the database can process. In this case, find the beginning and end of the current week and use a range filter. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: best resources for learning django
On Fri, Mar 2, 2012 at 1:23 PM, gowtham wrote: > Not sure if it is the best one (would like to here from Pros on this). But > following really helped me to get started. I finishing this tutorial in 2 > days and the next two days, i started and had a working application (simple > though) for my project.. > > https://docs.djangoproject.com/en/1.2/intro/tutorial01/ even if you find any other 'better' source, the tutorials are a necessary prerequisite. there are lots of times where a newcomer asks something in the list and even if the answer might not be in the tutorials themselves, not doing them leads to a big obstacle to communication. for me, the best order is: - the tutorials (all of them, even if they're not related to your needs) - ask a little in the list. - read other sections in the documentation. - read the Django Book. even if it's a little dated, the concepts stay valid. - ask a little more on the list - read the whole docs. - start answering on the list! yes, that helps learning too -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problems creating django project in Windows 7
On Wed, Mar 7, 2012 at 11:03 PM, Mika wrote: > But I'm just curious about the > objective advantages of Ubuntu over Windows vis a vis django? all OpenSource tools and libraries are developed first and foremost to work on unix-like systems. while most of them do work very well on windows too, it's always a second-class system. conversely, if you develop on .NET, you can deploy on Linux if you want, but it's always a step behind on that stack. it's much easier to just go with the preferred platform. > Why would > Windows cause headaches down the road? there are several things: maybe you'd want to use IIS which doesn't play well with FastCGI / WSGI. or NGINX, which runs great on POSIX, but on windows you're limited in the choice of backtransports. or uWSGI, which has a lot of very handy process control abilities... but few of them works on non-POSIX environments. or you want Redis as a mind-numbingly-fast on-memory database, but it's unsupported on windows because it can't do persistence without sane fork() primitives. > Also, is VMWare or Virtualbox > necessary? How would it benefit my development environment? if you want to try a new OS, you have two options: install on a real machine, or on a virtual machine. if you certainly can keep your windows OS and tools and just use a linux machine as a test server. since it doesn't need a lot of power for that, you can avoid dedicating a real machine by using a virtual one. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django is very slow on windows server 2003, mssql database
On Tue, Mar 13, 2012 at 7:57 AM, Virginia wrote: > We add datas but not that much to slow it down so > much. this is usually not about data itself, being heavy but about having a bad algorithmic behavior. the most common culprit is having unexpected queries inside a loop. for example: {% for msg in message.objects.all %} {{ msg.author.get_full_name}} {{ msg.text }} {% endfor %} sounds clean, no? but if the 'author' field is a ForeignKey, getting the full name might do a new query for each message. then you have the awful "N+1 queries" problem (1 to get all messages, and N for all the users). in this case it's easy to add 'select_related' to the first line. a slightly harder case (but almost as common) is when you have nested loops (say, listing all books for each author). here select_related usually won't help; you have to reformulate the loop. typically you can list all books sorted by author and insert an {% ifchanged book.author%} within the loop to display the author info at the appropriate places. another one that bite me is fetching related fields in the __unicode__ function, this makes a simple list (or popup menu) increasingly heavy. it could be fixed with select_related, just like the first case; but if if happens in the admin pages, you might not be able to add it where needed. fortuately, the admin objects can be annotated to make the necessary prefetching. finally, to find this before going to production, you just have to check on the number of queries per page. it's not important to cut everything down to just one or two; just check that the total number of queries doesn't grow when the data grows. For this a great tool is the django_bebug_toolbar, it clearly shows every query used to generate each page. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django is very slow on windows server 2003, mssql database
On Tue, Mar 13, 2012 at 9:55 AM, Phanounou wrote: > I installed the django_debug_toolbar and I see that in the sql part I have > 1852 queries in 18228.00ms. great, so this is indeed the problem. which page is this?, the listing or the edit page? check the SQL code, which tables is it accessing? if this happens on the edit page, it might be when constructing the select elements. how does the __unicode__ of the related models look like? -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django is very slow on windows server 2003, mssql database
On Tue, Mar 13, 2012 at 10:41 AM, Phanounou wrote: > When I look at the traceback from the django_debug_toolbar, there is 1852 > queries in 20956ms, there is several repetition of the same calls. And there > is a lot of unnacessary calls. How can I optimise that? what can I do about > it? is there a way to overwrite the page for a given object. Because I > realise that my custom pages take less time to load. in a similar situation, i found that defining the formfield_for_foreignkey() method lets you optimize the queryset used for the selection widgets. check the admin docs, there are lots of tuning there. specifically https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey and many more. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django is very slow on windows server 2003, mssql database
On Tue, Mar 13, 2012 at 2:14 PM, Phanounou wrote: > Hello, > > have tryed to use the formfield_for_foreignkey() and > formfield_for_manytomany() in the admin.py file. In fact, I have reduced > the reponse time (around 10 sec. less then before) by replacing extra = 2 by > extra=0 in my admin.StackedInline objects. It still taking 20-24 seconds to > edit an object in the admin interface. The 2 methods mention on top did not > help to reduce the time. I don't know what else to try now I'm stuck. Any > one has a subjection? this is what did the trick for me: def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == 'pagina': kwargs['queryset'] = Pagina.objects.select_related() return super(EventAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) in short, it adds the select_related() to the queryset used for the 'pagina' foreign key. that was needed because the __unicode__() method of the Pagina model uses some related fields. but you still haven't verified what generates the thousands of queries. take the tieme to read the SQL generated to see what is it fetching and why. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django making box
On Tue, Mar 13, 2012 at 3:37 PM, Sophia wrote: > Thanks all for helping, as I told I read that tutorial, but my supervisor > said that I should do that with Django. He didn't mention about learning > JavaScript, but is it impossible just with Django? django runs on the server. if you want to do some client processing you need code running on the client, typically Javascript. of course that code is served from a Django app, and modifying a django-handled page and form, so the project in a whole is still 'done with Django'. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django is very slow on windows server 2003, mssql database
On Wed, Mar 14, 2012 at 7:55 AM, Phanounou wrote: > This is what is taking the most of the time. the gattering of the list of > TObjectAttribute, 3 or 4 times each at a time because TmyObject has 3-4 > attributes value. Because I called it as an admin.StackedInline object in > the admin page. > > I don't know how to resolve this issue. find where is it loading the list of TmyObject objects (or rather, a queryset of them) and add select_related() to it. quite likely, it's on formfield_for_foreignkey() or a similar method. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django is very slow on windows server 2003, mssql database
On Wed, Mar 14, 2012 at 8:56 AM, Phanounou wrote: > I got itmany thanks Javier for your patience and your help.I put > formfield_for_foreignkey method everywhere and now it's super fast. I'm glad > you help me find the solution. Again thanks a lot. You made my day :-) great. i'm glad i wasn't too far off the mark -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Database User-Side Access Basics
On Wed, Mar 14, 2012 at 1:35 PM, Fady Kamal wrote: > no i need a tutorial to help me do these tasks that's exactly what was suggested: go to the Django site and do the tutorial. incidentally, most of the exercises are about a poll application -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Testing class based views
On Thu, Mar 15, 2012 at 10:47 AM, msbuck wrote: > I have used class based views in my latest project. Now I'm trying to write > tests. I can write tests like the ones I wrote for function based views but > these seem to me to be functional tests. Does anyone do unit testing on a > class based view methods? I'm not sure how to go about instantiating a view > to use in a unit test. And I'm wondering if they are really useful and/or > worth the effort. typically, in my projects I try to put most of the functionality in the models, in most cases the views do little more than selecting the appropriate model object and show with a template, or just do a little verifications and call some model's methods. with that in mind, my full process looks like this in relation to tests: - first i design the data structure that supports the (yet unimplemented) functionality. for this i simply write the models.py files, repeatedly calling the graph_models command so i have an auto-refreshing graphical view of the structure. here i spend some time thinking what belongs where, splitting and merging apps several times until they look fine, both in code and in graph. - when the models diagram fits my vision, i start writing tests for the basic functionality. usually at this stage i write them in the same models.py, and interact only with the models layer. in a typical TDD methodology, i write tests that exercise the concepts and then write the methods to implement them. sometimes this grows to the point where i have to split models.py into a subdirectory. - when the tests do in python most of what i want the user be able to do via web, i start to write the views, urls and templates. sometimes i found i have to write some extra data handling code. if i can't push it down to the models, then i try to factor it out to a 'utils.py'. there i should (and sometimes do) first write tests (now in tests.py, not in models.py). still, the tests are kind of 'unit tests' trying to test the code out of the web environment (but usually don't bother to write mock objects to please the Unit test idealists) - finally, when the views are mostly working, i write some tests that use the test client to do fake web requests. these tests are not TDD, and have more 'integration test' flavor. typically they're there to ensure user restrictions and to refuse to do some actions or to show some data when not appropriate. I use lots of 'assertRedirects' and 'assertNotContains'. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Question about threading a view[REPOSTED]
On Tue, Mar 20, 2012 at 9:52 AM, Arruda wrote: > But I still wanted to know how to use the celery in this case =/ the idea is to use a Queue: you have a separate process (typically implemented in a manage command) that stays running, and waits for messages in the queue. when the web app wants to do some slow processing, writes any needed parameters to the queue and returns with a 'wait...' message the background process receives the queue item and does the process without tying up the web response. the first implementation almost everybody does is called "Ghetto queues", it consist of writing the parameters to the database in a 'todo' table, and a cron process that periodically checks these todo's and processes them. it works, but falls down at a certain load. after that, you need a real queue manager; either RabbitMQ, Redis Queues, or a lot of other options. Celery is a python package that allows you to simply add a '@task' decorator to any function; so that when you call them, they're not executed, but instead the argument list is pushed to a queue. it also creates an admin command that does the queue reading and actually calls the functions with the arguments it founds on there. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: [bump] Preventing JOIN while checking if a self referencing FK is null
try: > Blog.objects.filter(editor_id=None) -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Automatic indexes on foreign keys
On Fri, Mar 23, 2012 at 4:37 AM, Aryeh Leib Taurog wrote: > My understanding is that one usually > wants an index on the *referenced* field, not the *referencing* > field. it's for the back-reference link. so that you can do group.item_set.all() and get all the items that share a group. yes, the unique_together index implies the other one and could be used, but Django doesn't do that analysis for you. yes, it seems you could drop the index, but be sure to test if any of your queries is affected. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Simple question on queryset.
On Tue, Mar 27, 2012 at 1:57 AM, Stanwin Siow wrote: > queryset = Memberships.objects.get(id__exact=4) the .get() method doesn't return a queryset, it returns a record object, so your 'queryset' variable is the 'membership' object itself. the error you get: > Memberships has no attribute all. means exactly that, you already have a Membership object, no need to iterate it calling .all() using the .filter() call you do get a queryset, but since you're using the primary key, you won't ever get more than one object, so it is more appropriate to use .get() -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django error about utf8 with BOM when running "python manage.py compilemessages"
On Tue, Mar 27, 2012 at 3:52 AM, Davide Setti wrote: > But that file is in django, not in his code, am i wrong? many brain-dead editors silently add BOMs to files when saving. being a .po file, i'd guess somebody did a small localization by editing it with the wrong tool. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Implementing Tagging with Django
On Fri, Mar 30, 2012 at 3:02 PM, Willy wrote: > Django-taggit works quite well, I would suggest trying it over > django-tagging can you elaborate on why do you find it better? i have only tried django-tagging some time ago, and maybe on a soon project would like to do better -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Profiling Django (WAS Django database-api)
On Tue, Apr 3, 2012 at 8:21 AM, Andre Terra wrote: > I have some complex and database intensive asynchronous tasks running under > celery which take a LONG time to complete and I'd just love to be able to > keep track of the queries they generate in order to optimize and possibly > remove the biggest bottlenecks. the easiest would be to write detailed logs, which _can_ be analysed in real time, not only 'after the fact'. my second idea would be to hack the log output so instead of writing to a file, it would store messages (probably with some structure) to some comfortable database. I'd use Redis, but i guess MongoDB or even an SQL-based DB could work too. then you can easily filter and aggregate times according to task type, when it happened, etc. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Profiling Django (WAS Django database-api)
On Tue, Apr 3, 2012 at 5:25 PM, Andre Terra wrote: > To make things a little more complicated, the task involves writing a large > amount of data to a temp database, handling it and then saving some > resulting queries to the permanent DB. This makes it a tad harder to analyze > what goes on in the first part of the code. i haven't had that kind of problem, but these are the things i would try: - time-limiting logs. if the last call was too recent, just discard the message (for some log levels, those used in the inner loops) - send the logfiles to fast devices (maybe even in ram, like tmpfs in Linux) and aggressively rotate them (so they don't accumulate needlessly) - log to a fast database (like Redis) and do automated analysis every hour or maybe even every minute, discarding the raw log entries. - log to a listening process that checks if each (time limited) entry is out of the ordinary. if so, keep it for analysis. if not, discard it. 'ordinary' could mean if some indicator is growing or reducing as expected, or just changed from the last, or stable, or whatever you could expect from your intended calculations. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Profiling Django (WAS Django database-api)
On Wed, Apr 4, 2012 at 4:07 AM, Tom Evans wrote: > One pretty cool method I've used for live debugging in the past is to > 'log' to rabbitmq (Note - not celery - raw amqp), and send messages to > a logging exchange. You can use a topic key so that different > processes can be distinguished. a similar thing can be done with ZeroMQ, with the advantage of not needing a mq daemon. but i guess Andre already uses rabbitmq, so yours would be the easiest way. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Contrib Auth + Class Based Generic Views
On Wed, Apr 4, 2012 at 4:14 AM, Sergiy Khohlov wrote: > As result your views.py should be : > > from django.views.generic import TemplateView > # Create your views here. > class HomeView(TemplateView): > template_name='home.html' > > Only three lines of the code ! > You dont need more! if in urls.py you replace (r'^$', login_required(HomeView.as_view())), with (r'^$', login_required(TemplateView(template_name='home.html').as_view())), you don't need any HomeView class! -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: [Question] Filter Queryset in a Template
On Mon, Apr 16, 2012 at 6:00 AM, Nikhil Somaru wrote: > If I do the filtering in views.py, I the template would have to make > assumptions about the type of context variables I will be passing it. > > Or am I seeing this the wrong way? i think so. the view is where you manage _what_ is shown, the template is where you manage _how_ is shown. from that, filtering is usually more apropriate to be done on the view. i usually don't worry too much about the template assuming the view works in a specific way, since templates are _so_ rarely reusable (except for inheritance, but i don't think it's your problem) i don't really get what do you mean by "would have to make assumptions about the type of context variables", filtering data (in the view) usually shoudln't change type of variables (querysets are still querysets), it should only change the content of them. -- 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.