Customizing field widgets and classes from model.Field (aka fields, fields and widgets)

2022-12-01 Thread Bernd Wechner
Generic views are awesome. Simply specifying a model, sees a lovely default form provided to templates built by the modeform_factory. This beautifully obviates any need to construct a Form or deal with one. All done implicitly There is some modest confusion easily in Django if model fields

Serializing forms and formsets to pass to Celery task

2020-02-28 Thread Bernd Wechner
I'm using Celery quite effectively with Django as many are. It's just awesome for running time consuming background tasks, and providing progress bar updates to a web page. Love it. Now I would like a celery task to do some form processing. That is in a Django view, where I have access to the

Re: Providing help on a website (basic CMS for on-site site documentation)

2019-03-06 Thread Bernd Wechner
ot;middle ground" where > you need both a pile of flat pages and a pile of dynamic pages a chance > for creativity on your part! > > On Monday, 4 March 2019 12:08:36 UTC+2, Bernd Wechner wrote: >> >> Derek, >> >> Empirically by evidence of the lack of

Re: Providing help on a website (basic CMS for on-site site documentation)

2019-03-04 Thread Bernd Wechner
gt; > On Friday, 22 February 2019 12:02:27 UTC+2, ukeplayer01 wrote: >> >> Sorry to go off topic but I can recommend HuGo for simple markdown web >> pages. >> Cheers >> Roger >> On 22/2/19 5:24 pm, Bernd Wechner wrote: >> >> Hmmm, no-one has an

Re: Using Django Window Functions on a Filtered QuerySet

2019-02-26 Thread Bernd Wechner
Stunning silence on this all round ... Hmmm On Tuesday, 29 January 2019 11:01:56 UTC+11, Bernd Wechner wrote: > > I have a filtered queryset, and annotated it with a few window functions. > I got a most surprising result when the filter is on fields in a related > model and

Re: Providing help on a website (basic CMS for on-site site documentation)

2019-02-22 Thread Bernd Wechner
> On Tuesday, 19 February 2019 16:26:57 UTC+11, Bernd Wechner wrote: >> >> I'm at the point of wanting to write some help for a website, the >> standard helpfile sort of scenario ;-). If that means little to you, just a >> hierarchy of pages that document things and c

Re: Providing help on a website (basic CMS for on-site site documentation)

2019-02-21 Thread Bernd Wechner
Hmmm, no-one has any thoughts here ... and I'm on ma' own reinventing the wheel? Surely tehre's a canonical way to provide help on Django website . I'm leaning toward simple flatpages app with a tinymce editor for them for the admin. On Tuesday, 19 February 2019 16:26:57 UTC+11, Bernd Wechner

Providing help on a website (basic CMS for on-site site documentation)

2019-02-18 Thread Bernd Wechner
I'm at the point of wanting to write some help for a website, the standard helpfile sort of scenario ;-). If that means little to you, just a hierarchy of pages that document things and can be linked. I wrote page one with the Django flatpages app:

Using Django Window Functions on a Filtered QuerySet

2019-01-28 Thread Bernd Wechner
I have a filtered queryset, and annotated it with a few window functions. I got a most surprising result when the filter is on fields in a related model and it turns out this lies in the structure of the SQL. I asked the question here:

Re: Generating server-side off-line HTML of Django pages ...

2018-06-12 Thread Bernd Wechner
On Monday, 4 June 2018 16:00:09 UTC+10, Bernd Wechner wrote: > > Say I have a page on my Django website (because I do) that I would like to > take a snapshot of on an automated basis on the server itself with a > crontab say. I imagine writing a small python script that

Re: Generating server-side off-line HTML of Django pages ...

2018-06-04 Thread Bernd Wechner
Thanks Melvyn, looks exactly like what I wanted! Will investigate. I had a feeling this could not be a novel or unique use case. Regards, Bernd. On Monday, 4 June 2018 20:09:25 UTC+10, Melvyn Sopacua wrote: > > On maandag 4 juni 2018 08:00:08 CEST Bernd Wechner wrote: > > > Sa

Generating server-side off-line HTML of Django pages ...

2018-06-04 Thread Bernd Wechner
Say I have a page on my Django website (because I do) that I would like to take a snapshot of on an automated basis on the server itself with a crontab say. I imagine writing a small python script that I could run, that loads Django, a settings file, knows a URL and has a way of saying "give me

Re: Is it possible to instantiate a model (create an object) and flag the instance as unsaveable?

2018-06-03 Thread Bernd Wechner
Thanks James, I like that idea. I'll experiment with it. Have used Proxies before just not with this in mind. On Sunday, 3 June 2018 15:06:41 UTC+10, James Schneider wrote: > > > > On Sat, Jun 2, 2018, 6:14 PM Bernd Wechner > wrote: > >> I'd like to instantiate

Is it possible to instantiate a model (create an object) and flag the instance as unsaveable?

2018-06-02 Thread Bernd Wechner
I'd like to instantiate a model, and play around with it, but ensure it's never saved. At bare minimum instantiate it, play around with it then delete it, but ideally disable saving somehow. I imagine I can override save() on the instance, but am wondering if anyone has experience doing this

Re: dumpdata fails with crytpic error

2018-06-01 Thread Bernd Wechner
All sorted, thanks for the tips. Bernd Wechner wrote: Just tried this: | $ python3 manage.py dumpdata --format json --indent 4>data.json CommandError:Unableto serialize database:'NoneType'objecthas noattribute 'is_authenticated' | Anyone seen this before. How does one diagnose this gi

dumpdata fails with crytpic error

2018-05-31 Thread Bernd Wechner
Just tried this: $ python3 manage.py dumpdata --format json --indent 4 > data.json CommandError: Unable to serialize database: 'NoneType' object has no attribute 'is_authenticated' Anyone seen this before. How does one diagnose this given the vague nature of the message? I mean I presume it's

Re: Adding to all templates context via Middleware

2018-05-07 Thread Bernd Wechner
efore tag as a safe and clean bet. The result is here: https://github.com/bernd-wechner/CoGs/blob/develop/django_stats_middleware/__init__.py Works well for me and is a good hook for inserting any kind of stats really that can be collected in the middleware layer. Regards, Bernd. On Thurs

Adding to all templates context via Middleware

2018-05-02 Thread Bernd Wechner
This interests me: https://teamtreehouse.com/community/django-how-can-i-retrieve-a-value-from-the-middleware alas no answer there, and time has changed things. I have checked form experience, that stuff added to response.context_data in middleware is not seen in templates (perhaps comes

Adding to all templates context via Middleware

2018-05-01 Thread Bernd Wechner
This interests me: https://teamtreehouse.com/community/django-how-can-i-retrieve-a-value-from-the-middleware alas no answer there, and time has changed things. I have checked form experience, that stuff added to response.context_data in middleware is not seen in templates (perhaps comes too

Re: Finding a decent ordering widget ...

2018-03-22 Thread Bernd Wechner
ough, 'cause you could provide functionality to > reorder using plain JS, just reordering divs around moving the DOM around. > > On Wed, Mar 21, 2018 at 6:54 AM, Bernd Wechner <bernd@gmail.com > > wrote: > >> Hmmm, my next problem. >> >> I envisage a widget whi

Re: Finding a decent ordering widget ...

2018-03-21 Thread Bernd Wechner
onders if there isn't or shouldn't be, or if I should try and start, a Django widget library with Django Widgets like this for reuse. Just musing. Regards, Bernd. On Wednesday, 21 March 2018 20:54:35 UTC+11, Bernd Wechner wrote: > > Hmmm, my next problem. > > I envisage a w

Finding a decent ordering widget ...

2018-03-21 Thread Bernd Wechner
Hmmm, my next problem. I envisage a widget which is kind of like a HTML textarea, but basically each line would hold the name of a field say, and I'd like a user to be able to order the lines, not change the text. Basically click anbd drag lines up and down to reposition them. I've poked

Re: Given a model, how can I get a widget for each field?

2018-03-21 Thread Bernd Wechner
Actually I stand corrected, no need to build a format all. *django.forms.fields_for_model* provides just the fields for model and their widgets. Awesome. Neat and tidy. On Wednesday, 21 March 2018 13:08:31 UTC+11, Bernd Wechner wrote: > > Andréas and Andreas, > > I admit I smiled to

Re: Given a model, how can I get a widget for each field?

2018-03-20 Thread Bernd Wechner
Andréas and Andreas, I admit I smiled to see Andréas seconding Andreas' post ;-). One my best friends in primary school was an Andreas ;-). Given I have no form and don't want one, ModelForm in its declarative for seems undesirable. But your thinking is good and I realise in response and in

Given a model, how can I get a widget for each field?

2018-03-20 Thread Bernd Wechner
Pulling my hair out again. I don't have a form, nor want a form, stunning really, but I just have the model. And I want the field widgets. I can't seem to find them anywhere. I know you can specify widget= on form fields when declaring the model, but can't find it anywhere in the data

Re: Phone Number Validation

2018-03-15 Thread Bernd Wechner
Not really a Django question, just basic Python. For starters strip() will remove only leading and trailing chars in the set, not embedded chars. Curiously though, with all due respect, this: if dataless.isdigit() != True: has beginner written all over it. What's wrong with: if not

Re: tutorial 2.0 - 1: problem

2018-03-15 Thread Bernd Wechner
Looks to me like runserver is telling you more or less what's up. What it's not telling you is what you've not told us, namely teh URL you're navigating to. But the tutorial suggests " http://localhost:8000/polls/; and if you are using that, and you have set up

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-03-15 Thread Bernd Wechner
; > > > *From:* django...@googlegroups.com [mailto: > django...@googlegroups.com ] *On Behalf Of *Bernd Wechner > *Sent:* Thursday, March 15, 2018 1:57 AM > *To:* Django users > *Subject:* Re: Fetching next and/or prior objects given an arbitrary > ordering > > > >

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-03-15 Thread Bernd Wechner
return (ao[0].neighbour_prior,ao[0].neighbour_next) else: raise None On Wednesday, 14 March 2018 06:28:55 UTC+11, Bernd Wechner wrote: > > Hmmm, really stuck on this. Can find no way of selecting from a select in > the ORM. The whole premise seems be to start from

Re: How to add an OR criterion to an existing QuerySet?

2018-03-15 Thread Bernd Wechner
to OR an existing querysets filters by using the "|" operator between querysets of the same model. That would be the following: qs |= Model.objects.filter(Q(...)) Simon Le mercredi 14 mars 2018 23:45:41 UTC-4, Bernd Wechner a écrit : Another interesting problem. Let's say I have a Quer

Re: Email = models.EmailField()

2018-03-14 Thread Bernd Wechner
Khaled, You need to learn how to read the documentation I suspect. Start here for the standard field options: https://docs.djangoproject.com/en/2.0/ref/models/fields/#field-options Then for EmailField specific options:

How to add an OR criterion to an existing QuerySet?

2018-03-14 Thread Bernd Wechner
Another interesting problem. Let's say I have a QuerySet which already applies some filters. It's provided by a third party library mind you, and all you have is the QuerySet instance. Now I would like to loosen the filter a bit, ad an ORed filter. Not a trivial thing it seems. Q objects

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-03-13 Thread Bernd Wechner
nds up on the select in in my_querset. we want to wrap the whole of my_queryset with select * from my_queryset where pk=pk But how? Can anyone think of a way to do that? Regards, Bernd. On Monday, 12 March 2018 23:43:33 UTC+11, Bernd Wechner wrote: > > OK Trying to implement this now and has SQL tha

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-03-12 Thread Bernd Wechner
OK Trying to implement this now and has SQL that works but can't work how to use the Django ORM to produce it. Here is the proforma SQL: SELECT * FROM ( SELECT id, LAG(id, 1) OVER (ORDER BY ) AS prior, LEAD(id 1) OVER (ORDER BY ) AS next FROM ) result WHERE id=; There's

Re: Customizing mode loading ...

2018-03-09 Thread Bernd Wechner
use this to enforce privacy on certain fields, marke them appropriately and overrride save() to similarly not save private fields. And it all works like a charm! On Monday, 5 March 2018 14:53:15 UTC+11, Bernd Wechner wrote: > > Found this lovely doc: > > > https://docs.djangoproject

Re: Making an object unsaveable ...

2018-03-07 Thread Bernd Wechner
> No matter how much you do to your model class in Python, someone who's > sufficiently determined will always be able to find a way to save it. Only > by cutting off the ability to run INSERT/UPDATE queries at the > database-permission level can you completely stop this. > > >

Re: Making an object unsaveable ...

2018-03-07 Thread Bernd Wechner
10:41:52 CET Bernd Wechner wrote: > > > Here is the use case: > > > > 1. Load an object from database > > 2. Flag it as unsaveable, not to be written back to database under any > > circumstances > > 3. Make changes to the object (its fields) >

Re: Django 1,11 upgrade, render template with context in template.Node

2018-03-04 Thread Bernd Wechner
Can't say I'm experienced with template.Node, but you piqued my curiosity so I found this: https://stackoverflow.com/questions/14434624/how-to-get-dictionary-of-requestcontext-imported-from-django-template which may help, but am left wondering why upgrade to 1.11 when 2.0 is out already and

Customizing mode loading ...

2018-03-04 Thread Bernd Wechner
Found this lovely doc: https://docs.djangoproject.com/en/2.0/ref/models/instances/#customizing-model-loading But it leaves me with a thirst for more knowledge. My conclusion form reading it is, that if I wanted to put a hook into some custom code that always ran after data was loaded from the

Re: Making an object unsaveable ...

2018-03-04 Thread Bernd Wechner
circumvented. > > On 4 March 2018 at 09:41, Bernd Wechner <bernd@gmail.com > > wrote: > >> An interesting question I've not been able to solve reading docs or >> Googling. As every posting here only after some serious research efforts >> including class

Making an object unsaveable ...

2018-03-04 Thread Bernd Wechner
An interesting question I've not been able to solve reading docs or Googling. As every posting here only after some serious research efforts including class inspections ;-). But am stumped and wonder if anyone else has any ideas. Here is the use case: 1. Load an object from database 2. Flag

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-03-01 Thread Bernd Wechner
to get back to the ORM that would create that. Can you provide an sql  statement that does what you want for us to help you think about it? On Wednesday, February 28, 2018 at 6:50:56 PM UTC-5, Bernd Wechner wrote: Julio, Thanks for giving it some though. But I think you misread me

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-03-01 Thread Bernd Wechner
t back to the ORM that would create that. Can you provide an sql  statement that does what you want for us to help you think about it? On Wednesday, February 28, 2018 at 6:50:56 PM UTC-5, Bernd Wechner wrote: Julio, Thanks for giving it some though. But I think you misread me a little

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-02-28 Thread Bernd Wechner
d be arbitrarily large (millions, or more) which is true for a generic scenario which makes no assumptions about the model other than what is provided by its ordering and known about the current object. Regards, Bernd. Mike Dewhirst wrote: On 1/03/2018 10:50 AM, Bernd Wechner wrote: >

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-02-28 Thread Bernd Wechner
ext, you can do `list_of_previous = > Things.objects.filter(pk__lt=...).limit(1)` and `list_of_next = > Things.objects.filter(pk__gt).limit(1)`. > > Or something like that ;P > > On Wed, Feb 28, 2018 at 8:56 AM, Bernd Wechner <bernd@gmail.com > > wrote: > >>

Re: Fetching next and/or prior objects given an arbitrary ordering

2018-02-28 Thread Bernd Wechner
= > Things.objects.filter(pk__lt=...).limit(1)` and `list_of_next = > Things.objects.filter(pk__gt).limit(1)`. > > Or something like that ;P > > On Wed, Feb 28, 2018 at 8:56 AM, Bernd Wechner <bernd@gmail.com > > wrote: > >> I'm a bit stumped on this. Giv

Fetching next and/or prior objects given an arbitrary ordering

2018-02-28 Thread Bernd Wechner
I'm a bit stumped on this. Given an arbitrary ordering as specified by the ordering meta option: https://docs.djangoproject.com/en/2.0/ref/models/options/#ordering for example: class Thing(models.Model):     field1 = ...     field2 = ...     field2 = ...     class Meta:

Re: How to define a url that does not belong to any app?

2017-11-25 Thread Bernd Wechner
I'm curious too ;-). I suspect you can do pretty much anything at the project level that you can do at the app level but am not a pro in that space by any measure. This might be a useful read: https://stackoverflow.com/questions/4879036/django-projects-vs-apps Regards, Bernd. Kubilay

Wrapping basic static HTML page in sites base template. How to?

2017-10-16 Thread Bernd Wechner
Curious and I admit lazy question as I don't even know where to look or how for such a general idea. But there it is, I'd like to be able to write a static HTML file (like say about.html) and render that inside of the sites style and basic template. So I have base.html for example, which

Re: More bizarre URL behaviour after deploying

2017-09-13 Thread Bernd Wechner
Antonis, Well truth be told I'm with uwsgi only because of the snowball effect you're alluding to, namely we have so many options I'm like looking on-line for what the most popular and recommended one is, and uwsgi has a huge fan base.  As to server, I opted for lighttpd only because I

Re: More bizarre URL behaviour after deploying

2017-09-13 Thread Bernd Wechner
lighttpd doesn't do to Django's satisfaction and so it needs tweaking and I have both a uwsgi application tweak and a middleware tweak for the job now). Regards, Bernd. Bernd Wechner wrote: OK, I've more or less solved my original problems in deploying in this space. Well I've deployed and am

Re: Django select filter

2017-09-12 Thread Bernd Wechner
Here are a pile of options: https://djangopackages.org/grids/g/auto-complete/ and the winner it seems is: https://djangopackages.org/packages/p/django-autocomplete-light/ Cheers, Bernd. -- You received this message because you are subscribed to the Google Groups "Django users" group. To

More bizarre URL behaviour after deploying

2017-09-12 Thread Bernd Wechner
OK, I've more or less solved my original problems in deploying in this space. Well I've deployed and am happy. BUT, I am still bamboozled by something and wonder if anyone has any clue or insights to share? I have these two urlpatterns defined:     url(r'^list/(?P\w+)',

Re: How to pre-load model data?

2017-09-08 Thread Bernd Wechner
Mark, It depends a bit on where you're getting your data from. One of the safest ways would to build a fixture, and use "manage.py loaddata". The fixture can be in json, xml or yaml formats. If it's in some other format, then there are other ways of course too. There are always a few

Re: Bizarre URL behaviour after deploying

2017-09-07 Thread Bernd Wechner
James, you da man! Fixed it at last. The problem in the end was indeed lighttpd and is explained here: https://searchcode.com/codesearch/view/12783344/ Essentially lighttpd splits REQUEST_URI into SCRIPT_NAME and PATH_INFO and passes those three along with a host of other values in the

Re: How to display ipconfig /all in template html django

2017-09-07 Thread Bernd Wechner
. . . . . . . . . . . : X.X.X.XSubnet Mask . . . . . . . . . . . : 255.255.255.255Default Gateway . . . . . . . . . : 0.0.0.0 Do you have idea? On Thursday, September 7, 2017 at 12:44:17 PM UTC+4:30, Bernd Wechner wrote: Ramin, I'm sorry but your question is not very clear. How about you capture

Re: How to display ipconfig /all in template html django

2017-09-07 Thread Bernd Wechner
Ramin, I'm sorry but your question is not very clear. How about you capture the output of "ipconfig /all" with something like: IPconfig = subprocess.check_output(["ipconfig", "/all"], stderr=devnull) then add Config to your template context in a view something like: def

Re: Bizarre URL behaviour after deploying

2017-08-31 Thread Bernd Wechner
sers wrote: On Thu, Aug 31, 2017 at 2:09 AM, Bernd Wechner <bernd.wech...@gmail.com> wrote: > Daniel, > > Yes, I have deployed, that is the problem in a sense. URLs are clean in dev > and suddenly contain an app_name when deployed. > > Not sure what you mean by configura

Re: Bizarre URL behaviour after deploying

2017-08-31 Thread Bernd Wechner
im for now. Regards, Bernd. Daniel Roseman wrote: On Thursday, 31 August 2017 10:51:22 UTC+1, Tom Evans wrote: On Thu, Aug 31, 2017 at 2:09 AM, Bernd Wechner <bernd@gmail.com > wrote: > Daniel, > > Yes, I have deployed, that is the problem in a sense.

Re: Bizarre URL behaviour after deploying

2017-08-31 Thread Bernd Wechner
y to debug (uwsgi is loading and running django). Regards, Bernd. 'Tom Evans' via Django users wrote: On Thu, Aug 31, 2017 at 2:09 AM, Bernd Wechner <bernd.wech...@gmail.com> wrote: > Daniel, > > Yes, I have deployed, that is the problem in a sense. URLs are clean in dev >

Re: Bizarre URL behaviour after deploying

2017-08-30 Thread Bernd Wechner
rnd-wechner/CoGs <https://github.com/bernd-wechner/CoGs/blob/master/CoGs/urls.py> and I want to lose app name form my URLs (and ideally understand why they are there to begin with) not add them! Kind regards, Bernd mohammad k wrote: you have Different app in your project yes ? you ha

Re: Bizarre URL behaviour after deploying

2017-08-30 Thread Bernd Wechner
Daniel, Yes, I have deployed, that is the problem in a sense. URLs are clean in dev and suddenly contain an app_name when deployed. Not sure what you mean by configuration? The Django settings are here: https://github.com/bernd-wechner/CoGs/blob/master/CoGs/settings.py The rest

Bizarre URL behaviour after deploying

2017-08-30 Thread Bernd Wechner
is shared there seems to apply. For anyone really keen on code explorations urls.py is here: https://github.com/bernd-wechner/CoGs/blob/master/CoGs/urls.py and the whole site is there too. What I want to understand is why this "app" suddenly appears in my URLs and how I can control i

Re: How to Minify, obfuscate, and compress django code

2017-08-09 Thread Bernd Wechner
I'm a little confused as to what this has to do with Django, which runs server side. The code it emits to the client is limited to what you put in your templates, including perhaps the widgets that django provides for forms. I use a lot of javascript in my forms, and it's my responsibility to

Re: Vim plugin that does Django code completion?

2017-07-09 Thread Bernd Wechner
For what it's worth I use PyDev which is free. And am very happy with it. Though I donate money now and again because it is so good and free. On 9/07/2017 10:33 PM, Gabriel - Iulian Dumbrava wrote: I also suggest buying a PyCharm license. If you are working on a professional level and you

Re: request.GET as an OrderedDict

2017-06-08 Thread Bernd Wechner
ernd. Melvyn Sopacua wrote: On Thursday 08 June 2017 17:11:36 Bernd Wechner wrote: > Am curious if there's an easy way to walk through request.GET in the > order they appeared on the URL? It strikes me the dictionary has lost > this ordering information, and I wonder if it's available anywh

Re: Adding a attribute to a model property

2017-06-08 Thread Bernd Wechner
rnd. Melvyn Sopacua wrote: On Thursday 08 June 2017 16:18:42 Bernd Wechner wrote: > This works charmingly. Though I admit I don't fully understand it. The > type "property" passed to isinstance seems to be a built in type as I > don't import it anywhere and I can't find a defini

request.GET as an OrderedDict

2017-06-08 Thread Bernd Wechner
Am curious if there's an easy way to walk through request.GET in the order they appeared on the URL? It strikes me the dictionary has lost this ordering information, and I wonder if it's available anywhere or how one might extend Django to supply an OrderedDict when requested? Kind regards,

Adding a attribute to a model property

2017-06-08 Thread Bernd Wechner
I'm a tad stuck getting my head around decorating a decorator and how to do this well. But here is a proforma model: class Thing(models.Model): my_field = models.CharField('My Field') @property def my_property(self) do stuff ... return

Re: Extending the user model and accessing fields in template context

2017-06-07 Thread Bernd Wechner
wrote: On Thursday 08 June 2017 08:46:38 Bernd Wechner wrote: > Have failed to find an easy answer to this so will lazily ask the > broader community before I retire tonight ;-). > > I have a model that I use to extend the User model like yo: > > from django.contrib.auth.

Extending the user model and accessing fields in template context

2017-06-07 Thread Bernd Wechner
Have failed to find an easy answer to this so will lazily ask the broader community before I retire tonight ;-). I have a model that I use to extend the User model like yo: from django.contrib.auth.models import User class Dude(models.Model): nickname =

Re: template drop down menu

2017-06-06 Thread Bernd Wechner
If you want a sample for a javascript postback when drop down changes I have one here: https://github.com/bernd-wechner/CoGs/blob/master/Leaderboards/templates/CoGs/view_leaderboards.html It's attached to the select "selNames" which you can trace to the Django view "aj

Re: Django bugfix release: 1.11.2

2017-06-01 Thread Bernd Wechner
Any tips on how to install it? Forgive the ignorance please. Tim Graham wrote: Details are available on the Django project weblog: https://www.djangoproject.com/weblog/2017/jun/01/bugfix-release/ -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Where is all the time going?

2017-05-23 Thread Bernd Wechner
it ;-), if Django is going it, at least one step closer to understanding. Regards, Bernd James Schneider wrote: On Mon, May 22, 2017 at 10:12 PM, Bernd Wechner <bernd.wech...@gmail.com <mailto:bernd.wech...@gmail.com>> wrote: James, If you have the fortitude and kind h

Re: Where is all the time going?

2017-05-23 Thread Bernd Wechner
and seeing if it improves In mean time any other ideas welcome. Regards, Bernd. Thomas Lockhart wrote: On 5/22/17 10:12 PM, Bernd Wechner wrote: James, If you have the fortitude and kind heart to look at it, sure the code base (just checked in) is here: https://github.com/bernd-wechner

Re: Where is all the time going?

2017-05-22 Thread Bernd Wechner
James, If you have the fortitude and kind heart to look at it, sure the code base (just checked in) is here: https://github.com/bernd-wechner/CoGs it's the Create view on the Session model that is taking 30s to render, no other model, and that one is the central model of interest

Re: Aggregating a query while selecting more than grouped by ...

2017-05-14 Thread Bernd Wechner
t 4:16:19 PM UTC+3, Bernd Wechner wrote: Why thank you very kindly Todor for these insights! And some interesting reading! It surprises me, I admit (with no intention of being judgmental) that there isn't a simpler way, perhaps like: LatestAuthors = Author.ob

Re: Aggregating a query while selecting more than grouped by ...

2017-05-14 Thread Bernd Wechner
; > But be careful with this approach, because if you have more than one > maximum from a group, you get all in of them in return. > > PS. I've just recently just found out the 2nd approach, its not very clear > from the docs that it possible, maybe we can/need document it? T

Aggregating a query while selecting more than grouped by ...

2017-05-13 Thread Bernd Wechner
I'm bamboozled by Django aggregation: https://docs.djangoproject.com/en/1.11/topics/db/aggregation/ I'd like to add a little to the example they present to clarify my problem (keeping it in familiar territory with regards to the documentation): from django.db import models class

Re: Validating and cleaning related models ...

2017-02-01 Thread Bernd Wechner
Melvyn, Thanks. Alas That was but one example in an apocryphal model set, and I have rather more relationship criteria to test in a more complex nest of models. I'm still drilling down into Django to see what I can uncover. Notably form.instance for the main form and all the related formsets,

Re: Django and timezones ... how to initialize a field to now() in the in clients time zone?

2017-01-24 Thread Bernd Wechner
the one you are > using, or via a project like this: > https://github.com/Miserlou/django-easy-timezones. > > Regards, > > Andréas > > > 2017-01-21 10:40 GMT+01:00 Bernd Wechner <bernd@gmail.com > >: > >> I have a model with this field: >> &g

Validating and cleaning related models ...

2017-01-24 Thread Bernd Wechner
I find myself in a conundrum with related models and related formsets. I'll try and simplify a rather complex set of relations to illustrate the bare bones gist of my issue. Imagine the standard Djnago docs example: class Musician(models.Model): first_name = models.CharField(max_length=50)

Django and timezones ... how to initialize a field to now() in the in clients time zone?

2017-01-21 Thread Bernd Wechner
I have a model with this field: date_time = models.DateTimeField(default=timezone.now) if I look at the generic create form, it inializes the date_time field with now in UTC, not in local time. Now I appreciate there are two things at play here: 1. the desired UX is to see now in my time

Pretty printing filters

2017-01-20 Thread Bernd Wechner
I've implement a list view using the rather awesome Django URL filter package: https://pypi.python.org/pypi/django-url-filter/0.2.0 Basically it makes it easy to filter a list view just by putting Django filter terms in the URL (as GET params) Now I find myself wanting to report the filter

Re: A Backup Model in Django?

2017-01-19 Thread Bernd Wechner
and is what I'm now in process of implementing. Of course data entry is transactioned and the database will be backed up regularly, but they are separate issues. Regards, Bernd. On Sunday, 16 October 2016 17:40:15 UTC+11, Bernd Wechner wrote: > > A curious question I've had trouble f

A Backup Model in Django?

2016-10-16 Thread Bernd Wechner
A curious question I've had trouble finding an answer for alas. I have a model that I'd like to backup in the database in a backup model. This being the pro-forma so to speqk: from django.db import models class MyModel(models.Model): # Declare fields class MyModel_backup(MyModel): def

Re: Generic forms (ModelForm) provide HTML for a form! Can generic views (DetailView) do same?

2015-08-12 Thread Bernd Wechner
is they give us this quick easy view from which we can start tweaking and thinking how to make it what we want, by styling and/or templating. On Wednesday, 12 August 2015 22:36:09 UTC+10, Mike Dewhirst wrote: > > On 12/08/2015 8:54 PM, Bernd Wechner wrote: > > OK, I give up, seriou

Re: Generic forms (ModelForm) provide HTML for a form! Can generic views (DetailView) do same?

2015-08-12 Thread Bernd Wechner
OK, I give up, seriously dismayed that Django doesn't have this built in already I did as I threatened to and derived a class as follows: from django.utils import six from django.utils.safestring import mark_safe from django.utils.html import conditional_escape from django.utils.encoding import

Generic forms (ModelForm) provide HTML for a form! Can generic views (DetailView) do same?

2015-08-10 Thread Bernd Wechner
This has bamboozled me for a while. I Have a wonderful little test app I'm playing with which lists objects (ListView) and next to each object puts an edit and view link. Sort of like: - [view] [edit] Object 1 - [view] [edit] Object 2 - [view] [edit] Object 3 The ListView works like a

How to prevent label wrap in Django Administration

2015-04-19 Thread Bernd Wechner
I'm just playing around with Django and have cut a simple model and all is working fine. The Django administration tool works a charm, and I can move onto some views and forms. But what puzzles me immensely is why editing a tuple looks like this (with crazy label wrap). Can I fix this any