Re: Struggling with formsets

2015-02-19 Thread Werner Brand
Thanks for the reponse! My template looks like this: {{ formset.management_form }} {{ formset }} {% csrf_token %} Here is the print request.POST: form-1-salaryform-MAX_NUM_FORMSform-0-surnameform-0-nameform-TOTAL_FORMSform-MIN_NUM_FORMSform-0-idform-1-nameform-

extracting data from three tables

2015-02-19 Thread sum abiut
Hi, I have three models that i want to extract data from them. The models are join using foreign key. i am not sure how to do that in django. Can someone please point me to the right path. Cheers -- You received this message because you are subscribed to the Google Groups "Django users" group.

Re: Proble understanding DetailView url doesn't match the slug

2015-02-19 Thread 严超
What is the specific error Django printed out ? We can narrow down the cause by checking the errors maybe. *Best Regards!* *Chao Yan--About me : http://about.me/chao_yan * *My twitter: @yanchao727 * *My Weibo: http://weibo.co

Re: Proble understanding DetailView url doesn't match the slug

2015-02-19 Thread inoyon artlover KLANGRAUSCH
Many thanks! Now I got it! :) Am Samstag, 14. Februar 2015 05:28:40 UTC+1 schrieb inoyon artlover KLANGRAUSCH: > > Hi there, there is something I obviously don't understand. According to > django reference, > the DetailView has to be provided a slug or pk. I do it in the url but > django consta

Re: allow certain users to access certain views

2015-02-19 Thread sum abiut
Hi James, Thanks heaps for direction. Cheers On Thu, Feb 19, 2015 at 6:18 PM, James Schneider wrote: > You should be able to handle this pretty easily with Django's built-in > permission system. > > Just create a group, add the users to it, and assign the requisite > permissions to the group.

Re: html response to be loaded in a div

2015-02-19 Thread Vijay Khemlani
There's no "range" in django templates, you just use {% for elem in sols %} Regarding making the request using POST, are you sure you're not having a proble with CSRF? https://docs.djangoproject.com/en/1.7/ref/contrib/csrf/ It has a section for AJAX requests On Thu, Feb 19, 2015 at 7:44 PM,

Re: JSON Response

2015-02-19 Thread Vijay Khemlani
What is the actual content of the respose you are getting back from the server? On Thu, Feb 19, 2015 at 7:06 PM, elcaiaimar wrote: > I mean in a correct form. My code doesn't work. It seems like the JS code > doesn't receive the jsonresponse. > I get a page with {"status":"True","product_id":p.i

Re: Sqlite3 to Postgres Migration?

2015-02-19 Thread Mike Dewhirst
On 20/02/2015 3:07 AM, Tom Lockhart wrote: On Feb 18, 2015, at 11:04 PM, talex wrote: I have a functioning Django application that is based on sqlite3, but I want to change to using Postgres. I’ll point out for the benefit of others who might be getting started: Postgres is a full feature

Re: Question about form security.

2015-02-19 Thread Carl Meyer
On 02/19/2015 04:03 PM, Chen Xu wrote: > what if I have two addresses, id is 1 and 2, and I want to update 2, how > I should distinguish 2 from 1, I mean, if I have addressid in the form, > and someone modify it from 2 to 1, and that will update 1, right? How to > prevent this? Your server-side co

Re: Question about form security.

2015-02-19 Thread Chen Xu
what if I have two addresses, id is 1 and 2, and I want to update 2, how I should distinguish 2 from 1, I mean, if I have addressid in the form, and someone modify it from 2 to 1, and that will update 1, right? How to prevent this? On Thu, Feb 19, 2015 at 6:01 PM, Mario Gudelj wrote: > Because t

Re: Question about form security.

2015-02-19 Thread Mario Gudelj
Because the user must be logged in to update their username you can get the current user from the request. You don't need to have their id inside the form. On 20/02/2015 9:49 am, "Chen Xu" wrote: > Hi > I am implementing a feature while building a website using Django, > basically, I want user to

Question about form security.

2015-02-19 Thread Chen Xu
Hi I am implementing a feature while building a website using Django, basically, I want user to be able to update their usernames. All of a sudden, this question comes to me, if I have the userid (ex: 1) somewhere in the form as a data attribute, if someone use firebug or something to change the da

Re: html response to be loaded in a div

2015-02-19 Thread João Marques
Thank You guys for all the aswers. Your were crucial debugging this error. By the way, on the GET request matter, I'm using a GET because I can't actually get POST to work I'll explain: As I execute the POST request, the url is loaded and everything runs fine except that the code on the view d

Re: html response to be loaded in a div

2015-02-19 Thread João Marques
Thank you all for being so fast aswering! I've looking through your answers and I've improved my code altough, I'm stuck with another error right now, wich is: Environment: Request Method: GET Request URL: http://localhost:8000/saveToDbAndReturn/?sols=%5B%5B%5B%2211C%22,%2211E%22,%229E%22,%

Re: JSON Response

2015-02-19 Thread elcaiaimar
I mean in a correct form. My code doesn't work. It seems like the JS code doesn't receive the jsonresponse. I get a page with {"status":"True","product_id":p.id} But this should be read for the JS code, and if it's True show an alert saying Remove it! Is there anything wrong in my code? El jue

matplotlib pyplot stop working

2015-02-19 Thread dk
I am using matplotlib.pyplot to generate a plot image, put it in a temp folder, and then use that to populate a webpage. the problem is: 1) always display the same image, I all ready deleted the image before creating the new one, I also set pyplot .close() to close all my figures. 2) some t

Re: JSON Response

2015-02-19 Thread Vijay Khemlani
What do you mean with "in a good way"? Does your code work? On Thu, Feb 19, 2015 at 4:14 PM, elcaiaimar wrote: > Hello, > > I was wondering how I can send a response JSON in a good way, because I > have the next code: > > if "product_id" in request.POST: > try: > id_p

Re: Seems like a geodjango bug with multiple databases

2015-02-19 Thread George Silva
I'm using with success two postgis enabled databases on a single application, without quirks. I have a read-only database, and a read/write database. No problems, so far. On Thu, Feb 19, 2015 at 5:11 PM, Collin Anderson wrote: > Hi, > > Interesting. What version of django is this? > > Here's so

JSON Response

2015-02-19 Thread elcaiaimar
Hello, I was wondering how I can send a response JSON in a good way, because I have the next code: if "product_id" in request.POST: try: id_producto = request.POST['product_id'] p = Pozo.objects.get(pk=id_producto) mensaje = {"status":"

Re: Seems like a geodjango bug with multiple databases

2015-02-19 Thread Collin Anderson
Hi, Interesting. What version of django is this? Here's something to try: Room.objects.using('another').select_related('hotel').get(pk=10) It could very well be an issue with GeoManager / GeoQuerySet. You also could ask on the geodjango list to see if anyone else has run into that. http://gro

Re: Trouble changing from sqlite3 to postgres

2015-02-19 Thread Collin Anderson
Hi, It seems strange that it would be trying to convert a "date" column to an integer. Since you're creating a new database from scratch, you could try deleting your migrations and generating them from scratch to see if that helps. Otherwise, what does your "app_1.0003_auto_20141126_2333" file

Re: Form Wizard: how to send instance_dict based on the request

2015-02-19 Thread Collin Anderson
Hi, You could instead just override get_form_instance(step). That way you'll have access to self.request. Collin On Tuesday, February 17, 2015 at 8:26:30 PM UTC-5, Karim Gorjux wrote: > > Hello mates! > > I have some problems to understand how to set the view for > the NamedUrlSessionWizardVie

Re: Can migrated apps depend on unmigrated apps?

2015-02-19 Thread Collin Anderson
Hi Carsten, I in my experience, it _sometimes_ works to have migrated apps depend on unmigrated apps. If you haven't yet, you could try generating migrations for the unmigrated app, and reference them using MIGRATION_MODULES. Collin On Tuesday, February 17, 2015 at 5:00:26 PM UTC-5, Carsten F

Re: Django 1.7.4, PostgreSQL: Migrate FK to M2M?

2015-02-19 Thread Andrew Pinkham
On Feb 19, 2015, at 11:54 AM, Tom Evans wrote: > Django accepts the keyword argument "null" on all fields, but it is > meaningless for an M2M. That is an excellent point. That's what I get for writing this up based on memory late at night. Sorry for the error. Andrew -- You received this mes

Re: Handling FormSet client side with javascript

2015-02-19 Thread Collin Anderson
Hi, Sorry for the late reply. Does simply using {{ formset.media }} work? Collin On Friday, February 13, 2015 at 11:02:31 AM UTC-5, aRkadeFR wrote: > > Hello everyone, > > I'm using FormSet in order to add multiple object at once on > a view. To have a more user friendly approach, I created a

Re: JsonResponse and Ajax function.

2015-02-19 Thread Collin Anderson
Hi, Sorry for the late reply. Do you need to use JSON.parse(response).status? Collin On Tuesday, February 10, 2015 at 8:33:58 AM UTC-5, elcaiaimar wrote: > > Hello! > > I've written a code to delete db registers and I want to call an ajax > function when the delete is done. > At the moment, whe

Re: Django: get profiles having auth.Group as foreign key

2015-02-19 Thread Collin Anderson
Hi, Sorry for the late reply. Do you just want something like this? {% for dashboard in group.dashboard_set.all %} {{ dashboard.d_name }} etc {% endfor %} Collin On Tuesday, February 10, 2015 at 12:41:15 AM UTC-5, itsj...@gmail.com wrote: > > I have an model which uses auth.models Group as fo

Re: Custom model field and custom widget

2015-02-19 Thread Collin Anderson
Hi, Sorry for the late reply. Check out editable=False if you haven't. Collin On Friday, January 30, 2015 at 9:03:41 AM UTC-5, Thomas Weholt wrote: > > Hi, > > I need to create a custom django model field, a varchar(10) field which > has a calculated value set on save on the model using it and

Re: Django 1.7.4, PostgreSQL: Migrate FK to M2M?

2015-02-19 Thread Tom Evans
On Thu, Feb 19, 2015 at 4:56 AM, Andrew Pinkham wrote: > Hi Micky, > When I had to migrate FK->M2M, I found that hand-hacking a migration file was > the way to go. I wrote a multiple operation migration class that did the > following: > > 1. create a M2M, nullable field, and set all defaults to

Re: how to handle race conditions?

2015-02-19 Thread Carl Meyer
Hi Abraham, On 02/19/2015 03:41 AM, Abraham Varricatt wrote: > I've heard of the term 'atomic operations' , but didn't realize it had > support in django. Thank you for the detailed explanation! You're welcome. > It's an interesting idea - to mark the field in the database as a > positive intege

Re: Struggling with formsets

2015-02-19 Thread aRkadeFR
Hello, Can we have the template? Did you rendered the hidden fields id of your forms ? Dump (by printing) the request.POST informations to see if you received any "id" :) On 02/19/2015 04:25 PM, Werner Brand wrote: I cannot seem to figure this, although I suspects it is really elementary:

Re: Doubt

2015-02-19 Thread Andrew Pinkham
On Feb 19, 2015, at 7:48 AM, sriraag paawan wrote: > Hello guys i am Paawan and i am new to Python Django.. i was getting an error > like "activate.bat is not recognised" when installing virtualenv. I am unable > to work with environment variable WORKON and version of Django... We need way mor

Re: Modify Installed_Apps settings

2015-02-19 Thread Andrew Pinkham
I am learning all sorts of things about Django's testing system (instead of actually getting work done). The database schema is actually created via a call create_test_db() called on line 366 of setup_databases() in DiscoverRunner in django/test/runner.py. It's within this function, found in dj

Re: How to install django in redhat where i have python 2.6 and 2.7 and i need to install django in python 2.7

2015-02-19 Thread Tom Evans
On Thu, Feb 19, 2015 at 1:27 PM, SHINTO PETER wrote: > How to install django in redhat where i have python 2.6 and 2.7 and i need > to install django in python 2.7 > You use scl: http://developerblog.redhat.com/2013/02/14/setting-up-django-and-python-2-7-on-red-hat-enterprise-6-the-easy-way/ Ch

Re: ImageField isn't working

2015-02-19 Thread Valéria Pacheco
Thank you very much! it worked! Both solutions combined. I'm still trying to understand what happened but thank you!! :) 2015-02-19 16:18 GMT+00:00 Tom Lockhart : > On Feb 19, 2015, at 8:03 AM, Valéria Pacheco > wrote: > > Hello! I'm a newbie in Django and Python, I'm trying to use the ImageFiel

Doubt

2015-02-19 Thread sriraag paawan
Hello guys i am Paawan and i am new to Python Django.. i was getting an error like "activate.bat is not recognised" when installing virtualenv. I am unable to work with environment variable WORKON and version of Django... So please help me guys Thank u in advance -- You received this messag

Struggling with formsets

2015-02-19 Thread Werner Brand
I cannot seem to figure this, although I suspects it is really elementary: I have two models: class Employee(models.Model): id_number = models.CharField(max_length=13) surname = models.CharField(max_length=100) name = models.CharField(max_length=100) class Payslip(models.Model): surname =

Re: How to install django in redhat where i have python 2.6 and 2.7 and i need to install django in python 2.7

2015-02-19 Thread Matthias Runge
On 19/02/15 14:27, SHINTO PETER wrote: > How to install django in redhat where i have python 2.6 and 2.7 and i > need to install django in python 2.7 > Do you have the possibility to upgrade to RHEL 7? That has python2.7 on board. Btw. there is a Django-1.6 package for RHEL7 on EPEL package repos

Re: ImageField isn't working

2015-02-19 Thread Tom Lockhart
On Feb 19, 2015, at 8:03 AM, Valéria Pacheco wrote: > Hello! I'm a newbie in Django and Python, I'm trying to use the ImageField > property. > The problem is represented in the attachment images. > The uploading of the image works fine, but when trying to access it, the link > seems to be broke

Re: ImageField isn't working

2015-02-19 Thread Jorge Andrés Vergara Ebratt
Hello Valéria, That's Django's default, it doesn't handle media files by itself, if you are in development you can add this line to urls.py urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Don't forget you need to import static and settings: from django.conf import s

Re: ImageField isn't working

2015-02-19 Thread Lucas Klassmann
Hi Valéria, Try verify if that support for statics files is correctly configured. Check this: https://docs.djangoproject.com/en/1.7/howto/static-files/ Before read the documentation, check which version of your django is installed. Cheers. On Thu, Feb 19, 2015 at 2:03 PM, Valéria Pacheco wrot

Re: Sqlite3 to Postgres Migration?

2015-02-19 Thread Tom Lockhart
On Feb 18, 2015, at 11:04 PM, talex wrote: > I have a functioning Django application that is based on sqlite3, > but I want to change to using Postgres. I’ll point out for the benefit of others who might be getting started: Postgres is a full featured database and supports the full range of Dj

Re: Sqlite3 to Postgres Migration?

2015-02-19 Thread Andrew Pinkham
On Feb 19, 2015, at 1:04 AM, talex wrote: > Am I correct that use of "python makemigrations" followed by > "python migrate", should copy the existing data into Postgres > and leave me with a working application? I'm afraid not. Migration allows for predictable and reversible alterations to the d

Re: How to install django in redhat where i have python 2.6 and 2.7 and i need to install django in python 2.7

2015-02-19 Thread Tom Lockhart
On Feb 19, 2015, at 5:27 AM, SHINTO PETER wrote: > How to install django in redhat where i have python 2.6 and 2.7 and i need to > install django in python 2.7 Use virtualenv to select and install python 2.7 from your existing installation into a separate place. There is a redhat package for

Re: How to install django in redhat where i have python 2.6 and 2.7 and i need to install django in python 2.7

2015-02-19 Thread Vijay Khemlani
you can compile python locally On Thu, Feb 19, 2015 at 10:27 AM, SHINTO PETER wrote: > How to install django in redhat where i have python 2.6 and 2.7 and i need > to install django in python 2.7 > > -- > You received this message because you are subscribed to the Google Groups > "Django users"

How to host django application in redhat using virtual environment?

2015-02-19 Thread SHINTO PETER
How to host django application in redhat using virtual environment? -- 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

How to install django in redhat where i have python 2.6 and 2.7 and i need to install django in python 2.7

2015-02-19 Thread SHINTO PETER
How to install django in redhat where i have python 2.6 and 2.7 and i need to install django in python 2.7 -- 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 dja

Re: how to handle race conditions?

2015-02-19 Thread Abraham Varricatt
@Carl, I've heard of the term 'atomic operations' , but didn't realize it had support in django. Thank you for the detailed explanation! It's an interesting idea - to mark the field in the database as a positive integer, but since it doesn't apply to all DBs, I think I'll keep it aside for now

Re: how to handle race conditions?

2015-02-19 Thread aRkadeFR
On 02/19/2015 01:04 AM, Mario Gudelj wrote: Great reply. You're a champion, Carl! Couldn't say more. Very thorough answer and interesting :) On 19 February 2015 at 05:31, Carl Meyer > wrote: Hi Abraham, On 02/17/2015 10:01 PM, Abraham Varricatt wrote: