Re: query join tables

2014-10-13 Thread dk
I will give a try, how does django know that have to join using double filter? or it just auto-magically knows behind the hood? or filtering by another model/class django get the idea, and joins the tables? Thanks Tom =) -- You received this message because you are subscribed to the Google

Static Media Server (Tango with Django)

2014-10-13 Thread Max Nathaniel Ho
Hi all, I am going through this tutorial on Tango with Django - http://www.tangowithdjango.com/book/chapters/templates_static.html I extracted the specific part of the tutorial as seen in *BOLD*. *4.4. The Static Media Server

Re: how to query max count

2014-10-13 Thread Jirka Vejrazka
Hi there, you could do it manually by counting occurrences or you could take a look at aggregation functions here: https://docs.djangoproject.com/en/1.7/topics/db/aggregation/ Do as it suits your use case. HTH Jirka On 13 October 2014 06:30, dk wrote: > I am storing the information

Re: Static Media Server (Tango with Django)

2014-10-13 Thread Daniel Roseman
On Monday, 13 October 2014 08:39:26 UTC+1, Max Nathaniel Ho wrote: > > Hi all, > > I am going through this tutorial on Tango with Django - > http://www.tangowithdjango.com/book/chapters/templates_static.html > > I extracted the specific part of the tutorial as seen in *BOLD*. > *4.4. The Static Me

Re: Static Media Server (Tango with Django)

2014-10-13 Thread Max Nathaniel Ho
Hi DR, Thanks for your reply. I wanted to clarify - 1. The purpose of Static Media Server and 2. If it is an outdated concept On Monday, October 13, 2014 4:57:32 PM UTC+8, Daniel Roseman wrote: > > On Monday, 13 October 2014 08:39:26 UTC+1, Max Nathaniel Ho wrote: >> >> Hi all, >> >> I am goi

Re: Static Media Server (Tango with Django)

2014-10-13 Thread Andreas Kuhne
Using a static media server or not is more a choice. I don't think it is an outdated concept, rather the opposite, depending on how you want to deploy it. We are using Amazon CloudFront for our media and static files. That way we don't get the load on our nginx servers (we generate alot of pictures

redirect to admin with parameter

2014-10-13 Thread Christian Schulz
Hey, i'd like to redirect with a parameter to specific entry in an admin model table entry Is it possible with a TemplateView in urls.py directly? If not , what is the proper way to do it without a template? Example I call: reporting/netreach/2695/ and would like redirect to adminreporting/n

Re: query join tables

2014-10-13 Thread Anderson
HI there.. Looks like you already have the person ID , you don't need hit the database every time to call Person object. You can make faster only check for ID not Person object. instead this: person = Person.objects.get(name=person_name) choices_for_person_on_date = Choice.objects.filter(date=d

Re: How to trace a page not showing up?

2014-10-13 Thread Helgi Örn Helgason
Found this in a __init__.py file: HAYSTACK_SEARCH_ENGINE = 'solr' Solr was not running, the Jetty servlet engine is on a seperate server that was not working. The thing is running now and one of the branches on the site is up and running again. Two more to go. :-/ On Friday, 10 October 2014 1

Re: redirect to admin with parameter

2014-10-13 Thread Christian Schulz
Got it with a simple redirect. Am Montag, 13. Oktober 2014 11:54:31 UTC+2 schrieb Christian Schulz: > > Hey, > > i'd like to redirect with a parameter to specific entry in an admin model > table entry > Is it possible with a TemplateView in urls.py directly? > > If not , what is the proper way t

Re: query join tables

2014-10-13 Thread Jani Tiainen
On Sun, 12 Oct 2014 22:01:51 -0700 (PDT) dk wrote: > I have this 2 models > > class Choice(models.Model): > restaurant = models.ForeignKey(Restaurant) > person = models.ForeignKey(Person) > date = models.DateField("time published") > time = models.TimeField("date published") > >

Re: django email client (reusable app) kickstarter

2014-10-13 Thread Internet Profil Filip Kowalski
This project is a reusable app and license MIT I do not know and I'm not sure to which projects will be used in the future but I assume that the imagination of people is very large so even to this reason we prefer to give a database that gives you a lot more possibilities and the first examp

Problem when getting the ID of the record just created

2014-10-13 Thread Daniel Grace
Hi, I have problem when getting the ID of the record just created. class CreateFlow(CreateView): model = Flow fields = ['state'] template_name = 'create_flow.html' def form_valid(self, form): user = User.objects.get(pk=self.request.user.id) flow = Flow.objects.get(pk=self.kwargs['pk']) log = Log(u

Re: Problem when getting the ID of the record just created

2014-10-13 Thread Joseph Mutumi
Should get the flow instance from the form.save() so: user = User.objects.get(pk=self.request.user.id) flow = form.save() log = Log(user=user, flow=flow, state=1) On Mon, Oct 13, 2014 at 4:13 PM, Daniel Grace wrote: > Hi, > I have problem when getting the ID of the record just created. > > clas

Re: Best approach to adding user notification and message alerts

2014-10-13 Thread Collin Anderson
Hi Chris, Also, check out assignment_tags if you haven't. https://docs.djangoproject.com/en/1.7/howto/custom-template-tags/#assignment-tags Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receivi

Re: Postgres database server

2014-10-13 Thread Collin Anderson
Hi Sheyda, What does the error message say? Collin -- 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 email to django-users+unsubscr...@googlegroups.com. To post to this g

Re: Problem when getting the ID of the record just created

2014-10-13 Thread Giuseppe Saviano
On Mon, Oct 13, 2014 at 3:13 PM, Daniel Grace wrote: > Hi, > I have problem when getting the ID of the record just created. > > class CreateFlow(CreateView): > model = Flow > fields = ['state'] > template_name = 'create_flow.html' > def form_valid(self, form): > user = User

Re: Problem when getting the ID of the record just created

2014-10-13 Thread Giuseppe Saviano
> User.objects.get(pk=self.request.user.id) because request.user is your > user object. > it's self.request.user - sorry. But the sense is the same: you don't need User.objects.get -- $ gpg --recv-key da5098a7 -- You received this message because you are subscribed to the Google Groups "Djang

Re: How to get user ID and ID of newly created record in a CreateView?

2014-10-13 Thread Collin Anderson
Hi Daniel, Interesting. Could you post a traceback? Thanks, Collin -- 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 email to django-users+unsubscr...@googlegroups.com. T

Re: Upgrade to Django 1.7 - AppRegistryNotReady exception

2014-10-13 Thread Collin Anderson
Hi Luca, Yes, you have django.setup() commented out in your get_wsgi_application(). That is required. Collin -- 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 email to d

Re: Question on url routing

2014-10-13 Thread Collin Anderson
Hi Robert, I once had a 4-step ecommerce checkout, and at one point, I considered using class based views for each step, and have a class method on each view that runs form validation on the current data in the database to see if the user is allowed to continue. It would then need to redirect b

Re: Static Media Server (Tango with Django)

2014-10-13 Thread Collin Anderson
Hi Max, By default, the runserver command in a new django project will serve static media, which I think is what the tutorial is referencing. It's useful for developing your website, but be sure to read the tutorial's warning: > While using the Django development server to serve your static me

Re: How to get user ID and ID of newly created record in a CreateView?

2014-10-13 Thread Daniel Grace
I made a different approach after getting help, which I now have working: https://groups.google.com/forum/#!topic/django-users/eYDfCEZ0eQQ On Monday, 13 October 2014 14:45:09 UTC+1, Collin Anderson wrote: > > Hi Daniel, > > Interesting. Could you post a traceback? > > Thanks, > Collin > > -- You

Re: Problem when getting the ID of the record just created

2014-10-13 Thread Daniel Grace
Thanks for the help. I got the ID working and I used the "self.user.request". -- 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 email to django-users+unsubscr...@googlegr

Re: Closing modal when user sign up or login

2014-10-13 Thread Collin Anderson
Hello, You probably need to use some sort of ajax for that. Collin -- 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 email to django-users+unsubscr...@googlegroups.com. T

Re: Best way to change Site.__str__ to return name not domain

2014-10-13 Thread Collin Anderson
Hi Michael, As you said, it sounds like monkey patching is your best option, besides re-writing the whole sites app. You could, if you wanted to, explain your use-case on the django-developers mailing list and propose having "swappable" site models, which would help you out. See this ticket:

What is the correct way to set a field value in the form_valid method of a CreateView?

2014-10-13 Thread Daniel Grace
Hi, What is the correct way to set a field value in the form_valid method of a CreateView? Note the field is not on the form and I don't want to use a default value in the model. For example: def get_state(type_desc, state_desc): type = Type.objects.get(description=type_desc) return State.objec

A better "manage.py shell" with syntax highlighting and multiline editing.

2014-10-13 Thread Jonathan S
Hi all, Two weeks ago I released the python-prompt-toolkit library with the "ptpython" REPL. That is a nice python interactive shell with decent multiline editing, syntax highlighting and autocompletion. For a list of all the features, see: http://github.com/jonathanslenders/python-prompt-toolk

Re: django email client (reusable app) kickstarter

2014-10-13 Thread Scot Hacker
On Monday, October 13, 2014 4:18:52 AM UTC-7, biuro wrote: > > > > perhaps I run out too far in the future and this should be put on a > different database. > what do you think guys? > I think that database independence is a core feature of Django and of virtually every reusable app. Your p

Re: A better "manage.py shell" with syntax highlighting and multiline editing.

2014-10-13 Thread Aaron C. de Bruyn
That's awesome! Thanks. -A On Mon, Oct 13, 2014 at 8:35 AM, Jonathan S wrote: > Hi all, > > Two weeks ago I released the python-prompt-toolkit library with the > "ptpython" REPL. That is a nice python interactive shell with decent > multiline editing, syntax highlighting and autocompletion. >

Re: Static Media Server (Tango with Django)

2014-10-13 Thread Carl Meyer
Hi Max, On 10/13/2014 01:39 AM, Max Nathaniel Ho wrote: > Hi all, > > I am going through this tutorial on Tango with Django > - http://www.tangowithdjango.com/book/chapters/templates_static.html > > I extracted the specific part of the tutorial as seen in *BOLD*. > > > *4.4. The Static Med

Re: Upgrade to Django 1.7 - AppRegistryNotReady exception

2014-10-13 Thread Carl Meyer
Hi Luca, To be clear, the call to ``django.setup()`` should be in the ``get_wsgi_application()`` function in the file ``django/core/wsgi.py``, which is part of Django, and you should not need to comment that out. It should not be necessary to have a call to ``django.setup()`` in your project's ws

Naive datetime / time zone warning

2014-10-13 Thread Daniel Grace
Hi. Here is my model: class Flow(models.Model): state = models.ForeignKey(State) created = models.DateTimeField(default=datetime.now) modified = models.DateTimeField(db_index=True, default=datetime.now) def __str__(self): return str(self.id) I am getting warnings about time zone support such as t

Re: Naive datetime / time zone warning

2014-10-13 Thread Carl Meyer
Hi Daniel, On 10/13/2014 12:04 PM, Daniel Grace wrote: > Here is my model: > > class Flow(models.Model): > state = models.ForeignKey(State) > created = models.DateTimeField(default=datetime.now) > modified = models.DateTimeField(db_index=True, default=datetime.now) > def __str__(self): > return s

How to "automatically " populate "last_updated_by" DB columns with the current user's id

2014-10-13 Thread Ken Winter
I'm building a Django app that will work against a pre-existing PostgreSQL database. Every user data table in my DB has an auditing column called last_updated_by. The requirement I need to meet is that every time an UPDATE is run against a table, that column is automatically set to the id

Re: Naive datetime / time zone warning

2014-10-13 Thread Daniel Grace
I changed "datetime.now" to "timezone.now" and I get the exact same warning. What is going on? -- 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 email to django-users+uns

Re: Postgres database server

2014-10-13 Thread sheyda kianimehr
Yes, I did but when I want to run server python manage.py runserver I got this message django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" You think there is a problem with my DB? I have made a n

Re: Postgres database server

2014-10-13 Thread sheyda kianimehr
Hi Collin, I made a Database, I can see the tables of my DBs in terminal but when I use this python manage.py runserver for connecting to server I got this error. django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres" FATAL: password authentication failed

Re: Naive datetime / time zone warning

2014-10-13 Thread Daniel Grace
I used "auto_now_add=True" in the model and the warning went away. -- 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 email to django-users+unsubscr...@googlegroups.com. To

Re: Postgres database server

2014-10-13 Thread Babatunde Akinyanmi
Hi Sheyda, Perhaps you need to adjust your postgres configuration file On 13 Oct 2014 19:52, "sheyda kianimehr" wrote: > Hi Collin, > I made a Database, I can see the tables of my DBs in terminal but when I > use this python manage.py runserver > for connecting to server I got this error. > > dj

Re: Postgres database server

2014-10-13 Thread Hannu Krosing
On 10/13/2014 08:31 PM, sheyda kianimehr wrote: > Yes, I did but when I want to run server python manage.py runserver > I got this message > > django.db.utils.OperationalError: FATAL: password authentication > failed for user "postgres" > FATAL: password authentication failed for user "postgres"

Re: how to query max count

2014-10-13 Thread dk
I need to learn how to use aggregation in django, I was thinking on filter by date, and then loop the query and make a dictionary with the name, and += value and then use the python max function. On Monday, October 13, 2014 3:12:39 AM UTC-5, JirkaV wrote: > Hi there, > > you could do it m

Django: How to apply filter on geometry type using GeoDjango QuerySet

2014-10-13 Thread Shoaib Ijaz
I am trying to convert a SQL into Django Query: SELECT * from tbl_name where geometrytype(geometry) LIKE 'POINT'; I have searched on it but cannot find any geometry type function. Any Help? Thank you -- You received this message because you are subscribed to the Google Groups "Django users"