Re: Best practice for server-generated downloads?

2013-10-02 Thread Timothy W. Cook
I tried to return a generated file but it seems that the Admin interface (or middleware?) is capturing my response. I get a brief blank page and then the Admin interface again without eve getting the download prompt. My last attempt looked like this: fname = 'ccd-'+self.ct_id+'.xsd' respo

Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Timothy W. Cook
In the ModelAdmin I use a get_form() to test for conditions on the object. Specifically, if this item has been published then make it read_only. You should be able to test for users as well. I had to add the try/except in order to add new objects because obj.published doesn't exist on a new objec

Re: readonly_fields depending on request

2013-10-10 Thread Timothy W. Cook
Can you post the code you tried with get_form()? It should be the solution. On Thu, Oct 10, 2013 at 9:45 AM, Roberto López López wrote: > Hi, > > In my project I make use of django-admin. I need to have different > readonly_fields depending on the user is connected, thus administrators > will

Re: readonly_fields depending on request

2013-10-10 Thread Timothy W. Cook
On Thu, Oct 10, 2013 at 10:04 AM, Roberto López López wrote: > This is, for example, my code overriding get_readonly_fields(): > > def get_readonly_fields(self, request, obj=None): > readonly = super(NewsAdmin, self).get_readonly_fields(request, obj) > if request.user.groups.fi

Re: admin template customization

2013-10-18 Thread Timothy W. Cook
Did you add: TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')] to settings.py ? On Fri, Oct 18, 2013 at 6:47 PM, Gavin Lowry wrote: > I'm following the tutorial at > https://docs.djangoproject.com/en/1.5/intro/tutorial01/ > ...I'm at the stage where I can change the template of the admin

Re: css

2013-10-20 Thread Timothy W. Cook
Check the FAQs or Google django staticfiles. On Sun, Oct 20, 2013 at 10:07 AM, Diogene Laerce wrote: > Hi, > > Could someone tell me if it is normal to have the css not working once one > starts the real server (nginx) instead of the dev server on the admin > interface ? > > Cos we've got a nice

HOWTO: Create a ManyToMany Relationship?

2013-10-22 Thread Timothy W. Cook
Can someone point me to where this is explained in the docs (1.6)? I have a ManyToMany relationship in my models between Author and Paper. I am processing an XML file to create records for Papers. I want to check if an Author exists and if not create the record. This was quite easy for Foreign

Re: HOWTO: Create a ManyToMany Relationship?

2013-10-23 Thread Timothy W. Cook
1:M and N:M relationship experiments. > > Can someone point me to where this is explained in the docs (1.6)? > > > https://docs.djangoproject.com/en/1.6/topics/db/examples/ > > > > > > On Tuesday, October 22, 2013 11:59:14 PM UTC+2, Timothy W. Cook wrote: >> >> Can

Re: HOWTO: Create a ManyToMany Relationship?

2013-10-23 Thread Timothy W. Cook
ysets/#django.db.models.**query.QuerySet.get_or_create<https://docs.djangoproject.com/en/1.5/ref/models/querysets/#django.db.models.query.QuerySet.get_or_create> > > hth > > Mike > > >> >> >> >> >> On Tuesday, October 22, 2013 11:59:14 PM UTC+2, Ti

Deleting FileField Content

2013-10-24 Thread Timothy W. Cook
When I delete an object that has a FileField I expected that the associated file would also be removed. But alas, this doesn't happen. At least not through the admin interface. Is there something I am missing? Thanks, Tim -- MLHIM VIP Signup: http://goo.gl/22B0U =

Re: Deleting FileField Content

2013-10-24 Thread Timothy W. Cook
Thanks Russ. That makes sense of course in the bigger picture. I was living in my own little use-case. :-) On Thu, Oct 24, 2013 at 8:00 AM, Russell Keith-Magee < russ...@keith-magee.com> wrote: > > On Thu, Oct 24, 2013 at 4:32 PM, Timothy W. Cook wrote: > >> When I dele

Re: Bulk add foreign keys in admin interface

2013-10-26 Thread Timothy W. Cook
Yes it is possible and quite easy to do. Take a look at https://docs.djangoproject.com/en/1.6/ref/contrib/admin/actions/ Cheers, Tim On Sat, Oct 26, 2013 at 12:17 AM, Kristofer Pettijohn < kristo...@cybernetik.net> wrote: > I am using the following type of model setup: > > class Product(models

Re: Digging up Django class-based views - 1

2013-10-28 Thread Timothy W. Cook
Very timely for me. Well written post for those of us just getting started with Django. Thanks, looking forward to the next installment. --Tim On Mon, Oct 28, 2013 at 6:01 AM, Leonardo Giordani < giordani.leona...@gmail.com> wrote: > Hi all, > > I want to share with you a post about class-ba

Re: ImportError: No module named django.core.wsgi even if sys.path contains my virtualenv

2013-10-28 Thread Timothy W. Cook
CentOS is a bit of a PITA. Because it is so secure. Try turning off SELinux http://www.centos.org/docs/5/html/5.2/Deployment_Guide/sec-sel-enable-disable.html To test this out from the commandline: $setenforce 0 How to actually make it work WITH SELinux? I haven't figured that out yet. HTH,

Re: ImportError: No module named django.core.wsgi even if sys.path contains my virtualenv

2013-10-28 Thread Timothy W. Cook
module loading? > If I activate my virtualenv from shell I can load Django. > > giovanni > > > > 2013/10/28 Timothy W. Cook > >> >> >> >> CentOS is a bit of a PITA. Because it is so secure. Try turning off >> SELinux >> >> >> h

Re: User names not support Unicode in 1.5

2013-10-30 Thread Timothy W. Cook
What version of Python are you using? Tried 3.3? On Wed, Oct 30, 2013 at 4:37 AM, Григорий Крамаренко wrote: > Hello. > My applications version 1.4.x contained Unicode characters in user names. > In version 1.5.x is not possible due to the validator. So I can't go on > this version. > Whether

Re: Django 1.5 or Django 1.6 with python 3.3 on windos Server 2008

2013-11-07 Thread Timothy W. Cook
Did you see this: https://docs.djangoproject.com/en/1.6/howto/auth-remote-user/# On Thu, Nov 7, 2013 at 8:18 AM, Robert Jonathan Šimon wrote: > I search for how can i do this, but i didnt find anything. Can you help me? > It would be great if it can be on IIS 7.5 > > -- > You received this messag

Re: Django 1.5 or Django 1.6 with python 3.3 on windos Server 2008

2013-11-07 Thread Timothy W. Cook
better than 2.7 unless you need >> libraries which are only available for 2.7. Happily, things are changing >> fast in favour of 3.3. >> >> Good luck >> >> Mike >> >>> >>> >>> On Thu, Nov 7, 2013 at 11:21 AM, Timothy W. Cook >

List in a Template

2013-11-09 Thread Timothy W. Cook
I have a view that creates a list of managers in the context. I want to test if a logged in user is in the list before displaying a link to the manager dashboard. class IndexView(TemplateView): template_name = 'index.html' def get_context_data(self, **kwargs): context = super(Ind

Re: List in a Template

2013-11-09 Thread Timothy W. Cook
SOLVED (sort of). On Sat, Nov 9, 2013 at 2:56 PM, donarb wrote: > If the user is a manager, you should be able to just test for membership in > the list: > > {% if user in mgr_list %} This made perfect sense after I realized that I was looking at a list of objects and not just the email string

Re: List in a Template

2013-11-10 Thread Timothy W. Cook
On Sat, Nov 9, 2013 at 11:37 PM, donarb wrote: > > The better way is to use the database to find the values, rather than doing > it in Python. Okay, this is good information to know. Off the top of my head, I'd do something like this: > > def get_context_data(self, **kwargs): > context = sup

Re: List in a Template

2013-11-10 Thread Timothy W. Cook
BTW: The code worked without editing. :-) Thanks. On Sun, Nov 10, 2013 at 6:23 AM, Timothy W. Cook wrote: > On Sat, Nov 9, 2013 at 11:37 PM, donarb wrote: >> >> The better way is to use the database to find the values, rather than doing >> it in Python. > > Okay,

Re: Deploying Django apps with nginx

2013-11-10 Thread Timothy W. Cook
This should help http://michal.karzynski.pl/blog/2013/10/29/serving-multiple-django-applications-with-nginx-gunicorn-supervisor/ On Sun, Nov 10, 2013 at 10:20 AM, Sandeep kaur wrote: > Hi, > I want to deploy multiple django apps on a server with nginx. When we do it > on apache > we do it in /e

Re: Invalid control character char 30262

2013-11-11 Thread Timothy W. Cook
The replace was my thought as well. I would just replace it with an empty string. Especially since it is a control character and apprently doesn't carry human readable information. ? On Mon, Nov 11, 2013 at 11:38 AM, Chi Tak Lam wrote: > Is there anyone can help? > > I think i should do a

Re: presetting a field value with ModelForm

2013-11-12 Thread Timothy W. Cook
Thanks for posting this. I was just about to post a question with the same exact scenario. Maybe we are missing it in the docs somewhere??? On Tue, Nov 12, 2013 at 12:30 PM, MikeKJ wrote: > This is driving me nuts I do not want the user to be able to select > organisation I want to popul

Django/Web Programming Pattern

2013-11-14 Thread Timothy W. Cook
Well, this isn't likely a Django specific question but since this project is built in Django, I'd like to know how best to handle this issue. I have a view that calls a function and performs a long running process. It reads and processes a file, creating potentially thousands of objects and can t

Re: Django/Web Programming Pattern

2013-11-14 Thread Timothy W. Cook
u, Nov 14, 2013 at 7:37 AM, Timothy W. Cook wrote: >> >> Well, this isn't likely a Django specific question but since this >> project is built in Django, I'd like to know how best to handle this >> issue. >> >> I have a view that calls a function and

Re: Django 1.6 error at creating project

2013-11-15 Thread Timothy W. Cook
Well, of course now you have a great OS in the VM. :-) However, even using Linux, please note that he was referring to a virtual Python environment. You should take a look at the link he provided. It will save you a lot of headaches. On Thu, Nov 14, 2013 at 11:41 PM, Vibhu Rishi wrote: > I wor

Re: mod_wsgi setup

2013-11-15 Thread Timothy W. Cook
On centos 6 I had (still have) problems similar to this due to SELinux restricting Apache from accessing the application. Even after rechecking permissions SELinux doesn't want to allow a user to access another users (specifically setup for the application) home directory. You can test if this i

Re: mod_wsgi setup

2013-11-15 Thread Timothy W. Cook
BTW: HEre is an old tutorial regarding SELinux and WSGI apps. It may be useful? http://www.packtpub.com/article/selinux-secured-web-hosting-python-based-web-applications On Fri, Nov 15, 2013 at 8:17 AM, Timothy W. Cook wrote: > On centos 6 I had (still have) problems similar to this due

Django Admin UI Bug - 1.7.3

2015-01-16 Thread Timothy W. Cook
Is this a bug or did I miss something in the release notes? ​Moving from 1.6.4 to 1.7.3 the listing in the Admin UI is not resolving a related field now. There are not any model changes involved. Attached are two screen shots named for the versions. I haven't changed the admin code either. Fo

Re: Django Admin UI Bug - 1.7.3

2015-01-16 Thread Timothy W. Cook
I should also mention that I have some AJAX calls for the same information and they still work fine. So I am quite certain it is in the Admin templates or the Admin properties definitions. On Fri, Jan 16, 2015 at 5:56 PM, Timothy W. Cook wrote: > Is this a bug or did I miss something in

Re: Django Admin UI Bug - 1.7.3

2015-01-18 Thread Timothy W. Cook
="prj_name" means you can't easily change the name of > the project. > > ​Yes, Once created the name cannot be changed, and once an item is assigned to a project the attached items are immutable. Thanks, Tim > Collin > > On Friday, January 16, 2015 at 3:14:55

Re: Django Admin UI Bug - 1.7.3

2015-01-18 Thread Timothy W. Cook
On Sun, Jan 18, 2015 at 5:35 PM, Collin Anderson wrote: > Hi, > > Rename your __unicode__ to __str__. Python 3 doesn't know what > "__unicode__" is. :) > > ​Yep, that did it.​ Interesting that it was working up until now and that my AJAX calls worked either way. > You say this works fine: >

Re: Version

2015-04-21 Thread Timothy W. Cook
I really doubt a new user wants to install 1.4 After getting your virtualenv setup then use: pip install django to install the latest version. On Tue, Apr 21, 2015 at 9:12 AM, Andreas Kuhne wrote: > Hi, > > First of all, don't use apt-get to install django, you will never get the > version

Migrations During Development

2015-04-25 Thread Timothy W. Cook
Django 1.8 Python 3.4 PostgreSQL 9.3 During development I am creating several migrations. It seems unnecessary to keep these since they only exist on my dev machine. Any data that I have created can be thrown away too. Is it safe to delete these migrations (and the database) before deploying to

Re: Migrations During Development

2015-04-25 Thread Timothy W. Cook
n the Django >> project you are deploying. >> >> On Sat, Apr 25, 2015 at 9:26 AM, Timothy W. Cook wrote: >> >>> Django 1.8 Python 3.4 PostgreSQL 9.3 >>> >>> During development I am creating several migrations. It seems >>> unnecessa

Re: Migrations During Development

2015-04-25 Thread Timothy W. Cook
On Sat, Apr 25, 2015 at 2:15 PM, Javier Guerra Giraldez wrote: > > > with South i used to save them to the repo too and push whole to > production. haven't tried Django migrations yet; is there any > difference that make this more appropriate? > > ​Hmmm, good question. That was kind of my quest

Admin Inlines

2015-04-25 Thread Timothy W. Cook
The usage of AdminInlines seems backwards to me. At least in the use case I have. I have two models: DvInterval: lower = models.CharField(max_length=110) upper = models.CharField(max_length=110) ... ReferenceRange: ​ ​ ​ ​ ... ​data_range = models.ForeignKey(DvInterval)

Re: Admin Inlines

2015-04-25 Thread Timothy W. Cook
For reference. My mistake is that I really have a ManyToMany relationship and I used this http://www.mc706.com/tip_trick_snippets/18/django-manytomany-inline-admin/ to solve the problem. Thanks to Ryan McDevitt. On Sat, Apr 25, 2015 at 3:11 PM, Timothy W. Cook wrote: > The usage

Stale contenttype

2015-05-06 Thread Timothy W. Cook
Django 1.8.1, PostgreSQL 9.3, Python 3.4, Ubuntu I have a project that started under Django 1.4 and I have been migrating through the updates as they were published. At one point (I think under Django 1.5) I installed django-authtools (currently at 1.2.0) I am of course using Django migrations n

Improve Performance in Admin ManyToMany

2015-05-13 Thread Timothy W. Cook
I have a model with 13 M2M relations and some of those have a few thousand instances. This renders rather slowly in the Admin. Thinking about improvements I wonder if it will help to setup prefetch_related queries https://docs.djangoproject.com/en/1.8/ref/models/querysets/#prefetch-related inside

Re: Improve Performance in Admin ManyToMany

2015-05-14 Thread Timothy W. Cook
raham wrote: > Are you sure it's the query that's slow and not the template rendering > and/or JavaScript performance? > > > On Wednesday, May 13, 2015 at 12:32:50 PM UTC-4, Timothy W. Cook wrote: >> >> I have a model with 13 M2M relations and some of those have a

Re: Improve Performance in Admin ManyToMany

2015-05-14 Thread Timothy W. Cook
lds is displayed in the admin. To make sure >>> only one query is executed you must make sure Baz.bars are selected with >>> their related Foo objects: >>> >>> from django.contrib import admin >>> >>> class BazAdmin(admin.ModelAdmin): >>>

Re: Improve Performance in Admin ManyToMany

2015-05-15 Thread Timothy W. Cook
On Fri, May 15, 2015 at 7:25 AM, Erik Cederstrand wrote: > > > I wonder if there is another approach that I can use to solve this? > > Does the suggestion to append select_related() / prefetch_related() to the > queryset in your admin view not work? > ​If I implemented it correctly, it doesn't h

Re: File Upload in Django

2015-05-16 Thread Timothy W. Cook
The official docs are a good place to start https://docs.djangoproject.com/en/1.8/topics/http/file-uploads/ This GitHub example is about the newest one available showing the changes in recent Django versions https://github.com/axelpale/minimal-django-file-upload-example On Sat, May 16, 2015 at

Re: Improve Performance in Admin ManyToMany

2015-05-16 Thread Timothy W. Cook
On Sat, May 16, 2015 at 5:27 PM, Erik Cederstrand wrote: > > > Den 15/05/2015 kl. 20.54 skrev Timothy W. Cook : > > > > def formfield_for_many_to_many(self, db_field, *args, **kwargs): > > formfield = super(ClusterAdmin, > self).formfield_for_many_to_

Re: Improve Performance in Admin ManyToMany

2015-05-17 Thread Timothy W. Cook
On Sun, May 17, 2015 at 4:20 PM, Erik Cederstrand wrote: > > I just noticed you have a typo: > > if db_field.name in ['cluster', ... > > should be: > > if db_field.name in ['clusters', ... > > according to your model definition. > > ​Thanks Erik. Yes, that was a typo. Unfortunately fixin

Re: Improve Performance in Admin ManyToMany

2015-05-20 Thread Timothy W. Cook
#x27;,'dvratio',]:* *formfield.queryset = formfield.queryset.select_related('prj_name')* *return formfield* Reduced the number of queries to 33 and the time to 182ms. Awesome, thanks for the pointers. On Sun, May 17, 2015 at 8:53 PM, Timothy W. Cook wrote:

Testing Setup gives 500, but dev server works okay

2015-05-25 Thread Timothy W. Cook
I have a project that I started, then decided I should apply a TDD approach. Well the user registration and login portion already works but I am attempting to add some tests to it. The user can register, is redirected back to the main page with a Login button. Here is the test code: def test

Re: Testing Setup gives 500, but dev server works okay

2015-05-25 Thread Timothy W. Cook
I should add that the actual error is: selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"id_login"} because the main page never loads so it can't find the login button, On Mon, May 25, 2

Re: Recommend guide to setting up a production server with Django and Python 3

2015-07-10 Thread Timothy W. Cook
This is a couple of years old but I used it for a template and it works great. http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/ On Fri, Jul 10, 2015 at 8:42 AM, Christian Kleineidam < christian.kleinei...@gmail.com> wrote: > Is there a recommended guide to

Re: Django - Website Bootstrap Design Breaks For Production

2015-07-17 Thread Timothy W. Cook
You may find that even after running collectstatic the dev server doesn't see the static files. You can add the --insecure option to runserver, with DEBUG=False and it should work as expected. On Fri, Jul 17, 2015 at 6:44 AM, Andreas Kuhne wrote: > Hi, > > There is a difference to running the r

Re: Python 3 Usage

2014-07-07 Thread Timothy W. Cook
I've been using Python 3 with Django for about 8 months. No real problems. Early on I had to patch a couple of add-ons. On Mon, Jul 7, 2014 at 9:10 PM, Richard Eng wrote: > I was wondering how many Django users have switched to Python 3. Are the > majority of users still on Python 2? I'm loo

Admin UI not commiting to DB

2014-07-12 Thread Timothy W. Cook
Django 1.65, PostgreSQL. Several users of the admin UI in my app have noted that clicking Save or Save and Continue buttons does not always actually save changes to the database. Has anyone else seen this? I do override get_form in admin.py so that I can set some fields as readonly based on a bo

Re: Admin UI not commiting to DB

2014-07-12 Thread Timothy W. Cook
n you > will struggle to debug. Have you tried adding in log statements at key > points to try & see where things go haywire? > > > On Saturday, 12 July 2014 10:52:37 UTC+2, Timothy W. Cook wrote: >> >> Django 1.65, PostgreSQL. >> >> Several users of the admi

Re: Admin UI not commiting to DB

2014-07-15 Thread Timothy W. Cook
On Mon, Jul 14, 2014 at 12:44 PM, Tom Evans wrote: > > > Have you ruled out that this is simply a mid air collision? IIRC, > django admin has no mid air collision detection system > > Cheers > > Tom > > Eg if user A loads Item i, user B loads Item i, user A changes > i.foo='hi' and saves item i,

Re: Any stable and trusted packages for python XML?

2014-09-19 Thread Timothy W. Cook
XML is more complex than JSON and AFAIK there isn't a generic tool to do this. I work with XML all the time with Python/Django and I would only recommend lxml http://lxml.de/ On Fri, Sep 19, 2014 at 9:39 PM, Chen Xu wrote: > Hi Everyone, > I wonder if there is any good, stable and trusted

Rendering XML using XSLT

2014-09-27 Thread Timothy W. Cook
I have a view that opens an XML file (it happens to be a schema but that doesn't matter) that specifies a stylesheet. It works as expected when opening the XML file locally. ​The stylesheet isn't applied when viewing the file via Django and I see in Firebug that I am getting a 404 on the styleshee

Re: Rendering XML using XSLT

2014-09-27 Thread Timothy W. Cook
Some details I forgot are that this is Django 1.6.4, Python 3.4.1. The 404 error is on http://192.168.1.9:8080/get_xsd/ccd-description.xsl On Sat, Sep 27, 2014 at 8:10 AM, Timothy W. Cook wrote: > I have a view that opens an XML file (it happens to be a schema but that > doesn't m

Re: Rendering XML using XSLT

2014-09-27 Thread Timothy W. Cook
return response ​ ​ ​Thanks for the nudge in the right direction. ​ > > > On 27/09/14 12:37, Timothy W. Cook wrote: > > Some details I forgot are that this is Django 1.6.4, Python 3.4.1. > The 404 error is on http://192.168.1.9:8080/get_xsd/ccd-description.xsl >

Re: Setting up Apache to be the web server for apache for Django 1.7 and python 3.3

2014-10-03 Thread Timothy W. Cook
Of course http://www.giyf.com/ but unless you have some very compelling need to use Apache. This may be a better choice. http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/ I found it to be much easier to setup and maintain. On Fri, Oct 3, 2014 at 9:42 AM,

Webcomponents in Django

2014-11-19 Thread Timothy W. Cook
I have a Django app that I want to include a UI similar to the Polymer designer https://www.polymer-project.org/tools/designer/ Source code here: https://github.com/twcook/TdV-app-designer/tree/tdv plus the components installed via bower. I have built this designer as a standalone app and it wo

Re: Webcomponents in Django

2014-11-19 Thread Timothy W. Cook
: > looks like the html rendered is making the recursive requests, are you > using {% static %} and {% url 'designer' %} ? > > On Wed, Nov 19, 2014 at 1:53 PM, Timothy W. Cook wrote: > >> >> I have a Django app that I want to include a UI similar to the Po

Re: Webcomponents in Django

2014-11-19 Thread Timothy W. Cook
d designer-element.html are both returning 200 even though the url gets longer with each recursion; seems strange to me. Thanks, Tim On Wed, Nov 19, 2014 at 11:02 AM, Timothy W. Cook wrote: > At the top of the both the main file where designer is called from and at > the top of designer.html I

Re: Webcomponents in Django

2014-11-19 Thread Timothy W. Cook
html except the file is named designer.html vs. index.html Thanks, Tim > On Wed, Nov 19, 2014 at 3:02 PM, Timothy W. Cook wrote: > >> At the top of the both the main file where designer is called from and at >> the top of designer.html I have: >> {% load staticfiles

Re: Webcomponents in Django

2014-11-19 Thread Timothy W. Cook
Maybe I bit off too much to start. IT looks like this may be a better place to start. http://themikelewis.com/2014/10/01/django-and-polymer-the-basics-and-vulcanizing/ ... and not running the Django development server. On Wed, Nov 19, 2014 at 12:18 PM, Timothy W. Cook wrote: > > On We

Re: Webcomponents in Django

2014-11-19 Thread Timothy W. Cook
. Cook wrote: > Maybe I bit off too much to start. IT looks like this may be a better > place to start. > > http://themikelewis.com/2014/10/01/django-and-polymer-the-basics-and-vulcanizing/ > > > ... and not running the Django development server. > > > On Wed, Nov 1

Re: Upgrading Django (to 1.7)

2014-11-26 Thread Timothy W. Cook
Excellent resource. Thanks Andrew. On Tue, Nov 25, 2014 at 10:16 PM, Andrew Pinkham wrote: > Hi, > Upgrading Django (to 1.7) Part IV: Upgrade Strategies is now available! > > For the article: > afrg.co/updj17/a4/ > > For all of the material: > afrg.co/updj17/ > > I've also provided a checkli

Re: Does Django offers a way to generate data grid from database table like web2py

2014-11-28 Thread Timothy W. Cook
The Django 'admin' section provides this functionality. On Fri, Nov 28, 2014 at 2:55 AM, Sarbjit singh wrote: > What web2py GRID does is, that it takes the SQL table/query as argument, > and return the records satisfying the query. > > Records which are returned are seen in bootstrap enabled ta

Re: Multiple levels of user in django application

2014-11-29 Thread Timothy W. Cook
On Sat, Nov 29, 2014 at 3:51 AM, Anju SB wrote: > Thank you Scot Hacker. > But my application needs more than one user from the same group. > > ​You can have multiple users in a group. That is kind of the definition of a group. :-) See here: https://docs.djangoproject.com/en/1.7/topics/aut

Re: Multiple levels of user in django application

2014-11-29 Thread Timothy W. Cook
​ ​There are similar examples you​ find with a search engine. The mailing list and stackoverflow are good places to look. > > On Saturday, 29 November 2014 13:34:49 UTC+5:30, Timothy W. Cook wrote: >> >> >> >> On Sat, Nov 29, 2014 at 3:51 AM, Anju SB wrote: >

Re: Multiple levels of user in django application

2014-11-29 Thread Timothy W. Cook
may have different > fields > > > > On Saturday, 29 November 2014 16:49:35 UTC+5:30, Timothy W. Cook wrote: >> >> >> >> On Sat, Nov 29, 2014 at 6:49 AM, Anju SB wrote: >> >>> Actually my application needs to store different information about

Re: Model to create forms

2015-01-09 Thread Timothy W. Cook
I think you are looking for a way to provide an abstraction like this http://django-forms-builder.readthedocs.org/en/latest/ On Thu, Jan 8, 2015 at 6:52 PM, Lorenzo Bernardi < lorenzo.berna...@lpn.cnrs.fr> wrote: > > Hello, > >> this is what _relational_ databases are built for. if you have two

Using Aggregate and Count

2013-11-20 Thread Timothy W. Cook
I see there was a similar question on this issue earlier today but alas it didn't answer my question. In my app I have models for: Project: a project (not really part of this question but used for context in the question). Paper: an academic paper description Review: a review of a paper ... other

Re: Using Aggregate and Count

2013-11-20 Thread Timothy W. Cook
Hi Daniel, On Wed, Nov 20, 2013 at 5:47 PM, Daniel Roseman wrote: > On Wednesday, 20 November 2013 19:11:26 UTC, Timothy W. Cook wrote: > > You're accessing a `review_count` attribute via each Paper instance, but you > haven't set up anything that would do that - you on

Re: Using Aggregate and Count

2013-11-20 Thread Timothy W. Cook
ces=INCLUDE_CHOICES, help_text="Select Exclude to remove due to the language.") comments = models.TextField("Comments", null=True, blank=True, help_text="Enter your comments.") objects = PaperManager() def __str__(self): return self.title The Paper Man

Re: Using Aggregate and Count

2013-11-20 Thread Timothy W. Cook
xt=_("Select a paper.")) In the annotation I tried: papers = Paper.objects.filter(project__id=self.kwargs['pk']).annotate(Count('papers_reviews_related+')) with and without the '+'. Still get a Field Error. Thanks, Tim On Wed, Nov 20, 2013 at 7:43

Re: Using Aggregate and Count

2013-11-21 Thread Timothy W. Cook
On Thu, Nov 21, 2013 at 8:25 AM, Daniel Roseman wrote: > states that if the value is, or ends with, "+", then no reverse relationship > will be created. I'm not sure why you are doing that, but remove the "+" > from the related_name in the ForeignKey definition. Thanks for pointing this out. I k

CreateView and get_context_data()

2013-11-22 Thread Timothy W. Cook
I am trying to setup some context variable for use in a template when I execute a create view. class ReviewTitleCreateView(CreateView): model = Review form_class = ReviewTitleCreateForm template_name = 'papers/review_title.html' def get_context_data(self, **kwargs): contex

Re: CreateView and get_context_data()

2013-11-22 Thread Timothy W. Cook
Lucas, On Fri, Nov 22, 2013 at 9:58 AM, Lucas Magnum wrote: > Timothy, > The "get_context_data" is called in get method, once you override it > "get_context_data" isn't called anymore. > Right. So my thought process was that if I override it and place additional information there it would be av

Re: CreateView and get_context_data()

2013-11-22 Thread Timothy W. Cook
THanks Lucas and Daniel, On Fri, Nov 22, 2013 at 11:38 AM, Daniel Roseman wrote: > On Friday, 22 November 2013 13:13:46 UTC, Timothy W. Cook wrote: > You've added it to kwargs, but you haven't passed kwargs as the template > context - you've simply hard-coded that to `{&

Re: How to fix URL link redirecting from login?

2013-11-24 Thread Timothy W. Cook
Check in the docs for the instructions on decorating your views to restrict to authenticated users. This also talks about redirecting to a page instructing them to login. Sorry, I don't have the link available right now. On Sat, Nov 23, 2013 at 10:40 PM, nobody wrote: > Hi, > > I made an URL l

Form cleaned_data

2013-11-24 Thread Timothy W. Cook
I have an issue with save data from a form. The actual form has one required and two optional fields. The model has three additional fields that I want to assign based on the context, two of those are ForeignKey related. The post method in the view: def post(self, request, *args, **kwargs):

Re: Form cleaned_data

2013-11-24 Thread Timothy W. Cook
ing ... On Sun, Nov 24, 2013 at 11:46 AM, Timothy W. Cook wrote: > I have an issue with save data from a form. > > The actual form has one required and two optional fields. > The model has three additional fields that I want to assign based on > the context, two of those are Foreig

Re: Form cleaned_data

2013-11-24 Thread Timothy W. Cook
On Sun, Nov 24, 2013 at 4:38 PM, Daniel Roseman wrote: > Hmm, I tried to post an answer to your original question earlier but it never > appeared. > Thanks Daniel. Your help is very much appreciated. > The reason why adding the values to `cleaned_data` doesn't work is that those > fields aren

Re: Form cleaned_data

2013-11-25 Thread Timothy W. Cook
On Mon, Nov 25, 2013 at 8:22 AM, Daniel Roseman wrote: > On Sunday, 24 November 2013 18:46:21 UTC, Timothy W. Cook wrote: >> >> On Sun, Nov 24, 2013 at 4:38 PM, Daniel Roseman >> wrote: > > No, `f` is now an unsaved instance of the Review model, rather than a form

Re: Form cleaned_data

2013-11-27 Thread Timothy W. Cook
On Tue, Nov 26, 2013 at 9:34 AM, Daniel Roseman wrote: > On Monday, 25 November 2013 21:42:51 UTC, Timothy W. Cook wrote: > > But that's just what form.save() does. In your original code, you called it > and a new Review object was saved in the database (it was also returned, but

Re: Form cleaned_data

2013-11-27 Thread Timothy W. Cook
Thanks Tom. On Wed, Nov 27, 2013 at 8:13 AM, Tom Evans wrote: > > No, "form" is an instance of your form. Model forms have a method > called save(), when you call this method, the model form updates an > instance of the model with the values from the form, saves the > instance and then returns it

Re: Virtualenv and Hudson/Jenkins

2013-11-27 Thread Timothy W. Cook
Interesting in how you think that PHP is more mature and better documented than Python. Anyway, the OP asked about virtualenv with Hudson and Jenkins, not about Django. So maybe they asked in the wrong place. Django running virtualenv is quite well documented. But any Python app runs the same u

Re: Trying to run jobs in the background using multiprocessing

2013-11-27 Thread Timothy W. Cook
When I asked about this it seems that the best solution is to use Celery in combination with Django. There seems to be quite a bit of good experience here using them together. HTH, Tim On Wed, Nov 27, 2013 at 5:58 PM, Pau Creixell wrote: > Hi there! > > I am trying to run jobs in the backgroun

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

2013-11-30 Thread Timothy W. Cook
You can use type() on your instance(s) to find out their model class. If you have an instance of the model: stream = StreamItem.objects.create(user,ct,oid,pdate) Then type(stream) should return Is that what you wanted? On Sat, Nov 30, 2013 at 1:14 AM, Simon Charette wrote: > Do you want

Re: How to use primary key as an attribute

2013-11-30 Thread Timothy W. Cook
I'm not sure what you are trying to accomplish. Since the 'pk' field is going to be defined on your instances anyway, do you need a 'thread_pk' field? On Sat, Nov 30, 2013 at 3:38 PM, Aamu Padi wrote: > This may be a lame question, but how do I use the primary key as a default > value for an attr

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

2013-11-30 Thread Timothy W. Cook
= type(myinstance) or kwargs['classname'] = type(myinstance) HTH, Tim > > On Sat, Nov 30, 2013 at 2:45 PM, Timothy W. Cook wrote: >> >> You can use type() on your instance(s) to find out their model class. >> >> If you have an instance of the model: >>

Re: How to use primary key as an attribute

2013-12-01 Thread Timothy W. Cook
If I understand what you are building. You want some way to group messages into threads? I assume that a Thread will have many messages? Unless I am missing something you might want something like this: class Thread(models.Model): subject = models.CharField(max_length=256) class Message(mod

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

2013-12-01 Thread Timothy W. Cook
Be sure to post the results back here for the archive so others may find it in searches. On Sun, Dec 1, 2013 at 8:32 AM, Aamu Padi wrote: > Ok, I will try it! Thank you so very much!!! > > > On Sun, Dec 1, 2013 at 3:41 AM, Timothy W. Cook wrote: >> >> On Sat, Nov 30, 20

Re: python virtual environment

2013-12-02 Thread Timothy W. Cook
On Fri, Nov 29, 2013 at 3:44 PM, tino wrote: > > > Hello > > I am trying to run a project that was setup in another server, but getting > the following error. I am using python 2.7, django, virtualenv. So I am > running the project inside a python virtual environment > > > (virtualenv)[web.srv1 da

Re: Save the user from one model to the another model

2013-12-03 Thread Timothy W. Cook
On Tue, Dec 3, 2013 at 9:56 AM, Aamu Padi wrote: > Ok! Plural names. Got it. But I was looking for something more of a > overriding the save method for the Thread class, so that I don't have to do > that in the view. > You can do it in the same view as the message. You aren't limited to working

Re: python virtual environment

2013-12-05 Thread Timothy W. Cook
On Thu, Dec 5, 2013 at 2:09 PM, Vibhu Rishi wrote: > I am getting the same error when I did an upgrade of Django to 1.6 . > Reverted back to 1.5 and it seems to work, but i am still searching for a > solution for this to work with 1.6 > > V. > > execute_manager was deprecated: https://docs.django

Re: How do I test my Django App on my Phone

2013-12-09 Thread Timothy W. Cook
Tim Chase's answer works well for a now and then test. But many static IPs change every 24 hours or so. Plus you will probably want to do this many more times in the future as well as ask others to test it on various devices. . I suggest setting up a URL using no-ip.org or similar service. No

  1   2   >