Making inline form completion 'required'
Hi, I want to make the completion of an inline form called 'orders' required within the parent 'Invoices' admin change form. To stop users generating invoices with no orders attached to them. Is there an easy way to implement that? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
"View on Site" in admin
Getting a NoReverseMatch at /admin/r/14/1/ on a model in Admin Here's the traceback: Traceback: File "/home/queryclick/webapps/django/lib/python2.5/django/core/ handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/home/queryclick/webapps/django/lib/python2.5/django/contrib/ admin/sites.py" in root 154. return shortcut(request, *url.split('/')[1:]) File "/home/queryclick/webapps/django/lib/python2.5/django/contrib/ contenttypes/views.py" in shortcut 15. absurl = obj.get_absolute_url() File "/home/queryclick/webapps/django/lib/python2.5/django/utils/ functional.py" in _curried 55. return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs)) File "/home/queryclick/webapps/django/lib/python2.5/django/db/models/ base.py" in get_absolute_url 515. return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' % (opts.app_label, opts.module_name), func)(self, *args, **kwargs) File "/home/queryclick/webapps/django/lib/python2.5/django/db/models/ __init__.py" in inner 30. return reverse(bits[0], None, *bits[1:3]) File "/home/queryclick/webapps/django/lib/python2.5/django/core/ urlresolvers.py" in reverse 254. *args, **kwargs))) File "/home/queryclick/webapps/django/lib/python2.5/django/core/ urlresolvers.py" in reverse 243. "arguments '%s' not found." % (lookup_view, args, kwargs)) Exception Type: NoReverseMatch at /admin/r/14/1/ Exception Value: Reverse for 'product_detail' with arguments '()' and keyword arguments '{'id': 1L}' not found. I do have a custom save method in there and a get_absolute_url defined as: def get_absolute_url(self): return 'products/%s/' % (self.id) I might not be offering up much info here but if someone might give me a few pointers as to where to look to debug that would be great! Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom Save and calculating totals - weird behaviour
Daniel, I think that's what is happening too. I'm wondering if the save issue has something to do with my Invoice admin class: class CustomerInvoiceAdmin(admin.ModelAdmin): inlines = [ CustomerInvoiceOrderInline, ] def save_formset(self, request, form, formset, change): instances = formset.save(commit=False) units = 0 for instance in instances: instance.save() formset.save() Thanks On May 13, 12:13 pm, Daniel Roseman <roseman.dan...@googlemail.com> wrote: > On May 13, 11:28 am, Alfonso <allanhender...@gmail.com> wrote: > > > > > Discovered a weird bug in my custom save method for a model. Setup is > > a simple invoice model linked to multiple invoice order models (fk to > > invoice) and the invoice model holds data like total number of units > > of ordered... i.e. > > > Invoice order 1: > > 2 x X DVD @$9.99 > > Invoice order 2: > > 5 x Y DVD @$9.99 > > > Invoice: > > Total units: 7 > > > So to get that invoice total I have a custom save method: > > > def save(self): > > # Grab total invoice units > > units = 0 > > for item in self.customer_invoice_orders.all(): > > units += item.quantity > > self.invoice_units = units > > super(CustomerInvoice, self).save() > > > This is all set up in admin with invoice order inlines so the admin > > user can edit and add to related invoice orders. > > > I thought it all works fine but if I adjust the quantity figure in an > > inline invoice order and hit save the new total in the parent invoice > > doesn't get updated, only gets updated if I hit save and continue > > first, then save again. > > > I'm sure it's something very elementary I'm overlooking > > > Thanks > > I expect this is happening because inlines are saved *after* the > parent model. So, think what happens: you click save, and Django first > goes to save the invoice. It goes to the database to get all the > existing InvoiceOrders, but only finds the old values because the new > ones haven't been saved yet. Only then does it go and save the > inlines. But the second time you click save, the new values in the > inlines have already been saved, so it picks them up, and properly > updates your parent model. > > I can't think of a very good way of solving this. One possibility > might be to put the update code in the form, rather than the model. > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Custom Save and calculating totals - weird behaviour
Discovered a weird bug in my custom save method for a model. Setup is a simple invoice model linked to multiple invoice order models (fk to invoice) and the invoice model holds data like total number of units of ordered... i.e. Invoice order 1: 2 x X DVD @$9.99 Invoice order 2: 5 x Y DVD @$9.99 Invoice: Total units: 7 So to get that invoice total I have a custom save method: def save(self): # Grab total invoice units units = 0 for item in self.customer_invoice_orders.all(): units += item.quantity self.invoice_units = units super(CustomerInvoice, self).save() This is all set up in admin with invoice order inlines so the admin user can edit and add to related invoice orders. I thought it all works fine but if I adjust the quantity figure in an inline invoice order and hit save the new total in the parent invoice doesn't get updated, only gets updated if I hit save and continue first, then save again. I'm sure it's something very elementary I'm overlooking Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
User Authentication Woes
Hi, App I'm currently working on can be accessed by either authorised admin users or authenticated customers (one customer might have a number of users on their account). A non-admin user can login and view restricted sections of the site to check stuff like invoices, orders etc. So as an example a customer, called bob can view his company's invoices at /customer/invoices/85 (number being the invoice number viewed). In an attempt to break it I changed the url to /customer/ invoices/84 and Bob can see invoice 84 but that invoices isn't registered to him, its for a different customer entirely. Obviously I'm missing some authentication magic to stop that happening. Question is I'm not sure how to go about that - is there a straightforward way I can implement more robust user authentication so a customer only sees the invoices they are destined to view!? Code for invoice list and invoice detail: http://dpaste.com/hold/42642/ Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Getting to the 'latest' item in a template list
Hi, I'm using the following to pull all cost prices that match a particular product by the company that supplied the product: View: cost_prices = ProductCostPrice.objects.filter (product_id__product_id=product_id) Template: ... {% regroup cost_prices|dictsort:"supplier" by supplier as cost_list %} {% for cost in cost_list %} {% for item in cost.list %} {{ item.date_cost|date:"d/m/Y" }} {{ item.supplier }} {{ item.cost_price_gross }} {% endfor %} {% endfor %} Works great - only thing is that in some cases there is more than one cost price in the db for a supplier, how do I just grab the latest price entered for each supplier? Familiar with latest() lookup but not sure about it's use in the above scenario. I feel I should know this but can't make it work. FYI there is normally more than one supplier for a product hence why it's set up like this. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Saving inline objects
I've got a very simple Order model and an invoice model. Currently within the admin section, the invoice admin page contains associated orders as an edit_inline. The user adds orders to the invoice by clicking 'save and continue editing' at which point the system pulls through the correct prices. It's all good... However, the client has highlighted a potential blip with this - what if the staff admin just wants to put together an invoice and not save it to the database until all the correct orders have been added. Once the invoice is saved only then can it be seen by a customer logging in, it shouldn't be viewable till the admin has clicked 'save' (as in save and commit, not save and continue editing). So I'm wondering - can I create a custom 'save and continue editing' method that will accomplish that? Not sure If I explained that properly but I hope it makes sense! --~--~-~--~~~---~--~~ 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: HTML Forms and Sessions - Help!
Daniel, Thanks.. point taken I'm still a bit of a n00b so bear with me: So I'm trying to store the form fields in sessions , user navigates to /search/ and can then use the search form there to search/refine the results. http://dpaste.com/hold/39182/ thats the main form and the code in Django: http://dpaste.com/hold/39184/ Tried creating the session data (if field is in request.GET, add to session data) then deleting it from the session once I've passed that checkbox True/False to the template. in the template I'm checking to see whether that default has passed through then setting the checkbox state on that Al On 29 Apr, 11:07, Daniel Roseman <roseman.dan...@googlemail.com> wrote: > On Apr 29, 10:15 am, Alfonso <allanhender...@gmail.com> wrote: > > > Hi, > > > Leading on from a post I made a few days ago I'm having real trouble > > dealing with sessions to preserve form state and the standard HTML for > > I placed in the template. I can't seem to get to the session data for > > the form once submitted (via GET) and I'm wondering is that due to the > > fact it's a standard HTML form, not a django form? > > > Its a search form that allows users to refine results so I figured > > setting it up as a POST was going to be overkill but now I wonder if > > POST and sessions are connected? Am I going to save time if I rewrite > > the form as a django form (want to avoid that if I can) > > > Thanks anyone > > What do you mean by 'the session data for the form'? Django's sessions > framework only saves data if you tell it to. There's no automatic > session data associated with a Django form. > > Perhaps if you post some code showing what you have done so far and > what you are trying to do, we can help you more. > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
HTML Forms and Sessions - Help!
Hi, Leading on from a post I made a few days ago I'm having real trouble dealing with sessions to preserve form state and the standard HTML for I placed in the template. I can't seem to get to the session data for the form once submitted (via GET) and I'm wondering is that due to the fact it's a standard HTML form, not a django form? Its a search form that allows users to refine results so I figured setting it up as a POST was going to be overkill but now I wonder if POST and sessions are connected? Am I going to save time if I rewrite the form as a django form (want to avoid that if I can) Thanks anyone --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Sounding out form state preservation with session variables?
Hi, I've got a form with a number of checkboxes that allow a user to filter their search query based on the usual suspects of things like location, facilities etc. So now I need a way to preserve these checked options after the form is submitted to allow the user to adjust what they are looking for (the same form appears on the search results page). I've found a solution in using the sessions framework to capture the checked options in the get header and send back a simple boolean to the form view so I can say: {% if england %} {% else %} {% endif %}England This works but of course I'll need to set a boolean for each checked option (of which there are about 20). My question is - is this the most efficient way I can get this functionality?? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding a link to edit_inline
Solved this myself with the excellent tutorial at http://www.juripakaste.fi/blog/django-admin-inline-link.html. Thought it might be of use to someone else here! A On 22 Apr, 19:48, Alfonso <allanhender...@gmail.com> wrote: > I think this is probably a number of questions in one so here it goes: > > I need to add a hyperlink to an inline record that will take the user > to a 'price history' view that lists the previous prices for that > inline product. My question is can I edit edit_inline for that model > only and no other? > > I have a feeling I can't do that (I can with change_form of course) > but would be very happy to be told otherwise. > > The other part of the question is I need this link to hold the inline > object id for it to work, so how to I grab that from within the > template? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Writing csv files to server
I need to generate a statement at the end of the month that grabs all the invoices for that month and lets the client knows who hasn't paid on time. Problem is the usual setup I have of creating a view/template that simply shows unpaid invoices (within a statement) doesn't stay persistent, i.e. when one invoice is paid it disappears from the statement and the client wants to have these statements as a sort of permanent 'snapshot' of everything that wasn't settled at that time. I'm at a bit of a loss to make this work but figure writing the relevant data to csv on the server and pulling it through in a custom django template could be a way to go. Does anyone have a better suggestion and how would I start writing to csv on server. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Adding a link to edit_inline
I think this is probably a number of questions in one so here it goes: I need to add a hyperlink to an inline record that will take the user to a 'price history' view that lists the previous prices for that inline product. My question is can I edit edit_inline for that model only and no other? I have a feeling I can't do that (I can with change_form of course) but would be very happy to be told otherwise. The other part of the question is I need this link to hold the inline object id for it to work, so how to I grab that from within the template? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
mnax_num and extra on inlines
I've set up an inline cost price formset and configured the inline form with extra = 1 and max num=1 in associated admin.py. Problem is the inline is displaying the last two entered cost price records... not the last one (by date) and an empty inline form for adding a new entry which is what I'm looking for ideally. Any Suggestions Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Setting dates
Hi, I'd like to set the default date of a datefield to be 'the 20th of the current month', if past that date the date should be set to the 20th of the following month. So if a record is created on 1st April the datefield would be 20th April 2009, if record is created on 21st April then the datefield would be 20th May 2009. Figuring a custom save method would do fine for this but not sure on the syntax re. datetime and relativedelta etc. Anyone got any ideas or code lying around that might help? Thank you! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Admin - Hide fields on add, show on change?
Is it possible to hide some irrelevant fields when a user adds a record via django admin, i.e. they are only relevant on the change view? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: help! i'm new in django
Hi 83nini, It doesn't matter too much where you place the actual project folder for the django code, just ensure all your paths are setup correctly. For example I just have mine sitting in ~/Users/me/django/ django_projects/ but could be anywhere. Good luck! A On 16 Apr, 14:41, 83nini <83n...@gmail.com> wrote: > Hi all, > > I'm new to django and i'm trying to go through the first tutorial to > create a website. I am using the tutorial on the official website, > problem is i have no idea where i should put the folder where i am to > keep the project that i'm making! > > thanks guys for help. > cheers --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
PDFs with Pisa
Hi, I'm trying out Pisa to generate PDFs and am getting a weird error when rendering the pdf: Caught an exception while rendering: 'Context' object has no attribute 'push' Here's the code I'm using (largely unchanged from pisa example) http://dpaste.com/34323/ It seems to hit this error whenever it encounters a '{% block something %} If I remove the block tags and simply have plain html it's not a problem. Also having difficulty displaying images unless I specify an absolute path. Would love to make this work, any help greatly appreciated --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Changing raw_id_field from 'id'
Is there an easy way to change the raw_id_field in a foreign key relationship? I'd like to change an inline formset to display not the item pk id alongside the raw_id_field 'magnifying glass' but a barcode field instead. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Editing Submit line Template in Admin
Hi, I know it's not possible to easily override the submit_line.html template on model/app by model/app basis but I'm wondering if anyone has discovered a workaround for adding custom submit_line functionality? Basically within one app I'd like to hide everything but 'Delete' and 'Save'. At the moment I've implemented this sitewide. On another app I'd like to adjust the wording a little from 'Save and continue Editing' to 'Update'. My client doesn't get the functionality of these buttons and thinking a little semantic change might help! I notice references to show_save_and_add_another in the template itself, are these controllable through the app's admin.py? Thanks A --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
JQuery magic in admin?
Hi, I've got two very unremarkable models, Invoice Order that has a foreign key to an Invoice model. There are some tax calculations that happen on the save of the order model that populate and update the corresponding fields in the Invoice model. All works fine and in fact all calculations in the system happen within a custom save function. So as far as the user is concerned they see a few fields that are empty but populated when the form is saved. The client has requested to see if we can improve that functionality and populate the necessary fields as the user fills in the form, so once a price and tax rate are added the final price field is populated also. Along with that the form will be populated with the relevent prices when a user selects the product to add to the order. complicated I think. My question centers around how I would implement such functionality, it screams to me JQuery or similar doing it's magic to perform the necessary calcs and then django reverts to a normal save function. Obviously that is a pretty big rewrite and I'd like to avoid making things complicated and losing what coding I've done. Does anyone have any better suggestions for how I might accomplish that sort of functionality fairly cleanly? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
regroup by date
regrouping some results by date and I can't seem to make it work on date only, i.e. not including the time - I get the following error "'unicode' object has no attribute 'hour'" when I try: {% regroup results by date_time|date:"D m Y" as results %} Am I missing a special Django filter to get grouping by date only? Thanks a --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Date Filtering in Django-Sphinx
Using sphinx for search in my django app and whilst it's great I can't seem to get any date filtering happening. Sphinx conf is fairly unremarkable: source event_event_en : base { # main document fetch query # mandatory, integer document ID field MUST be the first selected column sql_query = \ SELECT yadda ya..., UNIX_TIMESTAMP(date_time) as date_time, yaddy ya... FROM event_event sql_query_info = SELECT * FROM event_event WHERE id=$id # ForeignKeys sql_attr_uint= category_id sql_attr_uint= venue_id sql_attr_uint= event_type sql_attr_uint= artist_id sql_attr_uint= delivery_days sql_attr_uint= region sql_attr_uint= event_status # DateFields sql_attr_timestamp = date_time } And in my search view I have a simple filter (which is where I think the problem lies): if date == "next30": results = queryset.filter(date_time>=(datetime.datetime.now)) (Attempting to pull future dates just to see something happen) Where am I going wrong? Thanks A --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Pondering on django-admin preview?
Hi, Prepare for a likely, very unclear explanation... I've got the bare bones of a preview feature built into my django app, all thanks to the fine tutorial at http://latherrinserepeat.org/2008/7/28/stupid-simple-django-admin-previews/ and works just fine for newly created posts. But here's a mildly plausible scenario I need some help on, what about posts that have been published but then need to be edited and fixed - the user will likely re-save those posts as drafts and do what they need to do. The problem with that is that the site I have built relies on set content being present, so for example if the user re-saves the homepage text as a draft to fix something, that text disappears from the homepage until it has been 'published' again in the admin. Is there any way I can create some sort of adapted preview feature that allows the user to check the work but not overwrite the previous content until they are absolutely sure? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GeoDjango - Multiple Features in Shapefile
Hi, I have a shapefile of England loaded into a geodjango model that is a combination of administrative boundaries (counties essentially) of the entire country. I'm trying to put together a query search that will return activities by country (then ultimately county) but layermapping has loaded the shapefile features as separate records (which was anticipated). So my question is - is it possible in GeoDjango to query multiple shapefile features at once to determine if 'Swimming Activity' is in 'England'? I guess its a kind of 'search for results in all england counties'. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Absolute URL
Hi, Insanely simple answer here I think but I'm trying to sort some url errors in a mapping app. Virtual earth requires an absolute url to the KML file django is generating for me and I can't seem to work out how to define that in the urls.py. of course I can just prepend the site root to the VE javascript but who wants to do that for each page! Also the site url will change so changing the urls in the JS is a hassle I don't want to deal with. url(r'^kml/popular_sites.kml','myproject.myapp.views.popular_sites', name="popular_sites"), When using the above with {% url popular_sites %} I get '/kml/ popular_sites.kml' which V Earth doesn't like. Is there a simple change in urls.py to get the full (I guess permalink) url - http://mysite.com/kml/popular_sites? Perhaps in the associated view? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Post Save Signal the best plan?
Hi there, I've got a few tax calculations running on a custom save method within admin which work great but I need to build in the option to override these calculations manually. So I have 2 questions - is this what I'd use a post save method for (would I move the save calculations to a pre-save and add this manual override function to save method) and, is there a way to detect a manual change to a field in django? A 'if not changed [manually] then do this' kind of concept? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Swapping existing stacked inlines and 'add new inline' presentation
I've got a list of products with a stacked inline showing their (foreign key related) selling prices which are different depending on the customer. My client has asked if I can change the look and feel so that the inline facility to add a new price is at the top with the previous selling prices below? Is that easily do-able!? Tried editing 'edit_inline' template set and didn't get very far. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Is a Complex filter with __in and __exact possible?
I've set up a simple filter to grab a queryset of objects matching a list of (many to many) categories like this: Book.objects.filter(categories__in=[1,2,3]).order_by('name').distinct () It's good, it works... it returns any books in those three categories.But I'd like to return ONLY Books with those three categories? I thought something like categories__exact__in would work but clearly not. Any ideas? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Sending a list of items by email
Thinking this should be easy but not sure of the correct path to success! Got a simple filter queryset that pulls order products from a db: order_list = CustomerBasket.objects.all() customer = UserProfile.objects.get(user=user).customer email = EmailMessage( 'New Customer Order: %s ' % customer, '%s' % order_list, to = ['email'] ) email.send() So when running the above I get this in the sent email: [, , ] At least it's sending the email :-) My question is, what's a straightforward way to iterate through the items in 'order list' and print them nicely in the email body. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
'Latest' foreign key template filter?
I'm trying to pull the latest foreign key selling price value for a particular product in the database. At the moment I am grabbing them all just by doing: {% for price in product.product_sell_price.all %} {{ price.unit_price }} {% endfor %} but what I want to do is just pull the latest one (some products have a selling price history), so can I do something like: {% for price in product.product_sell_price.latest %} {{ price.unit_price }} {% endfor %} Obviously that doesn't work but wondering whether the easiest route is to create a template tag or am I missing a built-in filter that can do the magic for me. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Custom Admin Save redirect?
Is it possible to define a url for the admin form submit? I'd like to redirect a user to a custom list view I've created (outside admin) following the save of a record update or record addition. Is that possible through the 'admin/submit_line.html' template? For example I'd like a user to end up at /products instead of /admin/ database/products/ or /customers instead of /admin/database/customers/ Thanks1 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django App build - the right process?
I've been putting together a Product Database and Customer Order application that requires a lot of interim calculations, things like tax, customer discounts etc. Due to my limited knowledge of django/ python I have been basically performing these calculations in a custom save function of the appropriate models. Example: http://dpaste.com/hold/760/ A mess huh!! The product model is associated with a PriceOverride table that is updated by the user and functions as a means of applying a unique price for a particular customer (let's say it's a great customer and they should be getting 10% on certain products) By doing it this way I've got myself in a horrible mess with the save functions, things that I haven't considered like updating a PriceOverride or changing the PriceOverride to cover a different set of products have meant that I need to write custom code for not only the save but also the delete and any 'change' operations. I'm really not sure what I should be asking to fix it other than maybe I've been going about this entirely wrong procedure and looking for some guidance that might make life easier for me. Think I could explain all that much better but I think I'll wait for a few queries first (if any!) Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GeoDjango - Distance between MultiPointFields?
I'm getting an error - "PostGIS spherical operations are only valid on PointFields." when I try to do a distance search on a MultiPointField in the db. I kind of understand why but wonder if it's possible to do such a query at all on MultiPointFields? All I'm looking for is: england_pnt = fromstr('POINT(-1.464854 52.561928)', srid=4326) object_list = Activity.objects.filter(coords__distance_lte= (england_pnt,D(mi=50))) At the moment, the MultiPointField in question only contains one x and y value, it was set as MultuiPoint in case there were imports of such fields so my next question would be can I convert that MultiPointField to PointField in my models and DB without messing everything up? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Weird error on Foreign key save?
Karen, Good point - I will certainly use dpaste in the future. Here's the traceback, I should have copied that in right from the start: Traceback: File "/home/queryclick/webapps/django/lib/python2.5/django/core/ handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/home/queryclick/webapps/django/lib/python2.5/django/contrib/ admin/sites.py" in root 157. return self.model_page(request, *url.split('/', 2)) File "/home/queryclick/webapps/django/lib/python2.5/django/views/ decorators/cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "/home/queryclick/webapps/django/lib/python2.5/django/contrib/ admin/sites.py" in model_page 176. return admin_obj(request, rest_of_url) File "/home/queryclick/webapps/django/lib/python2.5/django/contrib/ admin/options.py" in __call__ 197. return self.change_view(request, unquote(url)) File "/home/queryclick/webapps/django/lib/python2.5/django/db/ transaction.py" in _commit_on_success 238. res = func(*args, **kw) File "/home/queryclick/webapps/django/lib/python2.5/django/contrib/ admin/options.py" in change_view 580. self.save_model(request, new_object, form, change=True) File "/home/queryclick/webapps/django/lib/python2.5/django/contrib/ admin/options.py" in save_model 376. obj.save() File "/home/queryclick/webapps/django/bullet/invoices/models.py" in save 79. # self.customer.outstanding_amount = Decimal('100.00') File "/home/queryclick/webapps/django/lib/python2.5/django/db/models/ base.py" in save 311. self.save_base(force_insert=force_insert, force_update=force_update) File "/home/queryclick/webapps/django/lib/python2.5/django/db/models/ base.py" in save_base 361. values = [(f, None, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks] File "/home/queryclick/webapps/django/lib/python2.5/django/db/models/ fields/__init__.py" in get_db_prep_save 192. return self.get_db_prep_value(value) File "/home/queryclick/webapps/django/lib/python2.5/django/db/models/ fields/__init__.py" in get_db_prep_value 610. self.max_digits, self.decimal_places) File "/home/queryclick/webapps/django/lib/python2.5/django/db/backends/ __init__.py" in value_to_db_decimal 345. return util.format_number(value, max_digits, decimal_places) File "/home/queryclick/webapps/django/lib/python2.5/django/db/backends/ util.py" in format_number 130. return u'%s' % str(value.quantize(decimal.Decimal(".1") ** decimal_places, context=context)) Exception Type: TypeError at /admin/invoices/customerinvoice/1/ Exception Value: unsupported operand type(s) for ** or pow(): 'Decimal' and 'NoneType' Thanks for any help there. Al On Feb 18, 7:44 pm, Karen Tracey <kmtra...@gmail.com> wrote: > On Wed, Feb 18, 2009 at 2:30 PM, Alfonso <allanhender...@gmail.com> wrote: > > > I've got an invoice model that foreign key's to a customer model, when > > the invoice is saved I'm update a few fields in that related customer > > model to make other code in my setup work. I keep getting > > "unsupported operand type(s) for ** or pow(): 'Decimal' and > > 'NoneType'" whenever I try to save the foreignkey model: > > > [snip] > > I'm thinking I'm looking too closely at something there where the > > problem might be in the related model: > > > I'm missing something simple but what!? BTW these models are created > > in separate apps if that makes any difference. > > Your models wrap rather badly in email, someplace like dpaste.com would be > far better for viewing them. One really significant thing you've missed is > posting the traceback (again, probably better viewed on dpaste.com). The > traceback shows what exact line of code is trying to ** incompatible types, > which would be an incredibly useful bit of information to have when > diagnosing the problem. > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
Weird error on Foreign key save?
I've got an invoice model that foreign key's to a customer model, when the invoice is saved I'm update a few fields in that related customer model to make other code in my setup work. I keep getting "unsupported operand type(s) for ** or pow(): 'Decimal' and 'NoneType'" whenever I try to save the foreignkey model: class Customer(models.Model): """ Customer Model """ customer_id = models.CharField(max_length=10) customer_name = models.CharField(max_length=100) slug = models.SlugField(unique=True) outstanding_amount= models.DecimalField(editable=False, default='0.00') class CustomerInvoice(models.Model): customer= models.ForeignKey(Customer, related_name="customer_invoices") invoice_id = models.CharField(max_length=10, editable=False) invoice_paid_date = models.DateField(blank=True, null=True) invoice_total = models.DecimalField(max_digits=10, decimal_places=2, editable=False, default='0.00') def save(self): if not self.invoice_paid: self.customer.outstanding_amount = self.invoice_total self.customer.save() I'm thinking I'm looking too closely at something there where the problem might be in the related model: I'm missing something simple but what!? BTW these models are created in separate apps if that makes any difference. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Getting Django to generate a report automatically on a assigned date?
Hi, I have a client who wants to generate an invoice statment automatically on the first of every month. I'm trying to work out how I might do that in Django. I have a simple statement model and a simple invoice model and all I want to do is on 1st of calendar Month update the statement model with invoices that haven't been paid. I'm not sure how to make that 'fire' correctly without an admin doing the legwork of adding a statement? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Struggling to update a reverse foreign key lookup
Probably my very poor python coding rather than Django but I have the model below set up to update another table (reverse foreign key relationship I guess you would call it) class PriceOverride(models.Model): """ Product Price Override """ date_override = models.DateField() product_id = models.ManyToManyField(Product, related_name="product_override", blank=True, null=True) customer_id = models.ForeignKey(Customer, related_name="customer_override", blank=True, null=True) override_percentage = models.DecimalField(max_digits=10, decimal_places=2, editable=True, default='0.00', help_text="This is the percentage override amount expressed as 0.xx", blank=True, null=True) def __unicode__(self): return '%s' % self.customer_id def save(self): super(PriceOverride, self).save() ppo = self.positive_percentage_override.filter(override = self.id) if self.override_percentage: #give the positive percentage override relationship a variable #if there is no match in related positive_percentage_table then #add a new record for each product in the list if not ppo: for product in self.product_id.all(): p = PositivePercentageOverride( override_id=self.id, customer = self.customer_id, product=product, value=self.override_percentage, ) p.save() else: #if there are existing products in the table for product in self.product_id.all(): product_match = self.positive_percentage_override.filter (product = product) for item in product_match: p = PositivePercentageOverride( value=self.override_percentage, ) p.save(force_update=True) And the related model: class PositivePercentageOverride(models.Model): override = models.ForeignKey(PriceOverride, related_name="positive_percentage_override") customer = models.ForeignKey(Customer, related_name="positive_percentage_customer") product = models.ForeignKey(Product, related_name="positive_percentage_product") value = models.DecimalField(max_digits=10, decimal_places=2) So when a new 'Price Override' record is saved I'm checking for an override_percentage value and seeing if an associated record in the PositivePercentageOverride is there. If it is then I want the save() method to update that record. If not, save a set of new records for each product in the ManyToMany list. Saving a new set of records is fine but I cannot get the records in the related table to update at all. I get "Cannot force an update in save() with no primary key." Really not sure where to go from here, hope I've explained myself OK!! Help please! Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
(GeoDjango.. again) Silly question - grab single lat and long value from a MultiPointField?
PointField in a template... I can do {{ object.point.x }} and {{ object.point.y }} - works fine. But with a MultiPointField doing the same gives me nada. Where am I going wroing? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GeoDjango - Center of a Polygon
How do I grab the center x and y co-ordinates of a polygon and display that in a template? I'd do this with a PointField... {{ object.coords.x }} etc Can I do that to get the center x and y points of a polygon? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django HTML Sitemap Generator?
Anyone know of an easy way/pluggable app that can generate a simple html sitemap output? I've used the sitemap module of Django to generate the .xml just fine - but surely I can manipulate that to get a html output to drop in a template? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
User Auth... is_group in a template?
I'm wondering, I can easily add a if statement to detect whether a user is staff in a template - {% if user.is_staff %} blah {% endif %} but is there a similar syntax for displaying HTML blocks depending on the user group? A kind of {% if user.is_group(customer) %} blah for customer {% endif %} I'm thinking not but any help much appreciated! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I add a Custom ID Field that increments?
Thanks Guys, Will, your snippet was exactly what I was looking for - thanks for that. Alas Rama, the client has specified that these custom Invoice IDs get saved in the db alongside the primary key, otherwise I'd go with your suggestion (simpler!) On Feb 5, 8:27 am, Rama Vadakattuwrote: > CUSTOM_ID---ID > ~ > INV1 -- 1 > INV2 ---2 > INV33 > . > . > . > i think you need INV1 for display purposes and also i hope it does > not matter much whether you store 1 or INV1 in the db. > > in such cases why can't you follow the below approach? > -- > store as 1 but display it as INV1 (by appending 1 to 'INV') > when you want to search 'INV2' strip out the INV and convert the > other part to 2 and search for this 2 in the database. > > ~~ > I don't know whether this is feasible to you or not but just a thought > adding to suggestion of "Will Hardy". > > On Feb 3, 4:47 am, Will Hardy wrote: > > > There's no easy solution without saving the object to the database. > > Auto incrementing fields (AutoField or just id) get their value from > > the database, so they wont have one until you save. This is good > > because it prevents multiple objects ever having the same value. One > > way to do what you want is to save a new invoice to the database > > straight away when the user clicks "add new invoice" and allow them to > > edit it, but if you're using the admin site, this might not be > > straightforward. > > > You wont need to create a new field by the way, you could simply make > > a property that uses the ID field of a model: > > > @property > > def invoice_id(self): > > if self.id: > > return 'INV%d' % self.id > > > But you wouldn't be able to search for the full INV001 string, you > > would have to strip the INV beforehand or create a new charfield and > > populate that on save (sounds like what you're doing) > > > If you don't want to have such obvious incrementing values for your > > invoice numbers, you could use a perfect hash function to convert it > > to a more obscure value, > > likehttp://www.djangosnippets.org/snippets/1249/(Iwrote this snippet, > > don't worry that two people voted against it, they didn't say why... I > > have no idea... it's just a simple perfect hash function and base > > converter, and it certainly does the job it was designed to do) > > > Cheers, > > > Will --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
get_FOO_display
I've got a field called 'invoice_type' which is a ChoiceField. In my template I'm trying to pull out the 'humanized' invoice type by using {{ object.invoice_type.get_invoice_type_display }} but django's not happy. I'm guessing it's because of the invoice[underscore]type syntax I used? Any workarounds? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Autogenerate a Model on Save
I'm full of queries today!...This one seems a simple notion that I can't get my head around...How would I get django to auto-generate a new Invoice record and populate with some values when a user saves a new Order record? A custom def save(self) method? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How do I add a Custom ID Field that increments?
Hey, I want to add a field to an invoice model that contains a custom auto- incrementing value in the format - 'INV01" which increments... INV02 (obviously!). Anyone have a simple way I can build that into the model when a user clicks 'Add New Invoice'? I've written custom save methods but not one that implements on adding a new record? Thanks, any help would be great --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I correctly format a Querydict derived list in a url?
Thanks Alex, I tried that but no joy - the problem is I just can't get django to nicely capture the list's values - it's really stumped me! location_filter = request.POST.getlist("location") does give me a python list of location variables. But I can't get this resultant [u'ireland', u'nireland'] list to become iterable where I can just drop the values into a HttpResponseRedirect url like /ireland- nireland/ I think I am approaching this incorrectly - If I try request.POST ["location"] It all works but only with the last item in the QueryDict. Hope I'm making sense, Thanks! Allan On Jan 30, 7:35 pm, Alex Koshelev <daeva...@gmail.com> wrote: > Try this: > > return HttpResponseRedirect('/activities/%s/' % "-".join(location_filter)) > > On Fri, Jan 30, 2009 at 10:26 PM, Alfonso <allanhender...@gmail.com> wrote: > > > I've got a form delivering multiple variables from a checkbox group > > via POST to a view that defines where to redirect to. > > > I've got django to pass the values of this Querydict to a redirect > > response but can't change the formatting: > > > In my view: > > > location_filter = request.POST.getlist("location") > > return HttpResponseRedirect('/activities/%s/' % location_filter) > > > And that gives me: > > > myurl.com/activities/[u'ireland<http://myurl.com/activities/%5Bu%27ireland>', > > u'nireland']/: what I really want > > is: > > > /activities/ireland-nireland/ > > > Any help woukd be great - I've been staring at this far too long! > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How do I correctly format a Querydict derived list in a url?
I've got a form delivering multiple variables from a checkbox group via POST to a view that defines where to redirect to. I've got django to pass the values of this Querydict to a redirect response but can't change the formatting: In my view: location_filter = request.POST.getlist("location") return HttpResponseRedirect('/activities/%s/' % location_filter) And that gives me: myurl.com/activities/[u'ireland', u'nireland']/: what I really want is: /activities/ireland-nireland/ Any help woukd be great - I've been staring at this far too long! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
GET Requests and URLS
Hi, I've got a simple form that acts as a filter to enable users to reach listings in various countries and I've set up a view that either redirects the user to the correct url or in the case of a query present; diverts to a search url that processes via GET. So the problem I'm having is sending multi value list variables to the search feature - I get this: http://pitchup.queryclick.webfactional.com/activities/search/?q=horse%20riding=[u'ireland'] instead of http://pitchup.queryclick.webfactional.com/activities/search/?q=horse%20riding=englandscotlandwales In my view I have this: def activities(request): if request.method == 'POST': query_string = request.POST["q"] location_filter = request.POST.getlist("location") activity_filter = request.POST.getlist("activity") if query_string: return HttpResponseRedirect('/activities/search/?q=%s=%s' % (query_string, location_filter)) if location_filter == 'all': return HttpResponseRedirect('/activities/') else: return HttpResponseRedirect('/activities/%s/%s' % (location_filter, activity_filter)) else: activity_list = Activity.objects.all().order_by('name') context = { 'activity_list' : activity_list, } return render_to_response('activity/activity_list.html', context, context_instance=RequestContext(request)) Anyone point out where I'm messing things up!? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Automagical Invoice Generation
I've got a very simple customer order model that saves the usual details into the system on a successful order placement. I'm trying to think of a way I can generate an associative invoice at the same time an order is submitted? Something within a custom 'def save' method? How would I set something like that out? Thanks Al --~--~-~--~~~---~--~~ 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 Sphinx
All fixed - anyone who stumbles across this error - update to the latest trunk of django-sphinx and works fine! On Jan 20, 1:23 pm, Alfonso <allanhender...@gmail.com> wrote: > Hello, > > I've used django-sphinx/sphinx engine in the past and found it a > fantasic solution but now running into a problem in a new build I > haven't seen before: > > So sphinx is all set up and working and in the appropriate view I > have: > > def search(request): > search_query = request.GET.get('q','') > if search_query: > queryset1 = Books.search.query(search_query) > results1 = queryset1.order_by(@id) > else: > results1 = [] > return render_to_response("search.html", {"results1": results1, > "query": search_query }) > > Which should work... in the template I have a very simple block: > > {% if query %} > Your results for "{{ query|escape }}": > {% if results1 %} > {% for result in results1 %} > > {{ result.name }} > > {% endfor %} > {% else %} > No Results > {% endif %} > {% endif %} > > But that's where I'm getting the following error: > > TemplateSyntaxError at /search/ > Caught an exception while rendering: maximum recursion depth exceeded > in cmp > > It happens when I do a generic query with 1000 results returned or > specific yielding just 1 result. > > Anyone got any idea where the problem might lie? Interestingly if I > just send the result count to the template it is displayed just fine > with {{ result1 }}. > > Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django Sphinx
Hello, I've used django-sphinx/sphinx engine in the past and found it a fantasic solution but now running into a problem in a new build I haven't seen before: So sphinx is all set up and working and in the appropriate view I have: def search(request): search_query = request.GET.get('q','') if search_query: queryset1 = Books.search.query(search_query) results1 = queryset1.order_by(@id) else: results1 = [] return render_to_response("search.html", {"results1": results1, "query": search_query }) Which should work... in the template I have a very simple block: {% if query %} Your results for "{{ query|escape }}": {% if results1 %} {% for result in results1 %} {{ result.name }} {% endfor %} {% else %} No Results {% endif %} {% endif %} But that's where I'm getting the following error: TemplateSyntaxError at /search/ Caught an exception while rendering: maximum recursion depth exceeded in cmp It happens when I do a generic query with 1000 results returned or specific yielding just 1 result. Anyone got any idea where the problem might lie? Interestingly if I just send the result count to the template it is displayed just fine with {{ result1 }}. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GeoDjango: Extract Latitude and Longitude from PointField
Hey, Must be missing something extraordinarily simple - how do I individually parse the latitude and longitude values from a PointField entry into my app's templates? I just want... Latitude: Longitude: Thanks, Al --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Dynamic age count
Hi, Trying to implement a very simple template tag that will output a company's age. So idea being if company was established in 1860 then it should output '148 years old' if my math is right ;-) this is what I've got: from django.template import * register = Library() @register.filter def age(comp_age): d = datetime.date.today() b = 1860 comp_age = int(d.year - b) return comp_age No joy - any ideas, must be pretty simple !? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django site - CSS doesn't render in Safari/Webkit
OK tracked it down - appears Safari doesn't sit well with a master .css file and @import url(blah.css); I guess that's because of the way I'm serving up static files. Direct "<link" to css files fixes it Thanks anyway! On Dec 23, 2:03 pm, Alfonso <allanhender...@gmail.com> wrote: > Hey, > > I'm getting a weird issue in Django with my css and Safari - displays > great in all browsers except for Safari. Happens in two different > django installations on two separate servers so clearly I'm doing > something wrong. CSS files are accessible directly via URL in both > cases... odd > > Apart from the fact I'm prob missing something obvious in my code, > anyone else come across that?! > > Thanks > > Al --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Django site - CSS doesn't render in Safari/Webkit
Hey, I'm getting a weird issue in Django with my css and Safari - displays great in all browsers except for Safari. Happens in two different django installations on two separate servers so clearly I'm doing something wrong. CSS files are accessible directly via URL in both cases... odd Apart from the fact I'm prob missing something obvious in my code, anyone else come across that?! Thanks Al --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
GeoDjango Server-side Clustering
Anyone know of an straightforward way to cluster co-ordinate points server-side i.e. in geoDjango prior to being displayed on an openlayers map via a standard KML? At the moment I'm loading some 2000 coordinates from a KML generated by geoDjango but this is quite understandably slowing the performance even with some OpenLayers clustering magic! Thanks, Allan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Form Widget Attributes
I'd like to specify a unique id for each checkbox iteration in a CheckboxSelectMultiple setup. This is what I have so far: grading = forms.BooleanField(label="Site Grading", widget=forms.CheckboxSelectMultiple(choices=grading_choices)) So in my form using the tag {{ form.grading }} gives me: 1 star 2 stars 3 stars 4 stars 5 stars So is there any way I can apply a corresponding css id to the label? like id_grading_1_label? Its so I can add a background graphic or bullet, I can't apply a background graphic to an input - only the label (as far as I know). 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: Reusable forms!
Got it working, it was because I thought I had to pass the seach form class as an argument to 'show_form'. That wasn't necessary. Taking a step back from your work does wonders :-) Thanks Alex On Nov 26, 10:59 am, "Alex Koshelev" <[EMAIL PROTECTED]> wrote: > Oh.. and what is the error you get? > > On Wed, Nov 26, 2008 at 13:39, Alfonso <[EMAIL PROTECTED]> wrote: > > > Thanks Alex, > > > I'm attempting to go the inclusion tag route but having difficulty > > understanding how to get the form in place correctly. > > > I've defind a simple form within forms.py: > > > class PropertySearch(forms.Form): > > name = forms.CharField(max_length=100, initial="Property name or > > Location") > > > and within a templatetag folder under that application, > > 'search_form.py' > > > from django.template import Library, Node > > from pitchup.campsite.forms import PropertySearch > > from django import template > > > register = Library() > > > def show_form(Search): > > form = PropertySearch() > > return {'form': form} > > register.inclusion_tag('property/property_search.html')(show_form) > > > But rather predictably that is showing an error... I'm a bit lost, I > > understand the inclusion principle for things like 'last 5 blog posts' > > etc but including a form seems more difficult? > > > Thanks > > > On Nov 25, 5:55 pm, "Alex Koshelev" <[EMAIL PROTECTED]> wrote: > > > You have to pass form instance to all pages context where it is used. You > > > can do it explicitly or write custom context processor or (the better > > > solution) write custom inclusion tag. > > > > On Tue, Nov 25, 2008 at 20:13, Alfonso <[EMAIL PROTECTED]> wrote: > > > > > Hey, > > > > > I've put together a simple search form that works perfectly when > > > > navigating to the corresponding url - '/search.html'. However I want > > > > to reuse that form on multiple pages so where relevant I use {% > > > > include 'search.html' %} to inject the form where I need it. > > > > > Problem is this form is devoid of any fields when I do that?? > > > > > The search.html form: > > > > > > > > > > > > {{ form.as_p }} > > > > > > > > > > > > > > > > > Thanks > > > > > Alfonso --~--~-~--~~~---~--~~ 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: Reusable forms!
Thanks Alex, I'm attempting to go the inclusion tag route but having difficulty understanding how to get the form in place correctly. I've defind a simple form within forms.py: class PropertySearch(forms.Form): name = forms.CharField(max_length=100, initial="Property name or Location") and within a templatetag folder under that application, 'search_form.py' from django.template import Library, Node from pitchup.campsite.forms import PropertySearch from django import template register = Library() def show_form(Search): form = PropertySearch() return {'form': form} register.inclusion_tag('property/property_search.html')(show_form) But rather predictably that is showing an error... I'm a bit lost, I understand the inclusion principle for things like 'last 5 blog posts' etc but including a form seems more difficult? Thanks On Nov 25, 5:55 pm, "Alex Koshelev" <[EMAIL PROTECTED]> wrote: > You have to pass form instance to all pages context where it is used. You > can do it explicitly or write custom context processor or (the better > solution) write custom inclusion tag. > > On Tue, Nov 25, 2008 at 20:13, Alfonso <[EMAIL PROTECTED]> wrote: > > > Hey, > > > I've put together a simple search form that works perfectly when > > navigating to the corresponding url - '/search.html'. However I want > > to reuse that form on multiple pages so where relevant I use {% > > include 'search.html' %} to inject the form where I need it. > > > Problem is this form is devoid of any fields when I do that?? > > > The search.html form: > > > > > > {{ form.as_p }} > > > > > > > > > Thanks > > > Alfonso --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Reusable forms!
Hey, I've put together a simple search form that works perfectly when navigating to the corresponding url - '/search.html'. However I want to reuse that form on multiple pages so where relevant I use {% include 'search.html' %} to inject the form where I need it. Problem is this form is devoid of any fields when I do that?? The search.html form: {{ form.as_p }} Thanks Alfonso --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
geodjango importing existing data - pointfields
I have a legacy database that consists of a number of addresses with pre-geocoded WKT points. I'm trying to import these directly into a GeoDjango setup - postgres db, either by csv or psql csv copy - doesn't matter which. First problem is I get this error 'new row for relation "site_locations" violates check constraint "enforce_srid_point" - if I delete that constraint it imports but then I get a whole heap of new problems displaying that data on a map (tranforming SRID etc to work on a commercial map provider). I'm guessing Geodjango tags the srid to the pointfield when saving a new location in the admin, which must mean my syntax for the WKT imports is missing that vital info to make it all work sweetly: 1,1,'Edinburgh Castle','Edinburgh','Lothian','EH1 2NG','POINT (-3.20277400 55.95415500)' I've tried multiple variations on the POINT syntax (GeomFromText etc...) but no joy. What am I doing wrong!!? Thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GeoDjango - Input geometry has unknown (-1) SRID
Hey, I ran into this when placing EPSG:4326 coded vector points onto a Openlayers- Virtual Earth map setup. Due to the whole spherical mercator issue I'm attempting to convert these points to 900913 format but getting "Input geometry has unknown (-1) SRID" when running the following view: def index(request): featured_list = Site.objects.all() featured__list = featured__list.transform(900913) return render_to_response('homepage.html', {'featured_list': featured_list}) Any help appreciated as always! Something obvious I'm missing methinks. Thanks, Alfonso --~--~-~--~~~---~--~~ 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: GeoDjango - Input geometry has unknown (-1) SRID
btw ignore double underscores in featured list - typo A --~--~-~--~~~---~--~~ 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: GeoDjango - Difficulty placing vector marker from DB
Thanks Ariel - that worked great Al On Oct 21, 8:02 pm, "Ariel Mauricio Nunez Gomez" <[EMAIL PROTECTED]> wrote: > There are many ways to fix the projection issue, this is one (probably not > the best) > > On your view code: > sites_list=sites_list.transform(900913) > > Best, > Ariel. > > On Tue, Oct 21, 2008 at 1:57 PM, Alfonso <[EMAIL PROTECTED]> wrote: > > > Hey, > > > Having great trouble getting geodjango/openlayers to display vector > > markers propery - everything I try positions the sample point off the > > coast of Africa (no matter if I change the vector position in > > geoadmin). Here's what I'm working with - any help appreciated!: > > > var lon = -2.900; > > var lat = 54.160; > > var zoom = 6; > > var map, baselayer; > > var wkt_f = new OpenLayers.Format.WKT(); > > var v_markers = [{% for site in sites_list > > %}wkt_f.read('{{ site.point.wkt }}'){% if not forloop.last %},{% endif > > %}{% endfor %}]; > > var marker_style = {'strokeColor' : 'green', 'fillColor' : 'green', > > 'fillOpacity' : 0.9, 'pointRadius' : 6} > > for (var i = 0; i < campsite_markers.length; i++){v_markers[i].style = > > marker_style;} > > > function init(){ > > var options = { > > 'projection' : new OpenLayers.Projection("EPSG:900913"), > > 'units': "m", > > 'maxResolution': 156543.0339, > > 'maxExtent': new > > OpenLayers.Bounds(-20037508,-20037508,20037508,20037508), > > 'controls':[new OpenLayers.Control.Navigation(), new > > OpenLayers.Control.ZoomPanel()], > > 'numZoomLevels' : 20, > > }; > > // base map > > map = new OpenLayers.Map('map', options); > > > // - MS Virtual Earth Layer > > baselayer = new OpenLayers.Layer.VirtualEarth("Virtual Earth", > > { 'type': VEMapStyle.Street, "sphericalMercator": true}); > > map.addLayer(baselayer); > > > // Controls for the map > > map.addControl(new OpenLayers.Control.LayerSwitcher()); > > map.addControl(new OpenLayers.Control.MousePosition()); > > > var layermarkers = new OpenLayers.Layer.Vector("markers"); > > layermarkers.addFeatures(v_markers); > > > // Vector Layers for the sites > > var LonLat = new OpenLayers.LonLat(lon, lat).transform(new > > OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); > > > map.addLayer(layermarkers); > > map.setCenter(LonLat, zoom); > > > } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
GeoDjango 'module' object has no attribute 'OSMGeoAdmin'
Strange error I haven't seen before - configuring a new django development server and have installed Django v 1.0 In a app admin.py file I've specified a straightforward geo admin class to handle the geodjango enabled models: from django.contrib.gis import admin from models import Category, CSite class SiteAdmin(admin.OSMGeoAdmin): search_fields = ['name', 'address1'] admin.site.register(Category) admin.site.register(CSite, SiteAdmin) I know that this works fine on my local install but clearly it's something misconfigured on the dev server. Same result if I change the class to class SiteAdmin(admin.ModelAdmin) Anyone have any idea where I can start looking to resolve - have tried reinstalling Django. Thanks A --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
GeoDjango - Difficulty placing vector marker from DB
Hey, Having great trouble getting geodjango/openlayers to display vector markers propery - everything I try positions the sample point off the coast of Africa (no matter if I change the vector position in geoadmin). Here's what I'm working with - any help appreciated!: var lon = -2.900; var lat = 54.160; var zoom = 6; var map, baselayer; var wkt_f = new OpenLayers.Format.WKT(); var v_markers = [{% for site in sites_list %}wkt_f.read('{{ site.point.wkt }}'){% if not forloop.last %},{% endif %}{% endfor %}]; var marker_style = {'strokeColor' : 'green', 'fillColor' : 'green', 'fillOpacity' : 0.9, 'pointRadius' : 6} for (var i = 0; i < campsite_markers.length; i++){v_markers[i].style = marker_style;} function init(){ var options = { 'projection' : new OpenLayers.Projection("EPSG:900913"), 'units': "m", 'maxResolution': 156543.0339, 'maxExtent': new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508), 'controls':[new OpenLayers.Control.Navigation(), new OpenLayers.Control.ZoomPanel()], 'numZoomLevels' : 20, }; // base map map = new OpenLayers.Map('map', options); // - MS Virtual Earth Layer baselayer = new OpenLayers.Layer.VirtualEarth("Virtual Earth", { 'type': VEMapStyle.Street, "sphericalMercator": true}); map.addLayer(baselayer); // Controls for the map map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.MousePosition()); var layermarkers = new OpenLayers.Layer.Vector("markers"); layermarkers.addFeatures(v_markers); // Vector Layers for the sites var LonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); map.addLayer(layermarkers); map.setCenter(LonLat, zoom); } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Importing times and dates into Postgres DB via Django
Hi, I have a textfile full of event data that I'm trying to parse into the associated postgresql db via django. Wrote a simple load.py script I can run via shell. Being going well though I've stumbled when importing DateField and TimeField values. the relevant bits of the code that processes the .txt file runs like this: for line in fi: event = line.split('~') time = event[7].replace(".", ":") +":00" Which gives me a string along lines of "12:00:00" - what I wanted... ...but this throws an error against TimeField: "ValidationError: Enter a valid time in HH:MM[:ss[.uu]] format." So what do I need to do to the string before it will validate? I have a feeling its because it is a string being passed, not integer value? Any help appreciated! Allan --~--~-~--~~~---~--~~ 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: GeoDjango: ImportError: cannot import name DataSource
Thanks Ludwig, Your solution was spot on - geodjango couldn't locate gdal properly. Solved it with: GDAL_LIBRARY_PATH='/opt/local/lib/libgdal.dylib' in settings.py Thanks again Allan On Sep 17, 6:27 pm, Ludwig <[EMAIL PROTECTED]> wrote: > If you run something like>>> import django.contrib.gis.gdal > >>> print django.contrib.gis.gdal.libgdal.gdal_full_version() > > GDAL 1.5.0, released 2007/12/18 > > > > you should get the version number of the GDAL library -- and with an added > bonus the import statement will have loaded the GDAL libraries, which in my > experience (which is more on win32 and linux) is a good indicator that the > libraries itself are installed correctly. > > Maybe if you post the result from that call again it becomes clearer what is > going wrong. > > Ludwig > > 2008/9/17 Alfonso <[EMAIL PROTECTED]> > > > > > Finally got round to setting up geodjango properly - postgresql db > > etc. and been inspecting some shapefiles for import. I get this > > error: > > > >>> from django.contrib.gis.utils import ogrinfo, ogrinspect > > Traceback (most recent call last): > > File "", line 1, in > > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > > python2.5/site-packages/django/contrib/gis/utils/ogrinfo.py", line 7, > > in > > from django.contrib.gis.gdal import DataSource > > ImportError: cannot import name DataSource > > > Clearly something to do with my Gdal installation? I'm running OS X > > Leopard and wondering where to begin to debug the error? > > > Thanks, > > > Allan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
GeoDjango: MultiPolygon and Polygon
I've got a nice chunk of shapefile data to import into a GeoDjango DB via LayerMapping and have discovered only one of the entries is a MultiPolygon shape - the rest Polygon. My question is this... if I change the model definition for the corresponding polygon field from PolygonField to MultiPolygonField, will that have any affect on non- multipolygon data - i.e. will MultiPolygon play nice with 'PolygonField' data? I think I almost managed to confuse myself there!! Any help would be appreciated, hope that makes sense! Allan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
GeoDjango: ImportError: cannot import name DataSource
Finally got round to setting up geodjango properly - postgresql db etc. and been inspecting some shapefiles for import. I get this error: >>> from django.contrib.gis.utils import ogrinfo, ogrinspect Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/contrib/gis/utils/ogrinfo.py", line 7, in from django.contrib.gis.gdal import DataSource ImportError: cannot import name DataSource Clearly something to do with my Gdal installation? I'm running OS X Leopard and wondering where to begin to debug the error? Thanks, Allan --~--~-~--~~~---~--~~ 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: TypeError - unpack non-sequence
Aha, it was httpd.conf Because I am serving this django app from root I thought I could get away with - "PythonOption django.root /" which I realise now is stupid since that is exactly what django removes from the URL for portability. Fixed now. Thanks for all your help guys for pointing me in right direction. Regards Allan On Aug 20, 7:59 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-08-20 at 11:46 -0700, Alfonso wrote: > > Interestingly changing /django/core/handlers.py line 77 from: > > > request.path_info) > > > to: > > > request.path) > > > Makes everything work again - hmm. No idea why though. > > So what you're saying is that if you introduce old bugs back into > Django, your problem goes away? That's just hiding the symptom, not > fixing the problem. > > Did you make all the necessary changes mentioned in the backwards > incompatible changes page to accommodate that particular change in > Django? See here for > details:http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Chang... > > If you did make those changes, can you come up with a small example to > demonstrate how the problem occurs. So far, you've just said that it > occurs for a particular URL, but that isn't really enough to guess at > the cause. For example, when the exception is raised, what is trying to > unpack a sequence and what value is it trying to unpack (what is the > thing that isn't a tuple, but is expected to be)? > > 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: TypeError - unpack non-sequence
Malcom I see your point, should be fixing the problem - well put. I have made a couple of changes as laid out in BackwardsIncompatible... httpd.conf is like so: SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonPath "['path'] + sys.path" PythonOption django.root / PythonDebug On But unsure about the other criteria - namely "In all cases, you should remove the SCRIPT_NAME portion of the URLs from your URLConf file (they currently need to be included)" Forgive the newbie question but where do I make that adjustment? So to describe what's happening - any url save for the homepage is serving up the TypeError mentioned above. Just noticed something actually.. If I aim for http://www.mysite.co.uk/blog/ the TypeError responds with: Request URL:http://www.mysite.co.ukblog/ i.e. it's dropping the slash from www.mysite.co.uk/ So does that mean it's my root URL conf that's the issue? Thanks Allan On Aug 20, 7:59 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-08-20 at 11:46 -0700, Alfonso wrote: > > Interestingly changing /django/core/handlers.py line 77 from: > > > request.path_info) > > > to: > > > request.path) > > > Makes everything work again - hmm. No idea why though. > > So what you're saying is that if you introduce old bugs back into > Django, your problem goes away? That's just hiding the symptom, not > fixing the problem. > > Did you make all the necessary changes mentioned in the backwards > incompatible changes page to accommodate that particular change in > Django? See here for > details:http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#Chang... > > If you did make those changes, can you come up with a small example to > demonstrate how the problem occurs. So far, you've just said that it > occurs for a particular URL, but that isn't really enough to guess at > the cause. For example, when the exception is raised, what is trying to > unpack a sequence and what value is it trying to unpack (what is the > thing that isn't a tuple, but is expected to be)? > > 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: TypeError - unpack non-sequence
Interestingly changing /django/core/handlers.py line 77 from: request.path_info) to: request.path) Makes everything work again - hmm. No idea why though. Thanks Allan --~--~-~--~~~---~--~~ 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: TypeError - unpack non-sequence
Hi Christan, Thanks for your reply - last version where everything worked was 8255, to be honest not 100% sure where to track the problem or whether it's 100% related to a svn update but I'm confident that the major change since last worked. Allan On Aug 20, 2:19 pm, Christian Joergensen <[EMAIL PROTECTED]> wrote: > Alfonso wrote: > > Upgraded to latest svn trunk and now getting brand new error on every > > page/url path save for homepage. Not entirely sure how to track down > > the fault in configuration etc. Anyone help? Thankyou! > > Please specify the exact svn revision. > > Also, what revision was the last where your project worked? > > /Christian > > -- > Christian Joergensenhttp://www.technobabble.dk --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
TypeError - unpack non-sequence
Hey, Upgraded to latest svn trunk and now getting brand new error on every page/url path save for homepage. Not entirely sure how to track down the fault in configuration etc. Anyone help? Thankyou! Traceback: Environment: Request Method: GET Request URL: http://www.urbanebeauty.co.uk/beauty-salons/ Django Version: 1.0-beta_1-SVN-8447 Python Version: 2.5.0 Installed Applications: ['django.contrib.sites', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.admin', 'django.contrib.comments', 'django.contrib.localflavor', 'django.contrib.flatpages', 'basic.blog', 'geopy', 'urbanebeauty.directory', 'registration', 'django.contrib.markup', 'basic.inlines', 'tagging', 'voting', 'upload', 'djangosphinx'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware') Traceback: File "/home2/richbiscuit/webapps/urbanebeauty/urbanebeauty/django/core/ handlers/base.py" in get_response 77. request.path_info) Exception Type: TypeError at /beauty-salons/ Exception Value: unpack non-sequence --~--~-~--~~~---~--~~ 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: User Authentication - index/base
Hi Julien, Thanks for that but the auth processor is in place in settings, along with the debug and il8n processor obviously. Allan On Jul 1, 10:29 am, Julien <[EMAIL PROTECTED]> wrote: > Hi, > > Have you tried adding the auth context processor in your settings? > "django.core.context_processors.auth" > > Alfonso wrote: > > Hey, > > > I've implemented a user login widget on my site. A simple 'Sign in' > > at top of every page that turns into 'Welcome John, View your profile' > > following successful user authentication. Works great - only issue > > I'm having is that on home page the text reverts to 'Sign In' even > > when user is logged in, only happens on this page. Not sure why this > > is occurring. Code below is sited in base.html. > > > > > {% if user.is_authenticated %} > > Welcome, {{ user.username }}. > href="/accounts/logout/">Log > > Out | Your Profile | Blog | Promotions > > {% else %} > > Log > > in | Blog > a> | Promotions > > {% endif %} > > > > > > Thanks in advance > > > Allan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
User Authentication - index/base
Hey, I've implemented a user login widget on my site. A simple 'Sign in' at top of every page that turns into 'Welcome John, View your profile' following successful user authentication. Works great - only issue I'm having is that on home page the text reverts to 'Sign In' even when user is logged in, only happens on this page. Not sure why this is occurring. Code below is sited in base.html. {% if user.is_authenticated %} Welcome, {{ user.username }}. Log Out | Your Profile | Blog | Promotions {% else %} Log in | Blog | Promotions {% endif %} Thanks in advance Allan --~--~-~--~~~---~--~~ 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: Unexpected Keyword Argument 'radio_admin'
Thanks Karen and Brian for your suggestions. Turned out a combination of the two (got to read those error messages more closely - cough) It was incorrect radio_admin syntax in the 'pluggable' basic blog app - http://code.google.com/p/django-basic-apps/, had to clear pyc's as well. Now got a new error now - AttributeError at / 'Manager' object has no attribute 'published' Which is linked to the basic-blog app. Strange because code was working fine prior to newforms issue. I look forward to the day when I can confidently produe error free django apps! Thanks Allan On Jun 26, 8:38 pm, Brian Rosner <[EMAIL PROTECTED]> wrote: > On Jun 26, 2008, at 10:09 AM, Alfonso wrote: > > > > > TypeError: __init__() got an unexpected keyword argument > > 'radio_admin'. > > > Where did that come from? > > Sounds like you may have some lingering .pyc files that might be > causing this from newforms-admin if you have switched your copy of > Django from newforms-admin to trunk.\ > > Brian Rosnerhttp://oebfare.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 -~--~~~~--~~--~--~---
Unexpected Keyword Argument 'radio_admin'
Just updated to latest svn checkout of Django and seeing this error for the first time at root (across the entire site actually)?? TypeError: __init__() got an unexpected keyword argument 'radio_admin'. Where did that come from? Help appreciated! Alfonso --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Basic Blog and Newforms-Admin
Hi Guys, Just installed newforms-admin into my django app and having a strange issue with basic-blog app: Error while importing URLconf 'myapp.basic.blog.urls': The model Post is already registered Occurs on any page whenever basic.blog.urls urlconf is involved. Any suggestions would be appreciated! Thanks Al --~--~-~--~~~---~--~~ 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: problem representation
another option could be use the contenttype framework, it's not well documented but using the source and examples could help, take a look here http://feh.holsman.net/articles/2006/06/03/django-contenttype to get an idea about the framework and links to examples. Regards, Ali On 6/4/07, Joseph Heck <[EMAIL PROTECTED]> wrote: > > > If it's the *same* information, then use a foreign-key relationship. > If it's different information, then it needs to be stored separately, > and defining that on the models is a good way of doing that. > > You can shoot yourself in the foot by trying to re-use too much as > well as too-little. It is ultimatley a tradeoff choice that you need > to make for your own code. > > -joe > > On 6/4/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote: > > that is repeating a lot of common information about my models, what > about > > DRY, reusing, etc? > > > > On 6/4/07, Joseph Heck < [EMAIL PROTECTED]> wrote: > > > > > > Maybe a foreign key relationship would work, but you might just > > > consider adding all those attributes to each model. Unless you think > > > you'll end with really sparse tables, it may be worth it for the > > > simplicity. > > > > > > You wouldn't want to use a one-to-one table for common elements among > > > different models. > > > > > > -joe > > > > > > On 6/4/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote: > > > > Hi for everyone. I'm stuck with django, I want to represent this > > situation: > > > > > > > > I have a lot of content types like, news, images, urls, etc. All of > them > > > > have common attributres like creation date, expiration date, > publication > > > > date, title and so on. The problem is how to represent this with > django > > > > models so I don't have to repeat all of those attributes in all > models. > > > > Until now, I represented this situation like a > > Generalization/Specialization > > > > relationship with a on-to-one relation but I don't want to use it > due to > > > > this relation is going to change in future versions of django so, I > > don't > > > > know what to do, anyone could help me? > > > > > > > > > > > > -- > > > > Lic. José M. Rodriguez Bacallao > > > > Informatics Science University > > > > Habana-Cuba. > > > > > > > > > > > > > > > > > > > > > > > -- > > Lic. José M. Rodriguez Bacallao > > Cupet > > > > > > > > > > > --~--~-~--~~~---~--~~ 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: any django users in Cuba?
yes, at least in infomed we are two, i even offered two conferences about django, one as part of Lihab-LUG meeting's and the other as part of a course about python and free software, so i expect the number of users increase with the time ;), i also have in plan a course specifically about django for the developer's team of infomed. Regards, Ali On 6/5/07, Lic. José M. Rodriguez Bacallao <[EMAIL PROTECTED]> wrote: > > there is any django users in Cuba or just a cuban user? > > -- > Lic. José M. Rodriguez Bacallao > Cupet > > > --~--~-~--~~~---~--~~ 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 / Validation / Uniqueness
My solution is to use the base class parameter of form_for_[model|instance] function, for example: class SomeTest(models.Model): name = models.CharField(maxlength=50) user = models.ForeignKey(User) class Meta: unique_together = (('user', 'name'),) class SomeTestBaseForm(forms.BaseForm): def __init__(self, *args, **kwargs): super(SomeTestBaseForm, self).__init__(*args, **kwargs) def clean_name(self): if self.data.get('name', None) and self.data.get('user', None): try: sometest = SomeTest.get(name=self.data['name']) except SomeTest.DoesNotExist: return self.data['name'] raise forms.ValidationError(u'The name already exists') SomeTestForm = forms.form_for_model(SomeTest, SomeTestBaseForm) this way you can add custom validation and DRY when your form's fields match your model. Regards, Ali On 5/29/07, ringemup <[EMAIL PROTECTED]> wrote: > > > Hello -- > > I'm using a basic form_for_model() form object for a model that has a > unique=True constraint on a field other than the primary key. > > When validating submitted data, is there a reason the form check that > that constraint hasn't been violated and throw a validation error? > I'd like to be able to catch that input error and present a message to > the user, instead of what's currently happening, which is that no > error is thrown and when I try to save the data I get an integrity > error, which is unrecoverable. > > Do I need to create a custom form class just to handle a uniqueness > requirement? > > 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: Output category name in a generic view
Thanks Jay but for some reason django doesn't like that - nothing is output in the view?? While I'm here - if I get that to work how would I take that one step further and output that categories cescription text - does it make a huge difference if the dict reads: ammonite_dict = { 'queryset': Category.objects.get(pk=1), 'allow_empty': 'true', } or ammonite_dict = { 'queryset': Product.objects.filter(categories=1), 'allow_empty': 'true', } I think I've messed up a few things along the way because django is behaving strangely Cheers, Allan Jay Parlar wrote: > On 9/24/06, Alfonso <[EMAIL PROTECTED]> wrote: > > > > If I have a dict in my urls.py set up to obtain all products in a > > category like this: > > > > ammonite_dict = { > > 'queryset': Category.objects.get(pk=1), > > 'allow_empty': 'true', > > } > > > > and then use a generic view to map that url: > > > > (r'^glassware/ammonite/$', > > 'django.views.generic.list_detail.object_list', dict(ammonite_dict, > > template_object_name="products", > > template_name="products/products_list.html")), > > > > so (a simplified) products_list looks like this: > > > > {% extends "base.html" %} > > {% block title %}Glassware{% endblock %} > > {% block content %} > > {% for object in object_list %} > > {{ object }} > > {% endfor %} > > {% endblock %} > > > > Which all works fine, I get a nice list of products in that category - > > problems occur when I want to dynamically add the category title or > > description etc. Is there an easy way to do it using generic views? > > Yep, you can use 'extra_context', like this: > > (r'^glassware/ammonite/$', > 'django.views.generic.list_detail.object_list', dict(ammonite_dict, > template_object_name="products", > template_name="products/products_list.html", > extra_context={"title":"Glassware"})), > > Then in the template, you can have > {% block title %}{{title}}{% endblock %} > > If you look at the documentation, I think just about every generic > view can take 'extra_context'. > > Jay P. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Output category name in a generic view
If I have a dict in my urls.py set up to obtain all products in a category like this: ammonite_dict = { 'queryset': Category.objects.get(pk=1), 'allow_empty': 'true', } and then use a generic view to map that url: (r'^glassware/ammonite/$', 'django.views.generic.list_detail.object_list', dict(ammonite_dict, template_object_name="products", template_name="products/products_list.html")), so (a simplified) products_list looks like this: {% extends "base.html" %} {% block title %}Glassware{% endblock %} {% block content %} {% for object in object_list %} {{ object }} {% endfor %} {% endblock %} Which all works fine, I get a nice list of products in that category - problems occur when I want to dynamically add the category title or description etc. Is there an easy way to do it using generic views? Many Thanks Allan --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
serving static images
Complete newbie problem here but i can't seem to get django to show any images or stylesheets etc. In urls.py: (r'^images/(?P.*)$', 'django.views.static.serve', {'document_root': '/Users/whitebook/django/django_projects/mysite/ media/images'}), In the template I have . So when opening up the site in Safari the dreaded blue question mark appears where an image should be - opening the 'image' in a new tab yields 'ViewDoesNotExist at images/logo.gif' Any suggestions? I've had a thorough search for a solution but nothing seems to work. Thanks! P.S apologies to deezthugs for attaching my query to his query! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---