Re: Preventing race conditions when submitting forms

2014-11-25 Thread Simon Charette
Hi Paul, You might want to take a look at the third party packages listed under the *concurrency* category . I've used django-concurrency in the past and it worked well for me. Simon Le

Re: Foreign Key Deletion Problem

2014-11-25 Thread Simon Charette
Hi Jann, I think you'll need to write a custom deletion handler for this. The following should work: from django.db import models class SetNull(object): """Deletion handler that behaves like `SET_NULL` but also takes a list of extra fields to NULLify.""" def __init__(self,

Re: Preventing race conditions when submitting forms

2014-11-25 Thread Simon Charette
I can't think of a generic way of solving conflict resolution. I'd say it's highly application specific. Le mardi 25 novembre 2014 15:06:53 UTC-5, Paul Johnston a écrit : > > Tim, Simon, > > Thanks for the responses. Looks like django-concurrency is a good fit, and > it works the way Tim

Re: ModelAdmin.has_change_permission gives 403

2014-11-26 Thread Simon Charette
In order to make a model admin read only I suggest you make sure ` get_readonly_fields() ` return all of them. from django.contrib.admin.utils import flatten_fieldsets def

Re: Query set append

2014-12-01 Thread Simon Charette
Try using a subquery for this: tableC_QuerySet = models.TableC.objects.filter( tableC_id__in=models.TableB.objects.filter(table_ID = ).values() ) Le lundi 1 décembre 2014 14:07:59 UTC-5, check@gmail.com a écrit : > > Hello > > I am very new to python and Django . I have a basic question

Re: Prefetching a single item

2015-03-02 Thread Simon Charette
Can your seats be part of multiple trains? Is there a reason you defined a ManyToMany from Train to Seat instead of a ForeignKey from Seat to Train? If your schema was defined as the latter the following could probably work (given you only want the first Seat of each Train object): trains =

Re: Using proxy kind of Table in Admin Interface

2015-03-02 Thread Simon Charette
Hi Rootz, Unfortunately there's a long standing ticket to solve inconsistency with permissions for proxy models so your chosen approach won't work until this is fixed. Simon Le lundi 2 mars 2015 11:16:36 UTC-5, Rootz a écrit : > > Question. > How

Re: Query optimization - From 3 queries to 2

2015-03-02 Thread Simon Charette
Hi Humberto, The following should do: Provider.objects.prefetch_related( Prefetch('service_types', ServiceType.objects.select_related('service_type_category')) ) P.S. Next time you post a question try to remove data unrelated to your issue from your example (e.g `countries` and `user`

Re: Can the new `Prefetch` solve my problem?

2015-03-02 Thread Simon Charette
Hi cool-RR, The following should do: filtered_chairs = Chair.objects.filter(some_other_lookup=whatever) desks = Desk.objects.prefetch_related( PrefetchRelated('chairs', filtered_chairs, to_attr='filered_chairs'), PrefetchRelated('nearby_chairs', filtered_chairs,

Re: Custom lookup field for text comparison in Django 1.6

2015-03-04 Thread Simon Charette
Hi Jorgue, As you already know there's no officially supported API to create custom lookups in Django < 1.7 However it's possible to get something working by monkey patching WhereNode.make_atom. Here's an example GIST that expose a

Re: Prefetching a single item

2015-03-04 Thread Simon Charette
its own issues. (And can't be > used for any number of items other than 1 in this case.) > > On Tue, Mar 3, 2015 at 7:15 AM, Simon Charette <chare...@gmail.com > > wrote: > >> Can your seats be part of multiple trains? >> >> Is there a reason you defined a ManyToMa

Re: Sharing templates across multiple projects

2015-03-06 Thread Simon Charette
Hi John, I suggest you put the templates you want to share in a location accessible by your multiple projects and add this directory to your TEMPLATE_DIRS setting. Make sure you have

Re: Django 1.8 ImportError: No module named formtools

2015-03-11 Thread Simon Charette
Hi Neto, Here's an excerpt from the Django 1.8 release note : The formtools contrib app has been moved into a separate package. > *django.contrib.formtools* itself has been removed. The docs provide >

Re: Django 1.8 post_save without recursion

2015-03-13 Thread Simon Charette
I don't think there's best a way of doing it but in your specific case the following should do: @receiver(post_save, sender=Person) def do(instance, update_fields, *args, **kwargs): if update_fields == {'ok'}: return instance.ok = True instance.save(update_fields={'ok'})

Re: Need your advices to optimize when annotate foreign key

2015-03-16 Thread Simon Charette
Hi Sardor, Are you using PostgreSQL? Simon Le lundi 16 mars 2015 05:19:38 UTC-4, Sardor Muminov a écrit : > > > > Hello there, > > > I am trying to perform aggregation from all objects which have one foreign > key. > > > These are my models: > > ... > > class Post(models.Model): > id =

Re: Need your advices to optimize when annotate foreign key

2015-03-16 Thread Simon Charette
ention it. I am using PostgreSQL 9.3.6 > > Now I am implementing Chenxiong Qi's suggestion. > > Do you have any idea? > > > On Tuesday, March 17, 2015 at 12:25:00 AM UTC+9, Simon Charette wrote: >> >> Hi Sardor, >> >> Are you using PostgreSQL? >> >

Re: Django ReverseSingleRelatedObjectDescriptor.__set__ ValueError

2015-03-18 Thread Simon Charette
Hi Bradford, You must retrieve the ContentType model from the `apps` instead of importing it just like the other models you're using in your forwards function. ContentType = apps.get_model("contenttypes", "ContentType") The reason why you're getting such a strange exception is because you're

Re: Django project for multiple clients

2015-03-26 Thread Simon Charette
This concept is called multi-tenancy. I suggest you have a look at the django-tenant-schema application which isolate each tenant in it's own PostgreSQL schema. You could also build you own solution using a middleware and a database

Re: QueryDict and its .dict() method - why does it do that?

2015-03-27 Thread Simon Charette
Hi Gabriel, One thing I dislike about how PHP/Rail deal with this is the fact they expose an easy way to shoot yourself in the foot. e.g. PHP Your code expects $_GET['foo'] to be an array() but the querystring is missing the trailing "[]" (?foo=bar) and crash. This also open a door for

Re: Jinja2 with Django 1.8c1 & cannot import name 'Environment'

2015-03-28 Thread Simon Charette
Hi Rolf, Since your `jinja2.py` file sits before your installed `jinja2` package directory in your PYTHONPATH you end up trying to import `Environement` from your the module you're defining and not the installed `jinja2` module. Rename your jinja2.py file something else and things should be

Re: Jinja2 with Django 1.8c1 & cannot import name 'Environment'

2015-03-29 Thread Simon Charette
Hi Rolf, Did you install jinja2 in your python environment (I assumed /www/pbs-venv was a virtualenv)? What does /www/pbs-venv/bin/pip --freeze outputs? Simon Le dimanche 29 mars 2015 14:53:49 UTC-4, Rolf Brudeseth a écrit : > > >> Rename your

Re: Jinja2 with Django 1.8c1 & cannot import name 'Environment'

2015-03-29 Thread Simon Charette
Hi Rolf, Django 1.8+ adds built-in support but doesn't ship with Jinja2, the same way it has built-in support for PostgreSQL but doesn't ship the psycopg2 package. You must install it in your environment just like you did with the Django package. Simon Le dimanche 29 mars 2015 16:40:33

Re: Jinja2 with Django 1.8c1 & cannot import name 'Environment'

2015-03-30 Thread Simon Charette
You're welcome Rolf. Your question lead an initiative by Tim to clarify Jinja2 needs to be installed . Cheers, Simon Le lundi 30 mars 2015 19:47:46 UTC-4, Rolf Brudeseth a écrit : > > >> >> Django 1.8+ adds built-in support but doesn't ship with

Re: Accessing to my user

2015-04-02 Thread Simon Charette
Hi! Personna.objects.get(user__username='foo') should do. Simon Le jeudi 2 avril 2015 11:24:48 UTC-4, somen...@gmail.com a écrit : > > I have this > class Persona(models.Model):7 > >"""Person class:8 >

Re: "The outermost 'atomic' block cannot use savepoint = False when autocommit is off." error after upgrading to Django 1.8

2015-04-02 Thread Simon Charette
Hi Matt, I think it would be preferable to use atomic() here. >From reading the documentation it looks like you might already be in a transaction when calling `set_autocommit` but it's hard to tell without the full traceback.

Re: Django Dashboard

2013-07-30 Thread Simon Charette
I'd suggest you take a look at django-admin-tools . Le mardi 30 juillet 2013 14:09:00 UTC-4, Martin Marrese a écrit : > > Hi, > > I'm looking for a Django Dashboard to implement on an existing app. A > colleague recommended Dashing (1),

Re: Ordering a queryset on a reverse foreign key's attribute

2013-08-01 Thread Simon Charette
>From a quick look I'd also expect `order_by('-children__date')` to work. Can you provide the generated SQL query and some results? Le jeudi 1 août 2013 09:58:25 UTC-4, Daniele Procida a écrit : > > I have an Event model: > > class Event(Model): > parent = models.ForeignKey('self',

Re: Dynamic increasing choices object

2013-08-21 Thread Simon Charette
Not really Django related but you can achieve it by doing the following: WEIGHTS = tuple( (weight, "%dkg" % weight) for weight in range(40, 251) ) Le mercredi 21 août 2013 18:16:59 UTC-4, Gerd Koetje a écrit : > > > How do i automatic increase this from 40 tot 250kg > its a choices field

Re: Django ORM: default value from sql query

2013-08-21 Thread Simon Charette
You can achieve this by setting a callable default value [1] on you field: class MyModel(models.Model): count = models.PositiveIntegerField(default=lambda:MyModel.objects.count()) [1] https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.default Le mercredi 21

Re: How to handle exceptions in middleware?

2013-08-22 Thread Simon Charette
`Middleware.process_view ` can either return `None` or an `HttpResponse object [1] thus you could wrap your `AuthManager.ValidateToken(Token)` call into a try/catch block and return a response early if the service is unavailable. [1]

Re: Remove validation on a field if its empty

2013-09-05 Thread Simon Charette
Set `required=False`on your `password` field`. If you want to make sure it's only non-mandatory when the user exists override your `UserForm.__init__` this way: class UserForm(forms.ModelForm): password =

Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-24 Thread Simon Charette
Unfortunately the Django ORM's doesn't support conditionnal aggregates . Le mardi 24 septembre 2013 16:50:51 UTC-4, Victor Hooi a écrit : > > Hi, > > I'm trying to use aggregation to count the number of "likes" on an item. > > The likes for an item

Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-24 Thread Simon Charette
Unfortunately the Django ORM's doesn't support conditionnal aggregates . Le mardi 24 septembre 2013 16:50:51 UTC-4, Victor Hooi a écrit : > > Hi, > > I'm trying to use aggregation to count the number of "likes" on an item. > > The likes for an item

Re: Restrict access to user-uploaded files to authorized users

2013-09-24 Thread Simon Charette
I'm not aware of any solution except serving from Django if you can't install Apache plugins. If you're really stuck with serving large files from Django I'd recommend you streamthe content of the

Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-25 Thread Simon Charette
C-4, Daniel Roseman a écrit : > > On Tuesday, 24 September 2013 21:58:44 UTC+1, Simon Charette wrote: > >> Unfortunately the Django ORM's doesn't support conditionnal >> aggregates<https://code.djangoproject.com/ticket/11305> >> . >> > > This is true

Re: What's the difference between assertIn and assertContains?

2013-10-28 Thread Simon Charette
assertContains performs additional assertion such as the status code of the request and provides a way to perform comparison based on HTML semantic instead of character-by-character equality. Under the hood it also handles streaming and deferred response gracefully. I suggest you take a look at

Re: multiple databases and syncdb problem

2013-10-29 Thread Simon Charette
syncdb defaults to syncing the 'default' database when no --database is specified . Try specifying which database to synchronize, with the --database=inserv flag in your case. Le mardi 29 octobre 2013

Re: handling field DoesNotExist error within a model class

2013-11-01 Thread Simon Charette
Use the `DateTypeModelClass.DoesNotExist` exception. By the way, make sure you use `select_related()` if you want to use `__unicode__` on those instances or it will results in 1 + N * 6 queries where N = `Channel.objects.count()`. Le vendredi 1 novembre 2013 12:46:21 UTC-4, Rick Shory a écrit

Re: Django not installed, but clearly installed ??

2013-11-14 Thread Simon Charette
It looks like pip failed to install django. Look into pip.log for more details. Le jeudi 14 novembre 2013 23:28:51 UTC-5, icevermin a écrit : > > Hello, > > I installed Django using pip. It seems as if it was installed just fine. > However... > > cmd --> python --> import django I get an error

Re: override_settings decoration of non-test class function

2013-11-18 Thread Simon Charette
Hi Daniel! Prior to Django 1.6 (552a90b444) override_settings couldn't be safely nested . Could you try running your example against this version and report back

Re: How to get the class name of a ContentType in django

2013-11-29 Thread Simon Charette
Do you want to retrieve the class name of the model class associated with a content type? Le jeudi 28 novembre 2013 12:04:34 UTC-5, Aamu Padi a écrit : > > How do I get the class name in string of a ContentType? I tried it this > way, but it didn't worked out: > > class

Re: View decorators before CSRF verification?

2013-12-15 Thread Simon Charette
Hi Dalton, > Is this something to be bothered about? This is a request for advice and discussion rather than debugging a particular problem. I think I would prefer if there were a way for Django to check for view decorator compliance first because I think a 405 response is more descriptive and

Re: Honest feedback

2014-01-31 Thread Simon Charette
Just wanted to add/correct two points. > That also means some of the warts are still there like the difficulty in > writing reusable apps, file based settings, multiple user profiles, that 30 > char username length on the contrib.auth.User model. > Django 1.5 ships with a configurable user

Re: Context manager to pick which database to use?

2015-04-28 Thread Simon Charette
Hi Peter, I think you could use database routers to declare the default behavior and rely on the using() queryset method for the exceptional case? I'm afraid the introduction of a context

Re: Django model inheritance: create sub-instance of existing instance (downcast)?

2015-05-13 Thread Simon Charette
Hi Guettli, This isn't part of the public API but you could rely on how Django loads fixture internally . parent = Restaurant.objects.get(name__iexact="Bob's

Re: Improve Performance in Admin ManyToMany

2015-05-14 Thread Simon Charette
It's a bit hard to tell without your model definition and the executed queries but is it possible that the string representation method (__str__, __unicode__) of one the models referenced by a M2M access another related model during construction? e.g. from django.db import models class

Re: Improve Performance in Admin ManyToMany

2015-05-14 Thread Simon Charette
I meant if db_field.name == 'bars': Sorry for noise... Le jeudi 14 mai 2015 11:15:49 UTC-4, Simon Charette a écrit : > > The last example should read: > > if db_field.name == 'baz': > > > > Le jeudi 14 mai 2015 11:14:24 UTC-4, Simon Charette a écrit : >> >>

Re: Improve Performance in Admin ManyToMany

2015-05-14 Thread Simon Charette
The last example should read: if db_field.name == 'baz': Le jeudi 14 mai 2015 11:14:24 UTC-4, Simon Charette a écrit : > > It's a bit hard to tell without your model definition and the executed > queries but is it possible that the string representation method (__str__, > __unico

Re: select_related() / prefetch_related() and sharding

2015-05-21 Thread Simon Charette
Small correction, prefetch_related doesn't issue any JOIN unless a is query with a select_related is specified with a Prefetch object. Simon Le jeudi 21 mai 2015 17:53:30 UTC-4, Ash Christopher a écrit : > > Hi David, > > *select_related* does a JOIN under the hood, and you can't do >

Re: Reduce number of calls to database

2015-06-02 Thread Simon Charette
Hi Cherie, A `id__in` queryset lookup should issue a single query. levels = Level.objects.filter(id__in=level_ids) Cheers, Simon Le mardi 2 juin 2015 11:42:19 UTC-4, Cherie Pun a écrit : > > Hi, > > I am new to Django and I am performing some iteration on a queryset. When > I use

Re: Core error in showing records?

2015-06-16 Thread Simon Charette
Hi MikeKJ, I suppose the ModelAdmin subclass in use here has a list_display method marked as boolean that return an unexpected value

Re: custom model fields with to_python()/from_db_value() for different django version...

2015-06-17 Thread Simon Charette
Hi Jens, I haven't tested your alternative but it looks like it would work. I prefer the explicit check against django.VERSION since it makes it easy to search for dead code branch when dropping support a version of Django. Simon Le mercredi 17 juin 2015 10:59:27 UTC-4, Jens Diemer a écrit :

Re: Get the name of the method in QuerySetAPI

2015-06-17 Thread Simon Charette
Hi Utkarsh, I guess you could define a __getattribute__[1] method on your manager? from django.db import models class MyManager(models.Manager): def __getattribute__(self, name): print(name) return super(models.Manager, self).__getattribute__(name) Simon [1]

Re: Django SECRET_KEY : Copying hashed passwords into different Django project

2015-08-05 Thread Simon Charette
Hi Angit, It shouldn't be an issue since Django's default password hashers are not relying on settings.SECRET_KEY. Simon Le mercredi 5 août 2015 05:12:47 UTC-4, Ankit Agrawal a écrit : > > > > Hi everyone, > > > I have a Django powered site(Project-1) running with some users >

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-08 Thread Simon Charette
Hi Malcom! I would suggest you have a look at the ModelAdmin.get_fields() method to append your thumbnail read-only field names. As documented

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-09 Thread Simon Charette
o dynamically create >attributes on a ModelAdmin that passes system checks >2. The system check is incorrect, and should allow dynamically created >attributes on ModelAdmin when validating fields >3. Metaclass programming is really the right way to do this > > >

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Simon Charette
h together > this week. > > Cheers, > > Malcolm > > On 9 September 2015 at 18:17, Simon Charette <chare...@gmail.com > > wrote: > >> Hi Malcom, >> >> What I meant to suggest is to remove the fields from >> `fields`/`readonly_fields` an

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Simon Charette
ces, that is only the properties of the instances should be checked and not the return value of methods that could depend on request properties such as the user. Simon Le jeudi 10 septembre 2015 13:32:32 UTC-4, Malcolm Box a écrit : > > Hi Simon, > > On Thursday, 10 September 2015 16:57:51 UTC+1,

Re: Prefetch() with through models

2015-09-16 Thread Simon Charette
Hi Erik, I think the prefetch api uses IN [id1, ..., idn] instead of IN (SELECT * ...) because the default isolation level Django runs with is READ COMITTED and using the latter could return different results for the second query. e.g. SELECT id FROM foo WHERE bar = true; -- An other

Re: DJango 1.8 test case fails with IntegrityError error

2015-09-21 Thread Simon Charette
Hi Jose, I looks like ibm_db_django doesn't support Django 1.6+ yet . Simon Le lundi 21 septembre 2015 07:14:39 UTC-4, Jose Paul a écrit : > > I am trying to run DJango 1.8 test cases with DB2 > > Several insert statement fails > > Here is the

Re: Problem with date validator

2015-09-23 Thread Simon Charette
Hi Felix, The way you create your validator instance it is passed the value returned by `date.today()` at module initialization time. That is when the Python process starts. It means that if you started your development server or say a gunicorn process on your server yesterday the max value the

Re: Problem with date validator

2015-09-24 Thread Simon Charette
Hi Felix, >From what I know model and form DateField are completely TIME_ZONE agnostics. This is not the case for DateTimeField however. Is this what you're using? Simon Le jeudi 24 septembre 2015 15:13:01 UTC-4, felix a écrit : > > El 23/09/15 17:12, felix escribió: > > > When today's date

Re: Converting implicit m2m through table to explicit through model with Django 1.7 migrations

2015-09-28 Thread Simon Charette
Hi John, Until #23034 is fixed you'll have to keep using migrations.SeparateDatabaseAndState to achieve the implicit to explicit conversion. >From what I've read of your process everything should be working fine in the long term and your approach

Re: Load a static file with a variable name

2015-10-07 Thread Simon Charette
You'll want to use Because François' suggestion will break if you use a static file storage that doesn't allow missing files reference such as the ManifestStaticFilesStorage . Simon Le mardi 6

Re: Validating data for use directly in a model (not via forms)

2015-10-21 Thread Simon Charette
Hi Yunti, Did you read about model level validation ? Calling model_instance.full_clean() triggers validation but it's not implicitly called when you save an instance. For your date case you'll have to include a

Re: Locking / serializing access to one element in database

2015-10-21 Thread Simon Charette
Hi Joakim, I would suggest you use select_for_update() in a transaction. It's hard to provide a full example without more details about the kind of calculation required. Does it need to be run on new_text even if

Re: Reverse query name clashe with a M2M and through

2015-10-23 Thread Simon Charette
Hi Gagaro, Intermediate models are just like other in this regard, they create a related relation hence the reported clash. You should either add related_name='+' on your Wishlist related fields or give them a unique name. Simon Le vendredi 23 octobre 2015 06:01:30 UTC-4, Gagaro a écrit : >

Re: Reverse query name clashe with a M2M and through

2015-10-23 Thread Simon Charette
wishlist* (I > would understand if I named my attribute *wishlist_set*)? > > On Friday, 23 October 2015 15:40:42 UTC+2, Simon Charette wrote: >> >> Hi Gagaro, >> >> Intermediate models are just like other in this regard, they create a >> related relation hence

Re: Missing default callable breaks migration

2015-10-28 Thread Simon Charette
I would add that since migration files are normal Python modules you can simply replace the previously imported callable in the referencing migrations by inlining it. Simon Le mercredi 28 octobre 2015 11:33:28 UTC-4, Tim Graham a écrit : > > Please read >

Re: Custom QuerySet and __date field lookup

2015-11-05 Thread Simon Charette
Hi Adam, I couldn't reproduce your issue with Django 1.9.b1 with the following model definition: from __future__ import unicode_literals import datetime from django.db import models class EntryQuerySet(models.QuerySet): def today(self): today = datetime.date.today()

Re: Prefetch object with to_attr set to the same name as the field triggers rows deletions

2015-11-05 Thread Simon Charette
Hi mccc, Would it be possible to provide an example of the models and actions required to trigger the deletion. I suppose the deletion is triggered by the many to many relationship assignment logic and we should simply raise a ValueError if `to_attr` is set the same name as the referred

Re: Prefetch object with to_attr set to the same name as the field triggers rows deletions

2015-11-05 Thread Simon Charette
serialization over there, while if I specify a > different to_attr name I get back a list and I have to deal differently > with that. > How do these prefetch_related / Prefetch to_attr / Generic* things really > work? > > Merci beaucoup, > Michele > > On Thu, Nov 5

Re: Prefetch object with to_attr set to the same name as the field triggers rows deletions

2015-11-07 Thread Simon Charette
! > > All the best, > Michele > > On Fri, Nov 6, 2015 at 12:00 AM, Simon Charette <chare...@gmail.com > > wrote: > >> Bonsoir Michele, >> >> I'll try to explain what happens here with a simplified model definition >> assuming you are using Django 1.8. I use

Re: How do I add permissions in admin for proxy model?

2015-11-11 Thread Simon Charette
Hi frocco, This might be related to #11154 and #17904 . Did you try running the `migrate` command? It looks like it might trigger the creation of your custom permissions

Re: Usage of select_related() on a OneToOneField with parent_link=True doesn't work

2015-11-14 Thread Simon Charette
Hi Gilad, The `parent_link` option can only be used if the model the o2o field is pointing to is a direct base of the model it's attached to. From what I understand `select_related` simply ignores `parent_link` fields since it assumes it's pointing to a MTI parent table which are JOINed by

Re: Model Meta option default_related_name not setting related_query_name

2015-11-14 Thread Simon Charette
Hi Alejandro, This looks like a bug and overlook to me but as Tim pointed out simply changing it would be backward incompatible at this point. If we were to fix this issue we would need to deprecate the actual behavior first. The deprecation path would involve raising a warning when the actual

Re: Fixed column width in admin interface?

2015-11-14 Thread Simon Charette
Hi Jorgue, You can simply define a `list_display` method that truncates your text if required and append an ellipsis. e.g. class FooAdmin(admin.ModelAdmin): list_display =

Re: How can you use the @cache_page decorator with Django class based views?

2015-11-14 Thread Simon Charette
Hi Daniels, There's a tentative API being worked on Github. You might want to have a look at it . Simon Le samedi 14 novembre 2015 13:38:18 UTC-5, daniels a écrit : > > The only method that seems to be working is adding the decorator in > urls.py

Re: Unicode in email addresses

2015-12-01 Thread Simon Charette
Hi Zac, There's a ticket and a pull request suggesting to improve the actual email validation based on RFCs. You might want to join the conversation there. Simon Le mardi 1 décembre 2015

Re: Migrating from OneToOneField to ForeignKey in Django models

2015-12-03 Thread Simon Charette
Hi Cajetan, You can visit the ticket [1] and have a look and the commit messages. In this case the fix have been backported to 1.7.4[2] and should be part of Django 1.8+. Simon [1] https://code.djangoproject.com/ticket/24163 [2]

Re: Bi-directional ManyToMany with through gets broken when creating test database

2015-12-04 Thread Simon Charette
Hi filias, I personally didn't know one could define a reverse foreign key this way and I doubt this use case is covered by the test suite. I'm afraid it worked for Django < 1.8 by chance since it's not documented you can re-use the implicitly created intermediary model as a `through` argument. I

Re: Nested ArrayField error in 1.9

2015-12-04 Thread Simon Charette
Hi, This looks like a regression bug to me. We don't actually test nested array checks so I assume this scenario was overlooked when we this check was added. I think the bugs lies in the contrib.postgres component since the check errors on a fairly reasonable assumption: bounded fields should

Re: SubfieldBase deprecation

2015-12-07 Thread Simon Charette
Hi Matus! > Is there any replacement to this / what is the best way to do it if I'd like > to call to_python on assignment? If you'd like to have a field's `to_python()` called on assignement you should attach a descriptor[1] on the model class on `contribute_to_class()` that calls it. e.g.

Re: Model Meta option default_related_name not setting related_query_name

2015-12-09 Thread Simon Charette
Hi Alejandro, Did you get the reply to your previous similar question[1]? Simon [1] https://groups.google.com/d/topic/django-users/OGavpqJrw6g/discussion Le mercredi 9 décembre 2015 03:13:46 UTC-5, Alejandro Do Nascimento a écrit : > > Hello, > > I have a doubt, In a model I'm using the Meta

Re: ajax POST request being sent as GET

2015-12-15 Thread Simon Charette
Hi Larry, It's more of a JavaScript question but my first guess would be you'd need to use the `type` option instead of `method` because you are using an old version of jQuery? Simon Le mardi 15 décembre 2015 17:25:12 UTC-5, larry@gmail.com a écrit : > > I am sending an ajax POST request

Re: 'CharField' object has no attribute 'model'

2015-12-26 Thread Simon Charette
Hi Billlu, Does one your model use an ArrayField? Le samedi 26 décembre 2015 01:34:02 UTC-5, Billu a écrit : > > I'm trying to make a single choice quiz (i.e. Choose one from 4 options). > I'll populate the quiz (with 30 questions) depending upon what topic the > user chooses. I'm made some

Re: Conditional annotation super slow

2016-01-06 Thread Simon Charette
Hi Mark, I suppose you opened #26045 about the same issue. Are you using PostgreSQL? If it's the case the issue I suppose the issue is fixed in Django 1.9 . Simon

Re: CachedStaticFilesStorage and collectstatic for the very first time

2016-01-08 Thread Simon Charette
Hi Andrzej, CachedStaticFilesStorage requires you run `collectstatic` before deploying your application in production (non-DEBUG) mode. The deployment should look like that: 1) Update your code to the latest version. 2) Run `collectstatic` to cache paths to hashed versions of your assets. 3)

Re: CachedStaticFilesStorage and collectstatic for the very first time

2016-01-08 Thread Simon Charette
ic files from external application are copied to > STATIC_ROOT which enables me to proceed. This workaround is not very > beautiful nor django-like. Why? Because there is no such behaviour when I > fell back to default StaticFilesStorage. > > Andrzej > > W dniu piątek, 8 stycznia

Re: Django 1.9.1/python3.4 install errors

2016-01-09 Thread Simon Charette
Hi Nicholas, These warnings should be safe to ignore. See 1.9 release notes for more details. Simon Le samedi 9 janvier 2016 16:30:14 UTC-5, Nicholas Geovanis a écrit : > > Hi all - >

Re: Compilation Error while installing

2016-01-12 Thread Simon Charette
Hi, These warnings are safe to ignore, please see 1.9 release notes for more details . Simon Le mardi 12 janvier 2016 12:06:43 UTC-5, Kshitij Saraogi a écrit : > > Hello, > > I was

Re: How do I add permissions in admin for proxy model?

2016-01-15 Thread Simon Charette
Proxy model is working if the > model is in same app. But if the model is imported from another app it is > not working. Tried Migrate command. But issue is there. can you help me? > > Cheers, > Manimaran > > On Thursday, November 12, 2015 at 12:27:18 AM UTC+5:30, Simon C

Re: Filter object by calculating duration from start and end time

2016-01-19 Thread Simon Charette
Hi Steve, You can use annotate for this . from datetime import timedelta from django.db.models import DurationField, ExpressionWrapper, F Entry.objects.annotate( duration=ExpressionWrapper(

Re: Filter object by calculating duration from start and end time

2016-01-19 Thread Simon Charette
eve > > On Tuesday, 19 January 2016 18:52:06 UTC, Simon Charette wrote: >> >> Hi Steve, >> >> You can use annotate for this >> <https://docs.djangoproject.com/en/1.9/ref/models/expressions/#using-f-with-annotations> >> . >> >> from dateti

Re: Model validation across relationships

2014-03-23 Thread Simon Charette
I'd say that's exactly what you should use `Model.clean()` for. In this case you're *doing validation that requires access to more than a single field.* What sounds vague to you in the documentation? Le vendredi 21 mars 2014 19:43:07 UTC-4, Joshua Pokotilow a écrit : > > Given these models,

Re: Missing ORDER BY in subselect?

2014-04-16 Thread Simon Charette
I pretty sure this is related to #22434 . There's a patch on Github I'm actually reviewing and it's looking pretty good. If all goes well it should make it to Django 1.7. Le mercredi 16 avril 2014

Re: How to create Union in Django queryset

2014-04-17 Thread Simon Charette
I'm not sure this will work but you could try creating a VIEW on the database side that does the union there and access it through an un-managed model. CREATE VIEW *view_name* AS SELECT id, name FROM *a* UNION SELECT id, name FROM *b*; class C(models.Model): name = models.CharField()

Re: 3 table many to many relationship

2014-04-23 Thread Simon Charette
Django allows you to explicitly specify an intermediary model for many-to-many relationships with the `through` option. class A(models.Model): b_set = models.ManyToMany('B',

Re: Django explicit `order_by` by ForeignKey field

2014-04-25 Thread Simon Charette
The issue was referenced in #19195and it was suggested we add the ability to order by field name and not only by attribute name. I suggest you open a ticket for this and add a reference to it in #19195 .

Re: Django explicit `order_by` by ForeignKey field

2014-04-25 Thread Simon Charette
Actually the FieldError is not raised anymore in Django 1.7 (and master) and issuing a .order_by('group_id') is the equivalent of .order_by('group') which respect related model ordering if defined. I would argue we should seize the opportunity to provide a way of opting out of this default

  1   2   3   >