Friday, November 30, 2012

Re: Django apache mod_wsgi permission denied

okay it works now, I was just missing a trailing slash at
Alias /static/ /home/loai/workspace/Faculty/Faculty/static/

On Sat, Dec 1, 2012 at 8:17 AM, Loai Ghoraba <loai1991@gmail.com> wrote:
a strange thing is that when I remove the <Files> </Files> directive so it becomes:

<Directory /home/loai/workspace/Faculty/Faculty>
Order deny,allow
Allow from all
</Directory>

instead of 

<Directory /home/loai/workspace/Faculty/Faculty>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>

then trying to access any static or media file raises (not found) instead of permission denied !

On Sat, Dec 1, 2012 at 7:42 AM, Loai Ghoraba <loai1991@gmail.com> wrote:
thanks, but still I can't find what's wrong with the permission thing. The html pages are loaded without static content, no css or js or whatever, neither the media is accessible.



On Sat, Dec 1, 2012 at 7:15 AM, Mike Dewhirst <miked@dewhirst.com.au> wrote:
On 1/12/2012 3:57pm, Loai Ghoraba wrote:
thanks, but I have tried this now and it also doesn't work :X though the
author slides presentation mentioned chmod o+rx on the root dir only.

On Sat, Dec 1, 2012 at 6:53 AM, Mike Dewhirst <miked@dewhirst.com.au
<mailto:miked@dewhirst.com.au>> wrote:

    chmod -R o+rx

Here is my working apache2 conf for project "proj" on site mydomain.com. It is running happily on Ubuntu 12.04 with permissions on all /var/www/proj directories and files rwxrwx---

This is because I need users in the group to have access but no-one from outside. Apache is the owner.

Good luck

Mike

# proj #########################################################

<VirtualHost *:80>

 # proj resolves to lenny 109
 DocumentRoot /var/www/proj/htdocs/
 ServerName proj.mydomain.com
 ServerAdmin webmaster@mydomain.com

 HostnameLookups Off
 UseCanonicalName Off

 ErrorLog ${APACHE_LOG_DIR}/proj-error.log
 CustomLog ${APACHE_LOG_DIR}/proj-access.log combined

 Alias /robots.txt /var/www/static/proj/robots/robots.txt
 Alias /favicon.ico /var/www/static/proj/img/proj.ico

 # lock the public out
 <Directory /var/www/proj/>
  AllowOverride None
  Order deny,allow
  Deny from all
 </Directory>

 # serve uploaded media from here
 <Directory /var/www/media/proj/>
  AllowOverride None

  Order deny,allow
  Allow from all
 </Directory>

 # serve static stuff from here
 <Directory /var/www/static/proj/>
  AllowOverride None

  Order deny,allow
  Allow from all
 </Directory>

 <IfModule mod_alias.c>
  Alias /media/ /var/www/media/proj/
  Alias /static/ /var/www/static/proj/
  Alias /tiny_mce/ /var/www/static/proj/js/tiny_mce/
  Alias /jquery/ /var/www/static/proj/js/jquery/
 </IfModule>

 <IfModule mod_wsgi.c>
   WSGIScriptAlias / /var/www/proj/proj/proj.wsgi
   <Directory /var/www/proj/proj/>

     Order deny,allow
     Allow from all
   </Directory>
 </IfModule>

</VirtualHost>








--
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.




--
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: django1.5 subclass AbstractUser, How to get a password-(re)set field in admin

Hi Russ, 

Thanks that did solve the problem I was having. 

--
Regards,
Bruce


On Fri, Nov 30, 2012 at 9:32 PM, Russell Keith-Magee <russell@keith-magee.com> wrote:
Hi Bruce,

Update your Django checkout. This problem was fixed in 0fc5878c.

Yours,
Russ Magee %-)


On Fri, Nov 30, 2012 at 2:07 PM, Detectedstealth <bruce.wade@gmail.com> wrote:
Hi Russel,


password = ReadOnlyPasswordHashField(label=_("Password"),

        help_text=_("Raw passwords are not stored, so there is no way to see "

                    "this user's password, but you can change the password "

                    "using <a href=\"password/\">this form</a>."), widget=ReadOnlyPasswordHashWidget()) 

From what I seen in django/contrib/auth/forms UserChangeForm this gives me the change password URL however I get the error: 'CustUser' object has no attribute 'username' looking at the error line 136

/Library/Python/2.7/site-packages/django/contrib/auth/admin.py in user_change_password

  1.             'title': _('Change password: %s') % escape(user.username), 
It looks like this is either a bug or doesn't work with a custom user as planed as it looks for a username even though in the example you set the email to username field with: USERNAME_FIELD = 'email'

Am I missing something?

Regards,
Bruce

On Saturday, November 3, 2012 4:09:09 PM UTC-7, Russell Keith-Magee wrote:

On Sat, Nov 3, 2012 at 11:15 PM, Michael Muster <michael...@googlemail.com> wrote:
Hi again,

I have a subclass from AbstractUser

1 from django.contrib.auth.models import AbstractUser
2 from django.conf import settings
3
4 class cpUser(AbstractUser):
5     twitter = models.CharField(max_length=100)
6     def __unicode__(self):
7         return self.username

and
AUTH_USER_MODEL = 'account.cpUser'
in my settings.py set.

How do i get a password field to set and reset
a password in my admin app?
Adding the password field to admin.py does obviously not
work as it enters plain text and not the hashed password.

1 from django.contrib import admin
2 class cpUserAdmin(admin.ModelAdmin):
3    fields = ['twitter','username', 'first_name', 'last_name', 'password',]
4                                                                ~~~~~~~~
5 admin.site.register(cpUser, cpUserAdmin)


Do i have to set a passwort field to the models.py or
can i geht that from the models which i "abstracted" from
(as done with username, first_name, last_name...)

You need to follow the instructions that are in the documentation.


The key is that you can't just subclass admin.ModelAdmin -- you need to subclass the existing Django admin class for Users (django.contrib.auth.admin.UserAdmin) - that base class is what provides all the special password handling etc for User models.

Yours,
Russ Magee %-) 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sRmpO1m1Ng0J.
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.



--
--
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.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 apache mod_wsgi permission denied

a strange thing is that when I remove the <Files> </Files> directive so it becomes:

<Directory /home/loai/workspace/Faculty/Faculty>
Order deny,allow
Allow from all
</Directory>

instead of 

<Directory /home/loai/workspace/Faculty/Faculty>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>

then trying to access any static or media file raises (not found) instead of permission denied !

On Sat, Dec 1, 2012 at 7:42 AM, Loai Ghoraba <loai1991@gmail.com> wrote:
thanks, but still I can't find what's wrong with the permission thing. The html pages are loaded without static content, no css or js or whatever, neither the media is accessible.



On Sat, Dec 1, 2012 at 7:15 AM, Mike Dewhirst <miked@dewhirst.com.au> wrote:
On 1/12/2012 3:57pm, Loai Ghoraba wrote:
thanks, but I have tried this now and it also doesn't work :X though the
author slides presentation mentioned chmod o+rx on the root dir only.

On Sat, Dec 1, 2012 at 6:53 AM, Mike Dewhirst <miked@dewhirst.com.au
<mailto:miked@dewhirst.com.au>> wrote:

    chmod -R o+rx

Here is my working apache2 conf for project "proj" on site mydomain.com. It is running happily on Ubuntu 12.04 with permissions on all /var/www/proj directories and files rwxrwx---

This is because I need users in the group to have access but no-one from outside. Apache is the owner.

Good luck

Mike

# proj #########################################################

<VirtualHost *:80>

 # proj resolves to lenny 109
 DocumentRoot /var/www/proj/htdocs/
 ServerName proj.mydomain.com
 ServerAdmin webmaster@mydomain.com

 HostnameLookups Off
 UseCanonicalName Off

 ErrorLog ${APACHE_LOG_DIR}/proj-error.log
 CustomLog ${APACHE_LOG_DIR}/proj-access.log combined

 Alias /robots.txt /var/www/static/proj/robots/robots.txt
 Alias /favicon.ico /var/www/static/proj/img/proj.ico

 # lock the public out
 <Directory /var/www/proj/>
  AllowOverride None
  Order deny,allow
  Deny from all
 </Directory>

 # serve uploaded media from here
 <Directory /var/www/media/proj/>
  AllowOverride None

  Order deny,allow
  Allow from all
 </Directory>

 # serve static stuff from here
 <Directory /var/www/static/proj/>
  AllowOverride None

  Order deny,allow
  Allow from all
 </Directory>

 <IfModule mod_alias.c>
  Alias /media/ /var/www/media/proj/
  Alias /static/ /var/www/static/proj/
  Alias /tiny_mce/ /var/www/static/proj/js/tiny_mce/
  Alias /jquery/ /var/www/static/proj/js/jquery/
 </IfModule>

 <IfModule mod_wsgi.c>
   WSGIScriptAlias / /var/www/proj/proj/proj.wsgi
   <Directory /var/www/proj/proj/>

     Order deny,allow
     Allow from all
   </Directory>
 </IfModule>

</VirtualHost>








--
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.



--
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 apache mod_wsgi permission denied

thanks, but still I can't find what's wrong with the permission thing. The html pages are loaded without static content, no css or js or whatever, neither the media is accessible.


On Sat, Dec 1, 2012 at 7:15 AM, Mike Dewhirst <miked@dewhirst.com.au> wrote:
On 1/12/2012 3:57pm, Loai Ghoraba wrote:
thanks, but I have tried this now and it also doesn't work :X though the
author slides presentation mentioned chmod o+rx on the root dir only.

On Sat, Dec 1, 2012 at 6:53 AM, Mike Dewhirst <miked@dewhirst.com.au
<mailto:miked@dewhirst.com.au>> wrote:

    chmod -R o+rx

Here is my working apache2 conf for project "proj" on site mydomain.com. It is running happily on Ubuntu 12.04 with permissions on all /var/www/proj directories and files rwxrwx---

This is because I need users in the group to have access but no-one from outside. Apache is the owner.

Good luck

Mike

# proj #########################################################

<VirtualHost *:80>

 # proj resolves to lenny 109
 DocumentRoot /var/www/proj/htdocs/
 ServerName proj.mydomain.com
 ServerAdmin webmaster@mydomain.com

 HostnameLookups Off
 UseCanonicalName Off

 ErrorLog ${APACHE_LOG_DIR}/proj-error.log
 CustomLog ${APACHE_LOG_DIR}/proj-access.log combined

 Alias /robots.txt /var/www/static/proj/robots/robots.txt
 Alias /favicon.ico /var/www/static/proj/img/proj.ico

 # lock the public out
 <Directory /var/www/proj/>
  AllowOverride None
  Order deny,allow
  Deny from all
 </Directory>

 # serve uploaded media from here
 <Directory /var/www/media/proj/>
  AllowOverride None

  Order deny,allow
  Allow from all
 </Directory>

 # serve static stuff from here
 <Directory /var/www/static/proj/>
  AllowOverride None

  Order deny,allow
  Allow from all
 </Directory>

 <IfModule mod_alias.c>
  Alias /media/ /var/www/media/proj/
  Alias /static/ /var/www/static/proj/
  Alias /tiny_mce/ /var/www/static/proj/js/tiny_mce/
  Alias /jquery/ /var/www/static/proj/js/jquery/
 </IfModule>

 <IfModule mod_wsgi.c>
   WSGIScriptAlias / /var/www/proj/proj/proj.wsgi
   <Directory /var/www/proj/proj/>

     Order deny,allow
     Allow from all
   </Directory>
 </IfModule>

</VirtualHost>








--
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.


--
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: django1.5 subclass AbstractUser, How to get a password-(re)set field in admin

Hi Bruce,

Update your Django checkout. This problem was fixed in 0fc5878c.

Yours,
Russ Magee %-)

On Fri, Nov 30, 2012 at 2:07 PM, Detectedstealth <bruce.wade@gmail.com> wrote:
Hi Russel,


password = ReadOnlyPasswordHashField(label=_("Password"),

        help_text=_("Raw passwords are not stored, so there is no way to see "

                    "this user's password, but you can change the password "

                    "using <a href=\"password/\">this form</a>."), widget=ReadOnlyPasswordHashWidget()) 

From what I seen in django/contrib/auth/forms UserChangeForm this gives me the change password URL however I get the error: 'CustUser' object has no attribute 'username' looking at the error line 136

/Library/Python/2.7/site-packages/django/contrib/auth/admin.py in user_change_password

  1.             'title': _('Change password: %s') % escape(user.username), 
It looks like this is either a bug or doesn't work with a custom user as planed as it looks for a username even though in the example you set the email to username field with: USERNAME_FIELD = 'email'

Am I missing something?

Regards,
Bruce

On Saturday, November 3, 2012 4:09:09 PM UTC-7, Russell Keith-Magee wrote:

On Sat, Nov 3, 2012 at 11:15 PM, Michael Muster <michael...@googlemail.com> wrote:
Hi again,

I have a subclass from AbstractUser

1 from django.contrib.auth.models import AbstractUser
2 from django.conf import settings
3
4 class cpUser(AbstractUser):
5     twitter = models.CharField(max_length=100)
6     def __unicode__(self):
7         return self.username

and
AUTH_USER_MODEL = 'account.cpUser'
in my settings.py set.

How do i get a password field to set and reset
a password in my admin app?
Adding the password field to admin.py does obviously not
work as it enters plain text and not the hashed password.

1 from django.contrib import admin
2 class cpUserAdmin(admin.ModelAdmin):
3    fields = ['twitter','username', 'first_name', 'last_name', 'password',]
4                                                                ~~~~~~~~
5 admin.site.register(cpUser, cpUserAdmin)


Do i have to set a passwort field to the models.py or
can i geht that from the models which i "abstracted" from
(as done with username, first_name, last_name...)

You need to follow the instructions that are in the documentation.


The key is that you can't just subclass admin.ModelAdmin -- you need to subclass the existing Django admin class for Users (django.contrib.auth.admin.UserAdmin) - that base class is what provides all the special password handling etc for User models.

Yours,
Russ Magee %-) 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sRmpO1m1Ng0J.
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: calling the view function in the other view function

On Sat, Dec 1, 2012 at 4:45 AM, Chris Cogdon <chris@cogdon.org> wrote:
> It's generally very messy for one "view" function to call another.
Then what is the fun of making the function, if it is not reusable.
>
> Better solution is to factorise out the common parts into a third function,
> then make sure each of your two "view" functions have the required
> render_to_response.

What will i do if i have a large number of views having the common part.

> Also, I highly recommend using the "render" shortcut, which would turn your
> more complex calls into this:
Thanks, for the kind advise.
> return render ( request, 'report/report_base.html', {'Head':Head,} )
>
>

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

--
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 apache mod_wsgi permission denied

On 1/12/2012 3:57pm, Loai Ghoraba wrote:
> thanks, but I have tried this now and it also doesn't work :X though the
> author slides presentation mentioned chmod o+rx on the root dir only.
>
> On Sat, Dec 1, 2012 at 6:53 AM, Mike Dewhirst <miked@dewhirst.com.au
> <mailto:miked@dewhirst.com.au>> wrote:
>
> chmod -R o+rx

Here is my working apache2 conf for project "proj" on site mydomain.com.
It is running happily on Ubuntu 12.04 with permissions on all
/var/www/proj directories and files rwxrwx---

This is because I need users in the group to have access but no-one from
outside. Apache is the owner.

Good luck

Mike

# proj #########################################################

<VirtualHost *:80>

# proj resolves to lenny 109
DocumentRoot /var/www/proj/htdocs/
ServerName proj.mydomain.com
ServerAdmin webmaster@mydomain.com

HostnameLookups Off
UseCanonicalName Off

ErrorLog ${APACHE_LOG_DIR}/proj-error.log
CustomLog ${APACHE_LOG_DIR}/proj-access.log combined

Alias /robots.txt /var/www/static/proj/robots/robots.txt
Alias /favicon.ico /var/www/static/proj/img/proj.ico

# lock the public out
<Directory /var/www/proj/>
AllowOverride None
Order deny,allow
Deny from all
</Directory>

# serve uploaded media from here
<Directory /var/www/media/proj/>
AllowOverride None
Order deny,allow
Allow from all
</Directory>

# serve static stuff from here
<Directory /var/www/static/proj/>
AllowOverride None
Order deny,allow
Allow from all
</Directory>

<IfModule mod_alias.c>
Alias /media/ /var/www/media/proj/
Alias /static/ /var/www/static/proj/
Alias /tiny_mce/ /var/www/static/proj/js/tiny_mce/
Alias /jquery/ /var/www/static/proj/js/jquery/
</IfModule>

<IfModule mod_wsgi.c>
WSGIScriptAlias / /var/www/proj/proj/proj.wsgi
<Directory /var/www/proj/proj/>
Order deny,allow
Allow from all
</Directory>
</IfModule>

</VirtualHost>





>
>
> --
> 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 apache mod_wsgi permission denied

thanks, but I have tried this now and it also doesn't work :X though the author slides presentation mentioned chmod o+rx on the root dir only.

On Sat, Dec 1, 2012 at 6:53 AM, Mike Dewhirst <miked@dewhirst.com.au> wrote:
chmod -R o+rx

--
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 apache mod_wsgi permission denied

On 1/12/2012 3:48pm, Loai Ghoraba wrote:
> I have ran chmod o+rx on the root directory, isn't this enough (isn't
> chmod applied to all folders down recursively ?) ?

No. You need chmod -R o+rx


>
> and I have checked the directories from the root down to static, all
> have the permission of drwxr-xr-x
>
> On Sat, Dec 1, 2012 at 2:21 AM, Chris Cogdon <chris@cogdon.org
> <mailto:chris@cogdon.org>> wrote:
>
> Make sure all the directories, from static leading all the way up to
> the root, are chmod a+x
>
>
> On Friday, November 30, 2012 4:00:55 PM UTC-8, Loai Ghoraba wrote:
>
> Hi
>
> I have installed apache and mod_wsgi and my basic site *skeleton
> is running* on local host, but with NO static files loaded such
> as css, when I try to access a static file
> (e.g:http://localhost/static/__css/base.css
> <http://localhost/static/css/base.css>) it says that I don't
> have permission to access the file, same goes to media files
>
> I have followed the steps in the presentation slides
> http://code.google.com/__p/modwsgi/downloads/detail?__name=mod_wsgi-pycon-sydney-__2010.pdf
> <http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-pycon-sydney-2010.pdf> and
> made the directories accessible to others via chmod o+rx
> , my httpd.conf part is :
>
> WSGIScriptAlias / /home/loai/workspace/Faculty/__Faculty/wsgi.py
> WSGIPythonPath /home/loai/workspace/Faculty
>
> Alias /media/ /home/loai/workspace/Faculty/__Faculty/media
> Alias /static/ /home/loai/workspace/Faculty/__Faculty/static
>
> <Directory /home/loai/workspace/Faculty/__Faculty/static>
> Order deny,allow
> Allow from all
> </Directory>
>
> <Directory /home/loai/workspace/Faculty/__Faculty/media>
> Order deny,allow
> Allow from all
> </Directory>
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/L3Sm-aDXA_UJ.
>
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com
> <mailto:django-users%2Bunsubscribe@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.

--
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 apache mod_wsgi permission denied

I have ran chmod o+rx on the root directory, isn't this enough (isn't chmod applied to all folders down recursively ?) ?

and I have checked the directories from the root down to static, all have the permission of drwxr-xr-x

On Sat, Dec 1, 2012 at 2:21 AM, Chris Cogdon <chris@cogdon.org> wrote:
Make sure all the directories, from static leading all the way up to the root, are chmod a+x


On Friday, November 30, 2012 4:00:55 PM UTC-8, Loai Ghoraba wrote:
Hi 

I have installed apache and mod_wsgi and my basic site *skeleton is running* on local host, but with NO static files loaded such as css, when I try to access a static file (e.g:http://localhost/static/css/base.css) it says that I don't have permission to access the file, same goes to media files 

I have followed the steps in the presentation slides http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-pycon-sydney-2010.pdf and made the directories accessible to others via chmod o+rx 
, my  httpd.conf part is :

WSGIScriptAlias / /home/loai/workspace/Faculty/Faculty/wsgi.py
WSGIPythonPath /home/loai/workspace/Faculty

Alias /media/ /home/loai/workspace/Faculty/Faculty/media
Alias /static/ /home/loai/workspace/Faculty/Faculty/static

<Directory /home/loai/workspace/Faculty/Faculty/static>
Order deny,allow
Allow from all
</Directory>

<Directory /home/loai/workspace/Faculty/Faculty/media>
Order deny,allow
Allow from all
</Directory>

Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/L3Sm-aDXA_UJ.

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.

[Django 1.3] list_display, __unicode__ and sorting

Hello,

Would the below be an OK way to sort __unicode__ in the admin list_display?

Model:

def uni_sort(self):

return self.__unicode__()

uni_sort.admin_order_field = 'sort'
uni_sort.short_description = _(u'name')

Admin:

list_display = ('uni_sort', 'parent', 'name', 'slug',)

...

To save ya'll some time, the docs say:

[[

The __str__() and __unicode__() methods are just as valid in
list_display as any other model method, so it's perfectly OK to do
this:

list_display = ('__unicode__', 'some_other_field')

Usually, elements of list_display that aren't actual database fields
can't be used in sorting (because Django does all the sorting at the
database level).

However, if an element of list_display represents a certain database
field, you can indicate this fact by setting the admin_order_field
attribute of the item.

]]

Unless I'm mistaken, this does not work:

__unicode__.admin_order_field = 'sort'

Otherwise I could just do this:

list_display = ('__unicode__', 'parent', 'name', 'slug',)

My question:

Is it overkill to create a method, that returns the __unicode__ value,
just for the sake of being able to order on the "sort" field?

Thanks!

Cheers,
M

--
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 apache mod_wsgi permission denied

Make sure all the directories, from static leading all the way up to the root, are chmod a+x

On Friday, November 30, 2012 4:00:55 PM UTC-8, Loai Ghoraba wrote:
Hi 

I have installed apache and mod_wsgi and my basic site *skeleton is running* on local host, but with NO static files loaded such as css, when I try to access a static file (e.g:http://localhost/static/css/base.css) it says that I don't have permission to access the file, same goes to media files 

I have followed the steps in the presentation slides http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-pycon-sydney-2010.pdf and made the directories accessible to others via chmod o+rx 
, my  httpd.conf part is :

WSGIScriptAlias / /home/loai/workspace/Faculty/Faculty/wsgi.py
WSGIPythonPath /home/loai/workspace/Faculty

Alias /media/ /home/loai/workspace/Faculty/Faculty/media
Alias /static/ /home/loai/workspace/Faculty/Faculty/static

<Directory /home/loai/workspace/Faculty/Faculty/static>
Order deny,allow
Allow from all
</Directory>

<Directory /home/loai/workspace/Faculty/Faculty/media>
Order deny,allow
Allow from all
</Directory>

Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/L3Sm-aDXA_UJ.
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 apache mod_wsgi permission denied

Hi 

I have installed apache and mod_wsgi and my basic site *skeleton is running* on local host, but with NO static files loaded such as css, when I try to access a static file (e.g:http://localhost/static/css/base.css) it says that I don't have permission to access the file, same goes to media files 

I have followed the steps in the presentation slides http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-pycon-sydney-2010.pdf and made the directories accessible to others via chmod o+rx 
, my  httpd.conf part is :

WSGIScriptAlias / /home/loai/workspace/Faculty/Faculty/wsgi.py
WSGIPythonPath /home/loai/workspace/Faculty

Alias /media/ /home/loai/workspace/Faculty/Faculty/media
Alias /static/ /home/loai/workspace/Faculty/Faculty/static

<Directory /home/loai/workspace/Faculty/Faculty/static>
Order deny,allow
Allow from all
</Directory>

<Directory /home/loai/workspace/Faculty/Faculty/media>
Order deny,allow
Allow from all
</Directory>

Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/LG9AgaTxaWAJ.
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: Noobe alert

Hey and thanks for the post, I actually posted this back on saturday and I figured it out, actually the way you are saying but it wasn't the permissions. I had to much info, the url going into nginx had two static  directories next to each other, at first I tried to remove one but I decided to go with an empty string for STATIC_ROOT and that was it. No problems now, (basically follow the docs) duhh. But thanks I appreciate the post. 

--jerry

On Fri, Nov 30, 2012 at 5:12 PM, Chris Cogdon <chris@cogdon.org> wrote:
Check the error log for nginx to see if there's any hint of why the statics aren't showing up.

My best guess is that the web server is running as a user that does not have access to the files, and the error log should be showing up with various "permission denied" messages.

The usual culprit is that while the static directory and files are readable by everyone, the parent directories do not have the "execute" permission bit set. On a directory "execute" means the ability to trasverse the directory and get access to the contents, but not get a directory listing.

To fix, try something like this:

chmod a+x /var /var/www /var/www/virtualenv-test /var/www/virtualenv-test/ENV /var/www/virtualenv-test/ENV/testsite /var/www/virtualenv-test/ENV/testsite/static



On Saturday, November 17, 2012 11:28:01 AM UTC-8, Gerald Klein wrote:
Hi, I finally got a project in Django and I have a "what I hope is an easy question" I started to set up a production server and yes the admin css dissappeared, I went though the docs and followed them. I used the Collect Static Files method and still no joy. Here is my info: 

#settings.py
MEDIA_ROOT = '/var/www/virtualenv-test/ENV/testsite/media/'
STATIC_ROOT = '/var/www/virtualenv-test/ENV/testsite/static/'

#niginx


    root /var/www/virtualenv-test/ENV/testsite;

    location /media/ {
        root /var/www/virtualenv-test/ENV/testsite/media;
    }

    location /static/ {
        root /var/www/virtualenv-test/ENV/testsite/static;
    }

My project is located in /var/www/virtualenv-test/ENV/

the project is testsite so the hierarchy inside ENV is:

testsite/
        media/
        static/all files from collect static files
        testsite/
                __init__.py
                settings.py
                urls.py
                wsgi.py
        manage.py

I am using version (1, 4, 2, 'final', 0). 

If somebody can point out the probably obvious problem that I am missing I would greatly appreciate it. 

thanks in advance for your help

--jerry

-- 

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580 



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/kmAdUKxb57UJ.
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.



--

Gerald Klein DBA

ContactMe@geraldklein.com

www.geraldklein.com

geraldklein.wordpress.com

jk@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580 



--
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 use named urls from apps

And, don't forget, the form is:

{% load url from future %}
{% url 'auth_login' %}

OR

{% url auth_login %}

The former is highly recommend, as the latter is deprecated and will become the default in a future Django release.

If you ever get messages such as "view not found for reverse"... this has been my culprit 90% of the time.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Gxsauy6BCOIJ.
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: admin foreign key issues




class CategoryAdmin(admin.ModelAdmin):
    list_display = ('name')
    list_filter = ('name')
admin.site.register(Category, CategoryAdmin)

But that fails with 'CategoryAdmin.list_display' must be a list or tuple.

use:   list_display = ('name',)

Note the trailing comma, there?

In python, a tuple with a single element must use the form ( x, )  or it is indistinguishable from a parenthesised expression. 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/eXAQLOj3egYJ.
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: calling the view function in the other view function

It's generally very messy for one "view" function to call another.

Better solution is to factorise out the common parts into a third function, then make sure each of your two "view" functions have the required render_to_response.

Also, I highly recommend using the "render" shortcut, which would turn your more complex calls into this:

return render ( request, 'report/report_base.html', {'Head':Head,} )


On Thursday, November 29, 2012 10:31:03 PM UTC-8, Satinderpal Singh wrote:
I have to call a function into another function which displays the
values from the database to the browser, like this:

def result(request):
    zee = head.objects.aggregate(Max('id'))
    mee = zee['id__max']
    Head = head.objects.filter(id = mee)
    return render_to_response('report/report_base.html',
{'Head':Head,},context_instance=RequestContext(request))

def result_cube(request):
    Head = result(mee)
    organisation = Organisation.objects.all().filter(id = 1)
    return render_to_response('report/cube.html', { 'Head':Head,
'organisation':organisation},context_instance=RequestContext(request))

I want to call "result" view in the "result_cube",  as it displays the
html data but not showing the data from the database.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sv67A78gud4J.
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: Noobe alert

Check the error log for nginx to see if there's any hint of why the statics aren't showing up.

My best guess is that the web server is running as a user that does not have access to the files, and the error log should be showing up with various "permission denied" messages.

The usual culprit is that while the static directory and files are readable by everyone, the parent directories do not have the "execute" permission bit set. On a directory "execute" means the ability to trasverse the directory and get access to the contents, but not get a directory listing.

To fix, try something like this:

chmod a+x /var /var/www /var/www/virtualenv-test /var/www/virtualenv-test/ENV /var/www/virtualenv-test/ENV/testsite /var/www/virtualenv-test/ENV/testsite/static



On Saturday, November 17, 2012 11:28:01 AM UTC-8, Gerald Klein wrote:
Hi, I finally got a project in Django and I have a "what I hope is an easy question" I started to set up a production server and yes the admin css dissappeared, I went though the docs and followed them. I used the Collect Static Files method and still no joy. Here is my info: 

#settings.py
MEDIA_ROOT = '/var/www/virtualenv-test/ENV/testsite/media/'
STATIC_ROOT = '/var/www/virtualenv-test/ENV/testsite/static/'

#niginx


    root /var/www/virtualenv-test/ENV/testsite;

    location /media/ {
        root /var/www/virtualenv-test/ENV/testsite/media;
    }

    location /static/ {
        root /var/www/virtualenv-test/ENV/testsite/static;
    }

My project is located in /var/www/virtualenv-test/ENV/

the project is testsite so the hierarchy inside ENV is:

testsite/
        media/
        static/all files from collect static files
        testsite/
                __init__.py
                settings.py
                urls.py
                wsgi.py
        manage.py

I am using version (1, 4, 2, 'final', 0). 

If somebody can point out the probably obvious problem that I am missing I would greatly appreciate it. 

thanks in advance for your help

--jerry

-- 

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580 



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/kmAdUKxb57UJ.
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: Thumbnail resizing issue, strange behavior

On Fri, Nov 30, 2012 at 6:45 PM, Mo J. Al-Mughrabi
<mo.mughrabi@gmail.com> wrote:
> Hi,
>
> I've been trying to resolve this issue for a day without luck, its
> very strange error, i tried to post it on stackoverflow but still no
> luck.
>
>
> http://stackoverflow.com/questions/13629099/getting-cannot-identify-image-file-when-trying-to-create-thumbnail-in-django
>

Does it still crash if you fix the double commit?

instance = super(ImageForm, self).save(commit=False)

You shouldn't save it at all if commit=False was passed, and only save
it once if commit=True was passed.

Seeing the traceback may be informative too - sanitize it if needs be.

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.

Thumbnail resizing issue, strange behavior

Hi,

I've been trying to resolve this issue for a day without luck, its
very strange error, i tried to post it on stackoverflow but still no
luck.


http://stackoverflow.com/questions/13629099/getting-cannot-identify-image-file-when-trying-to-create-thumbnail-in-django

--
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: Drop foreign key, add another - keep data

On Fri, Nov 30, 2012 at 11:56 AM, Peter Edström <edstromp@gmail.com> wrote:
> Hello,
>
> I'd like to drop a ForeignKey-field and add another using south (mysql
> database), but it won't work. Googling it takes me not far, but it seems to
> be a problem with dropping foreign key constraints with InnoDB.
> What is the recommended way ot dropping a ForeignKey-field, and adding
> another?
>
> Say the model looks like this:
>
>> class Model1(models.Model):
>>
>> test = models.ForeignKey(Model2)
>
>
> And I won't to change it to:
>
>> class Model1(models.Model):
>>
>> test2 = models.ForeignKey(Model3)
>
>
> Right now I don't really care if I lose data, but for future reference I'd
> prefer a method that keeps it.
>
> Thank you.
>

How are you trying to do it? There should be several migrations:

1) A schema migration to add the new foreign key, which should be
nullable at this point
2) A data migration to move the old data into the new column
3) A schema migration to drop the nullability of the new foreign key
4) A schema migration to drop the old foreign key

You may not need as many migrations if you do not need to migrate the
old data over, or if the new foreign key is allowed to be null.

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.

Drop foreign key, add another - keep data

Hello,

I'd like to drop a ForeignKey-field and add another using south (mysql database), but it won't work. Googling it takes me not far, but it seems to be a problem with dropping foreign key constraints with InnoDB.
What is the recommended way ot dropping a ForeignKey-field, and adding another?

Say the model looks like this:

class Model1(models.Model):
    test = models.ForeignKey(Model2) 

And I won't to change it to:

class Model1(models.Model):
    test2 = models.ForeignKey(Model3) 
 
Right now I don't really care if I lose data, but for future reference I'd prefer a method that keeps it.

Thank you.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/1XoEfk3TBlQJ.
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: Noobe alert

Hello gerald !!, are you still with this probelm ?

2012/11/17 Gerald Klein <jk@zognet.com>
Hi, I finally got a project in Django and I have a "what I hope is an easy question" I started to set up a production server and yes the admin css dissappeared, I went though the docs and followed them. I used the Collect Static Files method and still no joy. Here is my info: 

#settings.py
MEDIA_ROOT = '/var/www/virtualenv-test/ENV/testsite/media/'
STATIC_ROOT = '/var/www/virtualenv-test/ENV/testsite/static/'

#niginx


    root /var/www/virtualenv-test/ENV/testsite;

    location /media/ {
        root /var/www/virtualenv-test/ENV/testsite/media;
    }

    location /static/ {
        root /var/www/virtualenv-test/ENV/testsite/static;
    }

My project is located in /var/www/virtualenv-test/ENV/

the project is testsite so the hierarchy inside ENV is:

testsite/
        media/
        static/all files from collect static files
        testsite/
                __init__.py
                settings.py
                urls.py
                wsgi.py
        manage.py

I am using version (1, 4, 2, 'final', 0). 

If somebody can point out the probably obvious problem that I am missing I would greatly appreciate it. 

thanks in advance for your help

--jerry

-- 

jk@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580 



--
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.



--
Rafael E. Ferrero
Claro: (03562) 15514856

--
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.

Thursday, November 29, 2012

calling the view function in the other view function

I have to call a function into another function which displays the
values from the database to the browser, like this:

def result(request):
zee = head.objects.aggregate(Max('id'))
mee = zee['id__max']
Head = head.objects.filter(id = mee)
return render_to_response('report/report_base.html',
{'Head':Head,},context_instance=RequestContext(request))

def result_cube(request):
Head = result(mee)
organisation = Organisation.objects.all().filter(id = 1)
return render_to_response('report/cube.html', { 'Head':Head,
'organisation':organisation},context_instance=RequestContext(request))

I want to call "result" view in the "result_cube", as it displays the
html data but not showing the data from the database.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

--
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: django1.5 subclass AbstractUser, How to get a password-(re)set field in admin

Hi Russel,

I have followed https://docs.djangoproject.com/en/dev/topics/auth/#a-full-example then added: 

password = ReadOnlyPasswordHashField(label=_("Password"),

        help_text=_("Raw passwords are not stored, so there is no way to see "

                    "this user's password, but you can change the password "

                    "using <a href=\"password/\">this form</a>."), widget=ReadOnlyPasswordHashWidget()) 

From what I seen in django/contrib/auth/forms UserChangeForm this gives me the change password URL however I get the error: 'CustUser' object has no attribute 'username' looking at the error line 136

/Library/Python/2.7/site-packages/django/contrib/auth/admin.py in user_change_password

  1.             'title': _('Change password: %s') % escape(user.username), 
It looks like this is either a bug or doesn't work with a custom user as planed as it looks for a username even though in the example you set the email to username field with: USERNAME_FIELD = 'email'

Am I missing something?

Regards,
Bruce

On Saturday, November 3, 2012 4:09:09 PM UTC-7, Russell Keith-Magee wrote:

On Sat, Nov 3, 2012 at 11:15 PM, Michael Muster <michael...@googlemail.com> wrote:
Hi again,

I have a subclass from AbstractUser

1 from django.contrib.auth.models import AbstractUser
2 from django.conf import settings
3
4 class cpUser(AbstractUser):
5     twitter = models.CharField(max_length=100)
6     def __unicode__(self):
7         return self.username

and
AUTH_USER_MODEL = 'account.cpUser'
in my settings.py set.

How do i get a password field to set and reset
a password in my admin app?
Adding the password field to admin.py does obviously not
work as it enters plain text and not the hashed password.

1 from django.contrib import admin
2 class cpUserAdmin(admin.ModelAdmin):
3    fields = ['twitter','username', 'first_name', 'last_name', 'password',]
4                                                                ~~~~~~~~
5 admin.site.register(cpUser, cpUserAdmin)


Do i have to set a passwort field to the models.py or
can i geht that from the models which i "abstracted" from
(as done with username, first_name, last_name...)

You need to follow the instructions that are in the documentation.


The key is that you can't just subclass admin.ModelAdmin -- you need to subclass the existing Django admin class for Users (django.contrib.auth.admin.UserAdmin) - that base class is what provides all the special password handling etc for User models.

Yours,
Russ Magee %-) 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sRmpO1m1Ng0J.
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: Error: No module named books

Thanks for the help everyone. I was using 1.4.x, not the 1.0 the book is based on. After fooling around with the commands for a bit, I was able to figure out that the problem was in the INSTALLED_APPS section - I included 'mysite.books', but the new way to do that is just 'books'.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/IzEq71WVR7wJ.
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: difficulty with static files

On Thu, Nov 29, 2012 at 6:00 PM, Sammy <hayssam.hajar@gmail.com> wrote:
> Hello django experts
> I am unable to get my static files to work. Here are my settings:
>
> projectfiles
> |
> |-----myproject
> | |
> | |-----static
> | | |
> | | |-----css
> | | |-----js
> | |-----__init__.py
> | |-----settings.py
> | |-----urls.py
> | |-----wsgi.py
> |
> |-----myapp
> |
> |-----templates
>
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
> settings.py
> import os
> SITE_ROOT = (os.path.realpath(os.path.dirname(__file__))).replace('\\','/')
> DEBUG = True
> MEDIA_ROOT = (os.path.join(SITE_ROOT, '/static')).replace('\\','/')
> MEDIA_URL = '/static/'
> STATIC_ROOT = ''
> STATIC_URL = ''

I think you are confused about MEDIA and STATIC. MEDIA is where files
are uploaded to by users, STATIC is where files are served from, the
_ROOT postfix denotes a directory path, the _URL postfix a URL path.

So you should have STATIC_ROOT=os.path.join(...) and STATIC_URL='/static/'

> STATICFILES_DIRS = ()
> STATICFILES_FINDERS = (
> 'django.contrib.staticfiles.finders.FileSystemFinder',
> 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> 'django.contrib.staticfiles.finders.DefaultStorageFinder',
> )
>

But do you have the staticfiles app in INSTALLED_APPS?

> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
> urls.py
> urlpatterns = patterns('',
> (r'^myurl/$', myview),
> )
>
>
> from myproject.settings import DEBUG

You should always import settings like this:

from django.conf import settings
if settings.DEBUG

https://docs.djangoproject.com/en/1.4/topics/settings/#using-settings-in-python-code

(It's really important actually, it can cause hard to find bugs!)

> if DEBUG:
> urlpatterns += patterns('', (r'^static/(?P<path>.*)$',
> 'django.views.static.serve',
>
> {'document_root': 'static'}))

This is not needed if you are using runserver in development, if you
are not using runserver, then it is better to use the shortcut methods
provided

https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-static-files-in-development

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.

difficulty with static files

Hello django experts
I am unable to get my static files to work.  Here are my settings:

projectfiles
|
|-----myproject
|     |
|     |-----static
|     |     |
|     |     |-----css
|     |     |-----js
|     |-----__init__.py
|     |-----settings.py
|     |-----urls.py
|     |-----wsgi.py
|
|-----myapp
|
|-----templates


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


settings.py
import os
SITE_ROOT = (os.path.realpath(os.path.dirname(__file__))).replace('\\','/')
DEBUG = True
MEDIA_ROOT = (os.path.join(SITE_ROOT, '/static')).replace('\\','/')
MEDIA_URL = '/static/'
STATIC_ROOT = ''
STATIC_URL = ''
STATICFILES_DIRS = ()
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


urls.py
urlpatterns = patterns('',
    (r'^myurl/$', myview),
)


from myproject.settings import DEBUG
if DEBUG:
    urlpatterns += patterns('', (r'^static/(?P<path>.*)$', 'django.views.static.serve', 

{'document_root': 'static'}))
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

the app works fine but no connection to my css's or javascripts.

I'm using pycharm if that makes a difference.

Any help would be greatly appreciated.



 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/kFq9WoTc9awJ.
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.