Wednesday, August 31, 2011

Re: Unable To Delete Records

Thanks Alotttttttttttttttt....

On Aug 30, 4:34 pm, Daniel Molina Wegener <d...@coder.cl> wrote:
> On Tuesday 30 August 2011,
>
> Showket Bhat <scorpion.sch...@gmail.com> wrote:
> > Hi All...
>
>   Hello Showket...
>
>
>
> > I have created a small application where in i am inserting and
> > deleting records. I am able to delete a single record however when a
> > select all or more then one record it deletes the last record only.. I
> > tried a lot but failed please help I am wring the Code and the Console
> > output here....
>
>   Probably you should try using:
>
>      m = Medecine.objects.get(pk = i)
>
>   Instead of using:
>
>      m = Medecine.objects.get(id = i)
>
>   Also, try to handle the DoesNotExist and similar exception once you
> try to retrieve the object using the /get()/ method. Also you can
> reduce the look by using:
>
>     del_ids = request.POST.getlist('del_id')
>     Medecine.objects.filter(id__in = del_id).delete()
>
>   Which should be faster than your loop.
>
>
>
>
>
> > ===========================================
> > my function to delete a medecine from its table  in views.py
> > ===========================================
>
> > def delete_medecine(request,medecine={}):
> >     print "------>>",request.POST
> >     list = []
> >     for i in request.POST['del_id']:
> >         m = Medecine.objects.get(id = i)
> >         m.delete()
> >     return HttpResponseRedirect('/medecine')
>
> > ==============================================
> > my template file
>
> > <form action="/delete_medecine/" name = "medecines" method = "POST">
> > <table cellspacing="0" cellpadding="0" border="0"><!-- Table -->
>
> >     <thead>
> >         <tr>
> >             <th><input type="checkbox" class="checkall" /></th>
> >             <th>SNo.</th>
> >             <th>Name</th>
> >             <th>Price</th>
> >             <th>Quantity</th>
> >             <th>Exp. Date</th>
> >             <th>Description</th>
> >         </tr>
> >     </thead>
>
> >     <tbody>
> >         {% for single in medecine_obj%}
> >             <tr>
> >                 <td><input type="checkbox" value="{{single.id}}"  name
> > = "del_id" /></td>
> >                 <td>{{single.id}}</td>
> >                 <td>{{single.name}}</td>
> >                 <td>{{single.price}}</td>
> >                 <td>{{single.exp_date}}</td>
> >                 <td>{{single.discription}}</td>
> >                 <td><a href="#"><img src="/login/media/assets/
> > action_check.png" alt="Check" /></a><a href="/delete_medecine/"><img
> > src="/login/media/assets/action_delete.png" alt="Delete" /></a><a
> > href="#"><img src="/login/media/assets/letter.png" alt="Letter" /></
> > a></td>
> >             </tr>
> >         {%endfor%}
> >     </tbody>
> >     <a href="/medecine_form/"><input type = "button" name = "add"
> > value = "    Add Record    " alt="Add" /></a>
> >     <input type = "submit" name = "delete" value = "Delete Records"
> > alt="Delete" />
>
> > </table>
> > </form>
>
> > ===========================
> > My Console
> > ===========================
>
> > /usr/local/lib/python2.6/dist-packages/django/middleware/csrf.py:262:
> > DeprecationWarning: CsrfResponseMiddleware and CsrfMiddleware are
> > deprecated; use CsrfViewMiddleware and the template tag instead (see
> > CSRF documentation).
> >   DeprecationWarning
> > ================================== <QueryDict:
> > {u'csrfmiddlewaretoken': [u'fea796e4bc7836bb8584140b71a0afcc'],
> > u'del_id': [u'1', u'2', u'8'], u'delete': [u'Delete Records']}>
> > ===== 8
> > [30/Aug/2011 06:04:56] "POST /delete_medecine/ HTTP/1.1" 302 0
>
> > ==============
>
> > Please help
>
> Best regards,
> --
> Daniel Molina Wegener <dmw [at] coder [dot] cl>
> System Programmer & Web Developer
> Phone: +56 (2) 979-0277 | Blog:http://coder.cl/

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Unable to have a template NOT show up

On Wed, 2011-08-31 at 12:05 -0700, Yves S. Garret wrote:
> Caught ViewDoesNotExist while rendering: Could not import polls.view.
> Error was: No module named view

should it not be views?
--
regards
Kenneth Gonsalves

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

A call for resumes

Seasoned, senior level Python / Django users please contact me for a gig opportunity pr forward your resume.

Thanks.

Sent from my iPhone

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Combining queries? A "join" in Python?

On Aug 30, 12:10 pm, graeme <graeme.piete...@gmail.com> wrote:
>
> What my query does is give me a list of subcategories, ordered by
> category, and then by the number of places in the category, and
> annotates each subcategory with the number of places in it.
>
> Having a single category model might simplify the query, but as I want
> the page to show something like:
>
> CATEGORY
> Subcategory One
> Subcategory Two
> CATEGORY TWO
> Subcategory Three
> etc.
>

I would take a different approach to build this structure. Take
advantage of the object model. You could get a list of root categories
and send those off to a function (probably a template filter) that
builds the html representation you want. If you have the root
categories, you have everything you need.

root_cats = Category.objects.filter(parent__isnull=True) # gets root
categories
for cat in root_cats: # iterate thru root categories
print "%s (%s)" % (cat.name, cat.texts.count()) # CATEGORY (2)
for t in cat.texts.all(): # iterate thru texts that belong to each
root category
print t
for c in cat.children.all(): # iterate thru child categories (one
level down from the root)
print "%s (%s)" % (c.name, c.texts.count()) # Subcategory One
(3)

Rework that code to traverse all the way to the bottom (smarter
iteration or maybe recursion) and you've got what you need without a
complicated query.


--Stuart

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Unable to have a template NOT show up

On 31-08-11 22:39, Yves S. Garret wrote:
> When I said you're right, I meant your insight into my spelling
> error.

That is the one thing that's hard in every web framework: find the spots
where something can be wrong when everything *seems* right.

Four common spots in django:

- Typo in urls.py (like you had).

- A circular import. Your models.py imports from views.py and views.py
imports from models.py. You get an error like "cannot import
yourproject.views", even though ``yourproject/views.py`` is right there
before your eyes :-)

- A url higher up in the urlpatterns that matches *before* the url you
*think* is matching. The url should match perfectly, but you get a
strange error because the wrong view is being called.

- You're depending on some application in your setup.py's
"install_requires" list. The application is installed. Why doesn't it
show up? You probably forgot to add it to your INSTALLED_APPS list in
your settings.py. At least, that happened to me a few times. "I can
import it, why doesn't it work?!?"


Reinout

--
Reinout van Rees http://reinout.vanrees.org/
reinout@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 post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Unable to have a template NOT show up

When I said you're right, I meant your insight into my spelling
error. Those are the most annoying errors since they are so difficult
to figure out after staring at the screen for so long.

On Aug 31, 3:35 pm, Reinout van Rees <rein...@vanrees.org> wrote:
> On 31-08-11 21:05, Yves S. Garret wrote:
>
> > In template c:\python27\lib\site-packages\django\contrib\admin
> > \templates\admin\change_list.html, error at line 11
> > Caught ViewDoesNotExist while rendering: Could not import polls.view.
> > Error was: No module named view
>
> Most possible reason that I can think of right now:
>
> You mis-typed something in your urls.py. I'd expect there to be a
> "polls.view...." in there instead of the customary "polls.views...", so
> with an 's'.
>
> The module is "views.py", not "view.py".
>
> Just guessing...
>
> Reinout
>
> --
> Reinout van Rees                    http://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 post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Unable to have a template NOT show up

You're right! Thank you.

I have another issue with this page and I'll write later (busy with
something else.)

On Aug 31, 3:35 pm, Reinout van Rees <rein...@vanrees.org> wrote:
> On 31-08-11 21:05, Yves S. Garret wrote:
>
> > In template c:\python27\lib\site-packages\django\contrib\admin
> > \templates\admin\change_list.html, error at line 11
> > Caught ViewDoesNotExist while rendering: Could not import polls.view.
> > Error was: No module named view
>
> Most possible reason that I can think of right now:
>
> You mis-typed something in your urls.py. I'd expect there to be a
> "polls.view...." in there instead of the customary "polls.views...", so
> with an 's'.
>
> The module is "views.py", not "view.py".
>
> Just guessing...
>
> Reinout
>
> --
> Reinout van Rees                    http://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 post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django setup.py access denies

On 08/31/2011 04:32 PM, Bill Freeman wrote:
> So far today I've gotten two useless messages from you, and no spams.
>

Don't feed the trolls. I'm sure a moderator will fix this, if they
didn't already unsubscribe themselves.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django setup.py access denies

So far today I've gotten two useless messages from you, and no spams.

On Wed, Aug 31, 2011 at 4:24 PM, Elie Obeid <elieobeid7@gmail.com> wrote:
> I know how to unsubscribe i don't need your link, I don't trust any of you,
> i don't know why this is the official group, this is the official spammers
> group
>
> --
> 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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django setup.py access denies

I know how to unsubscribe i don't need your link, I don't trust any of you, i don't know why this is the official group, this is the official spammers group

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django setup.py access denies

If you want to unsubscribe, just send an e-mail here: django-users+unsubscribe@googlegroups.com

On Wed, Aug 31, 2011 at 4:16 PM, Elie Obeid <elieobeid7@gmail.com> wrote:
so great I subscribed to OFFICIAL group of django for help and what I get???? SPAMS, i'm so delighted!!

--
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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django setup.py access denies

so great I subscribed to OFFICIAL group of django for help and what I get???? SPAMS, i'm so delighted!!

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

django setup.py access denies

I am having this issue with django

http://bit.ly/pTSSyY

you could answer it here or there, if you are actually stackoverflow
users then answer it there because I opened a 50pts for this question.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Custom Validation on Inline Generic Foreign Key

I went ahead and hardcoded checks for fields that as of today I know
will only be in one of the models. I would still love to hear any
cleaner solutions if anyone has them.

On Aug 26, 10:12 am, John <johnschra...@gmail.com> wrote:
> Any ideas?
>
> In the inline model's validation I could hardcode checks for data that
> I expect will only be in one of the models, but that does not seem
> like the best option. I am still hoping for a simpler alternative to
> this.
>
> 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Mystery... Faked Referrer Generates 500 Instead of 404 Error

On 31-08-11 21:19, charris wrote:
> Hello. I hope someone can provide some clues.I have begun receiving
> regular 500 errors from a page that does not exist. Without providing
> the entire error page, here are the essentials:
>
> [Django] ERROR (EXTERNAL IP): Internal Server Error:/sample/
> path/calendar.pl
>
> IOError: request data read error
>
> 'HTTP_REFERER': 'http://mydomain.org/calendar.pl',
> 'PATH_INFO': u'/sample/path/calendar.pl',
>
> If I visit the pagehttp://mydomain.org/calendar.pl, I get a 404
> error, but the error message referencing the same page generates an
> internal server (500) error.

Some ideas:

.pl sounds like a perl script. Perhaps google is hitting your server
with now-non-existing urls?

Regarding the error 500: can you put your server in debug mode for a
couple of minutes? Then you can see the exact error in your browser.
(Note that django 1.3 allows you to set up your logging so that those
500 errors end up in the logfile.)

The HTTP_REFERER header lists the page the request comes from, so
getting a 404 on that page and a 500 on another page isn't strange.

Request data read error: perhaps someone is trying to DDOS you: open
connections to your webserver but not closing them in an effort to hose
your webserver. Django gives a request data read error, perhaps, because
the connection stayed open but no data was forthcoming.

I don't know about your webserver, but you can probably tell your
webserver to immediately tell visitors to those specific pages that the
page is gone (apache rewriterule, for instance, with a "410 GONE" response).


Reinout

--
Reinout van Rees http://reinout.vanrees.org/
reinout@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 post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Unable to have a template NOT show up

On 31-08-11 21:05, Yves S. Garret wrote:
> In template c:\python27\lib\site-packages\django\contrib\admin
> \templates\admin\change_list.html, error at line 11
> Caught ViewDoesNotExist while rendering: Could not import polls.view.
> Error was: No module named view

Most possible reason that I can think of right now:

You mis-typed something in your urls.py. I'd expect there to be a
"polls.view...." in there instead of the customary "polls.views...", so
with an 's'.

The module is "views.py", not "view.py".


Just guessing...


Reinout

--
Reinout van Rees http://reinout.vanrees.org/
reinout@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 post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Mystery... Faked Referrer Generates 500 Instead of 404 Error

Hello. I hope someone can provide some clues.I have begun receiving
regular 500 errors from a page that does not exist. Without providing
the entire error page, here are the essentials:

[Django] ERROR (EXTERNAL IP): Internal Server Error: /sample/
path/calendar.pl

IOError: request data read error

'HTTP_REFERER': 'http://mydomain.org/calendar.pl',
'PATH_INFO': u'/sample/path/calendar.pl',

If I visit the page http://mydomain.org/calendar.pl, I get a 404
error, but the error message referencing the same page generates an
internal server (500) error.

QUESTIONS:
Should I be concerned?
Why do I get a 500 error instead of 404 error?
Any suggestions for troubleshooting?

This has been driving me nuts for a few days. Any help is very
appreciated.

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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Unable to have a template NOT show up

This is the current error that I'm getting in my browser:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++
Template error

In template c:\python27\lib\site-packages\django\contrib\admin
\templates\admin\change_list.html, error at line 11
Caught ViewDoesNotExist while rendering: Could not import polls.view.
Error was: No module named view
1 {% extends "admin/base_site.html" %}
2 {% load adminmedia admin_list i18n %}
3 {% load url from future %}
4 {% block extrastyle %}
5 {{ block.super }}
6 <link rel="stylesheet" type="text/css" href="{% admin_media_prefix
%}css/changelists.css" />
7 {% if cl.formset %}
8 <link rel="stylesheet" type="text/css" href="{%
admin_media_prefix %}css/forms.css" />
9 {% endif %}
10 {% if cl.formset or action_form %}
11 {% url 'admin:jsi18n' as jsi18nurl %}
12 <script type="text/javascript" src="{{ jsi18nurl|default:'../../
jsi18n/' }}"></script>
13 {% endif %}
14 {{ media.css }}
15 {% if not actions_on_top and not actions_on_bottom %}
16 <style>
17 #changelist table thead th:first-child {width: inherit}
18 </style>
19 {% endif %}
20 {% endblock %}
21
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++

Doesn't this part get populated? What am I missing?

On Aug 31, 11:23 am, "Yves S. Garret" <yoursurrogate...@gmail.com>
wrote:
> So I'm following this Django tutorial to become more familiar with how it
> works:
>
> https://docs.djangoproject.com/en/dev/intro/tutorial03/#write-views-t...
>
> I got to this part:
>
> Reload the page. Now you'll see an error:
>
> TemplateDoesNotExist at /polls/
> polls/index.html
>
> Ah. There's no template yet.
>
> I never had this happen.... I just got this displayed in my browser (after I
> cleared the cache on top of that):
>
> You're looking at the results of poll 2.
>
> What am I doing wrong?  The fact that I don't see this gives me the
> impression that I messed somewhere up, anyone have an idea where I could
> have possibly stumbled?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: This is nuts why dont I get POST?

Arrrrggggh all for a missing " Thank you Tom
talk about not seeing the woods for the trees! Sheesh


Tom Evans-3 wrote:
>
> On Wed, Aug 31, 2011 at 3:06 PM, MikeKJ <mike.jones@paston.co.uk> wrote:
> <snip>
>> <form action="." method=post" id="captureForm">
>
> Incorrectly formatted tag, browser falls back to default method, which is
> GET.
>
> Cheers
>
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--
View this message in context: http://old.nabble.com/This-is-nuts-why-dont-I-get-POST--tp32372381p32372666.html
Sent from the django-users mailing list archive at Nabble.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-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: This is nuts why dont I get POST?

On Wed, Aug 31, 2011 at 3:06 PM, MikeKJ <mike.jones@paston.co.uk> wrote:
<snip>
> <form action="." method=post" id="captureForm">

Incorrectly formatted tag, browser falls back to default method, which is GET.

Cheers

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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Password Field Not being encrypted

hi,
Use set_password method from django contrib auth models in your
custom model. while saving your custom form pass the password to set
password method and save returned encrypted password in your model.

Lokesh

On Aug 31, 12:05 am, raj <nano.ri...@gmail.com> wrote:
> Hey guys, I'm trying to make a custom registration form for a custom
> UserProfile class.
> I have the following form:
>
> class UserForm(ModelForm):
>         username = forms.EmailField(label = _("Email"), widget =
> forms.TextInput(attrs ={ 'id':'email'}), required=True)
>         first_name = forms.CharField(widget = forms.TextInput(attrs =
> {'id':'fname'}), required=True)
>         last_name = forms.CharField(widget = forms.TextInput(attrs =
> {'id':'lname'}), required=True)
>         linked_id = forms.CharField(widget = forms.HiddenInput(attrs =
> {'id':'linkedid'}))
>         password = forms.CharField(label=_('Password'),
> widget=forms.PasswordInput(render_value = False), required = True)
>         password2 = forms.CharField(label=_('Re-Enter your password'), widget
> = forms.PasswordInput(render_value = False))
>         email = forms.CharField(widget = forms.HiddenInput(), required =
> False)
>
>         class Meta:
>                 model = UserProfile
>                 fields = ('username', 'first_name', 'last_name', 'linked_id',
> 'password', 'email', )
>
>         def clean_password2(self):
>                 password1 = self.cleaned_data.get("password", "")
>                 password2 = self.cleaned_data['password2']
>                 if password1 != password2:
>                         raise forms.ValidationError(_("The passwords you entered did not
> match!"))
>                 return password2
>
>         def clean_email(self):
>                 email = self.cleaned_data['username']
>                 return email
>
> The issue that I'm having is that when the password is entered, and
> saved, its not being encrypted. So I can just view a users password in
> my admin panel...
> How do I get the passwords to be encrypted? I had another website and
> it worked then, but when I'm trying it now, it just isn't working.
> Help please. Thank 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

This is nuts why dont I get POST?

Model

from django.db import models

# Create your models here.

roof_choices = (
("South", "South"),
("South East", "South East"),
("South West", "South West"),
("East", "East"),
("West", "West"),
("North", "North")
)

pv_choices = (
("0.1-5 kWph", "0.1-5 kWph"),
("1-2 kWph", "1-2 kWph"),
("2-3 kWph", "2-3 kWph"),
("3-4 kWph", "3-4 kWph"),
("4-10 kWph", "4-10 kWph"),
(">10kWph", ">10kWph")
)

hear_choices = (
("Leaflet", "Leaflet",),
("Google", "Google"),
("Bing", "Bing"),
("Yahoo", "Yahoo"),
("Other Search Engine", "Other Search Engine"),
("Newspaper", "Newspaper"),
("Yellow Pages", "Yellow Pages"),
("Company Vehicle", "Company Vehicle"),
("Recommendation", "Recommendation"),
("TV", "TV"),
("Radio", "Radio"),
("Existing Customer", "Existing Customer"),
("Telephone Call", "Telephone Call"),
("Other", "Other")
)

class Capture(models.Model):
title = models.CharField(max_length=10)
initial = models.CharField(max_length=5)
surname= models.CharField(max_length=30)
email = models.EmailField()
telephone = models.CharField(max_length=30)
add1 = models.CharField(max_length=100)
add2 = models.CharField(max_length=100, null=True, blank=True)
town_city = models.CharField(max_length=100, null=True, blank=True)
county = models.CharField(max_length=100, null=True, blank=True)
pcode = models.CharField(max_length=30, null=True, blank=True)
roof = models.CharField(choices = roof_choices, max_length=25)
pv = models.CharField(choices = pv_choices, max_length=25)
heard = models.CharField(choices = hear_choices, max_length=50)

def __unicode__(self):
return self.email


View

from django import forms
from django.forms import ModelForm
from django.shortcuts import render_to_response
from django.http import HttpResponse, HttpResponseRedirect
from django.forms.util import ValidationError
from django.core.mail import send_mail
from django.conf import settings
from smartpages.models import SmartPage
import re
from django.template import RequestContext
from capture.models import Capture, pv_choices, hear_choices, roof_choices

class CaptureForm(ModelForm):
title = forms.CharField(required=True, label = "Title")
initial = forms.CharField(required=True, label = "Initial")
surname = forms.CharField(required=True, label="Surname")
email = forms.EmailField(required=True, label="Email Address")
telephone = forms.CharField(required=True, label="Telephone")
add1 = forms.CharField(required=True, label="Address 1")
add2 = forms.CharField(required=False, label="Address 2")
town_city = forms.CharField(required=True, label="Town/City")
pcode = forms.CharField(required=True, label="Post Code")
county = forms.CharField(required=True, label="County")
roof = forms.ChoiceField(choices=roof_choices, required=True,
label="Roof Orientation")
pv = forms.ChoiceField(choices=pv_choices, required=True, label="PV
Size")
heard = forms.ChoiceField(choices=hear_choices, required=True,
label="Heard of Us?")
class Meta:
model = Capture

def capture(request):
if request.POST:
raise NameError("XXXXXXXXXXXXXXX")
form = CaptureForm(request.POST)
if form.is_valid():
title = form.cleaned_data['title']
initial = form.cleaned_data['initial']
surname = form.cleaned_data['surname']
email = form.cleaned_data['email']
telephone = form.cleaned_data['telephone']
add1 = form.cleaned_data['add1']
if form.cleaned_data['add2']:
add2 = form.cleaned_data['add2']
town_city = form.cleaned_data['town_city']
county = form.cleaned_data['county']
roof = form.cleaned_data['roof']
pv = form.cleaned_data['pv']
heard = form.cleaned_data['heard']
msg_header = "Form content\n\n"
msg_middle = "Name: %s %s %s" % (form.cleaned_data['title'],
form.cleaned_data['initial'], form.cleaned_data['surname'])
msg_middle += "Email: %s\n\n" % form.cleaned_data['email']
msg_middle += "Telephone: %s\n\n" %
form.cleaned_data['telephone']
send_mail(settings.EMAIL_SUBJECT_PREFIX + "Email from the
capture detail form to use the calculator", msg_header+msg_middle,
settings.DEFAULT_FROM_EMAIL, [settings.CONTACT_EMAIL_TO,],
fail_silently=False)
return HttpResponseRedirect('/cost-and-earnings-calculator/')
else:
form = CaptureForm(request.POST)
else:
form = CaptureForm()
try:
content = SmartPage.objects.get(slug="calculator")
except SmartPage.DoesNotExist:
content = None
return render_to_response("capture/form.html", {"form": form, "content":
content, }, context_instance=RequestContext(request))


Template

{% extends "base.html" %}

{% block extrahead %}
{% block meta_title %}<title>{% if content.meta_title
%}{{content.meta_title}}{% else %}{% if title %}{{title}}{% else %}Default
title - change me{% endif %}{% endif %}</title>{% endblock %}
{% block meta_desc %}<meta name="description" content="{% if
content.meta_desc %}{{content.meta_desc}}{% else %}Default description -
change me{% endif %}" />{% endblock %}
{% block meta_keywords %}<meta name="keywords" content="{% if
content.meta_keywords %}{{content.meta_keywords}}{%else%}Default, keywords,
change, me{%endif%}" />{% endblock %}

{% endblock %}
{% block midimage %} {{ content.headimage.headimage.url }} {% endblock %}
{% block content %}
<div>{{ content.content }}</div>
<div>
<form action="." method=post" id="captureForm">
{{ form.as_p}}
<input type="submit" value="Continue" id="captureSubmitButton" />
</form>
</div>
{% endblock %}
--
View this message in context: http://old.nabble.com/This-is-nuts-why-dont-I-get-POST--tp32372381p32372381.html
Sent from the django-users mailing list archive at Nabble.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-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django-sms-gateway

__init.py__ (incorrect) or __init__.py (correct)?

I suspect you'll need to a) describe in more detail what you're trying
to do and what's failing, and b) share more of your code and the error
traceback in order for anyone to help you diagnose the problem.


On Aug 31, 4:28 am, damola oyeniyi <oyeniy...@yahoo.ca> wrote:
> Hi all,
>
> I have managed to install django-sms-gateway for use in my application, but I run into a few problems.
>
> The structure of the package is such that the 3 models are inside a models directory. So far, everything looks like its in place; there is an __init.py__ file in the models directory complete with proper code and each model file is aptly described with the app_label meta. However, I still cannot get the code to run.
>
> The errors I get after tweaking include:
>
> cannot import name Gateway
> no model named model
>
> What to do?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Argh: templates, admin, and app loading order

Hm, yes, that might work, although at this point I'm a little
concerned about changing the order of applications anyway, since I'm
not sure what other side effects it might have. Mostly I'm
uncomfortable with how important application order ends up being to
how one's project operates, especially given that the behavior is
inconsistent for different aspects of the framework.

Is there any way to force the third party app's admin.register() calls
to execute before running my own -- e.g. by importing thirdparty.admin
at the top of my admin.py?

On Aug 30, 5:51 pm, Doug Ballance <dball...@gmail.com> wrote:
> Can you use the filesystem loader as the first template loader, then
> set TEMPLATE_DIRS in settings.py to specify a template directory
> outside any app?  Use this location for all of your overrides, just
> make sure the path is right... ie each app you override would have its
> own subdirectory.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: how to render context like this :

thansk Evans , it worked . =)

On Aug 31, 6:48 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Wed, Aug 31, 2011 at 11:40 AM, kele <gisx...@gmail.com> wrote:
>
> > c = Context( {'teams':
> >                 {1: ['a', 'b'] , 2:['c', 'd']}
> >       } )
>
> > i have try like this :
>
> >        {% for k in teams %}
> >        <li> {{k}} {{k.0}}    # also try teams[k]  ... etc.  but also
> > dosent work
> >        {% endfor %}
>
> > sorry for my noob question , but pls show me how to to this .
>
> {% for k,v in teams.items %}
> {{ k }}: {{ v.0 }} , {{ v.1 }}
> {% endfor %}
>
> Cheers
>
> 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: How to run tests?

> Try "manage.py test data". Django doesn't really like those
> dot-separated namespace packages, sadly. Only the last part is used.

Ah, that works. Interesting. I wasn't the one who originally picked
the name. I'll look into changing it.

Thanks,
--Steve

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Django Development environment

On 08/31/2011 01:46 PM, graeme wrote:
>
>
> On Aug 31, 1:16 pm, Jani Tiainen<rede...@gmail.com> wrote:
>> On 08/28/2011 12:31 PM, Simon Connah wrote:
>>
>>
>>
>>> On 28 Aug 2011, at 04:41, Sam Walters wrote:
>>
>>>> Debug client-side:
>>>> firebug, yslow, a windows computer with ie7
>>
>>> Rather than using a separate computer with IE 7 I tend to just spin up an Amazon EC2 instance running Windows Server 2003 or Windows Server 2008 for a couple of hours. It makes everything so much easier when it comes to testing.
>>
>> Or you can always download "Internet Explorer Application Compatibility
>> VPC Image" [1] images from Microsoft directly.
>>
>> (there are IE6 - IE9 images available) for testing websites. Very useful
>> with VirtualBox.
>>
>> [1]http://www.microsoft.com/download/en/details.aspx?id=11575
>
> I thought it took a bit of work to get those VPC images to work with
> VirtualBox. The last time I looked they were tied to Virtual PC
> (virtual) hardware, and had activation issues with VirtualBox. Has
> that changed?
>

VirtualBox 4.1 in Ubuntu

Just downloaded image parts, extracted multipart rar package. Then comes
the tricky part:

When creating new VM you trick is to attach VHD image as an IDE drive,
not SATA (Defautl creation attaches image as SATA). And of course you
don't try to activate it but that's enough for testing.

--

Jani Tiainen

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django-sms-gateway

Hi Matt,

The file is unchanged! I have just added the 'sms' app into the INSTALLED_APPS section of my settings.py file. I'm trying to loadadmin pages to enter the parameters for my gateway account when I get the error


From: Matthew Schinckel <matt@schinckel.net>
To: damola oyeniyi <oyeniyi83@yahoo.ca>
Sent: Wednesday, August 31, 2011 12:03:03 PM
Subject: Re: django-sms-gateway

I'm guessing that you have a problem in models/gateway.py - perhaps there is a 'model' that should be 'models'.

What is the current contents of that file?

On 31/08/2011, at 5:58 PM, damola oyeniyi wrote:

Hi all,

I have managed to install django-sms-gateway for use in my application, but I run into a few problems.

The structure of the package is such that the 3 models are inside a models directory. So far, everything looks like its in place; there is an __init.py__ file in the models directory complete with proper code and each model file is aptly described with the app_label meta. However, I still cannot get the code to run.

The errors I get after tweaking include:

cannot import name Gateway
no model named model

What to do?



Re: Django Development environment

I am only supposed to be developing part time (mostly my own sites,
occasionally a client), so my choices may not suit everyone
(compromises with other needs, and have to be easy to learn).

Linux Mint Debian Edition
zsh (better history search reduces typing of various manage.py
commands etc.)
Komodo Edit with NST (New Source Tree)
South
debug_toolbar (very useful, especially for spotting mistakes)

On Aug 23, 3:07 am, Stephen Jackson <jackson.stephe...@gmail.com>
wrote:
> I am new to the world of Django. I would like to hear from other django
> developers describe their dev environment (tools, os, editors, etc.).

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: how to render context like this :

On Wed, Aug 31, 2011 at 11:40 AM, kele <gisxing@gmail.com> wrote:
>
>
> c = Context( {'teams':
>                 {1: ['a', 'b'] , 2:['c', 'd']}
>       } )
>
> i have try like this :
>
>        {% for k in teams %}
>        <li> {{k}} {{k.0}}    # also try teams[k]  ... etc.  but also
> dosent work
>        {% endfor %}
>
> sorry for my noob question , but pls show me how to to this .
>

{% for k,v in teams.items %}
{{ k }}: {{ v.0 }} , {{ v.1 }}
{% endfor %}

Cheers

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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Django Development environment

On Aug 31, 1:16 pm, Jani Tiainen <rede...@gmail.com> wrote:
> On 08/28/2011 12:31 PM, Simon Connah wrote:
>
>
>
> > On 28 Aug 2011, at 04:41, Sam Walters wrote:
>
> >> Debug client-side:
> >> firebug, yslow, a windows computer with ie7
>
> > Rather than using a separate computer with IE 7 I tend to just spin up an Amazon EC2 instance running Windows Server 2003 or Windows Server 2008 for a couple of hours. It makes everything so much easier when it comes to testing.
>
> Or you can always download "Internet Explorer Application Compatibility
> VPC Image" [1] images from Microsoft directly.
>
> (there are IE6 - IE9 images available) for testing websites. Very useful
> with VirtualBox.
>
> [1]http://www.microsoft.com/download/en/details.aspx?id=11575

I thought it took a bit of work to get those VPC images to work with
VirtualBox. The last time I looked they were tied to Virtual PC
(virtual) hardware, and had activation issues with VirtualBox. Has
that changed?

>
> --
>
> Jani Tiainen

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

how to render context like this :

c = Context( {'teams':
{1: ['a', 'b'] , 2:['c', 'd']}
} )

i have try like this :

{% for k in teams %}
<li> {{k}} {{k.0}} # also try teams[k] ... etc. but also
dosent work
{% endfor %}

sorry for my noob question , but pls show me how to to 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Security implications of using the form.fields dictionary directly

Hi all,

In relation to my previous post (unanswered,
http://groups.google.com/group/django-users/browse_thread/thread/aad6fc7e6ad71b4f)
I would like to ask about the security implications of doing the
following:

What I would like to have in the template is:
{{ form.tueren.A}}
{{ form.tueren.B }},
etc.

If I inherit from form.Field and create a tueren FormField with
attributes A,B, etc. I have a direct access to it via
form.fields['tueren'], so
I can write in the template:
{{ form.fields.tueren.A}}
{{ form.fields.tueren.B }}

However, this effectively circumvents the default mechanism of
instantiating a BoundField that restricts the use of the Field in
certain ways, so I was wondering what kind of security repercussions
this might have?

Best regards,
Venelin Petkov

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

django-sms-gateway

Hi all,

I have managed to install django-sms-gateway for use in my application, but I run into a few problems.

The structure of the package is such that the 3 models are inside a models directory. So far, everything looks like its in place; there is an __init.py__ file in the models directory complete with proper code and each model file is aptly described with the app_label meta. However, I still cannot get the code to run.

The errors I get after tweaking include:

cannot import name Gateway
no model named model

What to do?

Re: Django Development environment

On 08/28/2011 12:31 PM, Simon Connah wrote:
>
> On 28 Aug 2011, at 04:41, Sam Walters wrote:
>
>> Debug client-side:
>> firebug, yslow, a windows computer with ie7
>
> Rather than using a separate computer with IE 7 I tend to just spin up an Amazon EC2 instance running Windows Server 2003 or Windows Server 2008 for a couple of hours. It makes everything so much easier when it comes to testing.
>

Or you can always download "Internet Explorer Application Compatibility
VPC Image" [1] images from Microsoft directly.

(there are IE6 - IE9 images available) for testing websites. Very useful
with VirtualBox.

[1] http://www.microsoft.com/download/en/details.aspx?id=11575

--

Jani Tiainen

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Tuesday, August 30, 2011

Django and Cherokee...

Hi all,

I'm having some trouble getting Cherokee to work with Django, and I noticed there are a number of Cherokee, Django users out there. I've posted questions on the Cherokee list, but there are some Django specific questions I have.

My project is called triagedb. It resides in the directory /var/www/NurseTriage/triagedb. In Cherokee I have a vServer for the NurseTriage directory in the physical file system (/var/www/NurseTriage). There is an index.html file in this directory and it is served normally. Within this vServer, I have a rule with web directory of /triagedb (physical directory is /var/www/NurseTriage/triagedb), and only accepts requests from port 443 (required for this app). This rule's handler is set to SCGI with the usual settings as configured by the Django wizard. It uses an information source called Django 11. This is the interpreter line for that source:

python /var/www/NurseTriage/triagedb/manage.py runfcgi protocol=scgi host=127.0.0.1 port=44945

After browsing to https://localhost/NurseTriage/triagedb/admin, I notice there is no instance of manage.py running. Do I need to launch the above command in init.d, or will Cherokee do it? Also, when I run the above command manually from the command prompt, I get 6 distinct processes running all on the same port. Is this normal?

Finally, I'm getting the following error in the Cherokee error log every time I hit the url for Django app:

{'type': "error", 'time': "29/08/2011 01:22:34.324", 'title': "epoll_ctl: ep_fd 19, fd 5: 'Bad file descriptor'", 'code': "fdpoll-epoll.c:140", 'error': "81", 'description': "The issue seems to be related to your system.", 'version': "1.0.14", 'compilation_date': "Dec 13 2010 21:49:35", 'configure_args': " '--host=x86_64-linux-gnu' '--build=x86_64-linux-gnu' '--enable-os-string=Ubuntu' '--enable-pthreads' '--prefix=/usr' '--localstatedir=/var' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--docdir=/usr/share/doc/cherokee-doc' '--with-wwwroot=/var/www' '--with-included-gettext' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-Wall -g -O2' 'LDFLAGS=-Wl,-Bsymbolic-functions' 'CPPFLAGS=' '--host=x86_64-linux-gnu' '--build=x86_64-linux-gnu' '--enable-os-string=Ubuntu' '--enable-pthreads' '--prefix=/usr' '--localstatedir=/var' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--docdir=/usr/share/doc/cherokee-doc' '--with-wwwroot=/var/www' '--with-included-gettext' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-Wall -g -O2' 'LDFLAGS=-Wl,-Bsymbolic-functions' 'CPPFLAGS='", 'backtrace': ""}

This suggests a permissions problem to me. What should the file owners and permissions be on the Django files? Root, or only something readable by root?

Thanx in advance,

Brian

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Combining queries? A "join" in Python?

On Aug 30, 11:48 pm, Andre Terra <andrete...@gmail.com> wrote:
> FWIW, I'm using django-mptt to help me traverse my tree of self-referencing
> models, as well as run complex aggregates based on them.
>
> http://django-mptt.github.com/django-mptt/index.html
>
> Be aware that the API has changed a lot from 0.3 (which is easily found
> around the web) to 0.5 (which will require some more googling or cloning for
> a specific commit from github). The key advantage of using this library is
> that it takes care of adding (and handling) a tree_id column for your
> MPTTModels, which you can then use to filter aggregates and the like. So do
> check it out!
>
> As an anedoctal aside, In my use case I have AccountGroup, Account and
> Entry, and my problem could only be solved through a HUMONGOUS query (62
> lines total) that returns the aggregate sum for Entries for a given
> AccountGroup for a given month, including subtotals for each level of the
> AccountGroup and each Account. So be ready to sharpen up on your SQL skills
> if you're looking for something similar!

My needs are not as complex as yours: although I think I will need to
drop down to SQL if I ever need to optimise this.

What I am am doing (in Python) is effectively annotating the related
model with the result of a query: each Category the template gets has
data from the natching CategoryText added to it as attributes.

As this does not make sense to anyone who has lost track of the models
mentioned earlier, the structure is

SubCategoryText -> SubCategory -> Category <- CategoryText

where -> means "has a foreign key on" and a *Text contains a
translation.

>
> Cheers,
> AT
>
>
>
>
>
>
>
> On Tue, Aug 30, 2011 at 2:10 PM, graeme <graeme.piete...@gmail.com> wrote:
>
> > On Aug 30, 7:25 pm, Stuart <stu...@bistrotech.net> wrote:
> > > On Aug 30, 3:10 am, graeme <graeme.piete...@gmail.com> wrote:
>
> > > > I think I need to restate this question with the actual models.
>
> > > Apologies in advance for answering a question you didn't ask, but is
> > > your subcategory model truly representing something different from
> > > your category model? I think the problems you are having with the
> > > query may be indicative of a problem with your model definitions /
> > > database layout.
>
> > > Unless I have the wrong idea about what you are trying to accomplish,
> > > I recommend a single Category model with a parent field defined as a
> > > back-reference to itself. Something like this:
>
> > >     parent = models.ForeignKey('self', blank=True, null=True,
> > > related_name='child')
>
> > > This approach would eliminate the SubCategory and SubCategoryText
> > > models. The CategoryText looks about right as it is.
>
> > > I'm not clear on precisely what you are trying to accomplish with your
> > > query, but perhaps rethinking your models will make the query easier.
>
> > I must admit I never thought of structuring the database like that. I
> > had to think about it quite a bit.
>
> > What my query does is give me a list of subcategories, ordered by
> > category, and then by the number of places in the category, and
> > annotates each subcategory with the number of places in it.
>
> > Having a single category model might simplify the query, but as I want
> > the page to show something like:
>
> > CATEGORY
> > Subcategory One
> > Subcategory Two
> > CATEGORY TWO
> > Subcategory Three
> > etc.
>
> > I am still going to have to, at least, join the category table to
> > itself, instead of joining the subcategory table to the category
> > table. I have not yet figured out if this will give me easier access
> > to the CategoryText of a parent category (in that case it may simplify
> > things a lot).
>
> > If I am iterating over subcategories (which will now just be those
> > categories without a parent), will I have easier access to the
> > CategoryText of the parent.
>
> > The disadvantage is that the current structure enforces, at the
> > database level, that Places can only belong to a sub-category, and
> > that the hierarchy is only two levels deep. I would have to move some
> > validation out of the database if I did this.
>
> > My current approach, or adding the necessary attributes in Python
> > works. It does help, as I just found out, that I can add attributes to
> > the Categories while looping over SubCategoryTexts (i.e.
> > subcategorytextobject.subcategory.category.foo = bar works). It is
> > still an ugly hack, though.
>
> > > Hope that helps,
>
> > > --Stuart
>
> > --
> > 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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Password Field Not being encrypted

Raj,

PasswordInput deals with browser forms to make sure that a password
can't be seen in the form by someone looking over user's shoulder. But
it does nothing to encrypt passwords in database.

Why don't you check out django.contrib.auth.models for inspiration
about encrypting passwords if plan on doing it yourself and not
reusing the standard auth framework?

Cheers

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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Password Field Not being encrypted

Hey guys, I'm trying to make a custom registration form for a custom
UserProfile class.
I have the following form:

class UserForm(ModelForm):
username = forms.EmailField(label = _("Email"), widget =
forms.TextInput(attrs ={ 'id':'email'}), required=True)
first_name = forms.CharField(widget = forms.TextInput(attrs =
{'id':'fname'}), required=True)
last_name = forms.CharField(widget = forms.TextInput(attrs =
{'id':'lname'}), required=True)
linked_id = forms.CharField(widget = forms.HiddenInput(attrs =
{'id':'linkedid'}))
password = forms.CharField(label=_('Password'),
widget=forms.PasswordInput(render_value = False), required = True)
password2 = forms.CharField(label=_('Re-Enter your password'), widget
= forms.PasswordInput(render_value = False))
email = forms.CharField(widget = forms.HiddenInput(), required =
False)

class Meta:
model = UserProfile
fields = ('username', 'first_name', 'last_name', 'linked_id',
'password', 'email', )

def clean_password2(self):
password1 = self.cleaned_data.get("password", "")
password2 = self.cleaned_data['password2']
if password1 != password2:
raise forms.ValidationError(_("The passwords you entered did not
match!"))
return password2

def clean_email(self):
email = self.cleaned_data['username']
return email

The issue that I'm having is that when the password is entered, and
saved, its not being encrypted. So I can just view a users password in
my admin panel...
How do I get the passwords to be encrypted? I had another website and
it worked then, but when I'm trying it now, it just isn't working.
Help please. Thank 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Setting default form value in template

Hey, figured it out for the most part. Had to use a little jquery to
get it to work.
This is what it looked like:
<head>
<script type = "text/javascript" src="/media/js/jquery.form-
defaults.js"></script>
<script type="text/javascript">
function displayProfiles(profiles) {
member = profiles.values[0];
$(document).ready(function(){
var fname = member.firstName;
var lname = member.lastName;
var id = member.id;
$('#fname').val(fname);
$('#lname').val(lname);
$('#linkedid').val(id);
});
}
</script>
</head>
<body>
<form>
<table>
{{ form.as_table }}
</table>
</form>
</body>
________________________

And in the forms.py file, I just set a widget for each of the forms,
and then as one of the attrs, I stated the id's (as shown in the
jquery)
Example:
last_name = forms.CharField(widget = forms.TextInput(attrs =
{'id':'lname'}), required=True)
Hope you like it. :)
On Aug 26, 2:08 am, Mike Dewhirst <mi...@dewhirst.com.au> wrote:
> I think you need a bit of R&D here. The general advice I've seen is to
> get it working without javascript and then find a js solution.
>
> I feel it is difficult. Back at the server you only have the data the
> browser sends you. If I understand what you are saying, your problem is
> to write some javascript which finds some value(s) which only appear in
> the user's browser in the DOM or in the headers - not sure - and
> manipulate the DOM to save it somewhere before the user hits [Submit].
>
> I'm interested to see how you do this so if you figure it out please
> post your solution.
>
> Cheers
>
> Mike
>
> On 26/08/2011 2:46pm, raj wrote:
>
>
>
>
>
>
>
> > Bump**
>
> > On Aug 25, 12:49 pm, raj<nano.ri...@gmail.com>  wrote:
> >> Actually, I think I'm figuring it out. Just a quick question though.
> >> Is it possible to pass javascript values through the form attrs
> >> attribute? For example:
>
> >> class forms(forms.Form):
> >>      name = forms.TextInput(attrs={'size': 10, 'value': '<?
> >> js=firstName ?>'',})
>
> >> On Aug 25, 12:13 pm, raj<nano.ri...@gmail.com>  wrote:
>
> >>> Let me be a bit more clear.
> >>> Lets take, for example, the linkedin javascript api. Now, when you log
> >>> into your linkedin account through my website, the website can access
> >>> certain parts of your profile using javascript. Now, when the user
> >>> first logs in, I want to be able store some information about the user
> >>> in my database. So, if the user decides to create an article or
> >>> something on my website, his article can be attributed to that
> >>> account. Otherwise, I don't see any other way to attribute data to
> >>> that user. I don't really know how to pass what the javascript return
> >>> back into the view.
> >>> On Aug 25, 2:08 am, Daniel Roseman<dan...@roseman.org.uk>  wrote:
> >>>> On Thursday, 25 August 2011 06:10:38 UTC+1, raj wrote:
> >>>>> I'm trying to set a default form value in the template, and not in the
> >>>>> forms.py file (because I'm trying to make the default value dynamic
> >>>>> depending on something that javascript will return).
> >>>>> So To test it, I have the following line in my template:
> >>>>> {{ form.first_name|default:"Enter Your first name" }}
> >>>>> The issue is that it doesn't work, And I can't figure out why. Am I
> >>>>> doing something illegal?
> >>>>> Help Please. Thank you.
> >>>> No, that doesn't work at all, and never will. The "default" filter is for
> >>>> providing a value in case a particular context variable is empty, not for
> >>>> setting a form field's default value.
> >>>> Your reasoning doesn't seem to make sense, in any case. Templates are
> >>>> rendered server-side, so Javascript can have no effect on what is rendered.
> >>>> Do this in the view.
> >>>> --
> >>>> DR.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django-admin.py not found

The setup.py just gets opened as a text file.
 
But you can ignore it now, Django got installed once I used this command,
 
python setup.py install
 
instead of
 
setup.py install
 
Thanks for your great support.

On Tue, Aug 30, 2011 at 9:58 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
What do you mean it gets opened?  Also, I'd recommend doing this in a temp My Documents (Documents in Vista/Windows 7) folder, let the installers build the necessary directory trees (get rid of the previous installs.)


On Tue, Aug 30, 2011 at 9:52 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
I downloaded as mentioned and when I try this command the file setup.py gets opened.
 
C:\Django\Django-1.3>setup.py install

On Tue, Aug 30, 2011 at 8:49 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
No.  Here is a more lengthy explanation as to what you need to do:

https://docs.djangoproject.com/en/dev/topics/install/#installing-official-release


On Tue, Aug 30, 2011 at 8:46 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
Where do I type the following commands? Is it in the python shell?
 
tar xzvf Django-1.3.tar.gz
cd Django-1.3
sudo python setup.py install
 
What does tar xzvf mean?

On Tue, Aug 30, 2011 at 8:41 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
Where do you have Python installed?

I just followed these steps to install Django, worked like a charm (no special setup or anything.)  I did this just for the fun of it without any production settings (just to try stuff out), did you do something different?

https://docs.djangoproject.com/en/dev/intro/install/


On Tue, Aug 30, 2011 at 8:36 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
This is steps I used to download.
 
1. Download from the Django website.
2. Unzipped it to C:/Django-1.3 folder

On Tue, Aug 30, 2011 at 8:31 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
I dont see any file under site packages. I think my Django is not installed within Python.
 
Something is wrong..

On Tue, Aug 30, 2011 at 8:28 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
Do me a favor and check that you have <your python install>\Lib\site-packages\django\bin\django-admin.py

If you do, try that.  I don't think I have a C:\django-1.3\... directory, could be an issue with how you installed it (I didn't experiment, there was no need).


On Tue, Aug 30, 2011 at 8:18 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
My django-admin.py file is located in
 
C:\django-1.3\django\bin\django-admin.py
 
I tried executing this command but get the following error in my python shell,
 
>>> python C:\django-1.3\django\bin\django-admin.py startproject mysite
SyntaxError: invalid syntax
 


 
On Tue, Aug 30, 2011 at 11:28 AM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
What OS are you running?  Is it in your path?

I'm having a similar issue and managed to get around it (although the solution is not as elegant as I'd like) using this:
python C:\Python27\Lib\site-packages\django\bin\django-admin.py startproject mysite2

On Tue, Aug 30, 2011 at 10:39 AM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
I get the following error when I execute this command,
 
django-admin.py startproject mysite
 
Error:
django-admin.py not found.
 

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
Prem
408-393-2545




--
Prem
408-393-2545



--
Prem
408-393-2545




--
Prem
408-393-2545




--
Prem
408-393-2545




--
Prem
408-393-2545

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: django-admin.py not found

What do you mean it gets opened?  Also, I'd recommend doing this in a temp My Documents (Documents in Vista/Windows 7) folder, let the installers build the necessary directory trees (get rid of the previous installs.)

On Tue, Aug 30, 2011 at 9:52 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
I downloaded as mentioned and when I try this command the file setup.py gets opened.
 
C:\Django\Django-1.3>setup.py install

On Tue, Aug 30, 2011 at 8:49 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
No.  Here is a more lengthy explanation as to what you need to do:

https://docs.djangoproject.com/en/dev/topics/install/#installing-official-release


On Tue, Aug 30, 2011 at 8:46 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
Where do I type the following commands? Is it in the python shell?
 
tar xzvf Django-1.3.tar.gz
cd Django-1.3
sudo python setup.py install
 
What does tar xzvf mean?

On Tue, Aug 30, 2011 at 8:41 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
Where do you have Python installed?

I just followed these steps to install Django, worked like a charm (no special setup or anything.)  I did this just for the fun of it without any production settings (just to try stuff out), did you do something different?

https://docs.djangoproject.com/en/dev/intro/install/


On Tue, Aug 30, 2011 at 8:36 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
This is steps I used to download.
 
1. Download from the Django website.
2. Unzipped it to C:/Django-1.3 folder

On Tue, Aug 30, 2011 at 8:31 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
I dont see any file under site packages. I think my Django is not installed within Python.
 
Something is wrong..

On Tue, Aug 30, 2011 at 8:28 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
Do me a favor and check that you have <your python install>\Lib\site-packages\django\bin\django-admin.py

If you do, try that.  I don't think I have a C:\django-1.3\... directory, could be an issue with how you installed it (I didn't experiment, there was no need).


On Tue, Aug 30, 2011 at 8:18 PM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
My django-admin.py file is located in
 
C:\django-1.3\django\bin\django-admin.py
 
I tried executing this command but get the following error in my python shell,
 
>>> python C:\django-1.3\django\bin\django-admin.py startproject mysite
SyntaxError: invalid syntax
 


 
On Tue, Aug 30, 2011 at 11:28 AM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
What OS are you running?  Is it in your path?

I'm having a similar issue and managed to get around it (although the solution is not as elegant as I'd like) using this:
python C:\Python27\Lib\site-packages\django\bin\django-admin.py startproject mysite2

On Tue, Aug 30, 2011 at 10:39 AM, PremAnand Lakshmanan <prem1pre@gmail.com> wrote:
I get the following error when I execute this command,
 
django-admin.py startproject mysite
 
Error:
django-admin.py not found.
 

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.




--
Prem
408-393-2545




--
Prem
408-393-2545



--
Prem
408-393-2545




--
Prem
408-393-2545




--
Prem
408-393-2545

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.