django cursor fetchall change datetime.datetime and decimal stamp

2015-12-23 Thread Shekar Tippur
Hello, I am trying to use cursor to execute a sql and convert the results to a dictionary def dictfetchall(cursor): "Return all rows from a cursor as a dict" columns = [col[0] for col in cursor.description] return [ dict(zip(columns, row)) for row in cursor.fetchall()

Re: I'm missing something with Models and database migrations

2015-12-23 Thread Vijay Khemlani
If you want to make the middle table by yourself then those ManyToManyField need to be ForeignKey instead. On Wed, Dec 23, 2015 at 2:33 AM, Michael Molloy wrote: > I figured it out, again with help from Vijay. Thanks for getting me > thinking in the right direction. > > So here is my cross refer

How to serve a static file with django?

2015-12-23 Thread Dan Bikle
*Hi List,* *I am new to django.I read this:https://docs.djangoproject.com/en/1.9/howto/static-files/I did this:cd ~django-admin startproject mysiteI see this in ~/mysite/mysite/settings.pyINSTALLED_APPS = ['django.contrib.admin', 'dj

Re: How to serve a static file with django?

2015-12-23 Thread Vijay Khemlani
I guess the URL would be something like this 127.0.0.1:8000/static/my_app/hello.html (without the first "my_app") assuming your STATIC_URL is '/static/' On Wed, Dec 23, 2015 at 1:57 AM, Dan Bikle wrote: > *Hi List,* > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

Re: How to serve a static file with django?

2015-12-23 Thread Jani Tiainen
Hi, Also staticfiles and serving them is gone quire throughly in Django official tutorial part 6 On 23.12.2015 06:57, Dan Bikle wrote: *Hi List,* * I am new to django. I read this: https://docs.djangoproject.com/en/1.9/howto/static-f

Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Jonty Needham
I have a model of the form: class Jobs(models.Model): names = models.ManyToManyField(Workers) class Workers(modesl.Model): is_a_problem = True And I want the set of jobs that are done by workers who are a problem. Something like Jobs.objects.filter(names__is_contained_in=Workers

Re: Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Vijay Khemlani
You should be able to query it as a ForeignKey Jobs.objects.filter(names__is_a_problem=True).distinct() (distinct to prevent repeated jobs with more than one worker problem) On Wed, Dec 23, 2015 at 9:31 AM, Jonty Needham wrote: > I have a model of the form: > > class Jobs(models.Model): >

Re: Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Jonty Needham
Thanks :-) Should have guessed it was that easy! On Wed, Dec 23, 2015 at 12:44 PM, Vijay Khemlani wrote: > You should be able to query it as a ForeignKey > > Jobs.objects.filter(names__is_a_problem=True).distinct() > > (distinct to prevent repeated jobs with more than one worker problem) > > > O

Handling delete of foreignkey

2015-12-23 Thread Jonty Needham
So I have an object that contains a foreignkey to another object that will be deleted, that means that my object should get deleted. Having read some of the docs on https://docs.djangoproject.com/en/1.7/ref/models/fields/#django.db.models.ForeignKey.on_delete (yes I know it's 1.7) I understand tha

Re: Handling delete of foreignkey

2015-12-23 Thread Jonty Needham
The, um, link in my question answers my question. On Wed, Dec 23, 2015 at 4:57 PM, Jonty Needham wrote: > So I have an object that contains a foreignkey to another object that will > be deleted, that means that my object should get deleted. > > Having read some of the docs on > https://docs.djan

Commenting system to use to build with REST API

2015-12-23 Thread amarshall
Hi, I'm working on an android app and using django as the backend. I created an api using django rest framework and everything is fine so far. I want to add commenting to my main object. i.e - lets call it a "Post". I want each post to have a set of comments associated with it. simple comments.

Re: Commenting system to use to build with REST API

2015-12-23 Thread Dheerendra Rathor
You can write your own system with just two models - Post and Comment. Then write custom serializers and viewsets to submit comments. It's an easy task and won't take much of your time. I've worked in similar fashion on few of my own works. Here is a link of custom models I wrote: https://github.c

Re: django cursor fetchall change datetime.datetime and decimal stamp

2015-12-23 Thread Shekar Tippur
> > I got it to work .. > def dictfetchall(cursor): "Returns all rows from a cursor as a dict" fieldnames = [name[0] for name in cursor.description] result = [] for row in cursor.fetchall(): rowset = [] for field in zip(fieldnames, row): L=list(field)

Re: Migrate django project to eclipse/pydev ide

2015-12-23 Thread Gary Roach
To your first question, in one word $money. I would love to use PyCharm but I am not a commercial developer and can't see paying the freight for most of the commercial packages. I applied for a free version of PyCharm and never heard back from them. The biggest complaint with Eclipse that I hav

django 1.9 - application does not

2015-12-23 Thread Shekar Tippur
Hello, I have a application on my laptop and I am trying to move it to AWS. I have installed django 1.9 on aws server under a virtualhost and scp'd all my local files to aws server. Under the virtualhost, when I try to run the server, I get an error. $ python3.4 manage.py runserver 0.0.0.0:800