best practice to delete an object

2008-03-05 Thread cesco
Hi, my question is really basic but I'd like to make sure I'm doing the right thing. Say a user owns certain objects and it has the possibility to delete them by clicking on a "delete" link. I'm thinking of associating that link to a get request via a url like: /objects/delete/ but this would

django tagging usage_for_model problem

2008-02-23 Thread cesco
Hi, I'd like to use the manager method Tag.objects.usage_for_model(MyModel, filters=dict(field1__exact='value1')) from the django tagging application. In my case MyModel has as attribute a foreign key to the User model. My problem is that I'd like to filter out the authenticated users (and in

Re: problem with django tagging application

2008-02-21 Thread cesco
Hi, > Any chance you were using django-tagging previously and recently > updated to trunk? There are backwards incompatible changes - the > relation names have > changed:http://code.google.com/p/django-tagging/wiki/BackwardsIncompatibleCha... I was actually getting the same error before and

Re: problem with django tagging application

2008-02-21 Thread cesco
Hi > So the SQL that is being constructed by the joined queryset isn't valid. > I'm almost certain the answer to this is "it's fixed in > queryset-refactor, so will one day be fixed in trunk." Thanks for the work you are doing:-) > Pull the results back into Python and merge them manually.

problem with django tagging application

2008-02-20 Thread cesco
Hi, I'm using the latest version of the django tagging application (rev. 132) and I'm having problems with the get_by_model method of the TaggedItem manager. Say I have a QuerySet1 generated as follow: QuerySet1 = TaggedItem.objects.get_by_model(MyModel, 'tag1') and a QuerySet2 generated as

displaying errors after form validation

2008-01-12 Thread cesco
Hi, I'm a bit puzzled by the following behaviour of newforms. I have a field in the form called 'seller'. In the form validation I have a clean_seller method which if a certain condition is verified will do the following: self.errors.update(seller = ErrorList([u"message1: the indicated seller

db_index and loading data via fixtures

2007-12-27 Thread cesco
Hi, I recently started using the django-tagging application. The Tag and TagItem models have each a field which is indexed (db_index=True). Does loading data with json fixtures change because of having db_index=True? When the data are loaded via fixtures is the save method called on each loaded

Re: postgresql problem with django api (iregex)

2007-11-20 Thread cesco
QLite lack of reg- exp support? If that's the case then the code has to be changed when moving to production (that is, likely to a different database platform)? Thanks again Francesco On Nov 20, 12:58 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2007-11-19 at 13:59 -0800, ces

Re: postgresql problem with django api (iregex)

2007-11-19 Thread cesco
what could be wrong? Thanks again Francesco On Nov 19, 1:52 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sun, 2007-11-18 at 12:46 -0800, cesco wrote: > > Hi, > > > I have the following query which works perfectly with sqlite3: > > > from django.db import

postgresql problem with django api (iregex)

2007-11-18 Thread cesco
Hi, I have the following query which works perfectly with sqlite3: from django.db import models qs.filter(models.Q(myField__iregex="\\b%s\\b" % myString) In the production server, where I'm running postgresql the exact same query is not working. Do you have any idea why this happens? Maybe a

exclude on two querysets

2007-10-29 Thread cesco
Hi, I have two querysets: qs_big and qs_small with qs_small subset of qs_big (that is, all the objects in qs_small are also objects of qs_big). I'd like to obtain a queryset of objects which are in qs_big but not in qs_small. If exclude could accept a queryset as parameter I would do something

Union/join of two queryset?

2007-09-24 Thread cesco
Hi, I have two QuerySets and I need to join them to pass them as first parameter to the ObjectPaginator class. How can I do that? The "+" operator doesn't work (like it does for lists) and there is no a method like the list one "extend()". Any suggestion would be very appreciated. Best regards

Re: Using unitest or doc test with complex output

2007-09-20 Thread cesco
AIL PROTECTED]> wrote: > On 9/20/07, cesco <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > I'd like to test a query and the data returned by that query is a list > > containing a list of objects. For example: > > [[, , ..., ]] > > > If I try

Using unitest or doc test with complex output

2007-09-19 Thread cesco
Hi, I'd like to test a query and the data returned by that query is a list containing a list of objects. For example: [[, , ..., ]] If I try testing using unittests I get the following error: AssertionError: [[]] != [[]] though to me the expected output and the one I get look identical. If I

filtering based on property

2007-09-16 Thread cesco
Hi, is it possible to do filtering based on a method or a property of the model? Say I have a model with a from_date field and a to_date field and a method, defined within the model, which checks if the model instance is current, that is: from datetime import date @property def

Generating Q objects for different model fields

2007-09-16 Thread cesco
Hi, I'd like to make a filter composed by ORing several Q objects, each of which acts on a different model field. For example I have a model with the fields "name", "title", "description" and I want to make a Q object like the following: Q_name = (Q(name__istartswith="hello") &

Re: Email as username in django auth framework

2007-09-10 Thread cesco
Hi > I'm using this snippet which works fine. Which snippet? Thanks Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

CRUD generic views and new forms

2007-08-25 Thread cesco
In the current django documentation is written that the create_object generic view (from django.views.generic.create_update) returns as template context the "form" variable which is an instance of django.oldforms.FormWrapper. Is there a way to use new forms? Thanks and regards Francesco

Re: UnicodeEncodeError in template rendering

2007-08-19 Thread cesco
Thanks a lot Malcolm, I think we are getting there:-) > So, have a look at the debug screen and click on the "local variables" > link just below this last line in the extended traceback. What is "s" > here (in particular, it would be good know what type(s) is)? Also, what > is the value of

Re: UnicodeEncodeError in template rendering

2007-08-19 Thread cesco
Thanks for your replies. Just to avoid any doubt, I'm using __unicode__ instead of __str__ and I'm using the latest development version of django (post unicode merge). > What is most important to know is (a) what is the data that it is > trying to render (both type and content). It's trying to

UnicodeDecodeError in template rendering

2007-08-18 Thread cesco
Hi, I'm using sqlite3 as db for my django project. In order to load the data in the db I first generated a unicode string (which contains danish characters "ø, æ, å") and dumped such a string to a file (in json format) as follows: f_hdl = file(json_offers_path, 'w')

full-text indexing

2007-08-06 Thread cesco
Hi, is there any rough estimate on when the full-text indexing branch will be integrated into trunk? Thanks Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: ip to location

2007-07-16 Thread cesco
Thanks but I was asking for something more precise, like latitude and longitude (approximated, of course) rather than the country which would be too vague for my application. Any other suggestion? Thanks again On Jul 16, 1:07 pm, xaranduu <[EMAIL PROTECTED]> wrote: > cesco schrieb:

ip to location

2007-07-16 Thread cesco
Hi, does anyone in the django community know of a public algorithm to get the location from the ip. If such a thing doesn't exist do you know of a service with an API which does it? Or maybe such a functionality will be available with the upcoming Geodjango? Many thanks Francesco

Re: multiple inner joins in sql

2007-07-11 Thread cesco
Thanks:-) On Jul 11, 3:10 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > On Jul 10, 2:58 pm, novice <[EMAIL PROTECTED]> wrote: > > > but I get error that the offers_offerprice.offerseller_id column > > doesnt exist. > > I think you're missing an underscore. Your model has the field named >

Applying custom manager methods on querysets

2007-07-04 Thread cesco
Hi, in django we can chain multiple filter methods like: MyModel.objects.filter(field1__exact=value1).filter(field2__exact=value2) but I'd like to be able to chain custom filter methods defined by extending the models.Manager class. For example:

Chaining custom manager methods

2007-07-04 Thread cesco
Hi, I've created a MyManager class (extending models.Manager) to provide some custom filtering methods, then in the related MyModel(models.Model) class I put objects=MyManager() so I have the custom filtering methods available as MyModel.objects.my_filter(). Now I'd like to be able to chain the

geodjango

2007-07-01 Thread cesco
Hi, I'd simply like to know whether there is a rough estimate of when the geodjango branch will be merged trunk. Thanks Francesco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to

accessing dictionary in a template

2007-06-16 Thread cesco
Hi, I'm using the django-voting application whose method get_votes_in_bulk(object) returns a "votes" dictionary like: {object_id: {''score': score, 'num_votes': num_votes} I'm passing this dictionary as extra_context to a template where I'm also using the regroup tag on theobjects which I pass

accessing dictionary

2007-06-16 Thread cesco
Hi, I'm using the django-voting application whose method get_votes_in_bulk(object) returns a "votes" dictionary like: {object_id: {''score': score, 'num_votes': num_votes} I'm passing this dictionary as extra_context to a template where I'm also using the regroup tag on theobjects which I pass

applying patch

2007-06-10 Thread cesco
Hi, I'm trying to apply the patch given in http://code.djangoproject.com/ticket/3297 using tortoiseSVN on windows but I get the following error message: The line "Index: " was not found Either this is not a diff file or the diff is empty. The file I downloaded and used as patch is:

implementing admin filters in my own views

2007-06-10 Thread cesco
Hi, I'd like to implement in my own views the filter functionality that is available in the admin by setting class Admin: list_filter = ('field_name1', 'field_name2',) I went through the html of the admin and I kind of understand that it's related to the generation of hidden input fields

preserve ordering in filtering

2007-06-07 Thread cesco
Hi, I have the following query which I cannot implement with the django model API because I need to order it according to a calculated field. query = """SELECT id FROM offers_offer AS f1 ORDER BY (f1.original_price-f1.discounted_price) DESC LIMIT 20""" cursor = connection.cursor()

Re: use of save_FOO_file

2007-06-03 Thread cesco
On Jun 3, 6:52 pm, sansmojo <[EMAIL PROTECTED]> wrote: > The raw, binary data of the file. After uploading, it ends up at > request.FILES['file']['content'] (where 'file' is the name of your > form field). > > An example: > > if request.FILES.has_key('file'): > new_file =

use of save_FOO_file

2007-06-03 Thread cesco
In the following method available for FileFields: save_FOO_file(filename, raw_contents) what does "raw_contents" represents? I didn't find any example on the web about it. Many thanks Francesco --~--~-~--~~~---~--~~ You received this message because you are

Re: FileInput widget behaviour related to upload_to attribute

2007-06-03 Thread cesco
> Can you tell us more info about your view code ? Thanks for the quick response! in the view I have the following if request.method == 'POST': form = AddOfferForm(request.POST) if form.is_valid(): #new_offer = form.save()

FileInput widget behaviour related to upload_to attribute

2007-06-03 Thread cesco
I have a model called Offer containing, besides other fields, a picture field as in the following example: class Offer(models.Model): picture = models.ImageField(null=True, blank=False, unique=False, upload_to='offers/') I created a form for adding Offer objects as follows: class

loading data from fixtures

2007-05-19 Thread cesco
Hi, I'm experiencing a problem loading some data from fixtures. Some of the object loaded have danish letters (ø, å, æ) in their fields. If I use the ANSI encoding for the JSON file I'm trying to load I get the following error message: "Problem installing fixture ...: 'utf8' codec can't decode

dictionary lookup in template within regroup tag

2007-05-15 Thread cesco
Hi, I'm trying to render a template using a generic view of the list_detail type. The list of objects I'm trying to render in the template (which are offers) have an original_price and a discounted_price and I'd like to display also the relative discount (that is:

Re: Bug in django related to sqlite3?

2007-05-14 Thread cesco
table. Any other suggestion? Thanks again Francesco On May 14, 3:28 pm, Martin Winkler <[EMAIL PROTECTED]> wrote: > Hi Francesco, > > Am Mon, 14 May 2007 12:44:46 - > schrieb cesco <[EMAIL PROTECTED]>: > > > query = """SELECT id FROM my_table \

Bug in django related to sqlite3?

2007-05-14 Thread cesco
I have to execute the following SQL query: query = """SELECT id FROM my_table \ WHERE my_table.some_id IN %s""" cursor.execute(query, [(1, 2, 3)]) and the aim would be to replace the %s with the tuple (1, 2, 3) but I get the following error: Traceback (most recent call last):