Re: Using environment variables in settings.py - good practice? How to handle missing variables gracefully?

2013-09-18 Thread Mike Dewhirst

On 19/09/2013 3:59pm, Victor Hooi wrote:

Hi,

Hmm, in many cases there isn't really a sensible default (e.g. API keys
or passwords).

I was asking more in terms of - is this the "right" way of doing it in
Django, or are people using some other technique to handle configuration
you don't want in the repo?

And is there a special exception type you should throw if it's not being
set, or is there a better way to handle it?


Well worth checking out Two Scoops of Django - it has half a chapter on 
exactly this topic. In summary, the authors say to use environment 
variables and to raise ImproperlyConfigured if they don't work.




Cheers,
Victor

On Thursday, 19 September 2013 15:54:15 UTC+10, Dig wrote:

Hi,

   Do you means some thing like this?

os.environ.get('SOME_VARIABLE', 'default_value')

Regards,
Dig

On Sep 19, 2013 1:37 PM, "Victor Hooi" > wrote:

Hi,

I have several settings in my Django settings.py file that are
specific

Currently, I'm grabbing these from environment variables in
settings.py:

import os
...
# TODO - We need to gracefully catch if these aren't set.
SOME_VARIABLE = os.environ['SOME_VARIABLE']


This includes things like API keys, database IPs, database
username/passwords, static file locations etc.

I then set these in the virtualenv activate script.

Is this a good practice in Django?

Also, is there a graceful way of catching when these aren't set?
Currently, I'm using some of those settings variables in
models.py, and it's failing silently. Should I put each
os.environ call in a try/except block, or is there a more
Pythonic way?

Cheers,
Victor

--
You received this message because you are subscribed to the
Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to django-users...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users
.
For more options, visit https://groups.google.com/groups/opt_out
.

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using environment variables in settings.py - good practice? How to handle missing variables gracefully?

2013-09-18 Thread Victor Hooi
Hi,

Hmm, in many cases there isn't really a sensible default (e.g. API keys or 
passwords).

I was asking more in terms of - is this the "right" way of doing it in 
Django, or are people using some other technique to handle configuration 
you don't want in the repo?

And is there a special exception type you should throw if it's not being 
set, or is there a better way to handle it?

Cheers,
Victor

On Thursday, 19 September 2013 15:54:15 UTC+10, Dig wrote:
>
> Hi,
>
>   Do you means some thing like this?
>
> os.environ.get('SOME_VARIABLE', 'default_value')
>
> Regards,
> Dig
> On Sep 19, 2013 1:37 PM, "Victor Hooi" > 
> wrote:
>
>> Hi,
>>
>> I have several settings in my Django settings.py file that are specific 
>>
>> Currently, I'm grabbing these from environment variables in settings.py:
>>
>> import os
>>> ...
>>> # TODO - We need to gracefully catch if these aren't set.
>>> SOME_VARIABLE = os.environ['SOME_VARIABLE']
>>
>>
>> This includes things like API keys, database IPs, database 
>> username/passwords, static file locations etc.
>>
>> I then set these in the virtualenv activate script.
>>
>> Is this a good practice in Django?
>>
>> Also, is there a graceful way of catching when these aren't set? 
>> Currently, I'm using some of those settings variables in models.py, and 
>> it's failing silently. Should I put each os.environ call in a try/except 
>> block, or is there a more Pythonic way?
>>
>> Cheers,
>> Victor
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using environment variables in settings.py - good practice? How to handle missing variables gracefully?

2013-09-18 Thread Dig
Hi,

  Do you means some thing like this?

os.environ.get('SOME_VARIABLE', 'default_value')

Regards,
Dig
On Sep 19, 2013 1:37 PM, "Victor Hooi"  wrote:

> Hi,
>
> I have several settings in my Django settings.py file that are specific
>
> Currently, I'm grabbing these from environment variables in settings.py:
>
> import os
>> ...
>> # TODO - We need to gracefully catch if these aren't set.
>> SOME_VARIABLE = os.environ['SOME_VARIABLE']
>
>
> This includes things like API keys, database IPs, database
> username/passwords, static file locations etc.
>
> I then set these in the virtualenv activate script.
>
> Is this a good practice in Django?
>
> Also, is there a graceful way of catching when these aren't set?
> Currently, I'm using some of those settings variables in models.py, and
> it's failing silently. Should I put each os.environ call in a try/except
> block, or is there a more Pythonic way?
>
> Cheers,
> Victor
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Using environment variables in settings.py - good practice? How to handle missing variables gracefully?

2013-09-18 Thread Victor Hooi
Hi,

I have several settings in my Django settings.py file that are specific 

Currently, I'm grabbing these from environment variables in settings.py:

import os
> ...
> # TODO - We need to gracefully catch if these aren't set.
> SOME_VARIABLE = os.environ['SOME_VARIABLE']


This includes things like API keys, database IPs, database 
username/passwords, static file locations etc.

I then set these in the virtualenv activate script.

Is this a good practice in Django?

Also, is there a graceful way of catching when these aren't set? Currently, 
I'm using some of those settings variables in models.py, and it's failing 
silently. Should I put each os.environ call in a try/except block, or is 
there a more Pythonic way?

Cheers,
Victor

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: password field showing hashed value on form value update

2013-09-18 Thread Russell Keith-Magee
On Thu, Sep 19, 2013 at 12:49 PM, Sivaram R  wrote:

> Karkar,
>
>I am not getting your point.I am using django default user model,my
> requirement is,after the user successfully login,their is a page called
> update user profile,their i am showing first name,last name,email are in
> update mode but password is showing the hashed value and not the original
> value entered.How to decrypt that hashed value to original value.
>
> You don't. Ever. That's the whole point of a hashed password. You don't
store the password - you store a one way hash of the password.

Any authentication system that allows you to retrieve the original password
is, by very definition, broken. Any website using such a authentication
system is waiting to be exploited. And we have *plenty* of examples of
sites that have been broken in this way.

Django's user authentication system uses a one way hashing function (PBKDF2
by default, but other options exist). You *cannot* retrieve the original
password from the hash. This is a *deliberate* feature, and *will not* be
changed.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: password field showing hashed value on form value update

2013-09-18 Thread Sivaram R
Karkar,

   I am not getting your point.I am using django default user model,my 
requirement is,after the user successfully login,their is a page called 
update user profile,their i am showing first name,last name,email are in 
update mode but password is showing the hashed value and not the original 
value entered.How to decrypt that hashed value to original value.

Thanks 

On Wednesday, September 18, 2013 10:59:30 PM UTC+5:30, Kakar wrote:
>
> R u looking at the password from the admin?
>
>
>
> Sivaram R > wrote:
>
>
> I have views.py to show the form instance and update the instance.
>
> On edit the form data,all other field are showing the correct 
> value,password field is showing the entire hashed value from database and 
> not the entered password.
>
> Is any way to show the entered password instead of hashed value in 
> database.
>
> forms.py
>
> class UserRegisterForm(forms.ModelForm):
> password = forms.CharField(widget=forms.PasswordInput(render_value=True))
> class Meta:
> model = User
>
> Thanks
>
>
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: add marks of same roll number of different of different semestrs

2013-09-18 Thread Harjot Mann
On Thu, Sep 19, 2013 at 7:39 AM, Lachlan Musicman  wrote:
> Harjot,
>
> The answer to your question requires more information.
>
> We would need to see your model structure at the least.


I want to add the marks of same roll number in different classes as
given in the screenshot both the rows are of same roll number I want
to add the marks of physics of class 11th ans 12th according to roll
number.
Here id my models. Its simple.

class StudentDetail(models.Model):
roll_no=models.IntegerField()
Class=models.CharField(max_length=100, blank=True, null=True)
physics=models.IntegerField(blank=True, null =True)
maths=models.IntegerField(blank=True, null =True)
chemistry=models.IntegerField(blank=True, null =True)

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


while loop in django

2013-09-18 Thread Harjot Mann
Please tell me how to use while loop indjango so that marks of
students can be added untill the same roll number is going on?

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: add marks of same roll number of different of different semestrs

2013-09-18 Thread Lachlan Musicman
Harjot,

The answer to your question requires more information.

We would need to see your model structure at the least.

cheers
L.

On 19 September 2013 03:38, Harjot Mann  wrote:
> Here is the scrrenshot of my output, please tell me how can boht the
> marks of physics of same roll number of different classes or
> semesters?
> http://screencloud.net/v/aCsl
>
> --
> Harjot Kaur Mann
> Blog: http://harjotmann.wordpress.com/
> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Maya Otos (@maya_otos) tweeted at 9:27 PM on Tue, Jul 30, 2013:
When you used to be punk, and now you are still punk but not as punk,
are you post-punk or decaying punk or ex-punk or just not punk anymore

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: migrating from django 1.3.0 to 1.5.4, getting ImproperlyConfigured exceptions (AUTH_USER_MODEL refers to model 'auth.User' that has not been installed)

2013-09-18 Thread Russell Keith-Magee
On Thu, Sep 19, 2013 at 1:51 AM, Lauri Carpenter <
lauri.loebel.carpen...@gmail.com> wrote:

> We have been using django 1.3.0 for a long time.  We are now trying to
> migrate to 1.5.4.  We have not changed any schema or model information.  We
> have been using two layers of middleware and backends (notably something
> based on SSLAuth Django App to authenticate first by certificate issued
> from a trusted authority, then django_auth_ldap to login via ldap if no
> valid certificate is presented). Both of these live on top of whatever
> user/certificate/client/etc. scheme is supported in django 1.3.0.
>
> But under django 1.5.4 we are
> seeing django.core.exceptions.ImproperlyConfigured exceptions
> "AUTH_USER_MODEL refers to model 'auth.User' that has not been installed"
> on the gui page when trying to log in.  The chunk'o'code that handles
> looking for certificate and creating a user if the certificate is presented
> gets this error (so that nobody can use their certificates to log in); then
> the fallback "login" view kicks in, and gets the traceback shown here;
> Traceback:
> File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in
> get_response
>   115. response = callback(request,
> *callback_args, **callback_kwargs)
> File "/var/www/lauri/dj/ncis_gui/ncis_gui/src/ncis_gui.py" in login
>   244. return views.login(request, *args, template_name='login.html',
> extra_context=ncis_context, **kwargs)
> File "/usr/lib/python2.6/site-packages/django/views/decorators/debug.py"
> in sensitive_post_parameters_wrapper
>   75. return view(request, *args, **kwargs)
> File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in
> _wrapped_view
>   91. response = view_func(request, *args, **kwargs)
> File "/usr/lib/python2.6/site-packages/django/views/decorators/cache.py"
> in _wrapped_view_func
>   89. response = view_func(request, *args, **kwargs)
> File "/usr/lib/python2.6/site-packages/django/contrib/auth/views.py" in
> login
>   53. form = authentication_form(request)
> File "/usr/lib/python2.6/site-packages/django/contrib/auth/forms.py" in
> __init__
>   177. UserModel = get_user_model()
> File "/usr/lib/python2.6/site-packages/django/contrib/auth/__init__.py" in
> get_user_model
>   129. raise ImproperlyConfigured("AUTH_USER_MODEL refers to model
> '%s' that has not been installed" % settings.AUTH_USER_MODEL)
>
> Exception Type: ImproperlyConfigured at /login/
> Exception Value: AUTH_USER_MODEL refers to model 'auth.User' that has not
> been installed
>
>
> After googling and reading whatever I could find on the subject (most
> notably
> http://procrastinatingdev.com/django/using-configurable-user-models-in-django-1-5/
>  where
> it expressly says that if you're happy with the existing stuff you don't
> have to change any code) -- I am thoroughly vexed.
>
> What migration step have I missed in order to really use the stuff we were
> using before without changes?
>

It's difficult to answer without knowing more about your actual setup. I
don't know anything about the SSLAuth or django_auth_ldap apps, so I don't
know what they're doing internally. However, because they're doing fun
things with Django 1.3 authentication, it's possible they might be bending
some rules, making some model changes via monkey patching, or doing
otherwise unexpected things with auth.

In this case, the error you're getting is caused because the auth.User
model wasn't found in the app cache. This could be because
django.contrib.auth isn't in INSTALLED_APPS, or because one of the apps
you're using is patching the contents of the app cache for some reason.

Sorry I can't be more helpful here - if you can point us at the exact
repositories you're using for SSL auth and auth_ldap, it might be possible
to provide some more assistance.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: password field showing hashed value on form value update

2013-09-18 Thread kakararunachalservice
R u looking at the password from the admin?


Sivaram R  wrote:

I have views.py to show the form instance and update the instance.

On edit the form data,all other field are showing the correct value,password 
field is showing the entire hashed value from database and not the entered 
password.

Is any way to show the entered password instead of hashed value in database.

forms.py

class UserRegisterForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput(render_value=True))
class Meta:
model = User
Thanks



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need help figuring out why my { key:value } doesn't seem to be passed to my view by my javascript file.

2013-09-18 Thread C. Kirby
If you want to use key value pairs like that, and you are modifying data in 
your database, you should really be using a POST and not a GET

On Wednesday, September 18, 2013 10:00:51 AM UTC-5, 7equiv...@gmail.com 
wrote:
>
> "So I think that the ajax() function is calling the URL 
> "/pi/?pathID=somevalue," Is that different than how a key:value pair are 
> normally sent? I don't know much about this.
> This is the output from the development server...
>
> "GET /pi/ HTTP/1.1" 200 2600
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: password field showing hashed value on form value update

2013-09-18 Thread C. Kirby
Django doesn't store the original password, that would be a huge security 
hole. It only has the hashed password available.

On Wednesday, September 18, 2013 10:10:02 AM UTC-5, Sivaram R wrote:
>
> I have views.py to show the form instance and update the instance.
>
> On edit the form data,all other field are showing the correct 
> value,password field is showing the entire hashed value from database and 
> not the entered password.
>
> Is any way to show the entered password instead of hashed value in 
> database.
>
> forms.py
>
> class UserRegisterForm(forms.ModelForm):
> password = forms.CharField(widget=forms.PasswordInput(render_value=True))
> class Meta:
> model = User
>
> Thanks
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: iterating over a queryset?

2013-09-18 Thread Bill Freeman
.get() actually gets you an instance, while the queryset without the get
acts (somewhat) like a list of instances.  It is the .values() call that
causes you to have dicts rather than instances.  .get() considers it an
error if the queryset represents either zero objects, or two or more
objects (it doesn't know which one to give you).  In this case you may
actually want get, since I presume that there should only be one Customer
per User.

Just for completeness, context[0] is similar to context.get().  It will
still raise an error if there are no such Customer objects, but it won't
complain if there are more than 1.

And, yes, the decision of which field is shown in what order should
probably be in the template, since it is very much presentation, rather
than logic, so passing in just the one instance and using things like {{
data.field_name }} is likely the way to go.


On Wed, Sep 18, 2013 at 3:58 PM, Johan Bergkvist wrote:

> Hi
> Yeah I see.
> I tried it out just after writing, with little success, but without the
> .values() I do still have the {{ data.field_name }} available which Is
> probably more usefull than actually iterating over a dataset regardless of
> content.
> Still the relationsships are only available as forwards and backwards
> relations on instances, right? Which, if I understand you correctly I only
> get when omitting the .get() method.
> I probably should have started out with a Python tutorial before jumping
> in to django :) Well, no pain no gain I guess.
> thanks by the way.
>
> Den onsdag den 18. september 2013 20.14.47 UTC+2 skrev Daniel Roseman:
>
>> Well, not quite. That will work if you just omit .get(), because then
>> you'll have a ValuesQuerySet - basically, a list of dicts. However, if you
>> omit .values() as well you'll have a plain old QuerySet - ie a list of
>> model instances - and those instances aren't dicts and don't have an
>> .items() method. There's not really a good way of iterating over all the
>> fields in an instance with their names (you can muck about with the stuff
>> in _meta, but I wouldn't recommend it).
>>
>> As I say though, in practice that's rarely a problem as you usually want
>> to reference individual fields by name, rather than iterating over them.
>> --
>> DR.
>>
>>
>> On Wednesday, 18 September 2013 16:39:34 UTC+1, Johan Bergkvist wrote:
>>>
>>> Hi, thanks - that provides some perspective.
>>>
>>> So if I omitted the .get() and .values() i will have to loop over the
>>> queryset and then each dict, doing something like:
>>>
>>> {% for q in info %}
>>>   {% for k, v in q.items %}
>>>{{ k }} {{ v}}
>>>   {% empty %}
>>>no data
>>>   {% endfor %}
>>> {%endfor%}
>>> ?
>>>
>>>
>>>
>>>
>>> Den onsdag den 18. september 2013 00.02.21 UTC+2 skrev Daniel Roseman:

 Without the get(), you get a queryset, which is an iterable of all
 elements that match the query - in effect, a list of dicts. Even though
 only one record matches, you still get a queryset containing a single dict.
 So in order to use that in your template, you'd have to add an outer loop
 iterating through each item in the queryset, while the inner loop iterates
 over the elements in each dict.

 Reverse relations work with a model instance. But you don't have one of
 those - you've got a dict, because you used .values(). If you dropped that
 call, you'd have an instance which you could use the backwards relation on,
 but you wouldn't be able to iterate over the fields with .items(). Note
 that most of the time you don't need to do that, so mostly you would use
 the instance rather than calling .values().

 --
 DR.

  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: iterating over a queryset?

2013-09-18 Thread Johan Bergkvist
Hi
Yeah I see.
I tried it out just after writing, with little success, but without the 
.values() I do still have the {{ data.field_name }} available which Is 
probably more usefull than actually iterating over a dataset regardless of 
content.
Still the relationsships are only available as forwards and backwards 
relations on instances, right? Which, if I understand you correctly I only 
get when omitting the .get() method.
I probably should have started out with a Python tutorial before jumping in 
to django :) Well, no pain no gain I guess.
thanks by the way.

Den onsdag den 18. september 2013 20.14.47 UTC+2 skrev Daniel Roseman:
>
> Well, not quite. That will work if you just omit .get(), because then 
> you'll have a ValuesQuerySet - basically, a list of dicts. However, if you 
> omit .values() as well you'll have a plain old QuerySet - ie a list of 
> model instances - and those instances aren't dicts and don't have an 
> .items() method. There's not really a good way of iterating over all the 
> fields in an instance with their names (you can muck about with the stuff 
> in _meta, but I wouldn't recommend it).
>
> As I say though, in practice that's rarely a problem as you usually want 
> to reference individual fields by name, rather than iterating over them.
> --
> DR.
>
>
> On Wednesday, 18 September 2013 16:39:34 UTC+1, Johan Bergkvist wrote:
>>
>> Hi, thanks - that provides some perspective.
>>
>> So if I omitted the .get() and .values() i will have to loop over the 
>> queryset and then each dict, doing something like:
>>
>> {% for q in info %}
>>   {% for k, v in q.items %}
>>{{ k }} {{ v}}
>>   {% empty %}
>>no data
>>   {% endfor %}
>> {%endfor%}
>> ?
>>
>>
>>
>>
>> Den onsdag den 18. september 2013 00.02.21 UTC+2 skrev Daniel Roseman:
>>>
>>> Without the get(), you get a queryset, which is an iterable of all 
>>> elements that match the query - in effect, a list of dicts. Even though 
>>> only one record matches, you still get a queryset containing a single dict. 
>>> So in order to use that in your template, you'd have to add an outer loop 
>>> iterating through each item in the queryset, while the inner loop iterates 
>>> over the elements in each dict.
>>>
>>> Reverse relations work with a model instance. But you don't have one of 
>>> those - you've got a dict, because you used .values(). If you dropped that 
>>> call, you'd have an instance which you could use the backwards relation on, 
>>> but you wouldn't be able to iterate over the fields with .items(). Note 
>>> that most of the time you don't need to do that, so mostly you would use 
>>> the instance rather than calling .values().
>>>
>>> -- 
>>> DR.
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Hosting multiple sites on a single application

2013-09-18 Thread Doug Ballance
I can't recommend either of those solutions specifically, but I have been 
using an approach similar to that of django-multisite running on a threaded 
fastcgi instance since django .96 days and it has worked well for us.  My 
main concern would be with third-party apps that set static data initially 
from settings, and would bypass any per-request changes.   A seconday 
concern is with caching and handling cached templates, which means writing 
your own per-site template loader or not using template caching.

You can host multiple domains from one instance with a bit of work and 
auditing all the 3rd pary code you use to make sure it does what you 
expect, but it does add some quirks.  Worth it for the memory savings in my 
opinion though if you are willing to be careful and you are doing very 
little other than template customization for each site.  It also makes 
maintenance and upgrades much simpler.

On Tuesday, September 17, 2013 4:12:32 AM UTC-5, James Zildjian wrote:
>
>
> Hi 
>
> I am trying to run around 50 mini sites which share about 90% of their 
> code. Each site simply queries and API and returns the results, and will be 
> on it's own domain, and have a different style.css and config.py. The 
> userbase (and the database generally) will be shared across the board. My 
> initial idea was to run them as separate applications with a common 
> library, each with their own UWSGI thread. However, I have concerns about 
> large memory use. 
>
> I have read about the sites framework which would allow them to run from a 
> single instance.
> 4
>
> https://docs.djangoproject.com/en/dev/ref/contrib/sites/
>
> My question is, is the site framework the right approach to a problem like 
> this, and does it have real benefits over running separate applications. I 
> have heard the following:
>
> *Your SITE_ID is set in settings.py, so in order to have multiple sites, 
> you need multiple settings.py configurations, which means multiple distinct 
> processes/instances. You can of course share the code base between them, 
> but each site will need a dedicated worker / WSGIDaemon to serve the site.
> *
>
> Alternative ideas of systems:
>
> https://github.com/iivvoo/django_layers
> https://github.com/shestera/django-multisite 
>
> Any ideas or help would be most appreciated.
>
> James
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: migrating from django 1.3.0 to 1.5.4, getting ImproperlyConfigured exceptions (AUTH_USER_MODEL refers to model 'auth.User' that has not been installed)

2013-09-18 Thread Daniel Roseman
On Wednesday, 18 September 2013 18:51:30 UTC+1, Lauri Carpenter wrote:

> We have been using django 1.3.0 for a long time.  We are now trying to 
> migrate to 1.5.4.  We have not changed any schema or model information.  We 
> have been using two layers of middleware and backends (notably something 
> based on SSLAuth Django App to authenticate first by certificate issued 
> from a trusted authority, then django_auth_ldap to login via ldap if no 
> valid certificate is presented). Both of these live on top of whatever 
> user/certificate/client/etc. scheme is supported in django 1.3.0.
>
> But under django 1.5.4 we are 
> seeing django.core.exceptions.ImproperlyConfigured exceptions 
> "AUTH_USER_MODEL refers to model 'auth.User' that has not been installed" 
> on the gui page when trying to log in.  The chunk'o'code that handles 
> looking for certificate and creating a user if the certificate is presented 
> gets this error (so that nobody can use their certificates to log in); then 
> the fallback "login" view kicks in, and gets the traceback shown here;
> Traceback:
> File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in 
> get_response
>   115. response = callback(request, 
> *callback_args, **callback_kwargs)
> File "/var/www/lauri/dj/ncis_gui/ncis_gui/src/ncis_gui.py" in login
>   244. return views.login(request, *args, template_name='login.html', 
> extra_context=ncis_context, **kwargs)
> File "/usr/lib/python2.6/site-packages/django/views/decorators/debug.py" 
> in sensitive_post_parameters_wrapper
>   75. return view(request, *args, **kwargs)
> File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in 
> _wrapped_view
>   91. response = view_func(request, *args, **kwargs)
> File "/usr/lib/python2.6/site-packages/django/views/decorators/cache.py" 
> in _wrapped_view_func
>   89. response = view_func(request, *args, **kwargs)
> File "/usr/lib/python2.6/site-packages/django/contrib/auth/views.py" in 
> login
>   53. form = authentication_form(request)
> File "/usr/lib/python2.6/site-packages/django/contrib/auth/forms.py" in 
> __init__
>   177. UserModel = get_user_model()
> File "/usr/lib/python2.6/site-packages/django/contrib/auth/__init__.py" in 
> get_user_model
>   129. raise ImproperlyConfigured("AUTH_USER_MODEL refers to model 
> '%s' that has not been installed" % settings.AUTH_USER_MODEL)
>
> Exception Type: ImproperlyConfigured at /login/
> Exception Value: AUTH_USER_MODEL refers to model 'auth.User' that has not 
> been installed
>
>
> After googling and reading whatever I could find on the subject (most 
> notably 
> http://procrastinatingdev.com/django/using-configurable-user-models-in-django-1-5/
>  where 
> it expressly says that if you're happy with the existing stuff you don't 
> have to change any code) -- I am thoroughly vexed.
>
> What migration step have I missed in order to really use the stuff we were 
> using before without changes?
>
> -- lauri
>
>
Is 'django.contrib.auth' included in your INSTALLED_APPS? Potentially 
Django is stricter about this now than it used to be.
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: iterating over a queryset?

2013-09-18 Thread Daniel Roseman
Well, not quite. That will work if you just omit .get(), because then 
you'll have a ValuesQuerySet - basically, a list of dicts. However, if you 
omit .values() as well you'll have a plain old QuerySet - ie a list of 
model instances - and those instances aren't dicts and don't have an 
.items() method. There's not really a good way of iterating over all the 
fields in an instance with their names (you can muck about with the stuff 
in _meta, but I wouldn't recommend it).

As I say though, in practice that's rarely a problem as you usually want to 
reference individual fields by name, rather than iterating over them.
--
DR.


On Wednesday, 18 September 2013 16:39:34 UTC+1, Johan Bergkvist wrote:
>
> Hi, thanks - that provides some perspective.
>
> So if I omitted the .get() and .values() i will have to loop over the 
> queryset and then each dict, doing something like:
>
> {% for q in info %}
>   {% for k, v in q.items %}
>{{ k }} {{ v}}
>   {% empty %}
>no data
>   {% endfor %}
> {%endfor%}
> ?
>
>
>
>
> Den onsdag den 18. september 2013 00.02.21 UTC+2 skrev Daniel Roseman:
>>
>> Without the get(), you get a queryset, which is an iterable of all 
>> elements that match the query - in effect, a list of dicts. Even though 
>> only one record matches, you still get a queryset containing a single dict. 
>> So in order to use that in your template, you'd have to add an outer loop 
>> iterating through each item in the queryset, while the inner loop iterates 
>> over the elements in each dict.
>>
>> Reverse relations work with a model instance. But you don't have one of 
>> those - you've got a dict, because you used .values(). If you dropped that 
>> call, you'd have an instance which you could use the backwards relation on, 
>> but you wouldn't be able to iterate over the fields with .items(). Note 
>> that most of the time you don't need to do that, so mostly you would use 
>> the instance rather than calling .values().
>>
>> -- 
>> DR.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Middleware Causing OperationalError: (2006, 'MySQL server has gone away')

2013-09-18 Thread Paul Childs
After much research and help from a DBA in a company the solution to the 
problem was to put the following in the mysqld section of the my.ini file:

max_allowed_packet=128M

I think that the HTML header was so large that when the middleware made a 
call to MySQL it couldn't handle the size of the packet, which I am told is 
only 1MB by default for windows.

On Tuesday, September 10, 2013 11:01:42 AM UTC-3, Paul Childs wrote:
>
> Environment: Django 1.4, MySQL 5.5.33
>
> In one of my views I am consistently getting  a MySQL 
> error: OperationalError: (2006, 'MySQL server has gone away')
>
> Traceback (most recent call last):
>   File "C:\Python26\Lib\wsgiref\handlers.py", line 93, in run
> self.result = application(self.environ, self.start_response)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\contrib\staticfiles\handlers.py",
>  
> line 67, in __call__
> return self.application(environ, start_response)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\wsgi.py", 
> line 241, in __call__
> response = self.get_response(request)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py", 
> line 191, in get_response
> signals.got_request_exception.send(sender=self.__class__, 
> request=request)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\dispatch\dispatcher.py", 
> line 172, in send
> response = receiver(signal=self, sender=sender, **named)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\__init__.py", line 
> 62, in _rollback_on_exception
> transaction.rollback_unless_managed(using=conn)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\transaction.py", 
> line 129, in rollback_unless_managed
> connection.rollback_unless_managed()
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\__init__.py", 
> line 214, in rollback_unless_managed
> self._rollback()
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\mysql\base.py",
>  
> line 404, in _rollback
> BaseDatabaseWrapper._rollback(self)
>   File 
> "C:\virtual_env\sitar_env2\lib\site-packages\django\db\backends\__init__.py", 
> line 54, in _rollback
> return self.connection.rollback()
> OperationalError: (2006, 'MySQL server has gone away')
> [10/Sep/2013 10:29:11] "GET /trending/res_entry/pim/0/ HTTP/1.1" 500 59
>
> Looking at the stack trace it didn't look like the problem was with my 
> view.
>
> I traced through the code and the error occurs in one of the middleware 
> methods that is executed when I redirect to another page:
>
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(67)res_management()
> -> q_ress = Res.objects.filter(maintenance_phase=maintenance_phase)    
> Hitting the DB OK here
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(69)res_management()
> -> res_list = fmas.get_ress(q_ress, mode, maintenance_phase)
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(70)res_management()
> -> request.session['my_res_list'] = res_list
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(71)res_management()
> -> return redirect('/trending/res_{0}/{1}/1/'.format(mode,
> (Pdb)
> > c:\virtual_env\sitar_env2\cissimp\trending\views.py(72)res_management()
> -> maintenance_phase))
> (Pdb)
> --Return--
> > 
> c:\virtual_env\sitar_env2\cissimp\trending\views.py(72)res_management()->
> -> maintenance_phase))
> (Pdb)
> > 
> c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(124)get_response()
> -> if response is None:
> (Pdb) response is None
> False
> (Pdb) n
> > 
> c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(133)get_response()
> -> if hasattr(response, 'render') and callable(response.render):
> (Pdb) l
> 128 view_name = callback.__class__.__name__ + 
> '.__call__' # If it's a class
> 129 raise ValueError("The view %s.%s didn't return 
> an HttpResponse object." % (callback.__module__, view_name))
> 130
> 131 # If the response supports deferred rendering, 
> apply template
> 132 # response middleware and the render the response
> 133  -> if hasattr(response, 'render') and 
> callable(response.render):
> 134 for middleware_method in 
> self._template_response_middleware:
> 135 response = middleware_method(request, 
> response)
> 136 response = response.render()
> 137
> 138 except http.Http404, e:
> (Pdb) n
> > 
> c:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py(183)get_response()
> -> urlresolvers.set_urlconf(None)
> (Pdb) l
> 178 
> signals.got_request_exception.send(sender=self.__class__, request=request)
> 179 response = self.handle_uncaught_exception(request, 
> resolver, sys.exc_info())

Re: iterating over a queryset?

2013-09-18 Thread Bill Freeman
No.  q will be a model instance, not a dict.  Your inner loop would,
perhaps, loop over a sequence of names (like the arguments you were passing
to value()) and use those names to access the attributes of q.

This might more cleanly handled with a method on the q object's class that
returns the desired sequence.  You could, of course, name such a method
"items", in which case your code above is exactly correct, but I think a
more descriptive name is desireable.

Bill




On Wed, Sep 18, 2013 at 11:39 AM, Johan Bergkvist wrote:

> Hi, thanks - that provides some perspective.
>
> So if I omitted the .get() and .values() i will have to loop over the
> queryset and then each dict, doing something like:
>
> {% for q in info %}
>   {% for k, v in q.items %}
>{{ k }} {{ v}}
>   {% empty %}
>no data
>   {% endfor %}
> {%endfor%}
> ?
>
>
>
>
> Den onsdag den 18. september 2013 00.02.21 UTC+2 skrev Daniel Roseman:
>
>> Without the get(), you get a queryset, which is an iterable of all
>> elements that match the query - in effect, a list of dicts. Even though
>> only one record matches, you still get a queryset containing a single dict.
>> So in order to use that in your template, you'd have to add an outer loop
>> iterating through each item in the queryset, while the inner loop iterates
>> over the elements in each dict.
>>
>> Reverse relations work with a model instance. But you don't have one of
>> those - you've got a dict, because you used .values(). If you dropped that
>> call, you'd have an instance which you could use the backwards relation on,
>> but you wouldn't be able to iterate over the fields with .items(). Note
>> that most of the time you don't need to do that, so mostly you would use
>> the instance rather than calling .values().
>>
>> --
>> DR.
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


migrating from django 1.3.0 to 1.5.4, getting ImproperlyConfigured exceptions (AUTH_USER_MODEL refers to model 'auth.User' that has not been installed)

2013-09-18 Thread Lauri Carpenter
We have been using django 1.3.0 for a long time.  We are now trying to 
migrate to 1.5.4.  We have not changed any schema or model information.  We 
have been using two layers of middleware and backends (notably something 
based on SSLAuth Django App to authenticate first by certificate issued 
from a trusted authority, then django_auth_ldap to login via ldap if no 
valid certificate is presented). Both of these live on top of whatever 
user/certificate/client/etc. scheme is supported in django 1.3.0.

But under django 1.5.4 we are 
seeing django.core.exceptions.ImproperlyConfigured exceptions 
"AUTH_USER_MODEL refers to model 'auth.User' that has not been installed" 
on the gui page when trying to log in.  The chunk'o'code that handles 
looking for certificate and creating a user if the certificate is presented 
gets this error (so that nobody can use their certificates to log in); then 
the fallback "login" view kicks in, and gets the traceback shown here;
Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in 
get_response
  115. response = callback(request, *callback_args, 
**callback_kwargs)
File "/var/www/lauri/dj/ncis_gui/ncis_gui/src/ncis_gui.py" in login
  244. return views.login(request, *args, template_name='login.html', 
extra_context=ncis_context, **kwargs)
File "/usr/lib/python2.6/site-packages/django/views/decorators/debug.py" in 
sensitive_post_parameters_wrapper
  75. return view(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in 
_wrapped_view
  91. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/views/decorators/cache.py" in 
_wrapped_view_func
  89. response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/auth/views.py" in 
login
  53. form = authentication_form(request)
File "/usr/lib/python2.6/site-packages/django/contrib/auth/forms.py" in 
__init__
  177. UserModel = get_user_model()
File "/usr/lib/python2.6/site-packages/django/contrib/auth/__init__.py" in 
get_user_model
  129. raise ImproperlyConfigured("AUTH_USER_MODEL refers to model 
'%s' that has not been installed" % settings.AUTH_USER_MODEL)

Exception Type: ImproperlyConfigured at /login/
Exception Value: AUTH_USER_MODEL refers to model 'auth.User' that has not 
been installed


After googling and reading whatever I could find on the subject (most 
notably 
http://procrastinatingdev.com/django/using-configurable-user-models-in-django-1-5/
 where 
it expressly says that if you're happy with the existing stuff you don't 
have to change any code) -- I am thoroughly vexed.

What migration step have I missed in order to really use the stuff we were 
using before without changes?

-- lauri

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: password field showing hashed value on form value update

2013-09-18 Thread Bill Freeman
That is a bad idea.  It leaves your users vulnerable to a server or
database or database backup compromise.

The design is that if your server/database doesn't know the password, it
can't give it up.

If you truly want to store passwords in the clear, you will have to
re-implement the authentication back end for yourself.  Most of us would
feel that it would be irresponsible to help you.

Be sure you have a very good reason.  You don't, for example, need the
clear text of old passwords to prevent a user from reusing an old password:
the old hashes are enough.

Bill


On Wed, Sep 18, 2013 at 11:10 AM, Sivaram R  wrote:

> I have views.py to show the form instance and update the instance.
>
> On edit the form data,all other field are showing the correct
> value,password field is showing the entire hashed value from database and
> not the entered password.
>
> Is any way to show the entered password instead of hashed value in
> database.
>
> forms.py
>
> class UserRegisterForm(forms.ModelForm):
> password = forms.CharField(widget=forms.PasswordInput(render_value=True))
> class Meta:
> model = User
>
> Thanks
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


add marks of same roll number of different of different semestrs

2013-09-18 Thread Harjot Mann
Here is the scrrenshot of my output, please tell me how can boht the
marks of physics of same roll number of different classes or
semesters?
http://screencloud.net/v/aCsl

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


App which relies on collecting data from different APIs

2013-09-18 Thread Jaimin Patel
Hi - Its may or may not be Django specific question. I am wondering if I 
want to develop something which consumes json/xml/csv data from different 
sources like news RSS feed, Sports data api for scores or restaurant menu 
price. is there any good architecture workflow one can recommend to do it 
in Django/Python? 

I am looking for somewhat generic solution, which provides code 
reusability, instead of brute force way would be parse each of the dataset 
individually and on-board to the application with required format, but in 
that case each will follow their code base which will hardly work for other 
type of dataset. 

Happy to provide more information if one finds it confusing. Again the 
question is, How can I design the app so that adding new sources and new 
format is easy going forward.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: iterating over a queryset?

2013-09-18 Thread Johan Bergkvist
Hi, thanks - that provides some perspective.

So if I omitted the .get() and .values() i will have to loop over the 
queryset and then each dict, doing something like:

{% for q in info %}
  {% for k, v in q.items %}
   {{ k }} {{ v}}
  {% empty %}
   no data
  {% endfor %}
{%endfor%}
?




Den onsdag den 18. september 2013 00.02.21 UTC+2 skrev Daniel Roseman:
>
> Without the get(), you get a queryset, which is an iterable of all 
> elements that match the query - in effect, a list of dicts. Even though 
> only one record matches, you still get a queryset containing a single dict. 
> So in order to use that in your template, you'd have to add an outer loop 
> iterating through each item in the queryset, while the inner loop iterates 
> over the elements in each dict.
>
> Reverse relations work with a model instance. But you don't have one of 
> those - you've got a dict, because you used .values(). If you dropped that 
> call, you'd have an instance which you could use the backwards relation on, 
> but you wouldn't be able to iterate over the fields with .items(). Note 
> that most of the time you don't need to do that, so mostly you would use 
> the instance rather than calling .values().
>
> -- 
> DR.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


password field showing hashed value on form value update

2013-09-18 Thread Sivaram R


I have views.py to show the form instance and update the instance.

On edit the form data,all other field are showing the correct 
value,password field is showing the entire hashed value from database and 
not the entered password.

Is any way to show the entered password instead of hashed value in database.

forms.py

class UserRegisterForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput(render_value=True))
class Meta:
model = User

Thanks


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need help figuring out why my { key:value } doesn't seem to be passed to my view by my javascript file.

2013-09-18 Thread 7equivalents
"So I think that the ajax() function is calling the URL 
"/pi/?pathID=somevalue," Is that different than how a key:value pair are 
normally sent? I don't know much about this.
This is the output from the development server...

"GET /pi/ HTTP/1.1" 200 2600

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Any good books for learning django?

2013-09-18 Thread Sithembewena Lloyd Dube
I asked PyDanny and Audrey for a free copy and they graciously obliged.
Very good book, too.


On Wed, Sep 18, 2013 at 12:29 PM, Yinka  wrote:

> These were not written for beginners, but they certainly can be helpful to
> the beginnner:
>
>1. *Pro Django** **
>
> http://www.amazon.com/Pro-Django-Marty-Alchin/dp/1430258098/ref=sr_1_2?s=books&ie=UTF8&qid=1379499898&sr=1-2&keywords=django
>*
>2. *Instant Django 1.5 Application Development Starter **
>
> http://www.amazon.com/Instant-Django-Application-Development-Starter/dp/1782163565/ref=sr_1_6?s=books&ie=UTF8&qid=1379499898&sr=1-6&keywords=django
>
> *
>
>
> Thanks
>
>
>
> On Thursday, February 7, 2013 5:49:36 PM UTC, frocco wrote:
>
>> Hello,
>> Most of what I find are dated, 2008,2009.
>> Are these still good for learning django 1.4?
>>
>> Which books do you recommend?
>>
>> Thanks
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Regards,
Sithu Lloyd Dube

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Deployment + Apache2] difference between development server & production server

2013-09-18 Thread Karl Arunachal
Its always a pleasure. Have fun coding!


On Mon, Sep 16, 2013 at 11:20 PM, hung david wrote:

>
>
> On Monday, September 16, 2013 2:05:56 AM UTC+7, Kakar wrote:
>>
>> I dont know what you actually mean, but I think just by passing the url
>> that you have created in the urls.py, which points to the function you have
>> defined in ur views.py should work.
>>
>>
>>
> Yes you are right Kakar. I've figured it out and here is the solution I
> got ( the same as you say, but more specific ) :
> https://groups.google.com/forum/#!topic/django-users/ourayJhe1oY
> Thank you for the confirmation. This community is beautiful :D
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need help in my Django code

2013-09-18 Thread Rafael E. Ferrero
hello ghenessa, first of all i'll recommend that use pastebin to share code
since tabular spaces in python its relevand.

now, you want to do something like triggers on database but do it in Django
Admin? (something like automatic saving TimeStamp of a creation moment of
the registry or update ?)



2013/9/18 ghenessa sabaldan 

> I am really stuck in my code. I have this printing project I have created.
> I wanted that in my student profile class, it will automatically update the
> the total printout and the available printout after the user has inputted
> the corresponding value in the printout class. and also the report
> generation will be by computer lab rooms. this is done in the default
> administration of django. Im using by the way python 2.7, django 1.5.2,
> Eclipse Standard/SDK and mysql workbench 5.2.47 CE. thanks
>
> *model.py*
>
> class Student_Profile(models.Model):
> id_number = models.CharField(max_length= 60, unique = True)
> first_name = models.CharField(max_length= 60)
> middle_name = models.CharField(max_length= 60)
> last_name = models.CharField(max_length= 60)
> active = models.BooleanField()
> date_created = models.DateTimeField('date created')
>
>
> def my_property(self):
> return self.last_name + ', ' + self.first_name + ' ' + self.middle_name
> my_property.short_description = "Full name of the person"
>
> name = property(my_property)
>
> def __unicode__(self):
> return u'%s, %s %s' % (self.last_name, self.first_name, self.middle_name)
>
>
> class Semester(models.Model):
> #I manually encode it to mysql workbenc
> semester = models.CharField(max_length= 60)
>
> def __unicode__(self):
> return self.semester
>
>
> class Student_Subject(models.Model):
>
> Student_Profile = models.ForeignKey(Student_Profile)
> subject_code = models.CharField(max_length= 60)
> teacher = models.CharField(max_length= 60)
> total_printout = models.PositiveSmallIntegerField(default=0)
> available_printout = models.PositiveSmallIntegerField(default=50)
> room = models.CharField(max_length= 60)
> semester = models.ForeignKey(Semester)
> school_year = models.CharField(max_length= 30)
> date_joined = models.DateField()
>
>
>
> def __unicode__(self):
> return self.subject_code
>
>
> class Room(models.Model):
> #I manually encode it to mysql workbenc
> room = models.CharField(max_length= 60)
>
> def __unicode__(self):
> return self.room
>
>
> class Printout(models.Model):
> Student_Name = models.ForeignKey(Student_Profile)
> Subject = ChainedForeignKey(
> Student_Subject,
> chained_field="Student_Name",
> chained_model_field="Student_Profile",
> show_all=False,
> auto_choose=True
> )
> room = models.ForeignKey(Room)
> printout = models.PositiveSmallIntegerField(default=0)
> created_by = models.ForeignKey(User, null=True, blank=True)
> date_created = models.DateField()
> time_created = models.TimeField()
>
> *admin.py*
>
> from django.contrib import admin
> from models import Student_Profile, Student_Subject, Printout
>
>
> class Student_SubjectInline(admin.TabularInline):
> model = Student_Subject
> extra = 1
>
> class Student_ProfileAdmin(admin.ModelAdmin):
>
> inlines = (Student_SubjectInline,)
> search_fields = ['last_name', 'first_name', 'id_number']
> list_display = ('name', 'id_number')
> ordering = ('last_name', 'first_name', 'middle_name',)
> pass
>
> admin.site.register(Student_Profile, Student_ProfileAdmin)
>
>
>
> from django.contrib.auth.models import User
>
> class PrintoutAdmin(admin.ModelAdmin):
>
> list_display = ('room', 'created_by', 'Student_Name', 'printout',
> 'Subject', 'date_created', 'time_created' )
> #search_fields = ['room']
> list_filter = ['room']
>
> def formfield_for_foreignkey(self, db_field, request, **kwargs):
> if db_field.name == 'created_by':
> kwargs['queryset'] = User.objects.filter(username=request.user.username)
> return super(PrintoutAdmin, self).formfield_for_foreignkey(db_field,
> request, **kwargs)
>
> def get_readonly_fields(self, request, obj=None):
> if obj is not None:
> return self.readonly_fields + ('created_by',)
> return self.readonly_fields
>
> def add_view(self, request, form_url="", extra_context=None):
> data = request.GET.copy()
> data['created_by'] = request.user
> request.GET = data
> return super(PrintoutAdmin, self).add_view(request, form_url="",
> extra_context=extra_context)
> pass
>
> admin.site.register(Printout, PrintoutAdmin)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Rafael E. Ferrero

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails fro

Need help in my Django code

2013-09-18 Thread ghenessa sabaldan
I am really stuck in my code. I have this printing project I have created. 
I wanted that in my student profile class, it will automatically update the 
the total printout and the available printout after the user has inputted 
the corresponding value in the printout class. and also the report 
generation will be by computer lab rooms. this is done in the default 
administration of django. Im using by the way python 2.7, django 1.5.2, 
Eclipse Standard/SDK and mysql workbench 5.2.47 CE. thanks

*model.py*

class Student_Profile(models.Model):
id_number = models.CharField(max_length= 60, unique = True)
first_name = models.CharField(max_length= 60)
middle_name = models.CharField(max_length= 60)
last_name = models.CharField(max_length= 60)
active = models.BooleanField()
date_created = models.DateTimeField('date created')


def my_property(self):
return self.last_name + ', ' + self.first_name + ' ' + self.middle_name
my_property.short_description = "Full name of the person"

name = property(my_property)

def __unicode__(self):
return u'%s, %s %s' % (self.last_name, self.first_name, self.middle_name)


class Semester(models.Model):
#I manually encode it to mysql workbenc
semester = models.CharField(max_length= 60)

def __unicode__(self):
return self.semester


class Student_Subject(models.Model):

Student_Profile = models.ForeignKey(Student_Profile)
subject_code = models.CharField(max_length= 60)
teacher = models.CharField(max_length= 60)
total_printout = models.PositiveSmallIntegerField(default=0)
available_printout = models.PositiveSmallIntegerField(default=50)
room = models.CharField(max_length= 60)
semester = models.ForeignKey(Semester)
school_year = models.CharField(max_length= 30)
date_joined = models.DateField()



def __unicode__(self):
return self.subject_code


class Room(models.Model):
#I manually encode it to mysql workbenc
room = models.CharField(max_length= 60)

def __unicode__(self):
return self.room


class Printout(models.Model):
Student_Name = models.ForeignKey(Student_Profile)
Subject = ChainedForeignKey(
Student_Subject,
chained_field="Student_Name",
chained_model_field="Student_Profile",
show_all=False,
auto_choose=True
)
room = models.ForeignKey(Room)
printout = models.PositiveSmallIntegerField(default=0)
created_by = models.ForeignKey(User, null=True, blank=True)
date_created = models.DateField()
time_created = models.TimeField()

*admin.py*

from django.contrib import admin
from models import Student_Profile, Student_Subject, Printout


class Student_SubjectInline(admin.TabularInline):
model = Student_Subject
extra = 1

class Student_ProfileAdmin(admin.ModelAdmin):

inlines = (Student_SubjectInline,)
search_fields = ['last_name', 'first_name', 'id_number']
list_display = ('name', 'id_number')
ordering = ('last_name', 'first_name', 'middle_name',)
pass

admin.site.register(Student_Profile, Student_ProfileAdmin)



from django.contrib.auth.models import User

class PrintoutAdmin(admin.ModelAdmin):

list_display = ('room', 'created_by', 'Student_Name', 'printout', 
'Subject', 'date_created', 'time_created' )
#search_fields = ['room']
list_filter = ['room']

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'created_by':
kwargs['queryset'] = User.objects.filter(username=request.user.username)
return super(PrintoutAdmin, self).formfield_for_foreignkey(db_field, 
request, **kwargs)

def get_readonly_fields(self, request, obj=None):
if obj is not None:
return self.readonly_fields + ('created_by',)
return self.readonly_fields

def add_view(self, request, form_url="", extra_context=None):
data = request.GET.copy()
data['created_by'] = request.user
request.GET = data
return super(PrintoutAdmin, self).add_view(request, form_url="", 
extra_context=extra_context)
pass

admin.site.register(Printout, PrintoutAdmin)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Any good books for learning django?

2013-09-18 Thread Yinka
These were not written for beginners, but they certainly can be helpful to 
the beginnner:

   1. *Pro Django** **
   
http://www.amazon.com/Pro-Django-Marty-Alchin/dp/1430258098/ref=sr_1_2?s=books&ie=UTF8&qid=1379499898&sr=1-2&keywords=django
   *
   2. *Instant Django 1.5 Application Development Starter **
   
http://www.amazon.com/Instant-Django-Application-Development-Starter/dp/1782163565/ref=sr_1_6?s=books&ie=UTF8&qid=1379499898&sr=1-6&keywords=django
   
*
   

Thanks



On Thursday, February 7, 2013 5:49:36 PM UTC, frocco wrote:
>
> Hello,
> Most of what I find are dated, 2008,2009.
> Are these still good for learning django 1.4?
>
> Which books do you recommend?
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a standalone python application that uses the django environment (e.g. the ORM etc...)?

2013-09-18 Thread DJ-Tom
Hi Brad,

that fixed it - plus I now have a better understanding of how python works.

I'm beginning to understand what Jeff Knupp writes here: 
http://www.jeffknupp.com/blog/2012/12/11/learning-python-via-django-considered-harmful/

:-)

Am Dienstag, 17. September 2013 17:58:42 UTC+2 schrieb Brad Pitcher:
>
> To make my code work, you could set DJANGO_SETTINGS_MODULE to 
> 'my_project.settings', and just put formdesigner.py directly under 
> my_project.
>
> If you wanted to keep formdesigner.py where it is, you would want to 
> change the sys.path.append line to this:
>
> sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), 
> '..'))
>
>
> -
> Brad Pitcher
>
>
> On Tue, Sep 17, 2013 at 12:25 AM, DJ-Tom 
> > wrote:
>
>>
>> Hi,
>>
>> I'm also not sure if the python file is at the correct location.
>>
>> This is how the directory structure looks:
>>
>> my_project
>> \my_project\
>>  settings.py
>> \my_app\ # this is where my models are defined
>>  models.py
>>  formdesigner.py
>>
>>
>> Where should my formdesigner.py be located?
>>
>> my_project ? 
>> my_project\my_project ?
>> my_project\my_app ?
>>
>> What do I put into DJANGO_SETTINGS_MODULE?
>>
>> 'my_project.settings'?
>>
>>
>> Am Montag, 16. September 2013 18:17:21 UTC+2 schrieb Brad Pitcher:
>>
>>> You need to do something like this before import django stuff:
>>>
>>> import os
>>> import sys
>>>
>>> sys.path.append(os.path.**abspath(os.path.dirname(__**file__)))
>>> os.environ['DJANGO_SETTINGS_**MODULE'] = 'web.settings'
>>>
>>>
>>> -
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.