Re: Date() in Django query

2016-06-15 Thread Simon Charette
rite it as: > > calls = Call.objects.annotate(join_date=Func(F('jointime'), function='DATE'), > count=Count('uniquecallid', distinct=True)).values('join_date', 'count') > > > But it seems that the group by is not working as expec

Re: Prefetch Related with Multiple Column Join

2016-06-18 Thread Simon Charette
Hi Ram, I don't have a complete solution for you but I suggest you take a look at the django.db.models.fields.related.ForeignObject class. If I'm not mistaken it should allow you to define multi-column relationships on both your Article and PublisherMediumBilling models and refer to them using

Re: Prefetch Related with Multiple Column Join

2016-06-18 Thread Simon Charette
ect! > > On Saturday, June 18, 2016 at 8:34:31 PM UTC+5:30, Simon Charette wrote: >> >> Hi Ram, >> >> I don't have a complete solution for you but I suggest you take a look at >> the >> django.db.models.fields.related.ForeignObject class. &

Re: Prefetch Related with Multiple Column Join

2016-06-19 Thread Simon Charette
again > Ram > > On Sunday, June 19, 2016 at 5:30:03 AM UTC+5:30, Simon Charette wrote: >> >> Hi Ram, >> >> As PublisherMediumBilling.publisher and medium are unique together it's >> safe to >> silence the `fields.E310` check failure in this case. &g

Re: I need an expert Postgresql.

2016-06-19 Thread Simon Charette
Hi Seti, I suppose this has to do with your Func subclasses not defining an `output_field`. You might want to have a look at the Cast function's implementation which will be part of Django 1.10 for more details[1]. It should allow you to do the following: self.annotate(s=Cast('scoppe', models

Re: IntegrityError for unique_together ?

2016-06-23 Thread Simon Charette
Hi Derek, It's hard to tell without your exact model admin definitions but I suspect this might be related to #25987[1] which is fixed in Django 1.10. By the way you should at least upgrade to 1.8 as your Django version is not supported anymore and you could be exposed to multiple security issue

Re: Django 1.8.13 saving new user gets error NOT NULL constraint failed: auth_user.last_login

2016-07-21 Thread Simon Charette
If you upgraded from Django 1.7 you should make sure to run all auth migrations. If you're using a custom user model make sure to makemigrations for its app and proceed to migrate it. Simon Le jeudi 21 juillet 2016 11:46:37 UTC-4, bobhaugen a écrit : > > NOT NULL constraint failed: auth_user.l

Re: Loading fixtures inside a transaction

2016-08-03 Thread Simon Charette
I believe it already does[1] as it is a requirement to support forward references. Cheers, Simon [1] https://github.com/django/django/blob/5c63b3e5a797102d915e1683971517f747a28013/django/core/management/commands/loaddata.py#L68-L69 Le mercredi 3 août 2016 15:42:23 UTC-4, th...@copperleaf.com a

Re: Subtracting UNIX_TIMESTAMPS broke in Django 1.10

2016-08-17 Thread Simon Charette
Hi Dan! I'm the author of the temporal substraction changes in 1.10. I believe the main culprit here is your usage of `Func` with no explicit `output_field`. When this parameter is not specified the return type of `Func` expressions is determined by it's wrapped expressions given there's either

Re: Django query not returning all objects

2016-08-19 Thread Simon Charette
For reference there's a Django ticket to suggest using this technique. Cheers, Simon [1] https://code.djangoproject.com/ticket/19842 Le jeudi 18 août 2016 02:20:34 UTC-4, Todor Velichkov a écrit : > > Another solution would be to annotate min/max deadline date and order by > the annotation. Som

Re: Django-drip not working

2016-08-20 Thread Simon Charette
It looks like django-drip has not been ported to Django 1.8 yet. Le samedi 20 août 2016 09:41:06 UTC-4, M Hashmi a écrit : > > Now I am getting another error: > > Traceback: > > File > "C:\Users\Mudassar\dressikarepo\lib\site-packages\django\core\handlers\base.py" > > in get_response > > 132.

Re: Creation of default site not triggering post_save signal

2016-09-10 Thread Simon Charette
Hi Matt, I worked on the changes that broke your code. Starting with 1.10 the migration signals are passed an `apps` kwarg representing the state of models before and after the specified migrations are applied. This allows signal receivers to manipulate model definitions that are synchronized w

Re: Creation of default site not triggering post_save signal

2016-09-13 Thread Simon Charette
> be exact) when I run initial migrations, with the site finally getting > created at the end. This is why I've had to add some exception handling > for when the site doesn't exist. > > Simon, one last question for you -- where should this code live? I > currently have

Re: django.db.utils.OperationalError when remove the parent model

2016-09-13 Thread Simon Charette
Hi Cheng-Hung, This is know bug[1] Simon [1] https://code.djangoproject.com/ticket/24424 Le mardi 13 septembre 2016 22:02:54 UTC-4, Cheng-Hung Hsueh a écrit : > > The sample project: > https://github.com/sih4sing5hong5/django_migration_error > -- You received this message because you are sub

Re: Django 1.10.3 with Oracle database and --keepdb

2016-11-05 Thread Simon Charette
Hi Carsten, > In other words, without setting an explicit (non-random) password, database > errors are expected when starting the tests with --keepdb ? You are right. I just created a ticket[0] about preventing usage of `--keepdb` without defining a `TEST.PASSWORD` setting. Simon [0] https://

Re: Related name with %(app_label)s being an actual field?

2016-11-05 Thread Simon Charette
Hi Jonty, While support for related_query_name was added in 1.6 it only supports app_label and class_name interpolation since Django 1.10. You can either upgrade to Django 1.10 or rely on related_name's support for app_label and class_name interpolation as related_query_name defaults to related

Re: django.db.utils.OperationalError: near ")": syntax error ERROR at $ python3 manage.py migrate

2016-11-14 Thread Simon Charette
Hello Peter, That looks like https://code.djangoproject.com/ticket/24424 Simon Le lundi 14 novembre 2016 12:06:41 UTC-5, Peter Sels a écrit : > > Dear Django-ers, > > I ran into a problem with Django. > > -- > Situation: > -- > > I am using version 1.10.3 of Django. > > For the fifth time I upda

Re: DatabaseWrapper.needs_rollback and transaction.rollback()

2016-11-14 Thread Simon Charette
Hello Mark, Is there a reason for not using the transaction.atomic context manager instead of managing your transaction manually by calling .set_autocommit(False) and rollback? Simon Le lundi 14 novembre 2016 15:46:38 UTC-5, mark...@gmail.com a écrit : > > After a validationError occurs, why i

Re: Preparing for 2.2LTS - testing for Deprecation Warnings

2019-01-17 Thread Simon Charette
You can use the category kwarg of filterwarnings[0] to pass the Django deprecation warning classes. They can be found in the django.utils.deprecation module. (e.g. RemovedInDjango30Warning). Cheers, Simon [0] https://docs.python.org/3/library/warnings.html?highlight=filterwarnings#warnings.fi

Re: django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet with Django’s user database authentication from Apache

2019-01-28 Thread Simon Charette
Hello there, That looks like a Django bug to me as auth.get_user_model() should only be performed from within the check_password() function as it will certainly crash at the module level. You should file a bug report so it gets addressed[0]. Best, Simon [0] https://code.djangoproject.com/newt

Re: django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet with Django’s user database authentication from Apache

2019-01-28 Thread Simon Charette
get_user_model() in django.contrib.auth.handlers.modwsgi. Best, Simon Le lundi 28 janvier 2019 10:16:30 UTC-5, Simon Charette a écrit : > > Hello there, > > That looks like a Django bug to me as auth.get_user_model() should only be > performed > from within the check_password() functio

Re: Limiting a SubQuery based on instance's OuterRef

2019-01-29 Thread Simon Charette
Hello Nick, It isn't possible to reference columns in a LIMIT clause AFAIK. I'd suggest you use a RowNumber[0] window function ordered by your number column in a subquery and filter on the annotated value in the outer query. Cheers, Simon [0] https://docs.djangoproject.com/en/2.1/ref/models/d

Re: Local variable dump on exception in production environment (DEBUG=False)

2019-02-01 Thread Simon Charette
Hello there, I haven't tried it myself but you could try subclassing django.utils.log.AdminEmailHandler to rely on the better-exceptions[0] package to _better_ format exceptions sent in text emails or simply set the include_html option[1] to True in your LOGGING configuration to get report simi

Re: Django update field in many to many relationship

2019-02-14 Thread Simon Charette
Your DirectorForm model form doesn't include 'Leave_current_balance' in it's Meta.fields hence no form field is generated for it. Cheers, Simon Le jeudi 14 février 2019 17:50:21 UTC-5, suabiut a écrit : > > Hi, > > I have two models many to many relationships, I am trying to update the > field

Re: select_for_update Documentation is confusing(?)

2019-02-15 Thread Simon Charette
I meant, and *not* "Building a queryset" in my previous reply. Le vendredi 15 février 2019 14:18:27 UTC-5, Simon Charette a écrit : > > Hello Philoj, > > > Does this mean that the above code example will raise > TransactionManagementError... > > It won&#x

Re: select_for_update Documentation is confusing(?)

2019-02-15 Thread Simon Charette
Hello Philoj, > Does this mean that the above code example will raise TransactionManagementError... It won't cause a TransactionManagementError because of the lazy nature of queryset. Even if the QuerySet.select_for_update() call is made outside of the atomic block the query is really only ex

Re: Help with aggregates needed

2019-02-27 Thread Simon Charette
Hello Felix, month = ... year = ... Expenses.objects.filter( year=year, ).values( area_name=F('area__name'), element_name=F('element__name') ).annotate( year_sum=Sum('cost'), month_sum=Sum('cost', filter=Q(month=month)), ) Should generate SQL along the following lines on Postg

Re: Why are foreign keys rewritten when adding related_name?

2019-03-01 Thread Simon Charette
Hello HM, I know that some changes have been made to avoid unnecessary foreign key rebuilds on some option changes. Are you experiencing this on 2.1 and 2.2 pre release? Simon Le vendredi 1 mars 2019 02:40:01 UTC-5, HM a écrit : > > I added "related_name" to an exiting ForeignKey and checked wi

Re: Django 2.1.4: Permissions are not updated after migrations

2019-03-17 Thread Simon Charette
Hello Yevgeny, I don't have magic solution to suggest to you given the current state of your permission data after a few iterations but I just wanted to let you know that it's a known issue[0] and a contributor is actively working on getting it fixed[1]. Cheers, Simon [0] https://code.djangop

Re: Django 2.1.4: Permissions are not updated after migrations

2019-03-17 Thread Simon Charette
> On Sun, Mar 17, 2019, 9:21 PM Simon Charette > wrote: > >> Hello Yevgeny, >> >> I don't have magic solution to suggest to you given the current state of >> your >> permission data after a few iterations but I just wanted to let you know >> tha

Re: Django 2.1.4: Permissions are not updated after migrations

2019-03-18 Thread Simon Charette
rategy work? delete all app permission and use, > create_permissions to recreate them > b) How do I know to which db table a given permission points? Or does it > point to a model? > > On Mon, Mar 18, 2019 at 6:38 AM Simon Charette > wrote: > >> Hello Yevgeny, >

Re: Creating Objects from Annotations and Other Models

2019-03-21 Thread Simon Charette
I'm not sure where r_id comes from but Model.save usually deals with any expression correctly so you could try using a subquery assignment and see if it works. e.g. entry = Entry.objects.create( start=Subquery( Recurrence.objects.filter(pk=r_id).values('start_time')[:1] ) ) Note

Re: Unit-Testing Django Views

2019-03-28 Thread Simon Charette
This is effectively failing because of a mechanism added in 1.10 to protect against BREACH attacks[0] by salting the CSRF token. I'm not aware of any way to disable this mechanism but testing against the exact HTML returned from a view seems fragile. I suggest you use assertContains[1] (with or w

Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-04-09 Thread Simon Charette
No form validation is implemented for UniqueConstraint(condition) yet as that would require a non-trivial refactor of how it's performed. It was discussed during the feature development[0]. I'd suggest you override you form or your model's clean() method to perform the validation yourself until

Re: Django 2.2 and custom media in the admin

2019-04-09 Thread Simon Charette
Hello Thorsten, this is a change document in the 2.2 release notes[0]. There's even a resolution example for a django.jQuery dependency like you have > For example, widgets depending on django.jQuery must specify > js=['admin/js/jquery.init.js', ...] when declaring form media assets. [1] Cheers

Re: Pagination breaks in ListView after migrating from Django 1.11 to 2.2 with SQLite

2019-04-23 Thread Simon Charette
I assume you are either using a Subquery annotation that returns multiple results or an __in lookup against a query with multiple columns. I vaguely remember something changed in this area but it was documented in one of the 2.0, 2.1 or 2.2 release notes. Best, Simon Le mardi 23 avril 2019 10:31

Re: Django 2.2 creates multiple migration files when AbstractUser is used

2019-05-02 Thread Simon Charette
Hey David, Could you try explicitly defining an objects manager on your User model and see it if helps. e.g. from django.contrib.auth.models import UserManager class User(AbstractUser): ... # fields objects = UserManager() I'm also having trouble reproducing locally though. Simon Le

Re: Django tests appear to be getting substantially slower

2019-06-15 Thread Simon Charette
Hi Mark, It's hard to tell exactly what's going on without more details but assuming you are running tests against SQLite the 2.1 to 2.2 slowdown is likely caused by the fact database constraints are now checked of each TestCase[0]. Cheers, Simon [0] https://docs.djangoproject.com/en/2.2/relea

Re: Django tests appear to be getting substantially slower

2019-06-15 Thread Simon Charette
n increases, it's > getting slower as the version of Django increases. > > On Sat, Jun 15, 2019 at 7:20 AM Simon Charette > wrote: > >> Hi Mark, >> >> It's hard to tell exactly what's going on without more details but >> assuming you are r

Re: Django tests appear to be getting substantially slower

2019-06-16 Thread Simon Charette
Cellar/sqlite/3.28.0/lib/libsqlite3.dylib > > > On Sat, Jun 15, 2019 at 8:16 AM Simon Charette > wrote: > >> I meant Django 2.0 -> 2.1. As long as you are using Django 2.2 with >> SQLite 3.20+ >> the slowdown I mentioned should be effective. >> >> Si

Re: Package that helps update only changed fields

2019-06-18 Thread Simon Charette
Hello Dan, I'm not aware of any third party library handling this but a simple way to achieve what you're after would be to subclass ModelForm in order to override save() and pass commit=False in your super() call. e.g. (untested) class UpdateFieldsModelForm(ModelForm): update_fields = None

Re: IndexError: Number of args exceeds number of fields

2019-06-19 Thread Simon Charette
It's hard to tell without the full traceback but Django 1.11 doesn't support Python 3.7 so it'd start by either using Django 2.2 or downgrading to Python 3.6 Cheers, Simon Le mercredi 19 juin 2019 08:16:51 UTC-4, Ezequias Rocha a écrit : > > Hi everyone > > I am doing a modeling of my database o

Re: Vicious cycle: Cannot migrate a DB that uses a widget using a model

2019-06-19 Thread Simon Charette
Hello Victor, You should avoid performing database queries at module loading level as the code will necessary crash if the database is missing or unmigrated. I suggest you lazily define widgets instead by using a cached property[0] class PlaceWidget(widgets.MultiWidget): def __init__(self,

Re: From SQL to Django Queryset API

2017-03-29 Thread Simon Charette
Hello Mauro, The following should do from django.db.models import F Movimento.objects.values( 'anno','impianto' ).annotate( dare=Sum('dare), avere=Sum('avere), diff=Sum(F('dare') - F('avere)), ) Cheers, Simon Le mercredi 29 mars 2017 16:19:37 UTC-4, Mauro Ziliani a écrit : > >

Re: Executing DB-Queries during import

2017-03-29 Thread Simon Charette
> Is it advisable to execute db queries in my AppConfig ready signal handler? AppConfig.ready() is still at module-level. > Use case: I want to add URL patterns which get collected from db rows. It might be more appropriate to define an URL resolver (an object like django.conf.url) that perfor

Re: TransactionManagementError from inside atomic block

2017-03-29 Thread Simon Charette
Hi Ketan, I'm afraid this will be really hard to solve without the code that is raising this exception. Some details that could help debug the issue: 1. Are your workers multi-threaded? 2. Are you sure you are not calling functions performing manual transaction management? 3. Is your atomic()

Re: Annotated queryset + Prefetch object

2017-04-08 Thread Simon Charette
Hello Jose, I wouldn't be surprised if this was caused by a Django bug with prefetches doing weird things when the same model is referenced through different relations[0]. Simon [0] https://code.djangoproject.com/ticket/26318 Le samedi 4 mars 2017 13:36:20 UTC-5, Jose Kilo a écrit : > > Hi al

Re: JsonField icontains filter generates invalid SQL

2017-04-10 Thread Simon Charette
Hello there, I'm not sure where you determined the SQL that caused the error but I'm pretty sure this was caused by "my_model"."data" -> 'name' not being wrapped in a parenthesis before the ::text cast. This has been fixed in Django 1.11[0]. Cheers, Simon [0] https://github.com/django/django/

Re: There seems an issue in Django(1.11)'s password displaying form in admin site.

2017-04-19 Thread Simon Charette
Hey there, It looks like it has been fixed already[0] and will be part of the upcoming 1.11.1 release. Cheers, Simon [0] https://github.com/django/django/commit/dff559ff83a6aac14de0bbca58101786edf4195f Le mercredi 19 avril 2017 17:31:47 UTC-4, Xdynix a écrit : > > Hello everyone. > > I'm new

Re: Localization with thousand separator makes foreign key id invalid in forms

2017-05-11 Thread Simon Charette
Hello Thomas, Probably caused by #28075 [0], fixed in 1.11.1. Cheers, Simon [0] https://code.djangoproject.com/ticket/28075 Le jeudi 11 mai 2017 11:39:41 UTC-4, Alti a écrit : > > Hello, > > With localization and thousand separator active, my foreign keys ids are > rendered with a thousand se

Re: Subquery filter (__in) causing invalid SQL

2017-05-12 Thread Simon Charette
Hi Murray, That looks like a bug to me. Do you get similar results if you don't use the Subquery expression and pass the query directly instead? Something along the lines of Permit.objects.filter(~Q(uuid__in=activeSuspensionPermitUuidsQuery.values('permit__uuid')) Simon Le vendredi 12 mai 201

Re: Model representation with FK, exceeding queries

2017-05-12 Thread Simon Charette
Hello Cleiton, I'm a bit surprised only two queries were executed on 1.10 as each time a city string representation is created the associated state will need to be fetched as well. Were you using any form of select_related()/prefetch_related() to make sure this wasn't an issue? It's possible that

Re: Subquery filter (__in) causing invalid SQL

2017-05-12 Thread Simon Charette
issue tracker as a bug? > > On Friday, 12 May 2017 13:25:55 UTC-4, Simon Charette wrote: >> >> Hi Murray, >> >> That looks like a bug to me. >> >> Do you get similar results if you don't use the Subquery expression and >> pass the query >>

Re: Subquery - Expression | Django 1.11.1

2017-05-16 Thread Simon Charette
Hello there, This is a bug, there's an open Django issue for it [0]. I suggest you don't rely on Subquery for simple pk lookups. Django supported direct query passing for as long as I can remember. See https://groups.google.com/d/msg/django-users/aq7mL9Opd-s/z2LZ1jXlCAAJ for more details. Chee

Re: Annotate an object with the value of a filtered, related object's attribute

2017-05-21 Thread Simon Charette
Hello Yo'av, You'll want to use subqueries for this[0]. from django.db.models import OuterRef, Subquery children = Child.objects.filter(adult=OuterRef('pk')).order_by('dob').values('dob') Adult.objects.annotate( oldest_son_dob=Subquery(children.filter(gender='M')[:1]), oldest_daughter_

Re: Annotate an object with the value of a filtered, related object's attribute

2017-05-21 Thread Simon Charette
than running over my > Adult objects and for each one of them running a separate query looking for > their oldest son & daughter? Or is it the same and it just looks better? > > Thanks again. > > > > On Sunday, 21 May 2017 17:53:25 UTC+3, Simon Charette wrote: >&

Re: Updating 1.10 to 1.11.1 and AttributeError

2017-05-23 Thread Simon Charette
Hello, Could you please share all of your INSTALLED_APPS? Are you using any kind of query caching? Thanks, Simon Le mardi 23 mai 2017 08:52:56 UTC-4, Jorge Cadena a écrit : > > Hi > > using: django.db.backends.postgresql_psycopg2 > > DATABASE_ROUTERS = ['app.general.router.DatabaseAppsRouter']

Re: Trouble upgrading ModelField class for django 1.10

2017-06-03 Thread Simon Charette
Hello Alexis, As you've noticed Django 1.8 changed values()/values_list() to converts values returned from the database just like any other ORM method[0]. If you want to use the json module to serialize your horari.Horari instances you'll have to define your own JSONEncoder (or DjangoJSONEncode

Re: Combining querysets while maintaining desired ordering?

2017-06-03 Thread Simon Charette
Hello Richard, Since Django 1.11 you should be able to use the QuerySet.union() method[0] for that. queryset = self.many_field1.order_by('some', 'fields') combined = queryset.union(self.many_field2.order_by('some', 'fields')) Best, Simon [0] https://docs.djangoproject.com/en/1.11/ref/models/qu

Re: Why does combining multiple annotations work in my case?

2017-08-13 Thread Simon Charette
Hello there, The issue tracked by #10060 only manifests itself when two different multi-valued relationships are used to perform aggregated annotations. In both of your provided examples you only perform SUM()s on a single multi-valued relationship (ward and then munipality__ward) while the doc

Re: regarding virtualenv and python version 3.5 or 3.4 or other versions

2017-08-14 Thread Simon Charette
Hello there, I'd strongly suggest you use the same version of Python on your development machines and on your servers. You should be able to install a pre-compiled version of Python 3.5 on Ubuntu 14.04 LTS by adding the deadsnakes PPA[0] running apt-get update and then apt-get install python3.

Re: Mixing Q objects and lookups with When conditionals

2017-09-21 Thread Simon Charette
Hello Jason, I don't think this is explicitly documented but I feel like the TypeError raised explicitly states that this isn't supported: __init__() takes either a Q object or lookups as keyword arguments > Did you end up in this situation by following along the documentation or trial and err

Re: Get last instance object per each month and sum per month in Django

2020-02-25 Thread Simon Charette
If you don't want to operate on Activity instances annotations you can use the following queryset Status.objects.annotate( status_month=TruncMonth('status_date'), ).order_by( 'activity', 'status_month', ).values_list( 'activity', 'status_month', ).annotate( progress_sum=Sum(actual

Re: is there any way to django3.0 & oracle 11g together?

2020-03-21 Thread Simon Charette
Django 3.0 only supports Oracle 12.2 and and 18c[0]. Django 2.2 only supports Oracle 12.1+[1] Django 1.11 supports Oracle 11g but LTS support for it will end in April[2]. In short even if you downgrade to 1.11 LTS you won't get any support from Django after less than two weeks. It looks like O

Re: Impossible d'utiliser language_code 'fr-fr' avec django 3.0.4

2020-03-26 Thread Simon Charette
La documentation de Django est disponible en Français. Ce message d'erreur est traduit dans cette section: https://docs.djangoproject.com/fr/3.0/ref/checks/#translation Tu as deux choix: 1. Ajoute 'fr-fr' à ton setting LANGUAGES tel qu'indiqué 2. Définit ton setting LANGUAGE_CODE = 'fr' plutôt q

Re: ValueError: The database backend does not accept 0 as a value for AutoField.

2020-04-06 Thread Simon Charette
Hello there, By default MySQL interprets providing 0 for an AUTO_INCREMENT PRIMARY KEY as NULL which defaults to increment the field. CREATE TABLE foo (id int auto_increment primary key); INSERT INTO foo (id) VALUES(0); INSERT INTO foo (id) VALUES(0); SELECT * FROM foo; ++ | id | ++ | 1

Re: ValueError: The database backend does not accept 0 as a value for AutoField.

2020-04-06 Thread Simon Charette
at 10:16 AM Simon Charette > wrote: > >> Hello there, >> >> By default MySQL interprets providing 0 for an AUTO_INCREMENT PRIMARY KEY >> as NULL which defaults to increment the field. >> >> CREATE TABLE foo (id int auto_increment primary key); >> INSE

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 > registered

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
field_name) > > So I see three possibilities, in order of probability: > >1. I'm being dumb, and there's an easy way to dynamically create >attributes on a ModelAdmin that passes system checks >2. The system check is incorrect, and should all

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Simon Charette
anges - I'll try to put a patch together > this week. > > Cheers, > > Malcolm > > On 9 September 2015 at 18:17, Simon Charette > wrote: > >> Hi Malcom, >> >> What I meant to suggest is to remove the fields from >> `fields`/`readonly_fi

Re: Adding dynamic methods to ModelAdmin fails in 1.8

2015-09-10 Thread Simon Charette
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 transactio

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 inser

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 v

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 is

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 i

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 octobr

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 l

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 n

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
red if the attribute is name *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 &g

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 > https://docs.djangoproject.com/en/stab

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() retur

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 relati

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

2015-11-05 Thread Simon Charette
you might already have guessed: if I *do* use the > same name for following the GenericForeignKey relation (task_content), the > content of the relationship does not get deleted(no surprise there..?) and > I can go with my naïve serialization over there, while if I specify a > differen

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

2015-11-07 Thread Simon Charette
e on the lookout for that! > > All the best, > Michele > > On Fri, Nov 6, 2015 at 12:00 AM, Simon Charette > wrote: > >> Bonsoir Michele, >> >> I'll try to explain what happens here with a simplified model definition >> assuming you are using Django 1.8

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 defa

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 = ['text_field_

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 whi

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 17:37:30

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] https://github.com/django/django/commit/db2a97870d74bc689428d9c2a9

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 h

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 lik

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 mod

<    1   2   3   >