postgresql_psycopg2 configuration
I have successfully installed psycopg2 and postgresql, start a project and app, in project's settings.py DATABASE_ENGINE = 'postgresql_psycopg2' but after I run manage.py syncdb, it shows error: http://pastebin.com/m3538debc could anyone help me make sure which config is wrong or am I missing other config settings using postgresql_psycopg2? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Looping through my POST data?
On Sat, 2007-07-28 at 19:44 -0700, Greg wrote: > I tried to implement the above view. However, I'm having errors. > Again i think it has to do with the u character in my dict. Here is > my view: [... snipped ...] > This is the error I get: > > MultiValueDictKeyError at /rugs/cart/addpad/ > "Key 1 not found in u'2': [u'1'], u'5': [u'0'], u'4': [u'0'], u'7': [u'0'], u'6': [u'0'], > u'8': [u'0']}>" > > It can't find the key 1...because the key is actually u'1'??? I don't > know where the u is coming from. Form data values are always strings. The u'1' means it's a Unicode string in Python, but it's still a string. The fact is, we have no way of knowing, when somebody sends the byte for "1", whether they mean a string or an integer, so we don't guess. This is normally why helper functions, such as a newforms.Form subclass are normally used: it can validate that the data is what you are expecting (integers in this case) and convert them to the correct Python types. If you can't model the submitted data as a form somehow (e.g. if it's not regular enough), you are going to have to convert the values to the right Python types yourself. Form data names are always strings (essentially), so converting them won't be too useful. Possibly the solution in your case is to simply coerce the id values to Unicode strings (even normal strings will do) before comparison. So something like if request.POST[str(a.id)] != 0: # ... Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Looping through my POST data?
I tried to implement the above view. However, I'm having errors. Again i think it has to do with the u character in my dict. Here is my view: def addpad(request): if request.method == 'POST': pads = request.session.get('pad', []) pad = RugPad.objects.all() #assert False, pad for a in pad: if request.POST[a.id] != 0: opad = RugPad.objects.get(id=a) s = opad.size p = opad.price pads.append({'size': s, 'price': p, 'quanity': request[a]}) request.session['pad'] = pads return HttpResponseRedirect("/rugs/cart/checkout") /// This is the error I get: MultiValueDictKeyError at /rugs/cart/addpad/ "Key 1 not found in " It can't find the key 1...because the key is actually u'1'??? I don't know where the u is coming from. Thanks On Jul 28, 10:25 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Right... because, unless I'm misunderstanding your code... you're > creating a select drop down for each of your RugPad entires with the > RugPad id. So you know that the request.POST is going to have entries > for each id... > > But..I think it should be this: > opads = RugPad.objects.all() > for a in opads: > if request.POST[a.id] != 0: >opad = RugPad.objects.get(id=a) >s = opad.size >p = opad.price >pads.append({'size': s, 'price': p}) > > So now you'd be iterating through each of your rug pads, and checking > to see if the corresponding drop down had a non-zero value selected, > instead of iterating all of the request.POST keys. This way you can > have other items in your form if needed. > > On Jul 28, 10:58 am, Greg <[EMAIL PROTECTED]> wrote: > > > Carole, > > So your saying that I should do: > > > opad = RugPad.objects.all() > > for a in opad.id > > if request[a] != 0 > > .#add to session > > > On Jul 28, 8:43 am, "[EMAIL PROTECTED]" > > > <[EMAIL PROTECTED]> wrote: > > > Greg... I'm curious as to why you're iterating over the entire > > > request.POST when you could just use the id of each pad that you've > > > previously passed to your template to retrieve it from the > > > request.POST dict, as that is what you've named your select statements > > > with? > > > > While iterating through all of the request.POST key/value pairs works, > > > if you choose to later add any other inputs to your screen that aren't > > > drop downs for your CarpetPads, you'll have to add special code for > > > each of them so that your code won't attempt to add a RugPad for those > > > key/value pairs. Just wanted to point that out, in case you might > > > need to do that later. > > > > Carole > > > > On Jul 28, 9:15 am, Greg <[EMAIL PROTECTED]> wrote: > > > > > Nathan, > > > > Thanks for your help...I got it working. This is what I used: > > > > > if values != list("0"): > > > > > Is that what you were recommending? Because I couldn't convert a list > > > > (values) to a int. Since values was a list I decided to convert my > > > > int to a list and that worked. Can you tell me what the u stands for > > > > when i do a 'assert False, values': It returns a [u'0']. Why doesn't > > > > it just return a ['0']? Also, it there anyway that I can convert the > > > > 'values' variable to a int so that I can do a comparison without > > > > converting the 0 to a list? > > > > > Thanks > > > > > On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > > > > To illustrate with the Python shell: > > > > > > >>> 0 == "0" > > > > > False > > > > > >>> 0 == int("0") > > > > > > True > > > > > > On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote: > > > > > > > On Jul 27, 2007, at 10:36 PM, Greg wrote: > > > > > > > > AssertionError at /rugs/cart/addpad/ > > > > > > > [u'0'] > > > > > > > > Does that mean that the value is 0? below is my view function and > > > > > > > template code: > > > > > > > That little 'u' in front of the '0' means unicode so the value is > > > > > > the > > > > > > unicode string "0" not the number zero. Very different as far as > > > > > > Python is concerned. You may be used to other scripting languages > > > > > > that auto-convert. Python is not one of them. > > > > > > > try: > > > > > > num = int(values) > > > > > > if num == 0: > > > > > > deal_with_zero() > > > > > > else: > > > > > > deal_with_number(num) > > > > > > except ValueError: > > > > > > # hmm, values is a string, not a number > > > > > > deal_with_a_string(values) > > > > > Hope that helps. --~--~-~--~~~---~--~~ 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,
Using LimitRequestBody to Limit File Uploads
Hello, I have recently begun testing LimitRequestBody to limit file uploads. It works but there are some issues. Whenever the uploaded file hits the limit, I get "Connection reset by peer". Ideally I would like to be able to redirect the user to an error page but it seems that Django tries to run but it hits an exception: Traceback (most recent call last): File "/opt/ActivePython/lib/python2.4/site-packages/django/core/handlers/base.py", line 77, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/opt/ActivePython/lib/python2.4/site-packages/django/db/transaction.py", line 194, in _commit_on_success res = func(*args, **kw) File "/home/preownedcar/djangoapps/preownedcar/CoreApp/views.py", line 1108, in offer_post new_data = request.POST.copy() File "/opt/ActivePython/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 69, in _get_post self._load_post_and_files() File "/opt/ActivePython/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 50, in _load_post_and_files self._post, self._files = http.parse_file_upload(self._req.headers_in, self.raw_post_data) File "/opt/ActivePython/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 119, in _get_raw_post_data self._raw_post_data = self._req.read() SystemError: Objects/stringobject.c:3518: bad argument to internal function I get that traceback emailed to me every time an uploaded file hits the limit set by LimitRequestBody. I am using Django 0.96 and this is on the production server. Someone posted something similar on this list last December but the last question by the OP was never really addressed: http://groups.google.com/group/django-users/browse_thread/thread/162a66bf92cc5c37/b33c637c502b669e Has any progress been made with regards to handling 413 from within Django? -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: db mock for unit testing
On Sat, 2007-07-28 at 19:36 +0300, Andrey Khavryuchenko wrote: > Russell, > > RK> On 7/27/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: > >> > >> Then I've paused and wrote DbMock class for django that uses some black > >> magic to steal django db connection and substitute it with temporary > sqlite > >> in-memory db. > > RK> How is this different to the default Django behavior if you specify > RK> SQLite as your database? Can't you get exactly the same behavior by > RK> creating a test_settings.py file that contains: > > RK> from settings import * > RK> DATABASE_BACKEND='sqlite' > > RK> and then run: > > RK> ./manage.py --settings=test_settings test > > RK> ? > > Just replied on django-developers: I need database mock to speedup tests. > Mocking them into in-memory sqlite was the simplest way to reach this w/o > losing flexibility. That isn't an answer to the question Russell asked, though. You can get exactly the same end-effect (using in-memory SQLite) if you specify SQLite as the database engine in the settings file you use for testing. Deriving your testing settings file from the main settings file is just a matter of importing and replacing the right variable. The advantage of specifying SQLite directly (and the drawback to trying to "fake it") is that Django won't inadvertently use any MySQL- or PostgreSQL-specific SQL constructs under the covers when calling the database. There are places we consider the value of settings.DATABASE_ENGINE when constructing the SQL and we may leverage that more in the future. So what advantages are there to the mocking approach over just replacing the setting? Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms.CharField now returns unicode, but how to specify encoding?
On Fri, 2007-07-27 at 05:42 -0700, Gilbert Fine wrote: > I used django rev. 5559 for some time. After svn up today, I found > CharField's cleaned_data is unicode. I think it is a good idea. > Actually, I made this conversion in my source program. > > The only question is how to specify encoding of the string sent from > client browser? My users almost certainly using gb2312, not utf-8. This is documented in unicode.txt in the source. Online, it is at http://www.djangoproject.com/documentation/unicode/ although that may not be linked from the front documentation page yet (adding the doc file name after documentation/ is the pattern we use, though, so it's easy to guess -- an advantage of predictable URLs). If form submission is not in the default character set, it is up to you to set the encoding in your view function each time. However, we've given you the ability to do that for just the reason you mention. We don't do anything automatically (even with "accept-charset", since it's unreliably implemented and the browser doesn't always send the right information). Regards, Malcolm > > > Thanks. > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there any way to associate a view with a template?
On Jul 28, 1:33 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Yeah I was going to post a sample if that's what he said next :) Here > is another sample in addition to the link above .. on how to pass the > menu code via context processors: That works great! Thanks a bundle Carole! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Insert vs. Update
On Tue, 2007-07-24 at 20:59 +0800, Russell Keith-Magee wrote: > On 7/24/07, PyMan <[EMAIL PROTECTED]> wrote: > > > > Can anyone tell me why Django do this while using save()? : > > The behavior comes from the Object relational mapping (key word - > Object). Since save() is an operation on an Object relational mapper, > it was established as an unambiguous mechanism to get object instance > X onto the database. This means creating a row if one doesn't already > exist, and updating the existing row if it does. > > > Am I wrong? What am I missing? Surely something, please tell me what. > > You're not the first to suggest insert() and update() methods that > explicity do SQL INSERT and UPDATE calls. I have a vague recollection > that a decision was made about adding these calls, Late to the party here, since I'm catching up on a backlog, but I can possibly add some historical value... No really decisive consensus was reached. The problem is that insert() and update() methods don't solve many (any?) problems at all and they avoid solving things like the session collision problem and a number of the subtleties for custom primary keys (which were the only times they are really needed). I don't think they're necessary to this particular issue, either. I had a feeling there's a reason for the current setup, but I can't remember it right now. I'll try to recall. Using something like REPLACE or other extensions will be easier with the new query creation. We can revisit that then (I already have a note about it in my work). Cheers, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Name of inclusion-tag template built in run-time
On Mon, 2007-07-23 at 15:20 +0200, Peter Melvyn wrote: > Hi all, > > > I have a box containing some static texts in different languages and I > would like to plug-in into few pages as inclusion tag. > > But I'm not able to find-out a way how to supply language code for its > template name containing thos static text. I need something like this: > > register.inclusion_tag('%s/tag_cust_support.html' % > request.LANGUAGE_CODE, takes_context=True)(.) I'm not sure how you've got your code set up, but typically register.inclusion_tag is executed precisely once: at import time. At that point, there's not necessarily any concept of a current request. The other problem here is that inclusion_tag creates the name of the tag based on the name of the function passed to it. So you can only create one tag from each function. > > Please, is it somehow possible to access language code of current session > or I should pass those static text via underlying Python function? If your template is passed a RequestContext, you have access to the user's current locale settings (see the i18n documentation for details and ignore the small bug that says there are two variables available and then lists three things; three is the right number). So you might want to create a tag that isn't based on inclusion_tag, but rather inspects the requests locale and delivers the right content at rendering time. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model design help
On 7/28/07, Cole Tuininga <[EMAIL PROTECTED]> wrote: > I could do something like a simple many to many relationship in the > attendee model, but that doesn't indicate ordering (most preferred to > least preferred) per timeslot. You might want to look at thisL http://www.djangoproject.com/documentation/0.96/models/m2m_intermediary/ -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Model design help
When you use a ManyToMany field, a "private" table (not tied to a model like other tables) is created in the database with something like the following (created via the contrib.auth.User's user_permissions field: id, user_id, permission_id If you wanted to create your own table that mirrors this one (i.e. has two fields, "user" and "permission"), then you have the equivalent of ManyToMany. You can also add other fields (e.g. "order"). The big difference between this approach and using M2M are the methods you use to access information in those tables, otherwise they are equivalent. In fact, if you have an existing M2M field you can convert it to this approach without much difficulty. HTH, -rob On Jul 28, 11:00 am, "Cole Tuininga" <[EMAIL PROTECTED]> wrote: > Hey all - I was hoping I could solicit some help with a model design. > I'm using 0.96 rather than the svn version at the moment. > > I'm working on a website for my wife that is intended to help with > taking registrations for a conference. The idea is that each workshop > in the conference has a "timeslot" attribute. Obviously, multiple > sessions can point at the same timeslot. Timeslots are also models so > that as the conference is organized, my wife can alter them through > the admin interface. > > When a person registers, they are asked to select their top three > choices of workshops for each timeslot. The thing is that as the > timeslots are variable, I'm having trouble figuring out how I should > set up the relationship between the attendee and the selected > workshops. > > I could do something like a simple many to many relationship in the > attendee model, but that doesn't indicate ordering (most preferred to > least preferred) per timeslot. > > Have I explained this well enough? Anybody have thoughts? > > -- > Cole Tuiningahttp://www.tuininga.org/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Terminate HTTP connection
On Fri, 2007-07-20 at 07:36 -0700, [EMAIL PROTECTED] wrote: > Hi, > Can I terminate a connect without receiving all HTTP request > package? I have to check if there are some important data, if not, > just terminate it. No. This doesn't actually make sense for something like Django. By the time Django receives the call, the web server will have already received the data. So you can't short-circuit anything there and the HTTP request from the client is complete at that point. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
PARA TODOS, IMPORTANTE, PUEDES GANAR DINERO MUY COMODAMENTE
Copia y pega en tu navegador el siguiente link y empieza a generar beneficios al instante. http://groups.google.com/group/grandes-genios-de-la-economia . --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need some advice in new project
Hi, > [...] > All models etc. are the same in each, but we expressly don't want to > store same data in same table (i mean all companies bank accounts are > in different tables) > We have to create new 'database' dynamically from a web based > interface seamlessly. > Did you solve similar problem already? > Prefixing tables, different databases or what? You should not have to care about this, it's the "proxy" company's DBA business. It depends on what database vendor they use, how they deal with security, backups, replications, DBA's mood, what kind of data are stored, etc. As regards creating databases, schemas, users, tablespaces, etc..., you can do it in python with the DB-API modules for the relevant vendor and put a web interface in front of it. >From the Django side, beware of the fact that the database support has limitations (no MSQL, no Oracle, no schema on Postgres). Olivier --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blog engine
Henrik Lied escribió: > When you say "installs", do you mean that the plugin is retrieved from > the external site, and placed somewhere on the users host, or is it > constantly querying the plugin on a remote computer? > > The first of those two options would definitely be the best. But I'm > having some problems working it out IRL: > Let's say you've just installed the Akismet-plugin. How are we > supposed to notify the comment framework that a new plugin has been > installed - and better yet - how it should use it? This is a valid > problem for almost every plugin. If we manage to resolve a good answer > to that question, I'm done being a critic. :-) > The first version should do ;) As for your question about "letting the comment app know", it would be a nice idea to keep looking at django for answers. Does this situations sound familiar? I was thinking of middleware. You might "register" a plugin to work agains some app (or apps) and therefor, make the app(s) call certain methods within the plugin. The plugin would only have to implement those methods. If we do the "registering" stuff at database level, it would be a snap to automate the installation. Only, the apps need to know that they must call something. Definately, the current django apps (like comments) do not behave that way, and hacking them is not the answer. What about a plugin middleware? It could check incoming requests for certain data in the request (perhaps a post key?) and do something accordingly. If there's a way to make this approach work with a single middleware (BlogPluginMiddleware?) this would be a pretty nice beginning :-) Chris signature.asc Description: OpenPGP digital signature
Re: Is there any way to associate a view with a template?
Hi, > Oh, I do that, but it still requires setting the variable "menu" in > every single view based on that template. You may want to check out Jinja [1], a templating engine very close to the Django one, which enables to set variables in the template. It's not very much advertised here, but it's really a great stuff for those baffled by Django templates limitations. Olivier [1] http://jinja.pocoo.org/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need some advice in new project
Hi Anna, On 7/28/07, anna <[EMAIL PROTECTED]> wrote: > > Hello my friends. > > I need your help in designing our new based application. > The goal is to build a kind of backoffice system, which helps to > organize all data of a specific company. > No problem with it. Build your models, data structures, input and > output 'screens'. > > But... > this application goes to a 'proxy' company, who's job is organize > other companies data. (Assume its an accounting firm, for example) > All models etc. are the same in each, but we expressly don't want to > store same data in same table (i mean all companies bank accounts are > in different tables) > We have to create new 'database' dynamically from a web based > interface seamlessly. > Did you solve similar problem already? > Prefixing tables, different databases or what? > > Thank you for any advice. So you want to change setting values when the application is running? Sorry, if I didn't understand your problem right. If I understood correct, this could help you: http://code.google.com/p/django-values/ Not sure if it's already usable. > Anna Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Need some advice in new project
Hello my friends. I need your help in designing our new based application. The goal is to build a kind of backoffice system, which helps to organize all data of a specific company. No problem with it. Build your models, data structures, input and output 'screens'. But... this application goes to a 'proxy' company, who's job is organize other companies data. (Assume its an accounting firm, for example) All models etc. are the same in each, but we expressly don't want to store same data in same table (i mean all companies bank accounts are in different tables) We have to create new 'database' dynamically from a web based interface seamlessly. Did you solve similar problem already? Prefixing tables, different databases or what? Thank you for any advice. Anna --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there any way to associate a view with a template?
On Jul 28, 12:30 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Why not have a base template that contains the menu variable ( I put > mine in a session variable accessible to the templates named menu ), > then have all of your other templates extend from that template? Oh, I do that, but it still requires setting the variable "menu" in every single view based on that template. I was hoping I could use a view for nav.html which is included in that menu block and there I could set menu once and once only but have it work on every page. It's easy enough to do that with SSI, just make nav.html a seperate page and map a uri to it (thus letting you use a view) then include it with SSI inside the menu block. I was wondering if that's the only way, not every server supports SSI. Thanks, -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there any way to associate a view with a template?
Yeah I was going to post a sample if that's what he said next :) Here is another sample in addition to the link above .. on how to pass the menu code via context processors: In your settings.py file ... Find the line that says (there may be more in there depending on your setup): TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.request",) Change it to something like this: TEMPLATE_CONTEXT_PROCESSORS = ('yourproject.yourapp.somepythonfile.menu',"django.core.context_processors.request",) Then under in your python code create a menu function which corresponds to the above: def menu(request): return {'menu': "some html code for the menu"} Then when calling up each of your views add (context_instance=RequestContext(request)) when calling render_to_response: return render_to_response('somefile.html', {'someothervariableyouyoumightwant':value},context_instance=RequestContext(request)) Now you can access this via {{ menu }} in any of your templates. On Jul 28, 2:26 pm, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > I could be wrong, but I think the problem he's having is having to > specify the menu variable in the context for every view, not the > template end of it... > > To fix that, you will want to check out context > processors:http://www.djangoproject.com/documentation/templates_python/#subclass... > > On Jul 28, 10:30 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Why not have a base template that contains the menu variable ( I put > > mine in a session variable accessible to the templates named menu ), > > then have all of your other templates extend from that template? > > > In base.html: > > > your header code > > > > {% block menu %} > > {{ menu }} > > {% endblock%} > > > {% block content %}{% endblock %} > > > > > Then in your other templates: > > {% extends "base.html" %} > > > {% block content %} > > content for your html specific page here > > {% endblock %} > > > On Jul 28, 1:13 pm, Eloff <[EMAIL PROTECTED]> wrote: > > > > I've got a nav.html template that does the menu on every page. The > > > only trouble is I have to store the menu items in a global variable > > > and pass it to the page template in every view. Is there any way to > > > make a view for the nav.html template (which is included in all the > > > page templates)? I imagine it could be done with SSI but I don't want > > > to go that route unless I have no other option. > > > > Thanks, > > > -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newforms - attributes for splitdatetimewidget
I've tried something like this: def my_callback(field, **kwargs): if field.name == 'pub_date': return SplitDateTimeField(**kwargs) else: return field.formfield(**kwargs) class mySplitDateTimeWidget(SplitDateTimeWidget): def __init__(self, attrs=None): widgets = (TextInput(attrs={'class': 'vDateField required'}), TextInput(attrs={'class': 'vTimeField required'})) MultiWidget.__init__(self, widgets, attrs) def format_output(self, rendered_widgets): return u'%s: %s%s: %s' %\ (_('Date'), rendered_widgets[0], _('Time'), rendered_widgets[1])) def manage_entry(request, object_id=None): ... baseForm = form_for_instance(entry, formfield_callback=my_callback) ... baseForm.base_fields['pub_date'].widget = mySplitDateTimeWidget() and it works with admin calendar.js! Cheers On Jul 21, 5:34 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/21/07, jeffhg58 <[EMAIL PROTECTED]> wrote: > > > > > I am just digging into the newforms functionality. I am looking at the > >splitdatetimewidget. > > I am trying to having a different attributes for the first field and > > the second field, and would like to know how to go about doing it. > > I would suggest setting up some purpose based widgets - a DateWidget > and a TimeWidget - that define their attributes. Then, compose > yourSplitDateTimeWidgetout of the two custom widgets, rather than using > two standard TextInputs and trying to pass attributes down to them. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there any way to associate a view with a template?
I could be wrong, but I think the problem he's having is having to specify the menu variable in the context for every view, not the template end of it... To fix that, you will want to check out context processors: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext On Jul 28, 10:30 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Why not have a base template that contains the menu variable ( I put > mine in a session variable accessible to the templates named menu ), > then have all of your other templates extend from that template? > > In base.html: > > your header code > > {% block menu %} > {{ menu }} > {% endblock%} > > {% block content %}{% endblock %} > > > Then in your other templates: > {% extends "base.html" %} > > {% block content %} > content for your html specific page here > {% endblock %} > > On Jul 28, 1:13 pm, Eloff <[EMAIL PROTECTED]> wrote: > > > I've got a nav.html template that does the menu on every page. The > > only trouble is I have to store the menu items in a global variable > > and pass it to the page template in every view. Is there any way to > > make a view for the nav.html template (which is included in all the > > page templates)? I imagine it could be done with SSI but I don't want > > to go that route unless I have no other option. > > > Thanks, > > -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Model design help
Hey all - I was hoping I could solicit some help with a model design. I'm using 0.96 rather than the svn version at the moment. I'm working on a website for my wife that is intended to help with taking registrations for a conference. The idea is that each workshop in the conference has a "timeslot" attribute. Obviously, multiple sessions can point at the same timeslot. Timeslots are also models so that as the conference is organized, my wife can alter them through the admin interface. When a person registers, they are asked to select their top three choices of workshops for each timeslot. The thing is that as the timeslots are variable, I'm having trouble figuring out how I should set up the relationship between the attendee and the selected workshops. I could do something like a simple many to many relationship in the attendee model, but that doesn't indicate ordering (most preferred to least preferred) per timeslot. Have I explained this well enough? Anybody have thoughts? -- Cole Tuininga http://www.tuininga.org/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there any way to associate a view with a template?
Why not have a base template that contains the menu variable ( I put mine in a session variable accessible to the templates named menu ), then have all of your other templates extend from that template? In base.html: your header code {% block menu %} {{ menu }} {% endblock%} {% block content %}{% endblock %} Then in your other templates: {% extends "base.html" %} {% block content %} content for your html specific page here {% endblock %} On Jul 28, 1:13 pm, Eloff <[EMAIL PROTECTED]> wrote: > I've got a nav.html template that does the menu on every page. The > only trouble is I have to store the menu items in a global variable > and pass it to the page template in every view. Is there any way to > make a view for the nav.html template (which is included in all the > page templates)? I imagine it could be done with SSI but I don't want > to go that route unless I have no other option. > > Thanks, > -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Is there any way to associate a view with a template?
I've got a nav.html template that does the menu on every page. The only trouble is I have to store the menu items in a global variable and pass it to the page template in every view. Is there any way to make a view for the nav.html template (which is included in all the page templates)? I imagine it could be done with SSI but I don't want to go that route unless I have no other option. Thanks, -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: db mock for unit testing
Russell, RK> On 7/27/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: >> >> Then I've paused and wrote DbMock class for django that uses some black >> magic to steal django db connection and substitute it with temporary sqlite >> in-memory db. RK> How is this different to the default Django behavior if you specify RK> SQLite as your database? Can't you get exactly the same behavior by RK> creating a test_settings.py file that contains: RK> from settings import * RK> DATABASE_BACKEND='sqlite' RK> and then run: RK> ./manage.py --settings=test_settings test RK> ? Just replied on django-developers: I need database mock to speedup tests. Mocking them into in-memory sqlite was the simplest way to reach this w/o losing flexibility. -- Andrey V Khavryuchenko Django NewGate - http://www.kds.com.ua/djiggit/ Development - http://www.kds.com.ua Call akhavr1975 on www.gizmoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: a rather big, new django site:
Hi, sorry.. were just two users had fun typing in a wrong age. :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: a rather big, new django site:
Hi Bram, On 7/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > > > http://www.splicemusic.com/ Looks cool, just one thing: Isn't the age displayed wrong? Every user is about 90 years old. :-) Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: caching and "hello username" on each page
Bram - Smartelectronix <[EMAIL PROTECTED]> writes: > I would LOVE to use caching for both anonymous and logged in users, but > the problem is that every page on our site (http://www.splicemusic.com) > has the typical "hello username | log out | ..." at the top of each page. > > Now, how can I possibly cache both anonymous and logged in users easily? > I'm guessing that I would need to add @vary_on_cookie before for each > and every view? If the username is the only thing you could store the username in a cookie and have Javascript write it out. Then the page is completly cacheable. -- Nic Ferrier http://www.tapsellferrier.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Organising django projects
It occurs to me that django-admin looks for a template page in the project and it it isn't there, it defaults to another admin template. It would seem as though it might be good for modularity if we had something similar to: attempts to render app1 /home/dev/django/proj1/template_dir/app1 /home/dev/django/proj1/app1/template_dir then normal path This would help out a lot if we could set this up. (I know it would be something HCoF would be interested in). Basically if a project specific template isn't there, it will default to the application specific template. It might also be nice to change this priority listing via settings.py. Has this been discussed before? What are the dev's feelings on this? -justin -- Justin Lilly --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blog engine
Ok, so I've been thinking some more. The model could be something like this: class Plugin(models.Model): """(Plugin description)""" pointer = models.FilePathField() ## Could work, right? name = models.CharField(maxlength=200) description = models.TextField(blank=True, null=True) url = models.URLField() apply_to = models.ForeignKey(ContentType) active = models.BooleanField(default=False) We then would have to make a standard on how the plugin-packages would be designed. A zip-file would probably work out OK. We would then have to get this zip-file, run through it and copy its files into a plugins- subdirectory. The package should have a info.txt-document, where the plugin title would be on the first line and description on the second. But - I'm still not sure how we'd easily hook this into other applications - at least not without the user having to modify the source code... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Looping through my POST data?
Right... because, unless I'm misunderstanding your code... you're creating a select drop down for each of your RugPad entires with the RugPad id. So you know that the request.POST is going to have entries for each id... But..I think it should be this: opads = RugPad.objects.all() for a in opads: if request.POST[a.id] != 0: opad = RugPad.objects.get(id=a) s = opad.size p = opad.price pads.append({'size': s, 'price': p}) So now you'd be iterating through each of your rug pads, and checking to see if the corresponding drop down had a non-zero value selected, instead of iterating all of the request.POST keys. This way you can have other items in your form if needed. On Jul 28, 10:58 am, Greg <[EMAIL PROTECTED]> wrote: > Carole, > So your saying that I should do: > > opad = RugPad.objects.all() > for a in opad.id > if request[a] != 0 > .#add to session > > On Jul 28, 8:43 am, "[EMAIL PROTECTED]" > > <[EMAIL PROTECTED]> wrote: > > Greg... I'm curious as to why you're iterating over the entire > > request.POST when you could just use the id of each pad that you've > > previously passed to your template to retrieve it from the > > request.POST dict, as that is what you've named your select statements > > with? > > > While iterating through all of the request.POST key/value pairs works, > > if you choose to later add any other inputs to your screen that aren't > > drop downs for your CarpetPads, you'll have to add special code for > > each of them so that your code won't attempt to add a RugPad for those > > key/value pairs. Just wanted to point that out, in case you might > > need to do that later. > > > Carole > > > On Jul 28, 9:15 am, Greg <[EMAIL PROTECTED]> wrote: > > > > Nathan, > > > Thanks for your help...I got it working. This is what I used: > > > > if values != list("0"): > > > > Is that what you were recommending? Because I couldn't convert a list > > > (values) to a int. Since values was a list I decided to convert my > > > int to a list and that worked. Can you tell me what the u stands for > > > when i do a 'assert False, values': It returns a [u'0']. Why doesn't > > > it just return a ['0']? Also, it there anyway that I can convert the > > > 'values' variable to a int so that I can do a comparison without > > > converting the 0 to a list? > > > > Thanks > > > > On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > > > To illustrate with the Python shell: > > > > > >>> 0 == "0" > > > > False > > > > >>> 0 == int("0") > > > > > True > > > > > On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote: > > > > > > On Jul 27, 2007, at 10:36 PM, Greg wrote: > > > > > > > AssertionError at /rugs/cart/addpad/ > > > > > > [u'0'] > > > > > > > Does that mean that the value is 0? below is my view function and > > > > > > template code: > > > > > > That little 'u' in front of the '0' means unicode so the value is the > > > > > unicode string "0" not the number zero. Very different as far as > > > > > Python is concerned. You may be used to other scripting languages > > > > > that auto-convert. Python is not one of them. > > > > > > try: > > > > > num = int(values) > > > > > if num == 0: > > > > > deal_with_zero() > > > > > else: > > > > > deal_with_number(num) > > > > > except ValueError: > > > > > # hmm, values is a string, not a number > > > > > deal_with_a_string(values) > > > > Hope that helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
caching and "hello username" on each page
hello everyone, I would LOVE to use caching for both anonymous and logged in users, but the problem is that every page on our site (http://www.splicemusic.com) has the typical "hello username | log out | ..." at the top of each page. Now, how can I possibly cache both anonymous and logged in users easily? I'm guessing that I would need to add @vary_on_cookie before for each and every view? - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: File Upload field problem in auto-generated django forms
Awesome, sorry about the duplicate reply! Thanks so much, though -Robert On Jul 27, 11:11 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 7/28/07, Robert <[EMAIL PROTECTED]> wrote: > > > > > Hi all- > > I'm very new to django, so pardon my faulty nomenclature! > > I'm trying to create a view that creates a guides the user through > > inserting some information into a table in my database. One of the > > columns in my database model is of the type "models.FileField()". > > Hi Robert, > > FileFields (and ImageFields) are one part of newforms that isn't quite > complete yet. If you look at ticket #3297, you can see the progress > that is being made on this feature. > > If you're adventurous, you could try applying one of those patches to > your version of Django; otherwise, be aware that this is high on my > list of priorities as something to fix. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Looping through my POST data?
Carole, So your saying that I should do: opad = RugPad.objects.all() for a in opad.id if request[a] != 0 .#add to session On Jul 28, 8:43 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Greg... I'm curious as to why you're iterating over the entire > request.POST when you could just use the id of each pad that you've > previously passed to your template to retrieve it from the > request.POST dict, as that is what you've named your select statements > with? > > While iterating through all of the request.POST key/value pairs works, > if you choose to later add any other inputs to your screen that aren't > drop downs for your CarpetPads, you'll have to add special code for > each of them so that your code won't attempt to add a RugPad for those > key/value pairs. Just wanted to point that out, in case you might > need to do that later. > > Carole > > On Jul 28, 9:15 am, Greg <[EMAIL PROTECTED]> wrote: > > > Nathan, > > Thanks for your help...I got it working. This is what I used: > > > if values != list("0"): > > > Is that what you were recommending? Because I couldn't convert a list > > (values) to a int. Since values was a list I decided to convert my > > int to a list and that worked. Can you tell me what the u stands for > > when i do a 'assert False, values': It returns a [u'0']. Why doesn't > > it just return a ['0']? Also, it there anyway that I can convert the > > 'values' variable to a int so that I can do a comparison without > > converting the 0 to a list? > > > Thanks > > > On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > > To illustrate with the Python shell: > > > > >>> 0 == "0" > > > False > > > >>> 0 == int("0") > > > > True > > > > On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote: > > > > > On Jul 27, 2007, at 10:36 PM, Greg wrote: > > > > > > AssertionError at /rugs/cart/addpad/ > > > > > [u'0'] > > > > > > Does that mean that the value is 0? below is my view function and > > > > > template code: > > > > > That little 'u' in front of the '0' means unicode so the value is the > > > > unicode string "0" not the number zero. Very different as far as > > > > Python is concerned. You may be used to other scripting languages > > > > that auto-convert. Python is not one of them. > > > > > try: > > > > num = int(values) > > > > if num == 0: > > > > deal_with_zero() > > > > else: > > > > deal_with_number(num) > > > > except ValueError: > > > > # hmm, values is a string, not a number > > > > deal_with_a_string(values) > > > > > Hope that helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blog engine
When you say "installs", do you mean that the plugin is retrieved from the external site, and placed somewhere on the users host, or is it constantly querying the plugin on a remote computer? The first of those two options would definitely be the best. But I'm having some problems working it out IRL: Let's say you've just installed the Akismet-plugin. How are we supposed to notify the comment framework that a new plugin has been installed - and better yet - how it should use it? This is a valid problem for almost every plugin. If we manage to resolve a good answer to that question, I'm done being a critic. :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: a rather big, new django site:
Bravo Bram! Looks really cool. It's one of best sites made with django i've seen. On Jul 28, 1:19 pm, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > http://www.splicemusic.com/ > > ( summary: upload sounds, load them into a flash audio sequencer with > effects and synthesizers + standard community features) > > thanks a lot to all the people who have helped me getting this thing up > and running! :-) > > cheerio, > > - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ifequal not working?
> Dan, ifequal cannot evaluate its arguments. They must be variables, > numbers or constants in quotes. Thanks Stefan, I'll remember that in future. > But you can do this: > > {% for item in menu_items %} > {% if forloop.last%} class="last-item"{% endif %} > {% endfor %} > Thanks Nathan, that's very helpful, much neater too. Figures there'd be a way to do that in Django. -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Looping through my POST data?
Greg... I'm curious as to why you're iterating over the entire request.POST when you could just use the id of each pad that you've previously passed to your template to retrieve it from the request.POST dict, as that is what you've named your select statements with? While iterating through all of the request.POST key/value pairs works, if you choose to later add any other inputs to your screen that aren't drop downs for your CarpetPads, you'll have to add special code for each of them so that your code won't attempt to add a RugPad for those key/value pairs. Just wanted to point that out, in case you might need to do that later. Carole On Jul 28, 9:15 am, Greg <[EMAIL PROTECTED]> wrote: > Nathan, > Thanks for your help...I got it working. This is what I used: > > if values != list("0"): > > Is that what you were recommending? Because I couldn't convert a list > (values) to a int. Since values was a list I decided to convert my > int to a list and that worked. Can you tell me what the u stands for > when i do a 'assert False, values': It returns a [u'0']. Why doesn't > it just return a ['0']? Also, it there anyway that I can convert the > 'values' variable to a int so that I can do a comparison without > converting the 0 to a list? > > Thanks > > On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > > > To illustrate with the Python shell: > > > >>> 0 == "0" > > False > > >>> 0 == int("0") > > > True > > > On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote: > > > > On Jul 27, 2007, at 10:36 PM, Greg wrote: > > > > > AssertionError at /rugs/cart/addpad/ > > > > [u'0'] > > > > > Does that mean that the value is 0? below is my view function and > > > > template code: > > > > That little 'u' in front of the '0' means unicode so the value is the > > > unicode string "0" not the number zero. Very different as far as > > > Python is concerned. You may be used to other scripting languages > > > that auto-convert. Python is not one of them. > > > > try: > > > num = int(values) > > > if num == 0: > > > deal_with_zero() > > > else: > > > deal_with_number(num) > > > except ValueError: > > > # hmm, values is a string, not a number > > > deal_with_a_string(values) > > > > Hope that helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Looping through my POST data?
Nathan, Thanks for your help...I got it working. This is what I used: if values != list("0"): Is that what you were recommending? Because I couldn't convert a list (values) to a int. Since values was a list I decided to convert my int to a list and that worked. Can you tell me what the u stands for when i do a 'assert False, values': It returns a [u'0']. Why doesn't it just return a ['0']? Also, it there anyway that I can convert the 'values' variable to a int so that I can do a comparison without converting the 0 to a list? Thanks On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > To illustrate with the Python shell: > > >>> 0 == "0" > False > >>> 0 == int("0") > > True > > On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote: > > > On Jul 27, 2007, at 10:36 PM, Greg wrote: > > > > AssertionError at /rugs/cart/addpad/ > > > [u'0'] > > > > Does that mean that the value is 0? below is my view function and > > > template code: > > > That little 'u' in front of the '0' means unicode so the value is the > > unicode string "0" not the number zero. Very different as far as > > Python is concerned. You may be used to other scripting languages > > that auto-convert. Python is not one of them. > > > try: > > num = int(values) > > if num == 0: > > deal_with_zero() > > else: > > deal_with_number(num) > > except ValueError: > > # hmm, values is a string, not a number > > deal_with_a_string(values) > > > Hope that helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django admin + apache + mod_python => breakage
hello everyone, I have a rather "well connected" model like this ( used here: http://www.splicemusic.com/contests/ ): class Contest(models.Model): [ snip of regular fields ] # the sounds people HAVE to use to enter the contest required_sounds = models.ManyToManyField(Sound, null=True, blank=True) # the soungs people HAVE to use to enter the contest required_songs = models.ManyToManyField(Song, null=True, blank=True) # how they should tag theior sounds to enter the competition sound_tag = models.ForeignKey('Tag', related_name=u'contest_sound_set') # how they should tag their song to enter the competition song_tag = models.ForeignKey('Tag', related_name=u'contest_song_set') # the winners of the contes if it's already finished winners = models.ManyToManyField(Profile, null=True, blank=True) # a forum thread w/ more explanations forum_thread = models.ForeignKey(Thread, null=True, blank=True) As you can see, quite a lot of many-to-many and foreign keys in there (and they all point to tables with over 30K entries, so the admin page takes about 10 minutes to load). Now, when we try to edit this model in the admin the apache instance goes nuts and starts eating ALL the memory on the machine: it almost immediately jumps to 1.5GB of RAM and then just keeps consuming until the kernell kills the process. Does anyone have an idea why this could be?? No other models in our application show this behaviour (then again, no other model has this many connections to the rest of the models) Editing the model via manage.py shell works just fine. - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
a rather big, new django site:
http://www.splicemusic.com/ ( summary: upload sounds, load them into a flash audio sequencer with effects and synthesizers + standard community features) thanks a lot to all the people who have helped me getting this thing up and running! :-) cheerio, - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
shoppingkicks.com Shop nike air jordan air force 1 dunk sb bape sta shoes on sale only $75
Nike Shoes Air Force I Air Jordan 1-10 Air Jordan 11-22 Nike Dunk SB Nike Dunk SB For Women Air Max Series Nike Shox R4 Nike For women Adidas Shoes Adi Color Adidas Campus Adidas Stam Smith Adidas Country Adidas 35 Super Star Adidas For Women Other Brand Shoes BAPE STA BAPE STA For Women Timberland Gucci Prada Ice Cream Dsquared2 Jeans Red Monkey Bathing Ape Evisu Jeans Item No: bape-7w Color: view photo Price: US$ 73.99 Item No: bape-6w Color: view photo Price: US$ 73.99 Item No: bape-5w Color: view photo Price: US$ 73.99 Item No: bape-4w Color: view photo Price: US$ 73.99 Item No: bape-3w Color: view photo Price: US$ 73.99 Item No: bape-2w Color: view photo Price: US$ 73.99 Item No: bape-1w Color: view photo Price: US$ 73.99 Item No: AF-new20 Color: view photo Price: US$ 83.99 Item No: AF-new19 Color: view photo Price: US$ 81.99 Item No: AF-new18 Color: view photo Price: US$ 82.99 Item No: AF-new17 Color: view photo Price: US$ 81.99 Item No: AF-new16 Color: view photo Price: US$ 83.99 Item No: AF-new15 Color: view photo Price: US$ 82.99 Item No: AF-new14 Color: view photo Price: US$ 82.99 Item No: AF-new13 Color: view photo Price: US$ 82.99 Shoppingkicks.com shop. Shoppingkicks shop Nike Air force one (AF1), Nike Dunk SB, Air Jordan I-XXI, Air Max95, Air Max97, Air Max2003, Air Max2004, Air Max 360, TN, R4, NZ. Adidas, A Bathing APE, GUCCI, Timberland shoes. Name Brand jeans such as Evisu, Red Monkey, BAPE, True Religion, Rock & Republic and Seven. Branded fashions included Polo, Bape T-Shirt. Branded sportswear included Jordans, Nike, Adidas etc. We offer high quality stuff with best wholesale price. Good credit & best services, shipping in time, smooth delivery are guaranteed! We hope to make a long term cooperation with customers all over the world. Attention please: All prices listed are retail prices,and ALL prices listed at the website include the shipping charge. Don't hesitate to contact us for wholesale details. Please note : Your tracking numbers will not appear at the USPS website until your item has reached US grounds. So when you received your tracking numbers give it three days before checking at the USPS website. If you cannot find your record there, try to check after a day or two. Please be reminded that tracking numbers will be emailed to you once your order has been shipped. Thank you - Shoppingkicks.com Admin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Organising django projects
Almad escribió: > Hi, > > I'd like to ask how to organize Django application. To me, structure > of project/app is nice idea, however I have problems applying it in > practice, so I'd like to ask about best practices. > > Problems come, when application structure become deeper and nested. Is > it usual to start an application inside application? Django-admin > disagree with it. > > How is it with dependencies? When part of application depends on > another, should it be subapplication, or normal top-level application > depending on another one? > > Plus, when django philosophy is to have "application packages", why > are templates separated into another directory structure? I'm more > familiar (from my personal cherrypy structure) with lib/apps for > model, tpl/apps and web/apps separation for M/V/C, but django seem to > mixing it together. > > What are reasons for this and what are best practices for structuring > bigger/complicated apps? > > > > > Here's an example of my latest project structure: /var/www/django < this is on the pythonpath. everything else, beneath it. tagging, registration, etc. <- apps I consitently use across most projects are held just there. These are all svn checkouts. In case there is a backwards incompatible change affecting a project, the app gets copied into the project folder. project/ <--- the root project folder (eg. contains the settings and url files) is beneath the django folder, among the common apps. project/webroot/static < contains the files to be served statically project/webroot/php < I'm a minter :P and I keep php stuff on a separate subdomainm just in case I need to move it. Then, if an app is particularly bound to some project (eg a project with a single app, or apps being used ONLY for that project) are held beneath the project root. Each app holds it's own template directory. The app template loader looks for this directory when loading a template. Actually, my default project setup is pretty different from what you get with startproject . I wonder how I could change the template it uses... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Blog engine
Henrik Lied escribió: > This is great, Chris, but the fact of the matter is that it won't > appeal to the "Wordpress crowd". > That group wants in-browser setup, easy plugin architecture etc. > contrib.admin wouldn't do the trick. The admin-panel would have to be > hand made. > > For the plugin architecture: I have no idea how we'd do this well. Any > input here? > It *could* be done in a Facebook Apps-manner (the actual code is > remotely hosted, the admin-panel would show a list of available > plugins), but I don't know how ideal this would be in a real world > scenario. It sure would be great, though! > > > On Jul 25, 12:06 am, "Chris Moffitt" <[EMAIL PROTECTED]> wrote: > >> I think I mentioned earlier in this thread, that I do have my take on >> creating a blog here >> -http://www.satchmoproject.com/trac/browser/satchmoproject.com/satchmo... >> >> It's pretty full featured right now and makes use of the tagging and >> comment_utils libraries. It still needs the feeds but that should be pretty >> simple. It's BSD licensed so hopefully it will be useful to folks. >> >> -Chris >> > > > > > What about the symphony way of plugins? You have a page in the admin with the latest plugins available (rss?) and you just click one and the app downloads and istalls it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Looping through my POST data?
To illustrate with the Python shell: >>> 0 == "0" False >>> 0 == int("0") True On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote: > On Jul 27, 2007, at 10:36 PM, Greg wrote: > > > AssertionError at /rugs/cart/addpad/ > > [u'0'] > > > Does that mean that the value is 0? below is my view function and > > template code: > > That little 'u' in front of the '0' means unicode so the value is the > unicode string "0" not the number zero. Very different as far as > Python is concerned. You may be used to other scripting languages > that auto-convert. Python is not one of them. > > try: > num = int(values) > if num == 0: > deal_with_zero() > else: > deal_with_number(num) > except ValueError: > # hmm, values is a string, not a number > deal_with_a_string(values) > > Hope that helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ifequal not working?
2007/7/28, Eloff <[EMAIL PROTECTED]>: > > Thinking myself clever I added enumerate as a filter and did: > > {% for i, item in menu_items|enumerate %} > {% ifequal i|add:1 menu_items:length %} class="last-item"{% endifequal > %} Dan, ifequal cannot evaluate its arguments. They must be variables, numbers or constants in quotes. To special case the last element of a list, do this: {% for item in items %} {% if forloop.last %} class="last" {% endif %} ... {% endfor %} -- Stefan Matthias Aust --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ifequal not working?
ifequal can't do filters, unfortunately. But you can do this: {% for item in menu_items %} {% if forloop.last%} class="last-item"{% endif %} {% endfor %} Or class="{{ forloop.first|yesno:"first," }} {{ forloop.last| yesno:"last," }}" On Jul 27, 11:42 pm, Eloff <[EMAIL PROTECTED]> wrote: > Thinking myself clever I added enumerate as a filter and did: > > {% for i, item in menu_items|enumerate %} > {% ifequal i|add:1 menu_items:length %} class="last-item"{% endifequal > %} > > To me I expect it to be true only for the last item, I printed {i|add: > 1} and it works as expected. However, what happens is it's always > true. I don't understand it, does someone know why this is? > > Thanks, > -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ifequal not working?
Thinking myself clever I added enumerate as a filter and did: {% for i, item in menu_items|enumerate %} {% ifequal i|add:1 menu_items:length %} class="last-item"{% endifequal %} To me I expect it to be true only for the last item, I printed {i|add: 1} and it works as expected. However, what happens is it's always true. I don't understand it, does someone know why this is? Thanks, -Dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Looping through my POST data?
On Jul 27, 2007, at 10:36 PM, Greg wrote: > AssertionError at /rugs/cart/addpad/ > [u'0'] > > Does that mean that the value is 0? below is my view function and > template code: That little 'u' in front of the '0' means unicode so the value is the unicode string "0" not the number zero. Very different as far as Python is concerned. You may be used to other scripting languages that auto-convert. Python is not one of them. try: num = int(values) if num == 0: deal_with_zero() else: deal_with_number(num) except ValueError: # hmm, values is a string, not a number deal_with_a_string(values) Hope that helps. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---