Stuck in URL............!!! Help

2012-05-18 Thread Ali Shaikh
Using the URLconf defined in wikicamp.urls, Django tried these URL
patterns, in this order:

1. ^wikicamp/(?P[^/]+)/edit/$

2. ^wikicamp/(?P[^/]+)/save/$

3. ^wikicamp/(?P[^/]+)/$

The current URL, wikicamp/, didn't match any of these.

---

Any ideas? I'm admittedly lacking in the regex department... but I
assume this is a syntax issue due to the tutorial being for an older
version of Django, as I also had to use 'max_length' rather than
'maxlength', as others mentioned here.Am using Django 1.4...HOw to
overcome this.?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Stuck in URL............!!! Help

2012-05-18 Thread Jirka Vejrazka
> 1. ^wikicamp/(?P[^/]+)/edit/$
> 2. ^wikicamp/(?P[^/]+)/save/$
> 3. ^wikicamp/(?P[^/]+)/$
>
> The current URL, wikicamp/, didn't match any of these.

All defined URL's expect wikicamp/some_page_name/  (and maybe some
extras after). The requested URL has no page name, terminates right
after "wikicamp/" - hence the error...

  HTH

Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Stuck in URL............!!! Help

2012-05-18 Thread doniyor
you need something like this *^wikicamp/* separately, because even if your 
url doesnot match anything for page_name, your url is still asking 
something for *^wikicamp/at_least_something/* . 




Am Freitag, 18. Mai 2012 10:02:37 UTC+2 schrieb Ali Shaikh:
>
> Using the URLconf defined in wikicamp.urls, Django tried these URL 
> patterns, in this order: 
>
> 1. ^wikicamp/(?P[^/]+)/edit/$ 
>
> 2. ^wikicamp/(?P[^/]+)/save/$ 
>
> 3. ^wikicamp/(?P[^/]+)/$ 
>
> The current URL, wikicamp/, didn't match any of these. 
>
> --- 
>
> Any ideas? I'm admittedly lacking in the regex department... but I 
> assume this is a syntax issue due to the tutorial being for an older 
> version of Django, as I also had to use 'max_length' rather than 
> 'maxlength', as others mentioned here.Am using Django 1.4...HOw to 
> overcome this.?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/spyQ6aF_58kJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: import error: no model named .....

2012-05-18 Thread doniyor
try this 

urlpattern = patterns(' ',
url('^hello/$,hello),
)


Am Donnerstag, 17. Mai 2012 20:58:23 UTC+2 schrieb Ali Shaikh:
>
> Hey... 
>
>
> I am practicing to implement simple examples in django... 
>
> started project with 
> 1.django-admin.py startproject wikicamp 
> 2.python manage.py startapp wiki 
> 3.editing the setting 
> 4.python manage.py syncdb 
> 5.python mange.py runserver 
>
>  till this stage its working fine:) 
>
>
> But after editing urls.py and views.py ...i run the server 
> again that time its showing this error 
>
> IMMPORTERROR at .// 
>
> NO module named views...:'( 
>
>
>
>
>
> help pls.!!! 
>
> am getting 
>
> ImoprtError at //


Am Donnerstag, 17. Mai 2012 20:58:23 UTC+2 schrieb Ali Shaikh:
>
> Hey... 
>
>
> I am practicing to implement simple examples in django... 
>
> started project with 
> 1.django-admin.py startproject wikicamp 
> 2.python manage.py startapp wiki 
> 3.editing the setting 
> 4.python manage.py syncdb 
> 5.python mange.py runserver 
>
>  till this stage its working fine:) 
>
>
> But after editing urls.py and views.py ...i run the server 
> again that time its showing this error 
>
> IMMPORTERROR at .// 
>
> NO module named views...:'( 
>
>
>
>
>
> help pls.!!! 
>
> am getting 
>
> ImoprtError at //

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ft9YSeDKMkgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Image Update with Django - Admin site

2012-05-18 Thread nishad
Hi...
Am new to the Django community...

Topic:- I have noticed an issue related to the image uploading and it
saving with Django admin interface.

Steps to trace the issue :-

1. When i was uploaded/(browse) and saved an Article with an image
(.jpg) , for the first time it saves perfectly
as follows (smedia/images/misc/sample.jpg)
2. For the second time i have tried to update some textual contents in
the article and saves once again through the same admin interface ,
but this time image get saved as follows (smedia/images/misc/
sample_1.jpg)

Issue :-
It cause an image duplication in respective folder and also an error
when page/template is rendered through browser.

Can any one please suggest a method to avoid the duplication of image
on updating the existing one.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Image Update with Django - Admin site

2012-05-18 Thread Phang Mulianto
hi,

thats default behaviour of the image fields.

The old image not removed, but still keep intact, and the new image user
uploaded will be named with a _1.ext , _2.ext

you must handle the saving yourselft to make it rewrite the old images.

Check the snippet i use :
http://djangosnippets.org/snippets/2754/

hope helps

On Fri, May 18, 2012 at 5:42 PM, nishad  wrote:

> Hi...
> Am new to the Django community...
>
> Topic:- I have noticed an issue related to the image uploading and it
> saving with Django admin interface.
>
> Steps to trace the issue :-
>
> 1. When i was uploaded/(browse) and saved an Article with an image
> (.jpg) , for the first time it saves perfectly
>as follows (smedia/images/misc/sample.jpg)
> 2. For the second time i have tried to update some textual contents in
> the article and saves once again through the same admin interface ,
> but this time image get saved as follows (smedia/images/misc/
> sample_1.jpg)
>
> Issue :-
> It cause an image duplication in respective folder and also an error
> when page/template is rendered through browser.
>
> Can any one please suggest a method to avoid the duplication of image
> on updating the existing one.
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Unable to view results page of polls tutorial

2012-05-18 Thread First Rock
hi al
almost done with the django tutorial#4.. But my app doesnt use the
html pages, n doesnt load the radio buttons and results page.. Other
than those the app is displayed in the default template and shows al
the pages of groups users n polls.. i have placed the html templates
in templates directory which is in my app polls directory.. here is my
views file..

pls help..
thnx in advance..


# Create your views here.
from django.template import Context, loader
#from polls.models import Poll
from django.http import Http404
from django.http import HttpResponse
from django.template import RequestContext
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from polls.models import Choice, Poll
#def index(request):
#latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
#return render_to_response('polls/index.html', {'latest_poll_list':
latest_poll_list})
def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
t = loader.get_template('/home/hdp/mysite/polls/templates/polls/
index.html')
c = Context({
'latest_poll_list': latest_poll_list,
})
return HttpResponse(t.render(c))
#def detail(request, poll_id):
#try:
#p = Poll.objects.get(pk=poll_id)
#except Poll.DoesNotExist:
#raise Http404
#return render_to_response('polls/detail.html', {'poll': p})
#def detail(request, poll_id):
#return HttpResponse("You're looking at poll %s." % poll_id)
#def detail(request, poll_id):
#p = get_object_or_404(Poll, pk=poll_id)
#return render_to_response('polls/detail.html', {'poll': p})
def detail(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/detail.html', {'poll': p},
 
context_instance=RequestContext(request))
def results(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/results.html', {'poll': p})
#def vote(request, poll_id):
#return HttpResponseRedirect(reverse('poll_results',
args=(p.id,)))
 #return HttpResponse("You're voting on poll %s." % poll_id)
def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the poll voting form.

return render_to_response('polls/detail.html', {
'poll': p,
'error_message': "You didn't select a choice.",
}, context_instance=RequestContext(request))
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully
dealing
# with POST data. This prevents data from being posted twice
if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls.views.results',
args=(p.id,)))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Add Language menu in Admin

2012-05-18 Thread BadStorm

Hi,
I want to add a language value to my model, to permit to user the 
ability to add content in different languages that I configurated in the 
setting.py.


If my model is defined like this:

model.py


class News(models.Model):
content = models.TextField()
language = ??

---

What I must write in model.py to add a language dropdown list?

Thanks

Marco

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problem at activating the admin site (Django tutorial part 2)

2012-05-18 Thread Ravi Shakya
I am also facing the exact problem indicated by pasztilla.
My usernaleme thing is fine (normal) but I have not been able to fix this 
issue.
Any concrete cause/solution to this?

On Friday, August 26, 2011 3:35:39 AM UTC+5:45, pasztilla wrote:
>
> Hi Babatunde, 
>
> Hi Babatunde, 
>
>
>
> SITE_ID == 1 
>
>
>
> then I did what you've suggested:(see the result) 
>
>
>
> Microsoft Windows [verziószám: 6.1.7601] 
>
> Copyright (c) 2009 Microsoft Corporation. 
> Minden jog fenntartva. 
>
>
>
> C:\Users\Pászkán Attila> 
>
>
> D:\>cd Atilla\Programoz\Django\Gyakorlaas\mysite 
>
>
> D:\Atilla\Programoz\Django\Gyakorlaas\mysite>python manage.py shell 
>
>
> Python 2.7.1 (r271:86832, Feb  7 2011, 11:30:38)[MSC v.1500 32 bit 
> (Intel)] on win32 
>
> Type "help", "copyright", "credits" or "license" for more information. 
> (InteractiveConsole) 
>
>
> >>> from django.contrib.sites.models import Site 
>
> >>> Site.objects.get(id=1) 
>
>
> Traceback (most recent call last): 
>
>   File "", line 1, in  
>
>   File "D:\Python27\lib\site-packages\django\db\models\manager.py", 
> line 132, in get 
>
> return self.get_query_set().get(*args, **kwargs) 
>
>   File "D:\Python27\lib\site-packages\django\db\models\query.py", line 
> 349, in get 
>
> % self.model._meta.object_name) 
>
> DoesNotExist: Site matching query does not exist. 
>
>
> >>> 
>
>
>
>
>
>  +  
>
> Meanwhile came an idea that this error could have slyly, 
> somehow undercover, something to do with my User Name (under Windows) 
> which contains some unusual characters (two á-s, see above) ... 
> I've set up a new user (without unusual characters) 
> and repeated the whole procedure (building up an application 
> according to the tutorial) and it worked fine!!! :-) 
>
>
> So, seemingly the problem has been resolved! :-) 
> (It would be interesting to find out why and how 
> has influenced that unusual user name the functioning 
> of my admin-site...but it is maybee to much effort to investigate) 
>
> Anyway,  thanks for your efforts and support! 
>
> PA 
>
>
> On aug. 25, 19:28, Babatunde Akinyanmi  wrote: 
> > Hi paszkan, 
> > First I want you to go to your settings file and tell me what value is 
> > specified for SITE_ID. You will need that value for the next step. 
> > 
> > In your terminal where you would have typed "python manage.py 
> > runserver" type "python manage.py shell" 
> > 
> > Doing that would load django's inbuilt shell. 
> > 
> > Next type: 
> > "from django.contrib.sites.models import Site" 
> > If there's no error type this is where you would need the SITE_ID 
> > setting value. Assuming SITE_ID value is 1 then type: 
> > "Site.objects.get(id=1)" 
> > 
> > Do this and give feed back 
> > 
> > On 8/25/11, Pászkán Attila  wrote: 
> > 
> > 
> > 
> > > Can you give more details? 
> > 
> > > 2011/8/25 Babatunde Akinyanmi  
> > 
> > >> The error you stated normally happens when there are problems with 
> the 
> > >> django_site table created when you start a project. 
> > 
> > >> On 8/25/11, Babatunde Akinyanmi  wrote: 
> > >> > Please say exactly what you did. It will be easier to help that way 
> > 
> > >> > On 8/25/11, raj  wrote: 
> > >> >> In ur urls.py, 
> > >> >> Did u import admin, make it discoverable, and also uncomment the / 
> > >> >> admin/ url? 
> > >> >> Also, make sure that you syncdb by running python manage.py 
> syncdb. 
> > >> >> Lemme know if that helps :) 
> > >> >> On Aug 25, 9:29 am, pasztilla  wrote: 
> > >> >>> Hi there, 
> > >> >>> I'm just trying to accomodate myself with Django - and so I tried 
> to 
> > >> >>> go through the Django Tutorial from the Django official site. 
> There 
> > >> >>> went everything ok with part 1,  but at the very beginning of the 
> part 
> > >> >>> 2 I've met a problem(https://docs.djangoproject.com/en/1.3/intro/ 
> > >> >>> tutorial02). In spite of that I've perform all settings/changes 
> > >> >>> described in the 'Activate the admin site' section going to the 
> next 
> > >> >>> section 'Start the development server' (ie. 127.0.0.1:8000/admin/) 
> led 
> > >> >>> merely to an error message: 
> > 
> > >> >>> "DoesNotExist at /admin/ 
> > >> >>> Site matching query does not exist. 
> > >> >>> Request Method: 
> > >> >>> GET 
> > >> >>> Request URL:http://127.0.0.1:8000/admin/ 
> > >> >>> Django Version: 
> > >> >>> 1.3 
> > 
> > >> >>> Exception Type: 
> > >> >>> DoesNotExist 
> > 
> > >> >>> Exception Value: 
> > >> >>> Site matching query does not exist. 
> > 
> > >> >>> Exception Location: 
> > 
> > >> >>> D:\Python27\lib\site-packages\django\db\models\query.py in get, 
> line 
> > >> >>> 349 
> > 
> > >> >>> Python Executable: 
> > >> >>> D:\Python27\python.exe 
> > 
> > >> >>> Python Version: 
> > >> >>> 2.7.1" 
> > 
> > >> >>> [...] 
> > >> >>> and something more: 
> > 
> > >> >>> "Settings 
> > >> >>> Using settings module mysite.settings 
> > 
> > >> >>> Setting 
> > >> >>> Value 
> > 
> > >> >>> USE_L10N 
> > >> >>> True 
> > 
> > >> >>> USE_THOUSAND_SEPARATOR 

Re: where do you host your django app and how to you deploy it?!

2012-05-18 Thread Cal Leeming [Simplicity Media Ltd]
I know this is an old thread, but I feel obliged to comment.

Some of our legacy clients used DreamHost for their django/python apps..
Then dreamhost decided their VPS's needed a software and hardware upgrade,
which resulted in lost data, 4-ish days of downtime, numerous server config
inconsistencies  which were impossible to repair without resetting the VPS,
and a whole bunch of other problems.

Dreamhost have been absolutely terrible on every experience we had with
them with multiple clients, and I would STRONGLY advice saying away from
them.

Do remember, although they say they support Django, it is actually NOT
supported, and it clearly states so in their wiki documentation.

http://wiki.dreamhost.com/Passenger_WSGI


The instructions provided in this article or section are considered
advanced.
You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes may cause this to break. Be prepared to troubleshoot this
yourself if this happens.
*We seriously aren't kidding about this.*



On top of this, I am yet to come across a decent django specific host
(there's plenty out there, but none that I would consider recommending at
this time).

If you have the relevant devops skills, then I'd recommend either linode or
rackspace cloud and just build your own stack with nginx/uwsgi/supervisord.

Cal

On Wed, Apr 4, 2012 at 2:24 PM, Dan Gentry  wrote:

> Dreamhost shared account
>
> http://dashdrum.com/blog/2011/08/django-on-dreamhost/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: where do you host your django app and how to you deploy it?!

2012-05-18 Thread azizmb.in
Im very happy with webfaction . Its a great shared
host. It is a tad bit expensive, but the service is awesome. Have used it
for multiple projects, with no complaints.

As for deployments, Ive been playing around using fabric, there is
also a project
on github  with
deployment scripts for webfaction, but I havent had much success.

On Fri, May 18, 2012 at 5:48 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> I know this is an old thread, but I feel obliged to comment.
>
> Some of our legacy clients used DreamHost for their django/python apps..
> Then dreamhost decided their VPS's needed a software and hardware upgrade,
> which resulted in lost data, 4-ish days of downtime, numerous server config
> inconsistencies  which were impossible to repair without resetting the VPS,
> and a whole bunch of other problems.
>
> Dreamhost have been absolutely terrible on every experience we had with
> them with multiple clients, and I would STRONGLY advice saying away from
> them.
>
> Do remember, although they say they support Django, it is actually NOT
> supported, and it clearly states so in their wiki documentation.
>
> http://wiki.dreamhost.com/Passenger_WSGI
>
> 
> The instructions provided in this article or section are considered
> advanced.
> You are expected to be knowledgeable in the UNIX shell.
> Support for these instructions is not available from DreamHost tech
> support.
> Server changes may cause this to break. Be prepared to troubleshoot this
> yourself if this happens.
> *We seriously aren't kidding about this.*
>
> 
>
> On top of this, I am yet to come across a decent django specific host
> (there's plenty out there, but none that I would consider recommending at
> this time).
>
> If you have the relevant devops skills, then I'd recommend either linode
> or rackspace cloud and just build your own stack with
> nginx/uwsgi/supervisord.
>
> Cal
>
> On Wed, Apr 4, 2012 at 2:24 PM, Dan Gentry  wrote:
>
>> Dreamhost shared account
>>
>> http://dashdrum.com/blog/2011/08/django-on-dreamhost/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
- Aziz M. Bookwala

Website  | Twitter  |
Github 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Struggling with formsets

2012-05-18 Thread David
Given 2 models:

class Person(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)

class PersonAttendance(models.Model):
person = models.ForeignKey(Person)
attend_date = models.DateField()

I need to produce a formset that lists all Person(s) and their 
PersonAttendance if it has been entered, and blank fields for Persons that 
have no PersonAttendance related record so their attendance can be filled 
in.

In SQL I guess this would be achieved using a LEFT JOIN on Person, but I 
can't work out how to get this working with the ORM and Django Formsets.

Any help would be greatly appreciated, I've been stumped on this for ages.

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/2dRj9IjQwO4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



alternative to .values(*fieldnames)

2012-05-18 Thread Sells, Fred
I'm using Django 1.3 but plan toupgrade to 1.4 later this month.  I
generally return XML which is consumed by a Flex HttpService in the
client so I only use the django template to  convert a dictionary to
XML.  My application is strictly intranet with limited data and users so
efficiency considerations are minimal.  While I'm adequate with Django,
I'm far from an expert and I wanted to see if there is a better way to
achieve my objective.

 

In my current application I'm finding a common pattern where I need to
do a select_related() and return a list of dictionaries with only a
subset of the fields, preferably with simpler names that are typical in
the default behavior.  Thus in my model, a field name could be
"appointment__patient__order__action"  while I would prefer the simpler
name of "action" be passed to the client.  The standard use of the
.values(*args) does not meet my needs because it does not allow me to
convert field names.

 

I find myself doing a select_related().values()  and then later  using a
for loop to extract/rename the fields of interest.  I use the same
template to return xml for all queries that return "table-like" data.

 

I am considering defining multiple dictionaries that I would use to
rename/extract only the desired fields such as:

Mymap = dict(action="appointment__patient__order__action"  ,
fname="appointment__patient__fname", ...

 

Thus I would return a list of dictionaries  containing only the  fields
that had the corresponding dictionary value and the dictionary key would
be the one in Mymap using a snippet like...

 

(please ignore capitalization inconsistencies, Outlook just insists on
doing this)

 

Values  = models.Appointment.objects.select_related().filter(x=1,
...).values()

 

And later

Results = [ ]

For value in values:

Improved = { }

For (newname, oldname) in Mymap.items():

Improved[newname] = value[oldname]

Results.append(Improved)

 

I see two ways to implement this:

a)  Since the name map is really specific to the model being used, I
would embed it in that model as a class (or perhaps meta) object and
also create my own abstract model class that all my "real" models would
inherit from so I could embed the mapping inside the model.

b)  In order to isolate business logic from client api, I could do
all the mapping in the views.py class and have the business logic not be
aware of which fields were actually required.

 

 

 

 

 

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to serve staticfiles with full URL for local development?

2012-05-18 Thread pedesen
I have a similar problem. My STATIC_URL is a full URL like 
http://static.mysite.com. When I use the development server with runserver, 
django *always* takes this URL. In the templates I use 
{{STATIC_URL}}/myimage.jpg, and in development I always 
see http://static.mysite.com/myimage.jpg in my browser. When I add a static 
file in development it doesn't yet exist in the production static server...

I couldn't find a way to fix this, except serving my static files at 
www.mysite.com/static/ instead of http://static.mysite.com. But this is 
just a workaround and no solution to the rpoblem for me. Maybe anyone has 
an idea.

Am Montag, 14. Mai 2012 15:29:07 UTC+2 schrieb Reinout van Rees:
>
> On 11-05-12 08:48, e.generalov wrote: 
> > ps: but why these restrictions are needed in the tool, which should 
> > assist in the development? 
>
> I think you're using it in a strange way, as I (nor anyone I know that 
> uses django-staticfiles) has any problem in development. 
>
> You said in a reply to one of my messages something about "needing a 
> full path name '/tmp/' for saved pages". What did you mean by that? 
> Such a full path is different from a proper localhost:8000 url. 
>
>
> Reinout 
>
> -- 
> Reinout van Reeshttp://reinout.vanrees.org/ 
> rein...@vanrees.org http://www.nelen-schuurmans.nl/ 
> "If you're not sure what to do, make something. -- Paul Graham" 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/IFRod3AkcCQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Struggling with formsets

2012-05-18 Thread pedesen
For this case inline-formsets should be the way to go: 
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets
But I think this will work for a particular person, but not for multiple 
persons...

Am Freitag, 18. Mai 2012 15:27:05 UTC+2 schrieb David:
>
> Given 2 models:
>
> class Person(models.Model):
> first_name = models.CharField(max_length=255)
> last_name = models.CharField(max_length=255)
>
> class PersonAttendance(models.Model):
> person = models.ForeignKey(Person)
> attend_date = models.DateField()
>
> I need to produce a formset that lists all Person(s) and their 
> PersonAttendance if it has been entered, and blank fields for Persons that 
> have no PersonAttendance related record so their attendance can be filled 
> in.
>
> In SQL I guess this would be achieved using a LEFT JOIN on Person, but I 
> can't work out how to get this working with the ORM and Django Formsets.
>
> Any help would be greatly appreciated, I've been stumped on this for ages.
>
> Thank you
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/aZuOiHNhGcEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Struggling with formsets

2012-05-18 Thread David
Thanks Pedesen for your reply.

I have tried inline-formsets and as you say unfortunately I could only get 
it to work with a single object.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LVLBaUUdY8MJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django in mobile devices

2012-05-18 Thread Phang Mulianto
HI all,

i recently see rhomobile.com , which running ruby in mobile devices, and
phonegap which use javascript.

do anyone aware of the equivalent python / django can be used for mobile
devices..

i am thinking about create app for the mobile client using web technology
without go deeper in java.

any comment appreciated.


Thanks,

Mulianto

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Does Django guarantees to generate well Optimized SQL Query ??

2012-05-18 Thread shariq
Hi,
I am writing an Django application.
This project need to be very efficient and well optimized.

I am very much concern about SQL-Query performance. I am using
postgreSQL.

I want to know whether Django Guarantees to generate well optimized
SQL-Query ???


Thanks

Shariq

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



What persists in memory across requests?

2012-05-18 Thread Ken J
Howdy,

I'm quite curious as to what persists in memory across requests in
terms of django application variables.  I'm currently running a django
app in mod_wsgi daemon mode.

Because of performance concerns when dealing with large numbers of
concurrent requests, I wanted to modify django to keep persistent DB
connections to Postgres using a connection pool.

This in turn got me wondering, how can I persist a thread pool, or
even a simple DB connection, across requests?  I realize anything that
is global to the wsgi entry point script will persist.  The current
wsgi entry point I'm using is something like:

import django.core.handlers.wsgi

_application = django.core.handlers.wsgi.WSGIHandler()

def application(environ, start_response):
return _application(environ, start_response)

Obviously _application will remain, but since code modules are
dynamically loaded based on URL resolvers, would the view/model/db
connection not be destroyed once the variables referencing said
objects go out of scope?

>From logging statements, it has become apparent I can in fact make DB
connections persistent simply by not closing the DB connection after
the request has finished.  Unfortunately, I also found this to slowly
leak socket connections to the DB eventually making it so that I can't
log into the DB, hence why I was looking into a connection pool.

Anyways, I was hoping someone could shed some light as to the
internals of python/django on why django/db/__init__.py is able to
reference persistent connections.

My best guess is that because

connections = ConnectionHandler(settings.DATABASES)

is at the top level of a module, it remains held within the python
interpreter after being imported, thus holding a reference.

Any insight would be greatly appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Does Django guarantees to generate well Optimized SQL Query ??

2012-05-18 Thread George Silva
Yes and no.

Django provide mechanisms that you will minimize hits to the database.
Check for select_related function for example.

George

On Fri, May 18, 2012 at 1:00 PM, shariq  wrote:

> Hi,
> I am writing an Django application.
> This project need to be very efficient and well optimized.
>
> I am very much concern about SQL-Query performance. I am using
> postgreSQL.
>
> I want to know whether Django Guarantees to generate well optimized
> SQL-Query ???
>
>
> Thanks
>
> Shariq
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
George R. C. Silva

Desenvolvimento em GIS
http://geoprocessamento.net
http://blog.geoprocessamento.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Does Django guarantees to generate well Optimized SQL Query ??

2012-05-18 Thread Thomas Lockhart

On 5/18/12 10:02 AM, George Silva wrote:

Yes and no.
And it does not (can not) protect one from building a bad model which 
could result in bad performance. So having a requirement for high 
performance without having done some reading on data normalization and 
SQL schema design probably gets the new user out of the "guaranteed 
well-optimized" realm.


One should also know how to work with the underlying database to 
evaluate and update the optimizer information otherwise the optimizer 
might make bad guesses for an otherwise perfectly good query.


hth

   - Tom

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



JQuery .get new url is not updating the page

2012-05-18 Thread furqanmlk
Hi there,

I implemented the JQuery to get the data from Database server and display 
in the form of table on the page when user click one of the DOM element.
I tried ,

*JQuery Code:*
$.get("RunId_TestCases",{Variable:Value},function(data){


Passed_TestCases = data['Data1'];
Failed_TestCases = data['Data2'];
//window.location.hash = this.url
   //window.location.assign(this.url)

});

*View.py*
def RunId_TestCases(request)

RunId = request.GET.get('ClickedRunId','')

#Some python Code to process data
results = {Data1:foo1,Data2:foo2}
json = simplejson.dumps(results)
   return HttpResponse(json, mimetype='application/json') 

*url.py*
url(r'^Home/.*/RunId_TestCases/$', RunId_TestCases)

using window.location browser url gets changed but page goes to empty page 
with data values.


Can you please help to solve this issue.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/fOxSNleyFnYJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django 1.3 online documentation ... error? ... quibble?

2012-05-18 Thread Kevin Cole
Hi,

I'm once again attacking the Django with vigor. And THIS time, I've 
actually got some forward momentum and am approximating progress! Yay! ;-)

In reading "Creating forms from models" 
(https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/) I note the 
mention of a model field called PhoneNumberField.  However. searching all 
the model documentation, I find no such mention of that field type.  In 
fact, a search of the term results in only two hits: the aforementioned 
page, and "The local flavor add-ons" page 
(https://docs.djangoproject.com/en/1.3/ref/contrib/localflavor/)

So, is there such a model field, and if so, where is it documented?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/y6yozCDgTFcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: where do you host your django app and how to you deploy it?!

2012-05-18 Thread francescortiz
I use django europe, cheap shared hosting with a good setup with lighttpd 
by default, but you can set up any server you want compiling it.

On Monday, April 2, 2012 12:48:24 PM UTC+2, fix3d wrote:
>
> Where do you host your django app and how to you deploy it?! 
>
> Please share personal exp.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/isJWANfbG8oJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



from django.http import HttpResponse: Unresolved Import. why ?

2012-05-18 Thread doniyor
hey guys, 

i am getting this error when i try to write my view. 

when i import this, from django.http import HttpResponse, the word 
HttpResponse is red error. Unresolved Import: HttpResponse. 

i dont understand why. i am using python 2.7 and django1.4. what i did 
before this is, i changed from django1.3 to django1.4. 

thanks for help 

doni 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/-cV9hoJd5I4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What persists in memory across requests?

2012-05-18 Thread akaariai
On May 18, 7:54 pm, Ken J  wrote:
> I'm quite curious as to what persists in memory across requests in
> terms of django application variables.  I'm currently running a django
> app in mod_wsgi daemon mode.
>
> Because of performance concerns when dealing with large numbers of
> concurrent requests, I wanted to modify django to keep persistent DB
> connections to Postgres using a connection pool.
>
> This in turn got me wondering, how can I persist a thread pool, or
> even a simple DB connection, across requests?  I realize anything that
> is global to the wsgi entry point script will persist.  The current
> wsgi entry point I'm using is something like:
>
> import django.core.handlers.wsgi
>
> _application = django.core.handlers.wsgi.WSGIHandler()
>
> def application(environ, start_response):
>     return _application(environ, start_response)
>
> Obviously _application will remain, but since code modules are
> dynamically loaded based on URL resolvers, would the view/model/db
> connection not be destroyed once the variables referencing said
> objects go out of scope?
>
> From logging statements, it has become apparent I can in fact make DB
> connections persistent simply by not closing the DB connection after
> the request has finished.  Unfortunately, I also found this to slowly
> leak socket connections to the DB eventually making it so that I can't
> log into the DB, hence why I was looking into a connection pool.
>
> Anyways, I was hoping someone could shed some light as to the
> internals of python/django on why django/db/__init__.py is able to
> reference persistent connections.
>
> My best guess is that because
>
> connections = ConnectionHandler(settings.DATABASES)
>
> is at the top level of a module, it remains held within the python
> interpreter after being imported, thus holding a reference.
>
> Any insight would be greatly appreciated.

First, you should look into external connection poolers. PgBouncer is
excellent if you need just a connection pool. Pg-pool II is another
option, but it provides way more than just a connection pool.

If you would like to implement a connection pool in Python code, it
isn't the easiest thing to do. If you are using Django 1.4, then the
connections object will be thread local - that is, it provides a
different connection for each thread. Note that if you are using
multiple processes (instead of threads) then the processes share
nothing between each other. This is the reason you should look for
external poolers - they can see all connection attempts
simultaneously, but Python poolers are restricted to seeing one
processes at a time.

Still, if you want to experiment on poolers in Python code, I have
written a couple of attempts for a connection pool you can use as
bases of your work. https://github.com/akaariai/django-psycopg-pooled
and https://github.com/akaariai/django_pooled.

Short answer from my experiments: you do not want to implement
connection pooling in Python, at least if performance is the reason
for pooling. You could however do some other funny things, like
rewriting queries to use prepared statements.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Trying to Edit Existing Post; Can't Get Form to Display

2012-05-18 Thread DF
Newbie question. I have an application where registered users can submit 
stories. The posting and display works great but I wanted users to have the 
ability to edit any of their stories. The goal would be for a user to find 
a list of their stories on their profile page, choose one that they would 
like to edit, and then retrieve the form they initially submitted with the 
current information filled in to make the necessary edits.

I composed a view, url and template to achieve this. The page displays, the 
story number from the url appears in the address bar but the form is 
nowhere to be found. I can't figure out if what I'm doing is an error in 
the template or the view (I'm thinking the former but can't be sure).

Here is the model:

class Story(models.Model):
objects = StoryManager()
title = models.CharField(max_length=100)
topic = models.CharField(max_length=50)
copy = models.TextField()
author = models.ForeignKey(User, related_name="stories")
zip_code = models.CharField(max_length=10)
latitude = models.FloatField(blank=False, null=False)
longitude = models.FloatField(blank=False, null=False)
date = models.DateTimeField(auto_now=True, auto_now_add=True)
pic = models.ImageField(upload_to='pictures', blank=True)
caption = models.CharField(max_length=100)

def __unicode__(self):
return " %s" % (self.title)

Here is the form:

class StoryForm(forms.ModelForm):
class Meta:
model = Story
exclude = ('author',)

def __init__(self, author, *args, **kwargs):
super(StoryForm, self).__init__(*args, **kwargs)
self.author = author


def save(self, commit=True):
self.instance.author = self.author
return super(StoryForm, self).save(commit)

Here are the submit and edit views:

@login_required
def submit_story(request):
story_form = None
if request.method =="POST":
story_form = StoryForm(request.user, data=request.POST, 
files=request.FILES)
if story_form.is_valid():
new_story = story_form.save(commit=True)
return HttpResponseRedirect("/report/all/")

return render_to_response("report/report.html", {'form': story_form or 
StoryForm(request.user) }, context_instance=RequestContext(request))

@login_required
def edit_story (request, story_id):
story_form = None
if story_id:
story_form = get_object_or_404(Story, pk=story_id)
if story_form.author != request.user:
return HttpResponse("You can only edit your own stories!")

if request.method == 'POST':
story_form = StoryForm(request.user, data=request.POST, 
files=request.FILES)
if story_form.is_valid():
story_form.save(commit=True)
return HttpResponse("/profiles/user_profile")
#else:
#story_form = StoryForm(instance=story_form)

return render_to_response('report/storyedit.html', {'form': story_form 
or StoryForm(request.user) }, context_instance=RequestContext(request))


The urls:

url(r'^report/$', 'project.report.views.submit_story', 
name='write_story'),
url(r'^detail/(?P\d*)/edit/$', 
'project.report.views.edit_story', )

And the edit template:

{% extends 'base.html' %}
{% load report %}
{% block page_title %}Edit Story{% endblock %}
{% block headline %}Edit Story{% endblock %}
{% block content %}




Edit your story, {{user.username}}!





{% generic_form form %}







{% endblock %}


This is likely a stupid error but hours of scratching my head led me to 
seek some guidance. Any help welcomed and appreciated. Trying very hard to 
learn.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/arNGcd_FldoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Model design question

2012-05-18 Thread oneroler
Mike, Anssi,

Thank you for your replies.  I will give this a shot and see if I can get 
it to work.

Sam

On Thursday, May 17, 2012 9:59:40 PM UTC-7, akaariai wrote:
>
> On May 18, 5:25 am, oneroler  wrote: 
> > Thanks Mike, that is what I was originally planning to do but realized 
> > there would be situations where that wouldn't do exactly what I wanted. 
> > For example, if there is a business that only has the strategy 
> 'wholesale' 
> > assigned, using ForeignKey would still allow me to assign a different 
> > strategy to a division.  I was hoping to find a solution where the 
> strategy 
> > for a division is constrained by the strategies assigned to its 
> respective 
> > business. 
>
> Django doesn't make this particularly easy. You should create the 
> constraint in the database by using custom SQL, and then constraint 
> the assignable objects in Python in your view code. The Strategy and 
> Business models will create three tables into the database, one of the 
> tables is the many-to-many table. The m2m table's structure should be 
> something like this (check manage.py sqlall output): 
>
> create table business_strategy( 
> id serial primary key, 
> business_id integer references strategy(id), 
> strategy id integer references business(id), 
> unique (business_id, strategy_id) 
> ) 
>
> Now, what you need to do is create a foreign key pointing to 
> business_id, strategy_id for your division table. The model should 
> look like this: 
>
> class Division(models.Model): 
> business = models.ForeignKey(Business) 
> name = models.CharField() 
> strategy = models.ForeignKey(Strategy) 
>
> this creates a table ( 
>  id serial primary key, 
>  business_id integer references business(id), 
>  name varchar(n), 
>  strategy_id integer references strategy(id), 
> ) 
>
> You will need to drop the strategy_id -> strategy(id) foreign key by 
> hand and add a new one: business_id, strategy_id -> 
> business_strategy(business_id, strategy_id). Check your database 
> vendors docs for details how to do this. You will want this constraint 
> to be deferred if available on your DB. 
>
> So, now you should have correct constraint in the database. You will 
> still have some problems: changing division's business changes the set 
> of available strategies. On UI side you will probably need to create 
> an AJAX call on business changed to fetch the available strategies. In 
> forms code you will need to do something like this: 
>
> class DivisionForm(forms.ModelForm): 
> class Meta: 
>   model = Division 
> def __init__(self, **kwargs): 
>   # Note, intentionally restrict the forms usage to only 
> kwargs. 
>   super(DivisionForm, self).__init__(**kwargs) 
>   business_id = None 
>   if 'initial' in kwargs: 
>   business_id = kwargs['initial'].business_id 
>   if 'data' in kwargs and 'business_id' in kwargs['data']: 
>   business_id = kwargs['data']['business_id'] 
>   self.fields['strategy'].queryset = 
> Strategy.objects.filter(business_set=business_id) 
>
> So, the restriction should be doable both in DB and Django, but isn't 
> trivial to do. The above is pseudo-code style, so the example code 
> will likely not work by copy-pasting... 
>
>  - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/JdPApZhO6x8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Trying to Edit Existing Post; Can't Get Form to Display

2012-05-18 Thread Jonathan Baker
The lines:
#else:
#story_form = StoryForm(instance=story_form)
...appear to be handling the GET request, and they're commented out.

On Fri, May 18, 2012 at 3:22 PM, DF  wrote:

> Newbie question. I have an application where registered users can submit
> stories. The posting and display works great but I wanted users to have the
> ability to edit any of their stories. The goal would be for a user to find
> a list of their stories on their profile page, choose one that they would
> like to edit, and then retrieve the form they initially submitted with the
> current information filled in to make the necessary edits.
>
> I composed a view, url and template to achieve this. The page displays,
> the story number from the url appears in the address bar but the form is
> nowhere to be found. I can't figure out if what I'm doing is an error in
> the template or the view (I'm thinking the former but can't be sure).
>
> Here is the model:
>
> class Story(models.Model):
> objects = StoryManager()
> title = models.CharField(max_length=100)
> topic = models.CharField(max_length=50)
> copy = models.TextField()
> author = models.ForeignKey(User, related_name="stories")
> zip_code = models.CharField(max_length=10)
> latitude = models.FloatField(blank=False, null=False)
> longitude = models.FloatField(blank=False, null=False)
> date = models.DateTimeField(auto_now=True, auto_now_add=True)
> pic = models.ImageField(upload_to='pictures', blank=True)
> caption = models.CharField(max_length=100)
>
> def __unicode__(self):
> return " %s" % (self.title)
>
> Here is the form:
>
> class StoryForm(forms.ModelForm):
> class Meta:
> model = Story
> exclude = ('author',)
>
> def __init__(self, author, *args, **kwargs):
> super(StoryForm, self).__init__(*args, **kwargs)
> self.author = author
>
>
> def save(self, commit=True):
> self.instance.author = self.author
> return super(StoryForm, self).save(commit)
>
> Here are the submit and edit views:
>
> @login_required
> def submit_story(request):
> story_form = None
> if request.method =="POST":
> story_form = StoryForm(request.user, data=request.POST,
> files=request.FILES)
> if story_form.is_valid():
> new_story = story_form.save(commit=True)
> return HttpResponseRedirect("/report/all/")
>
> return render_to_response("report/report.html", {'form': story_form or
> StoryForm(request.user) }, context_instance=RequestContext(request))
>
> @login_required
> def edit_story (request, story_id):
> story_form = None
> if story_id:
> story_form = get_object_or_404(Story, pk=story_id)
> if story_form.author != request.user:
> return HttpResponse("You can only edit your own stories!")
>
> if request.method == 'POST':
> story_form = StoryForm(request.user, data=request.POST,
> files=request.FILES)
> if story_form.is_valid():
> story_form.save(commit=True)
> return HttpResponse("/profiles/user_profile")
> #else:
> #story_form = StoryForm(instance=story_form)
>
> return render_to_response('report/storyedit.html', {'form': story_form
> or StoryForm(request.user) }, context_instance=RequestContext(request))
>
>
> The urls:
>
> url(r'^report/$', 'project.report.views.submit_story',
> name='write_story'),
> url(r'^detail/(?P\d*)/edit/$',
> 'project.report.views.edit_story', )
>
> And the edit template:
>
> {% extends 'base.html' %}
> {% load report %}
> {% block page_title %}Edit Story{% endblock %}
> {% block headline %}Edit Story{% endblock %}
> {% block content %}
>
> 
> 
> 
> Edit your story, {{user.username}}!
> 
>
>  enctype="multipart/form-data">
>
> 
> {% generic_form form %}
> 
> 
> 
> 
> 
> 
> 
> {% endblock %}
>
>
> This is likely a stupid error but hours of scratching my head led me to
> seek some guidance. Any help welcomed and appreciated. Trying very hard to
> learn.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/arNGcd_FldoJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django

Re: What persists in memory across requests?

2012-05-18 Thread Ken J
Thanks for the suggestions.

I have been using pgbouncer for awhile, and while it helps with the
issue of setup/tear down of postgres processes, it still leaves the
overhead of a socket setup/tear down between the django app and the
pgbouncer process.  Because almost every django request I have uses
the DB, I don't mind "wasting" a DB connection on the few that don't
touch the DB.

I dug into the django 1.3 code today and found that
BaseDatabaseWrapper is as you say, storing everything in thread local
storage including the db connection.  I also answered my own question
of how modules are cached in python.  Apparently, once a module has
been imported in any way, the module remains loaded, and can be
accessed through sys.modules by any thread if you so choose.  Any
globals defined in any loaded module remain in memory.

At the end of the day, I don't mind if there is simply a 1-to-1
mapping between django threads (spread over multiple processes even),
and DB connections.  I don't wish or requiring pooling strictly, I was
only looking into using a pool to work around the issue I have found
of DB connections being leaked if you disable the db connection close
after every request.  Ultimately, if I could find the source of this
leak, I would be a happy camper.

I know it sounds like I'm screwing around with a case of "premature
optimization" and all, but I've done a good amount of load testing
against our service, with the number of concurrent connections we
expect to see, and persistent DB connections do seem to make a
dramatic difference.  Over the course of tens going on hundreds of
thousands of requests, it can save mins worth of processing time.

On May 18, 1:52 pm, akaariai  wrote:
> On May 18, 7:54 pm, Ken J  wrote:
>
>
>
>
>
>
>
>
>
> > I'm quite curious as to what persists in memory across requests in
> > terms of django application variables.  I'm currently running a django
> > app in mod_wsgi daemon mode.
>
> > Because of performance concerns when dealing with large numbers of
> > concurrent requests, I wanted to modify django to keep persistent DB
> > connections to Postgres using a connection pool.
>
> > This in turn got me wondering, how can I persist a thread pool, or
> > even a simple DB connection, across requests?  I realize anything that
> > is global to the wsgi entry point script will persist.  The current
> > wsgi entry point I'm using is something like:
>
> > import django.core.handlers.wsgi
>
> > _application = django.core.handlers.wsgi.WSGIHandler()
>
> > def application(environ, start_response):
> >     return _application(environ, start_response)
>
> > Obviously _application will remain, but since code modules are
> > dynamically loaded based on URL resolvers, would the view/model/db
> > connection not be destroyed once the variables referencing said
> > objects go out of scope?
>
> > From logging statements, it has become apparent I can in fact make DB
> > connections persistent simply by not closing the DB connection after
> > the request has finished.  Unfortunately, I also found this to slowly
> > leak socket connections to the DB eventually making it so that I can't
> > log into the DB, hence why I was looking into a connection pool.
>
> > Anyways, I was hoping someone could shed some light as to the
> > internals of python/django on why django/db/__init__.py is able to
> > reference persistent connections.
>
> > My best guess is that because
>
> > connections = ConnectionHandler(settings.DATABASES)
>
> > is at the top level of a module, it remains held within the python
> > interpreter after being imported, thus holding a reference.
>
> > Any insight would be greatly appreciated.
>
> First, you should look into external connection poolers. PgBouncer is
> excellent if you need just a connection pool. Pg-pool II is another
> option, but it provides way more than just a connection pool.
>
> If you would like to implement a connection pool in Python code, it
> isn't the easiest thing to do. If you are using Django 1.4, then the
> connections object will be thread local - that is, it provides a
> different connection for each thread. Note that if you are using
> multiple processes (instead of threads) then the processes share
> nothing between each other. This is the reason you should look for
> external poolers - they can see all connection attempts
> simultaneously, but Python poolers are restricted to seeing one
> processes at a time.
>
> Still, if you want to experiment on poolers in Python code, I have
> written a couple of attempts for a connection pool you can use as
> bases of your work.https://github.com/akaariai/django-psycopg-pooled
> andhttps://github.com/akaariai/django_pooled.
>
> Short answer from my experiments: you do not want to implement
> connection pooling in Python, at least if performance is the reason
> for pooling. You could however do some other funny things, like
> rewriting queries to use prepared statements.
>
>  - Anssi

-- 
You received this message be

Re: Trying to Edit Existing Post; Can't Get Form to Display

2012-05-18 Thread DF
Thanks. This worked:

else:
story_form = StoryForm(request.user, instance=story_form)


One problem: it just adds a new version of the story instead of updating 
the previous version. So "editing" just creates multiple versions instead 
of actually editing the existing story.

Is there a way to remedy this?

On Friday, May 18, 2012 5:37:44 PM UTC-4, jondbaker wrote:
>
> The lines:
> #else:
> #story_form = StoryForm(instance=story_form)
> ...appear to be handling the GET request, and they're commented out.
>
> On Fri, May 18, 2012 at 3:22 PM, DF  wrote:
>
>> Newbie question. I have an application where registered users can submit 
>> stories. The posting and display works great but I wanted users to have the 
>> ability to edit any of their stories. The goal would be for a user to find 
>> a list of their stories on their profile page, choose one that they would 
>> like to edit, and then retrieve the form they initially submitted with the 
>> current information filled in to make the necessary edits.
>>
>> I composed a view, url and template to achieve this. The page displays, 
>> the story number from the url appears in the address bar but the form is 
>> nowhere to be found. I can't figure out if what I'm doing is an error in 
>> the template or the view (I'm thinking the former but can't be sure).
>>
>> Here is the model:
>>
>> class Story(models.Model):
>> objects = StoryManager()
>> title = models.CharField(max_length=100)
>> topic = models.CharField(max_length=50)
>> copy = models.TextField()
>> author = models.ForeignKey(User, related_name="stories")
>> zip_code = models.CharField(max_length=10)
>> latitude = models.FloatField(blank=False, null=False)
>> longitude = models.FloatField(blank=False, null=False)
>> date = models.DateTimeField(auto_now=True, auto_now_add=True)
>> pic = models.ImageField(upload_to='pictures', blank=True)
>> caption = models.CharField(max_length=100)
>>
>> def __unicode__(self):
>> return " %s" % (self.title)
>>
>> Here is the form:
>>
>> class StoryForm(forms.ModelForm):
>> class Meta:
>> model = Story
>> exclude = ('author',)
>>
>> def __init__(self, author, *args, **kwargs):
>> super(StoryForm, self).__init__(*args, **kwargs)
>> self.author = author
>>
>>
>> def save(self, commit=True):
>> self.instance.author = self.author
>> return super(StoryForm, self).save(commit)
>>
>> Here are the submit and edit views:
>>
>> @login_required
>> def submit_story(request):
>> story_form = None
>> if request.method =="POST":
>> story_form = StoryForm(request.user, data=request.POST, 
>> files=request.FILES)
>> if story_form.is_valid():
>> new_story = story_form.save(commit=True)
>> return HttpResponseRedirect("/report/all/")
>>
>> return render_to_response("report/report.html", {'form': story_form 
>> or StoryForm(request.user) }, context_instance=RequestContext(request))
>>
>> @login_required
>> def edit_story (request, story_id):
>> story_form = None
>> if story_id:
>> story_form = get_object_or_404(Story, pk=story_id)
>> if story_form.author != request.user:
>> return HttpResponse("You can only edit your own stories!")
>>
>> if request.method == 'POST':
>> story_form = StoryForm(request.user, data=request.POST, 
>> files=request.FILES)
>> if story_form.is_valid():
>> story_form.save(commit=True)
>> return HttpResponse("/profiles/user_profile")
>> #else:
>> #story_form = StoryForm(instance=story_form)
>>
>> return render_to_response('report/storyedit.html', {'form': 
>> story_form or StoryForm(request.user) }, 
>> context_instance=RequestContext(request))
>>
>>
>> The urls:
>>
>> url(r'^report/$', 'project.report.views.submit_story', 
>> name='write_story'),
>> url(r'^detail/(?P\d*)/edit/$', 
>> 'project.report.views.edit_story', )
>>
>> And the edit template:
>>
>> {% extends 'base.html' %}
>> {% load report %}
>> {% block page_title %}Edit Story{% endblock %}
>> {% block headline %}Edit Story{% endblock %}
>> {% block content %}
>>
>> 
>> 
>> 
>> Edit your story, {{user.username}}!
>> 
>>
>> > enctype="multipart/form-data">
>>
>> 
>> {% generic_form form %}
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> {% endblock %}
>>
>>
>> This is likely a stupid error but hours of scratching my head led me to 
>> seek some guidance. Any help welcomed and appreciated. Trying very hard to 
>> learn.
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/arNGcd_FldoJ.

Re: Trying to Edit Existing Post; Can't Get Form to Display

2012-05-18 Thread DF
Thanks. I get this error using that code:

TypeError at /report/detail/30/edit/

__init__() takes at least 2 arguments (1 given)

This is referring to this line:

  story_form = StoryForm(instance=story)

I added a "story_id" argument to this, which brought up the form, but when 
I submitted it, it returned the form with errors listing all the fields as 
empty.

This is far trickier than I thought.



On Friday, May 18, 2012 7:01:25 PM UTC-4, jondbaker wrote:
>
> Hmmm... I don't think you need to pass 'request.user' in as an argument. 
> Also, you want to be sure that the 'instance' you pass as an argument to 
> the model form is the model record you want to update. For instance:
>
> def edit_story(request, story_id)
> story = get_object_or_404(Story, pk=story_id)
> if request.method == 'POST':
> story_form = StoryForm(request.POST, request.FILES, instance=story)
> if story_form.is_valid():
> story_form.save()
> return HttpResponseRedirect("/profiles/user_profile")
> else: # GET request
> story_form = StoryForm(instance=story)
> return render_to_response('report/storyedit.html', {'form': 
> story_form}, context_instance=RequestContext(request))
>
>
>
> On Fri, May 18, 2012 at 4:52 PM, DF  wrote:
>
>> Thanks. This worked:
>>
>> else:
>> story_form = StoryForm(request.user, instance=story_form)
>>
>>
>> One problem: it just adds a new version of the story instead of updating 
>> the previous version. So "editing" just creates multiple versions instead 
>> of actually editing the existing story.
>>
>> Is there a way to remedy this?
>>
>> On Friday, May 18, 2012 5:37:44 PM UTC-4, jondbaker wrote:
>>>
>>> The lines:
>>> #else:
>>> #story_form = StoryForm(instance=story_form)
>>> ...appear to be handling the GET request, and they're commented out.
>>>
>>> On Fri, May 18, 2012 at 3:22 PM, DF  wrote:
>>>
 Newbie question. I have an application where registered users can 
 submit stories. The posting and display works great but I wanted users to 
 have the ability to edit any of their stories. The goal would be for a 
 user 
 to find a list of their stories on their profile page, choose one that 
 they 
 would like to edit, and then retrieve the form they initially submitted 
 with the current information filled in to make the necessary edits.

 I composed a view, url and template to achieve this. The page displays, 
 the story number from the url appears in the address bar but the form is 
 nowhere to be found. I can't figure out if what I'm doing is an error in 
 the template or the view (I'm thinking the former but can't be sure).

 Here is the model:

 class Story(models.Model):
 objects = StoryManager()
 title = models.CharField(max_length=**100)
 topic = models.CharField(max_length=**50)
 copy = models.TextField()
 author = models.ForeignKey(User, related_name="stories")
 zip_code = models.CharField(max_length=**10)
 latitude = models.FloatField(blank=False, null=False)
 longitude = models.FloatField(blank=False, null=False)
 date = models.DateTimeField(auto_now=**True, auto_now_add=True)
 pic = models.ImageField(upload_to='**pictures', blank=True)
 caption = models.CharField(max_length=**100)

 def __unicode__(self):
 return " %s" % (self.title)

 Here is the form:

 class StoryForm(forms.ModelForm):
 class Meta:
 model = Story
 exclude = ('author',)

 def __init__(self, author, *args, **kwargs):
 super(StoryForm, self).__init__(*args, **kwargs)
 self.author = author


 def save(self, commit=True):
 self.instance.author = self.author
 return super(StoryForm, self).save(commit)

 Here are the submit and edit views:

 @login_required
 def submit_story(request):
 story_form = None
 if request.method =="POST":
 story_form = StoryForm(request.user, data=request.POST, 
 files=request.FILES)
 if story_form.is_valid():
 new_story = story_form.save(commit=True)
 return HttpResponseRedirect("/report/**all/")

 return render_to_response("report/**report.html", {'form': 
 story_form or StoryForm(request.user) }, context_instance=**
 RequestContext(request))

 @login_required
 def edit_story (request, story_id):
 story_form = None
 if story_id:
 story_form = get_object_or_404(Story, pk=story_id)
 if story_form.author != request.user:
 return HttpResponse("You can only edit your own stories!")

 if request.method == 'POST':
 story_form = StoryForm(request.user, data=request.POST, 
 files=request.FILES)
 if story_form.

Re: Template: Foreign Key

2012-05-18 Thread Fady Kamal
it's not working with me

On Tuesday, June 30, 2009 10:43:15 AM UTC+2, russelson wrote:
>
> Hi, 
>
> I'm new to django 
>
> I have two models 
>
> #models.py 
>
> class House(models.Model): 
> name = models.CharField(blank=True, max_length=50) 
>
> class People(models.Model): 
> name = models.CharField(blank=True, max_length=50) 
> house = models.ForegnKey(House) 
>
> #views.py 
> def house_list(request): 
> houses = House.objects.all() 
> return render_to_response('test/house_list.html', {'object_list': 
> houses}) 
>
> #house_list.html 
> {% for object in object_list %} 
> {{ object.name }} 
> {{ object.people.name }}   #!?!? 
> {% endfor %} 
>
> How do i retrieve the information in the People model? 
>
> Please advice 
>
> Thanks in advance 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/piLnSG9ycFEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: JQuery .get new url is not updating the page

2012-05-18 Thread Lee Hinde

On May 18, 2012, at 11:52 AM, furqanmlk wrote:

> Hi there,
> 
> I implemented the JQuery to get the data from Database server and display in 
> the form of table on the page when user click one of the DOM element.
> I tried ,
> 
> JQuery Code:
> $.get("RunId_TestCases",{Variable:Value},function(data){
> 
> 
> Passed_TestCases = data['Data1'];
> Failed_TestCases = data['Data2'];
> //window.location.hash = this.url
>//window.location.assign(this.url)


not knowing anything about the page, but you want something more like:

$("#ID_FOR_THE_FIELD").val(data['Data1']);

> 
> using window.location browser url gets changed but page goes to empty page 
> with data values.
> 
> 
> Can you please help to solve this issue.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Use Django to implement my GUI!

2012-05-18 Thread Alec Taylor
Dde

That architecture diagram shows exactly your problem.

You are thinking about this problem incorrectly.

- Server: nginx [or whatever] with Django
- Client: web-browser
- Admin:  Client: web-browser

#done

On Fri, May 18, 2012 at 1:36 PM, Eugène Ngontang  wrote:
> Hi Guys!
>
> I've been busy a bit, I'm back to thread with the high level architecture.
> Attached here is a diagram, just to understand what i meant.
>
> Don't pay attention for object I use to describe modules or architecture
> components.
>
> Now you will be able to understand what I mean by the server module, the
> admin module, and the client module of my architecture.
>
> As you could see on the diagram, the admin module is installd on the
> server(where the server module is installed) and is destined to provide
> views to the GUI.
> The clients receive and send data to the server.
> When the admin make some actions, some clients are notifed, and when client
> send informations admin (GUi is notified).
>
> Now two things come in my mind when I was thinking :
>
> - First I could stay in the way I want the server to use HTTP for the admin
> side, and another protocol to communicate with client. In that way the Admin
> Module (Django) will alter and read data from data base. and the server
> module will alter and read data from database. Then each information
> retrievement will lead in reading database since informations could have
> been changed. You can that's really heavy.
>
> - Second do all things in http. Mean that my server is just a web
> application undertanding HTTP (I will the use django for that). The server
> will serve request depending on the type of request, and each client will
> communicate with the server using HTTP.  Then server will define pages/urls
> for admin (to be sent to the GUI), and pages/urls  for clients.
> By this way, the only relation between my modules will be the protocol (HTTP
> for the instance) and they could be implemented in what ever language we
> like. The sever will run asynchronously for admin and clients.
>   The admin will then be just an interface to wich convert data to the right
> display format for the GUI. And the GUI could be any type, and for the web
> interface type I will use DJANGO for my Admin module.
>    I will then also have to develop a http client for my client module.
>
> Actuallu I'm going to take the second choice, since it lets all the charge
> for read and write database to the server, which could run and publish
> informations asynchronously(websocket could help here).
>
> I precise that I'm not a web architect or designer, but i understand
> software architecture. I'm really a system and network engineer, with good
> developpement skill but not to much in web.
>
> Look now my architecture diagram and tell me if what I'm describing in the
> second item fit. And give idea if you have, about libraiies and or framwork
> that could help going fast and easy.
> I thing I will use django and green unicorn.
>
> Thanks for your attention.
>
>
>
> 2012/5/16 Alec Taylor 
>>
>> Oh right, it's just Pyjamas.
>>
>> Still, annoyed I didn't think to recommend it first!
>>
>>
>> On Thu, May 17, 2012 at 12:02 AM, Alec Taylor 
>> wrote:
>> > On Wed, May 16, 2012 at 10:49 PM, Frank Stüss 
>> > wrote:
>> >> or maybe you might have a look at http://pyjs.org/
>> >> which could help you having an event aware client app in your browser.
>> >> Served by and with django.
>> >
>> > I'm impressed
>> >
>> > (just read the exec summary from homepage)
>> >
>> >>
>> >> Am Sonntag, den 13.05.2012, 17:14 +0400 schrieb Alireza Savand:
>> >>> No, i posted django-tastypie not tastypie itself and it's easy to use.
>> >>> Anyway if i'm implementing GUI based i would make it website, since
>> >>> it's an advantages of SaaS.
>> >>> But using client app[desktop-app] and a server-app[django] and having
>> >>> multiply client and ... makes maintaining like a nightmare.
>> >>> All i knew was that, Despite that you asked several question and i
>> >>> just claimed to help in one of them :D
>> >>>
>> >>> On Sun, May 13, 2012 at 4:06 PM, Eugène Ngontang 
>> >>> wrote:
>> >>>         Yes, I can see tastypie is a good service, that even support
>> >>>         REST protocol.
>> >>>
>> >>>         But I'd firt basically implement my gui with django and when i
>> >>>         will master well django, i could use tastypie, and turn my
>> >>>         server to support REST, it will be a good thing.
>> >>>
>> >>>         But please let's keep using only django for the begining.
>> >>>
>> >>>         Thanks.
>> >>>
>> >>>
>> >>>         2012/5/13 Alireza Savand 
>> >>>                 https://github.com/toastdriven/django-tastypie
>> >>>
>> >>>
>> >>>                 On Sunday, May 13, 2012 2:14:36 PM UTC+4, Eugene
>> >>>                 NGONTANG wrote:
>> >>>                         Hi!
>> >>>
>> >>>                         I'm a python developper, but new in django.
>> >>>
>> >>>                         I'm devolopping a m

Re: Use Django to implement my GUI!

2012-05-18 Thread Kurtis Mullins
If you're dead set on using a non-browser GUI for the administration
application, just use the HTTP Protocol for your communications between the
Django Server and whatever Desktop Application you build. However, if you
can just use a web browser for that (even if it's a Qt browser or something
that looks like a desktop application, as others have mentioned) then your
life will be a lot easier.

On Fri, May 18, 2012 at 9:33 PM, Alec Taylor  wrote:

> Dde
>
> That architecture diagram shows exactly your problem.
>
> You are thinking about this problem incorrectly.
>
> - Server: nginx [or whatever] with Django
> - Client: web-browser
> - Admin:  Client: web-browser
>
> #done
>
> On Fri, May 18, 2012 at 1:36 PM, Eugène Ngontang 
> wrote:
> > Hi Guys!
> >
> > I've been busy a bit, I'm back to thread with the high level
> architecture.
> > Attached here is a diagram, just to understand what i meant.
> >
> > Don't pay attention for object I use to describe modules or architecture
> > components.
> >
> > Now you will be able to understand what I mean by the server module, the
> > admin module, and the client module of my architecture.
> >
> > As you could see on the diagram, the admin module is installd on the
> > server(where the server module is installed) and is destined to provide
> > views to the GUI.
> > The clients receive and send data to the server.
> > When the admin make some actions, some clients are notifed, and when
> client
> > send informations admin (GUi is notified).
> >
> > Now two things come in my mind when I was thinking :
> >
> > - First I could stay in the way I want the server to use HTTP for the
> admin
> > side, and another protocol to communicate with client. In that way the
> Admin
> > Module (Django) will alter and read data from data base. and the server
> > module will alter and read data from database. Then each information
> > retrievement will lead in reading database since informations could have
> > been changed. You can that's really heavy.
> >
> > - Second do all things in http. Mean that my server is just a web
> > application undertanding HTTP (I will the use django for that). The
> server
> > will serve request depending on the type of request, and each client will
> > communicate with the server using HTTP.  Then server will define
> pages/urls
> > for admin (to be sent to the GUI), and pages/urls  for clients.
> > By this way, the only relation between my modules will be the protocol
> (HTTP
> > for the instance) and they could be implemented in what ever language we
> > like. The sever will run asynchronously for admin and clients.
> >   The admin will then be just an interface to wich convert data to the
> right
> > display format for the GUI. And the GUI could be any type, and for the
> web
> > interface type I will use DJANGO for my Admin module.
> >I will then also have to develop a http client for my client module.
> >
> > Actuallu I'm going to take the second choice, since it lets all the
> charge
> > for read and write database to the server, which could run and publish
> > informations asynchronously(websocket could help here).
> >
> > I precise that I'm not a web architect or designer, but i understand
> > software architecture. I'm really a system and network engineer, with
> good
> > developpement skill but not to much in web.
> >
> > Look now my architecture diagram and tell me if what I'm describing in
> the
> > second item fit. And give idea if you have, about libraiies and or
> framwork
> > that could help going fast and easy.
> > I thing I will use django and green unicorn.
> >
> > Thanks for your attention.
> >
> >
> >
> > 2012/5/16 Alec Taylor 
> >>
> >> Oh right, it's just Pyjamas.
> >>
> >> Still, annoyed I didn't think to recommend it first!
> >>
> >>
> >> On Thu, May 17, 2012 at 12:02 AM, Alec Taylor 
> >> wrote:
> >> > On Wed, May 16, 2012 at 10:49 PM, Frank Stüss  >
> >> > wrote:
> >> >> or maybe you might have a look at http://pyjs.org/
> >> >> which could help you having an event aware client app in your
> browser.
> >> >> Served by and with django.
> >> >
> >> > I'm impressed
> >> >
> >> > (just read the exec summary from homepage)
> >> >
> >> >>
> >> >> Am Sonntag, den 13.05.2012, 17:14 +0400 schrieb Alireza Savand:
> >> >>> No, i posted django-tastypie not tastypie itself and it's easy to
> use.
> >> >>> Anyway if i'm implementing GUI based i would make it website, since
> >> >>> it's an advantages of SaaS.
> >> >>> But using client app[desktop-app] and a server-app[django] and
> having
> >> >>> multiply client and ... makes maintaining like a nightmare.
> >> >>> All i knew was that, Despite that you asked several question and i
> >> >>> just claimed to help in one of them :D
> >> >>>
> >> >>> On Sun, May 13, 2012 at 4:06 PM, Eugène Ngontang <
> sympav...@gmail.com>
> >> >>> wrote:
> >> >>> Yes, I can see tastypie is a good service, that even support
> >> >>> REST protocol.
> >> >>>
> >> >>> But I'd firt basic

CSRF verification failed. Request aborted.

2012-05-18 Thread plogult...@yahoo.com.cn
I find a code, but the Django version is 0.9, I am using 1.4 and I am
a new learner, I want to run below code but report CSRF verification
failed.

from django.http import HttpResponse

text = """
 + 
 
"""

def index(request):
if request.POST.has_key('a'):
a = int(request.POST['a'])
b = int(request.POST['b'])
else:
a = 0
b = 0
return HttpResponse(text % (a, b, a + b))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Use Django to implement my GUI!

2012-05-18 Thread Kurtis Mullins
>
> My questions are:
> - Can I override the djando admin methods so that i can not only
> customized my views and html page, but also manipulate objects in
> database, so that i can do another action when catching an  event in
> the GUi.


Anything that can be done with Django's Admin interface can be done
programmatically. If you choose to use a custom administration application
(for example, your Desktop Application) then you'll need to provide some
sort of an API over some sort of a Protocol (I vote HTTP). The easiest to
implement, in my opinion, is just using HTTP Methods (POST, GET, DELETE,
etc...) with proper HTTP Responses (200 OK, 404 Missing, etc...) and some
sort of a standard data-format (JSON, XML) as the Response Content when
sending data back and forth.

For example, taking the django admin tutorial, I would like to do and
> action like sending a message the user choose "add a poll". How can I
> do those things? Cause I noticed that method that alter data in data
> base are part of django admin module and cannot be overriden


I'm not sure if I understand you correctly, here. You can use signals to
fire off an event when a user saves an object. If you want to display a
message to a user (e.g. "Your new poll has been created") then use the
Django Messaging Framework. If the default admininstration application
doesn't do what you need and it's not flexible enough to do what you want
-- then don't fight it, write your own Views and Model Methods to perform
this behavior.

- To achieve what I want, i would like to run my server engine and my
> django admin in two separated threads. How do i run my admin module in
> a thread? Cause till now i'm using the command line "python manage.py
> runserver"


If you want to run the two as completely separate applications, simply take
two copies of your code-base and disable 'Admin' in one. Don't use Django's
runserver as a production server -- I'm sure others have already pointed
out (as well as the documentation) that it's not designed for that purpose.
Instead, use Nginx + uWSGI, Nginx + gunicorn, or even Apache for a
lower-traffic site.

 - I also tried to overide tables name, and foreign keys names. Could
> you guys provide me a true life example?


Override a table name:
https://docs.djangoproject.com/en/dev/ref/models/options/#table-names
Override foreign key name(s): Not really sure what you are asking here.

- And now in the production step, I would like you guys to tell me
> what to choose for serving files. I would like to with your experience
> what's better between running a unicorn server or apache with mod_wsgi


I use Nginx + uWSGI. There's plenty of sites out there that give you more
information on the subject. I chose this option because it's scalable, I've
got the configuration figured out, and it's pretty efficient and
lightweight.

I don't know if i'm clear, but i hope. In brief I'd like to use the
> django framework features to design my Gui like i want, customize
> interactions between the gui and the backend, and choose a good web
> server for the production.


>From your diagram you posted later-on, I think Django will work just fine
for your purpose. Just take it one step at a time and bulid it iteratively.
Break the whole architecture down into smaller pieces and tackle them one
at a time. You will learn a lot and will have a lot of fun doing it. Django
is a great framework to use and it's always been a pleasure for me except
the first month where there was *so many features* it was hard to pick a
place and go. Following the tutorials, as it appears you have done, is a
great way to start and you can learn more as you start to dive in deeper
and write more exciting code.

Good luck to you!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template: Foreign Key

2012-05-18 Thread Kurtis Mullins
Try something along these lines (Note: I'm switching up your variable names
a bit to make it easier to read)

{% for house in houses %}
{{ house.name }}
{% for person in house.people.all %}
{{ person.name }}
{% endfor %}
{% endfor %}

I just wrote that code block pretty quickly but it should step you in the
right direction. Also, here's a related stackoverflow post:
http://stackoverflow.com/questions/1014591/traversing-foreign-key-related-tables-in-django-templates

Good lucK!

On Fri, May 18, 2012 at 7:50 PM, Fady Kamal wrote:

> it's not working with me
>
> On Tuesday, June 30, 2009 10:43:15 AM UTC+2, russelson wrote:
>>
>> Hi,
>>
>> I'm new to django
>>
>> I have two models
>>
>> #models.py
>>
>> class House(models.Model):
>> name = models.CharField(blank=True, max_length=50)
>>
>> class People(models.Model):
>> name = models.CharField(blank=True, max_length=50)
>> house = models.ForegnKey(House)
>>
>> #views.py
>> def house_list(request):
>> houses = House.objects.all()
>> return render_to_response('test/**house_list.html',
>> {'object_list':
>> houses})
>>
>> #house_list.html
>> {% for object in object_list %}
>> {{ object.name }}
>> {{ object.people.name }}   #!?!?
>> {% endfor %}
>>
>> How do i retrieve the information in the People model?
>>
>> Please advice
>>
>> Thanks in advance
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/piLnSG9ycFEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template: Foreign Key

2012-05-18 Thread Kurtis Mullins
Whoops -- that might need to be 'house.people_set.all'. Sorry.

On Fri, May 18, 2012 at 10:50 PM, Kurtis Mullins
wrote:

> Try something along these lines (Note: I'm switching up your variable
> names a bit to make it easier to read)
>
> {% for house in houses %}
> {{ house.name }}
> {% for person in house.people.all %}
> {{ person.name }}
> {% endfor %}
> {% endfor %}
>
> I just wrote that code block pretty quickly but it should step you in the
> right direction. Also, here's a related stackoverflow post:
> http://stackoverflow.com/questions/1014591/traversing-foreign-key-related-tables-in-django-templates
>
> Good lucK!
>
>
> On Fri, May 18, 2012 at 7:50 PM, Fady Kamal wrote:
>
>> it's not working with me
>>
>> On Tuesday, June 30, 2009 10:43:15 AM UTC+2, russelson wrote:
>>>
>>> Hi,
>>>
>>> I'm new to django
>>>
>>> I have two models
>>>
>>> #models.py
>>>
>>> class House(models.Model):
>>> name = models.CharField(blank=True, max_length=50)
>>>
>>> class People(models.Model):
>>> name = models.CharField(blank=True, max_length=50)
>>> house = models.ForegnKey(House)
>>>
>>> #views.py
>>> def house_list(request):
>>> houses = House.objects.all()
>>> return render_to_response('test/**house_list.html',
>>> {'object_list':
>>> houses})
>>>
>>> #house_list.html
>>> {% for object in object_list %}
>>> {{ object.name }}
>>> {{ object.people.name }}   #!?!?
>>> {% endfor %}
>>>
>>> How do i retrieve the information in the People model?
>>>
>>> Please advice
>>>
>>> Thanks in advance
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/piLnSG9ycFEJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: JQuery .get new url is not updating the page

2012-05-18 Thread Furqan Malik
Thanks for the reply,

You misunderstood my question.

Passed_TestCases = data['Data1'];
Failed_TestCases = data['Data2'];
These values are fine, I am using them to create the table.

My question is once these values come from view.py, I want to change the
browser url so that url can be send to others.


On Fri, May 18, 2012 at 3:52 PM, Lee Hinde  wrote:

>
> On May 18, 2012, at 11:52 AM, furqanmlk wrote:
>
> Hi there,
>
> I implemented the JQuery to get the data from Database server and display
> in the form of table on the page when user click one of the DOM element.
> I tried ,
>
> *JQuery Code:*
> $.get("RunId_TestCases",{Variable:Value},function(data){
>
>
> Passed_TestCases = data['Data1'];
> Failed_TestCases = data['Data2'];
> //window.location.hash = this.url
>//window.location.assign(this.url)
>
>
>
> not knowing anything about the page, but you want something more like:
>
> $("#ID_FOR_THE_FIELD").val(data['Data1']);
>
>
> using window.location browser url gets changed but page goes to empty page
> with data values.
>
>
> Can you please help to solve this issue.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



user.set_password('new password')

2012-05-18 Thread Min Hong Tan
Hi,

I 'm trying to change password in views.py in one of my  def.
having the below code.
newpassword ="testing123"
user = User.objects.get(username__exact = request.user)
user.set_password(newpassword)
user.save

it didn't prompt me any error.  but, why my password still remained
unchanged?

Regards,
MH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: user.set_password('new password')

2012-05-18 Thread Jonathan D. Baker
Save is a method, so it needs parentheses: user.save()

Sent from my iPhone

On May 18, 2012, at 10:53 PM, Min Hong Tan  wrote:

> Hi,
> 
> I 'm trying to change password in views.py in one of my  def.
> having the below code.
> newpassword ="testing123"
> user = User.objects.get(username__exact = request.user)
> user.set_password(newpassword)
> user.save
> 
> it didn't prompt me any error.  but, why my password still remained unchanged?
> 
> Regards,
> MH
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



admin error, cannot edit fields or delete records, url refers to incorrect primary key

2012-05-18 Thread Mac
I've set up a 'Reps' model in the admin. I can add records
successfully, but if I try to change a record or field, I get a 404
error. When I try to delete a record, I get this traceback here:
http://dpaste.com/750121/
My primary keys are integers, but it appears that the urls return them
as floats. Please see the example below.

The model in whl.models is as follows:

class Reps(models.Model):
prim = models.AutoField(primary_key=True, db_column='PRIM')
custno = models.CharField(max_length=50, db_column='CUSTNO',
blank=True) # Field name made .
company = models.CharField(max_length=50, db_column='COMPANY',
blank=True)# Field name made
#etc, etc.

class Meta:
db_table = u'whl_reps'
def __unicode__(self):
return self.custno + " : " + str(self.company)+" :
"+str(self.city)+" : "+str(self.state)
def get_absolute_url(self):
return "/%i/" % self.prim

My admin.py is:

from whl.models import Reps

class RepAdmin(admin.ModelAdmin):
fields = ('company', 'email',  'salesmn',  'city',  'state')

And for example when I click on a record to change it, I get a 404
error with a message "reps object with primary key u'39.0' does not
exist". In this case, when i click on a record, it returns this url

localhost/admin/whl/reps/39.0/

As you can see, the last primary key above is not an integer as it
should be. When I manually change the url to /admin/whl/reps/39/ I can
edit the record.

I'm using Django 1.4, mysql db on Ubuntu.

Any thoughts on why this is happening? Any help would be appreciated
very much. Thanks.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: from django.http import HttpResponse: Unresolved Import. why ?

2012-05-18 Thread doniyor
okay, i solved the problem.. ctrl + 1. and import to parent modules.. and 
thats it.. 


Am Freitag, 18. Mai 2012 22:43:17 UTC+2 schrieb doniyor:
>
> hey guys, 
>
> i am getting this error when i try to write my view. 
>
> when i import this, from django.http import HttpResponse, the word 
> HttpResponse is red error. Unresolved Import: HttpResponse. 
>
> i dont understand why. i am using python 2.7 and django1.4. what i did 
> before this is, i changed from django1.3 to django1.4. 
>
> thanks for help 
>
> doni 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/1b91ZxH1-lMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



'Settings' object has no attribute 'ROOT_URLCONF'

2012-05-18 Thread doniyor
Hi 

i have this problem, i dont why, i have root_urlconf in my settings.py. i 
cannot figure out what it wants from me.. pls help 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/99LNudLYYB4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSRF verification failed. Request aborted.

2012-05-18 Thread doniyor
as Kurtis said, you need  {% csrf_token %}  and your rendering response 
should be something like this: 
return render_to_response('index.html', {'your_key': 
your_value},context_instance=RequestContext(request))   and those your 
value will be rendered thru youe_key tag. 

here is how your form should look like: 
text = """ *{% csrf_token %}* 
 +  
  
"""  





Am Samstag, 19. Mai 2012 04:20:39 UTC+2 schrieb plogu...@yahoo.com.cn:
>
> I find a code, but the Django version is 0.9, I am using 1.4 and I am 
> a new learner, I want to run below code but report CSRF verification 
> failed. 
>
> from django.http import HttpResponse 
>
> text = """ 
>  +  name="b" value="%d"> 
>   
> """ 
>
> def index(request): 
> if request.POST.has_key('a'): 
> a = int(request.POST['a']) 
> b = int(request.POST['b']) 
> else: 
> a = 0 
> b = 0 
> return HttpResponse(text % (a, b, a + b))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/uOi0CuZcYgcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Use Django to implement my GUI!

2012-05-18 Thread Jani Tiainen
Hi,

By looking your diagram it's still the same as you described in your
earlier mails. So it doesn't help at all. :)

1) Is your server something that exists and is used in everyday life or is
it something that you're going to build?

2) Are your clients something that already exists and is used in everyday
life?

3) Are you now trying to figure out how to plug in Django in "Adming
module/PC with GUI block"?


On Fri, May 18, 2012 at 6:36 AM, Eugène Ngontang wrote:

> Hi Guys!
>
> I've been busy a bit, I'm back to thread with the high level architecture.
> Attached here is a diagram, just to understand what i meant.
>
> Don't pay attention for object I use to describe modules or architecture
> components.
>
> Now you will be able to understand what I mean by the server module, the
> admin module, and the client module of my architecture.
>
> As you could see on the diagram, the admin module is installd on the
> server(where the server module is installed) and is destined to provide
> views to the GUI.
> The clients receive and send data to the server.
> When the admin make some actions, some clients are notifed, and when
> client send informations admin (GUi is notified).
>
> Now two things come in my mind when I was thinking :
>
> - First I could stay in the way I want the server to use HTTP for the
> admin side, and another protocol to communicate with client. In that way
> the Admin Module (Django) will alter and read data from data base. and the
> server module will alter and read data from database. Then each information
> retrievement will lead in reading database since informations could have
> been changed. You can that's really heavy.
>
> - Second do all things in http. Mean that my server is just a web
> application undertanding HTTP (I will the use django for that). The server
> will serve request depending on the type of request, and each client will
> communicate with the server using HTTP.  Then server will define pages/urls
> for admin (to be sent to the GUI), and pages/urls  for clients.
> By this way, the only relation between my modules will be the protocol
> (HTTP for the instance) and they could be implemented in what ever language
> we like. The sever will run asynchronously for admin and clients.
>   The admin will then be just an interface to wich convert data to the
> right display format for the GUI. And the GUI could be any type, and for
> the web interface type I will use DJANGO for my Admin module.
>I will then also have to develop a http client for my client module.
>
> Actuallu I'm going to take the second choice, since it lets all the charge
> for read and write database to the server, which could run and publish
> informations asynchronously(websocket could help here).
>
> I precise that I'm not a web architect or designer, but i understand
> software architecture. I'm really a system and network engineer, with good
> developpement skill but not to much in web.
>
> Look now my architecture diagram and tell me if what I'm describing in the
> second item fit. And give idea if you have, about libraiies and or framwork
> that could help going fast and easy.
> I thing I will use django and green unicorn.
>
> Thanks for your attention.
>
>
>
> 2012/5/16 Alec Taylor 
>
>> Oh right, it's just Pyjamas.
>>
>> Still, annoyed I didn't think to recommend it first!
>>
>>
>> On Thu, May 17, 2012 at 12:02 AM, Alec Taylor 
>> wrote:
>> > On Wed, May 16, 2012 at 10:49 PM, Frank Stüss 
>> wrote:
>> >> or maybe you might have a look at http://pyjs.org/
>> >> which could help you having an event aware client app in your browser.
>> >> Served by and with django.
>> >
>> > I'm impressed
>> >
>> > (just read the exec summary from homepage)
>> >
>> >>
>> >> Am Sonntag, den 13.05.2012, 17:14 +0400 schrieb Alireza Savand:
>> >>> No, i posted django-tastypie not tastypie itself and it's easy to use.
>> >>> Anyway if i'm implementing GUI based i would make it website, since
>> >>> it's an advantages of SaaS.
>> >>> But using client app[desktop-app] and a server-app[django] and having
>> >>> multiply client and ... makes maintaining like a nightmare.
>> >>> All i knew was that, Despite that you asked several question and i
>> >>> just claimed to help in one of them :D
>> >>>
>> >>> On Sun, May 13, 2012 at 4:06 PM, Eugène Ngontang > >
>> >>> wrote:
>> >>> Yes, I can see tastypie is a good service, that even support
>> >>> REST protocol.
>> >>>
>> >>> But I'd firt basically implement my gui with django and when i
>> >>> will master well django, i could use tastypie, and turn my
>> >>> server to support REST, it will be a good thing.
>> >>>
>> >>> But please let's keep using only django for the begining.
>> >>>
>> >>> Thanks.
>> >>>
>> >>>
>> >>> 2012/5/13 Alireza Savand 
>> >>> https://github.com/toastdriven/django-tastypie
>> >>>
>> >>>
>> >>> On Sunday, May 13, 2012 2:14:36 PM UTC+4, Eugene
>> >>>   

Re: user.set_password('new password')

2012-05-18 Thread Min Hong Tan
hi..

thanks!! haha... didn't notice  that. how can no error...prompt out one

On Fri, May 18, 2012 at 11:48 PM, Jonathan D. Baker <
jonathandavidba...@gmail.com> wrote:

> Save is a method, so it needs parentheses: user.save()
>
> Sent from my iPhone
>
> On May 18, 2012, at 10:53 PM, Min Hong Tan  wrote:
>
> Hi,
>
> I 'm trying to change password in views.py in one of my  def.
> having the below code.
> newpassword ="testing123"
> user = User.objects.get(username__exact = request.user)
> user.set_password(newpassword)
> user.save
>
> it didn't prompt me any error.  but, why my password still remained
> unchanged?
>
> Regards,
> MH
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.