Re: query values() calls don't use transforms as filter() does

2016-08-18 Thread Tim Graham
I merged support for expressions in values() a few hours ago: https://github.com/django/django/commit/39f35d4b9de223b72c67bb1d12e65669b4e1355b If that doesn't meet your needs, can you give an idea of what the QuerySet you want would look like? On Thursday, August 18, 2016 at 5:10:41 PM UTC-4,

Re: Django query not returning all objects

2016-08-18 Thread Koonal Bharadwaj
Hi Todor, I have implemented something similar: cases = HeartFlowCase.objects.all().annotate(Count('hf_id', distinct=True)) I also tried your suggestion and both seem to produce the same results. The number of duplicates is minimized but not removed entirely. Also the same problem when

Re: Django query not returning all objects

2016-08-18 Thread Koonal Bharadwaj
Hi Constantine, Thanks for the quick reply. No luck with distinct. I tried that before (cases = cases.distinct() ), right after the order_by but it seems to have no effect, returning multiple duplicates. On Wednesday, August 17, 2016 at 9:59:19 PM UTC-7, Constantine Covtushenko wrote: > >

query values() calls don't use transforms as filter() does

2016-08-18 Thread Rishi Graham
I noticed that the jsonb field indexing in postgres which is so handy in filtering does not seem to extend to calls to values(). After digging around a bit, it seems that sql.query.get_transform() is only called when building a filter, but not when adding fields for a values call. Using

Re: How to have Multiple models in Admin View

2016-08-18 Thread ludovic coues
You should add a foreign key to language on translation. To save the language from the dropbox. Then I would create a ModelAdmin and set the form value. If I remember correctly, the save method is on the form and you could save new objet for each word at the same time as saving the translation

How to have Multiple models in Admin View

2016-08-18 Thread Hanh Kieu
I'm a little new to django. I would like to display multiple models in one admin view in django. when I do this: admin.site.register(Language) admin.site.register(Word) admin.site.register(Translation) b It would register 3 different models. My models look like this (this is for a dictionary

Re: Unable to get tests to work

2016-08-18 Thread Matt
Sorry replied to the wrong thread: https://dpaste.de/OF8j On Wednesday, August 17, 2016 at 11:16:27 PM UTC-6, Gergely Polonkai wrote: > > Hello, > > this “refreshes.backups.tests” thing bothers me a lot. Could you show us > your directory structure, please? > > Best, > Gergely > > On Wed, Aug

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
Yes, that's what I did. It worked for the form field. But, still, how pervasive is this behavior? (That was the question in the message you answered). On Thursday, August 18, 2016 at 2:18:00 PM UTC-5, Sergiy Khohlov wrote: > > Hello, > This is trivial mistake. Use form.__init__ if you would

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread Sergiy Khohlov
Hello, This is trivial mistake. Use form.__init__ if you would like to change it dynamically 18 серп. 2016 22:14 "bobhaugen" пише: > Also, how pervasive is this behavior? Does it affect all querysets > generated by model methods? I do that all over the place. This could be

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
Also, how pervasive is this behavior? Does it affect all querysets generated by model methods? I do that all over the place. This could be bug heaven! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
Looks like it works if I "specify queryset=None when declaring the form field and then populate the queryset in the form’s__init__() method:" Does that make sense to you? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
On Thursday, August 18, 2016 at 1:34:29 PM UTC-5, Tim Graham wrote: > > I'd guess you're doing a query for the form field's choices at the module > level which will be executed once and cached for as long as the server > runs. See if >

Re: Python dictionaries saved to models

2016-08-18 Thread Tim Graham
`apps` should be the first argument to the RunPython function. Using the import you mentioned is incorrect and may cause bugs if your models change in the future. On Thursday, August 18, 2016 at 10:10:43 AM UTC-4, Aaron Weisberg wrote: > > Nevermind- the good folks at Django didn't add: > >

Re: Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread Tim Graham
I'd guess you're doing a query for the form field's choices at the module level which will be executed once and cached for as long as the server runs. See if https://docs.djangoproject.com/en/stable/ref/forms/fields/#fields-which-handle-relationships helps, otherwise please post the code for

Re: Using hashids in django template

2016-08-18 Thread Paul Aswa
Thanks for the shedding light on filters, really helpful. I should have thought about that! On Thursday, August 18, 2016 at 8:46:22 PM UTC+3, ludovic coues wrote: > > Filter are a way to apply a function to a value in a django template. > > The filter would look like that: > > def

Re: Using hashids in django template

2016-08-18 Thread ludovic coues
Filter are a way to apply a function to a value in a django template. The filter would look like that: def hashid(value): return hashids.encode(value) and your template like that: {{ id|hashid }} I omitted some part that are in the doc, like making the filter available in your

Re: Using hashids in django template

2016-08-18 Thread Paul Aswa
Being a newbie to python and django, this seems to be giving me problems On Thursday, August 18, 2016 at 2:57:56 PM UTC+3, ludovic coues wrote: > > You might be looking for this > https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/ > > 2016-08-18 12:57 GMT+02:00 Paul Aswa

Odd problem: some database updates do not appear on other pages until server restart

2016-08-18 Thread bobhaugen
I'm running django 1.8.14, I have an odd problem, that I have reproduced both locally using runserver and sqlite, and also using Apache with Postgres. I create a new model instance on one page, and go to another page where that same object should appear in a form selection list. It does not.

Re: Unable to get tests to work

2016-08-18 Thread Matt
Here you go: https://dpaste.de/OF8j On Wednesday, August 17, 2016 at 11:16:27 PM UTC-6, Gergely Polonkai wrote: > > Hello, > > this “refreshes.backups.tests” thing bothers me a lot. Could you show us > your directory structure, please? > > Best, > Gergely > > On Wed, Aug 17, 2016, 23:03 Matt

Re: Implementing django auth system with relational models

2016-08-18 Thread Shamaila Moazzam
ok thanx @ ludovic coues... i will try this and then tell you regards On Thursday, August 18, 2016 at 2:38:46 AM UTC+5, ludovic coues wrote: > > Ok, sorry, I made a off by one error on the link :) > > Try that: > > # shops/admin.py > from django.contrib import admin > from products.models

Re: Python dictionaries saved to models

2016-08-18 Thread Aaron Weisberg
Nevermind- the good folks at Django didn't add: from django.apps import apps in order to pull off this data migration On Thursday, August 18, 2016 at 8:40:26 AM UTC-5, Aaron Weisberg wrote: > > Thanks. > > However, when I write the function and try to run the data migration I run > into this

Re: Python dictionaries saved to models

2016-08-18 Thread Aaron Weisberg
Thanks. However, when I write the function and try to run the data migration I run into this error: Enter code here...NameError: name apps is not defined That is coming from this line in the migration: Players = apps.get_model("team","Players") This is a copy/paste from the documentation.

Re: New to Django

2016-08-18 Thread Derek
In your view you have: context = { "server_list": serverlist, "image_list": imagelist, "child_list": childimagelist } So the variables being passed through to your template are named: server_list, image_list, child_list. In your template you call this:

Re: Models of Speedy Net

2016-08-18 Thread Uri Even-Chen
Thank you Asad and Avraham! *Uri Even-Chen* [image: photo] Phone: +972-54-3995700 Email: u...@speedy.net Website: http://www.speedysoftware.com/uri/en/

Re: Python dictionaries saved to models

2016-08-18 Thread Tim Graham
Right, or even in a standalone script if a migration is more than you need: https://docs.djangoproject.com/en/stable/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage On Thursday, August 18, 2016 at 2:14:39 AM UTC-4, Todor Velichkov wrote: > > Maybe a data migration

Re: MIDDLEWARE vs MIDDLEWARE_CLASSES: 'WSGIRequest' object has no attribute 'user'

2016-08-18 Thread Tim Graham
Are you running Django 1.10? It looks like your MIDDLEWARE setting is ignored which suggests you might be using an older version. On Wednesday, August 17, 2016 at 6:43:14 PM UTC-4, Andrew Emory wrote: > > My settings.py file has the default MIDDLEWARE settings generated by > django-admin

Re: Models of Speedy Net

2016-08-18 Thread Avraham Serour
It doesn't matter, you should decide on something and stick to it, consistency is more important than some suggestion you read somewhere. What your suggested seems fair, write on your documentation that you decided this and ask politely for contributions to follow this style On Aug 18, 2016 3:08

Re: Models of Speedy Net

2016-08-18 Thread Asad Jibran Ahmed
Sorry, I just checked and I'm wrong about the ordering of elements in a class. The reason the constants need to be first is because you are using them when defining your fields. But other than that, the order doesn't matter. Here's the code that I used to check this: def get_const():

Re: Models of Speedy Net

2016-08-18 Thread Asad Jibran Ahmed
The ordering of your attributes and methods inside the model class doesn't have to do with Django, it has to do with Python. Inside a class, the ordering doesn't matter as far as I understand. All of these documents you will find are thus just conventions to follow. You could come up with your

Re: Models of Speedy Net

2016-08-18 Thread Uri Even-Chen
By the way, I found this document and I changed the order of elements in our models accordingly. But what about def __init__? And this document is for Django developers, what about Django users? Is there

Re: django on apache server

2016-08-18 Thread Asad Jibran Ahmed
Not being able to load CSS points to an Apache config issue. Did you setup apache so your static root configured to serve files from your static folder? Your apache config might be helpful here. Also, what you have pasted here seems like a warning, so while you should fix it, this is probably

Re: manage or manage.py

2016-08-18 Thread ludovic coues
Who did you created this ? Have you run `django-admin startproject mysite` ? 2016-08-18 10:41 GMT+02:00 Ziggo mail : > Hi There > > I’m busy with starting with django. > > My first mysite shows me this: > > mysite/ > > manage > > mysite/ > > __pycache__ > >

Re: Using hashids in django template

2016-08-18 Thread ludovic coues
You might be looking for this https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/ 2016-08-18 12:57 GMT+02:00 Paul Aswa : > Is there means of encoding an id using hashids in django templates? > > -- > You received this message because you are subscribed to the

Re: Implementing django auth system with relational models

2016-08-18 Thread ludovic coues
No idea. I've never looked into model managers. Maybe they can help in non-repeating code, maybe they won't work due to the lack of access to the currently logged user. 2016-08-18 12:55 GMT+02:00 M Hashmi : > Ludovic, > > Shouldn't she be using model managers for this? > >

Using hashids in django template

2016-08-18 Thread Paul Aswa
Is there means of encoding an id using hashids in django templates? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an

manage or manage.py

2016-08-18 Thread Ziggo mail
Hi There I'm busy with starting with django. My first mysite shows me this: mysite/ manage mysite/ __pycache__ __init__ __init__.py-tpl Settings Settings.py-tpl Urls Urls.py-tpl Wsgi Wsqi.py-tpl

django on apache server

2016-08-18 Thread hirok biswas
while i have configuring django app on apchhe basically it works almost well but shows this error log and css not work what can i do now??? i am using #apache2 #django 1.9.6 ` [Wed Aug 17 14:54:12.747345 2016] [wsgi:error] [pid 17910:tid 139970848413440]

Models of Speedy Net

2016-08-18 Thread Uri Even-Chen
To django-users, We are developing Speedy Net, a new social networks with apps (Speedy Match and Speedy Composer). Speedy Net is using Django (the previous version is written in PHP). I would like to ask you about the models, in

Re: Implementing django auth system with relational models

2016-08-18 Thread M Hashmi
Ludovic, Shouldn't she be using model managers for this? Just curious. Regards, Mudassar On Wed, Aug 17, 2016 at 2:37 PM, ludovic coues wrote: > Ok, sorry, I made a off by one error on the link :) > > Try that: > > # shops/admin.py > from django.contrib import admin >

Re: connecting to mssql database

2016-08-18 Thread sum abiut
got it fixed, it was the version issue. i down grade from django 1.10 to 1.9.9 and it fixed. cheers On Thu, Aug 18, 2016 at 9:18 AM, sum abiut wrote: > now i have made changes to settings file > > DATABASES = { > 'default': { > 'ENGINE': 'django_pyodbc', >

Re: Django query not returning all objects

2016-08-18 Thread Todor Velichkov
Another solution would be to annotate min/max deadline date and order by the annotation. Something like: cases = HeartFlowCase.objects.all().annotate(min_deadline=Min( 'data__deadline')).order_by('min_deadline') On Thursday, August 18, 2016 at 7:59:19 AM UTC+3, Constantine Covtushenko wrote:

Re: Python dictionaries saved to models

2016-08-18 Thread Todor Velichkov
Maybe a data migration is what you are looking for. On Thursday, August 18, 2016 at 8:38:33 AM UTC+3, Aaron Weisberg wrote: > > Great- thanks Tim. > > I understand the Python, but what I guess where I'm fuzzy is where to