Re: Announcement: django-quickview 0.3 - putting the nitro in rapid web development

2013-02-28 Thread Thomas Weholt
Packaging python is hard!! Fixed the problem now.

pip install django-quickview works.

Sorry.

Thomas

On Thu, Feb 28, 2013 at 5:03 AM, Bino Oetomo  wrote:
>
>
> On Feb 28, 2:39 am, Thomas Weholt  wrote:
>>
>> Documentation and tutorial 
>> athttps://bitbucket.org/weholt/django-quickview/src/fde97a0a0befaeda0ab...
>> for details.
>>
> Some how I failed to install .
> The pip log pasted at http://pastebin.com/ZNcc8CuH
>
> Sincerely
> -bino-
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: StreamingHttpResponse into a Template

2013-02-28 Thread Stefano Tranquillini
Yes, you are perfectly right about the fact that this is a bad 
implementation.
the fact is that where i host the code it does not support celery (so far). 
so i've to find out a workaround to be able to process a bunch 
of external APIs Call (that include the one for sending email). 
we'll probably keep the javascript reloading to process junks, waiting for 
the support of celery.

BTW: the StreamingHttpResposnse, when should it be used? i get the example 
on the docs about writing a cvs, pdf or similar, but, what else?

Thanks for the help.

On Wednesday, February 27, 2013 6:23:52 PM UTC+1, Stefano Tranquillini 
wrote:
>
> Django 1.5 is just came out and it ships the StreamingHttpResponse. 
>
> What i want to do is to print the output of a stream response into a 
> template, having for example a bar that grows based on the streamed data 
> (something similar to a loading bar).
>
> so far i've found a solution that basically is to write the pieces of the 
> final html page into the generator function, so each yield does a 
> render_to_text of a piece of the final html page (i splitted it manually) 
> putting each time the data just processed. 
>
> The problem of this solution is that i can't have the loading bar. What 
> I'm able to have are incremental data, so i can print out the list of 
> processed data, but it's different to what i want to do.
>
> Is there a way to do what i would like to do? 
>
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Use variable in my template?

2013-02-28 Thread Maria
Hello everyone,
 
I have a variable I want to have access to in my Django template. But 
somehow I can't manage to do that.
 
I got *Django/mytemplates/polls/detail.html (template) *where I want to 
insert an image: 
 

> {% load staticfiles %}
>
> 
> 
>  media="screen" />
> 
> 
>  
>  
>
 
 
and
 
*Django/mysite/polls/marke.py* :
 

> from choice import*
>
> global marke
> marke = read_m()
>
The value of marke is *marke3 *and I have an image marke3.jpg. I 
successfully used another variable to insert an image (poll.id) but this 
time it wont work. 
The folder 'polls' is in my INSTALLED_APPS.
 
What can I do?
 
 
 
 
 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




IntegrityError after updating to custom user field: django_admin_log still has fk to auth_user

2013-02-28 Thread Ben Roberts
This ring any bells? I updated my existing site to utilize my new Django 
1.5 custom user field, and now I can't update anything in Admin because i 
get the following error: (django_admin_log still has a fk to auth_user, 
apparently!) Any way to resolve this?



Traceback (most recent call last):

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", 
line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/app/.heroku/python/lib/python2.7/site-packages/
newrelic-1.10.0.28/newrelic/api/object_wrapper.py", line 220, in __call__
self._nr_instance, args, kwargs)

  File "/app/.heroku/python/lib/python2.7/site-packages/
newrelic-1.10.0.28/newrelic/hooks/framework_django.py", line 475, in wrapper
return wrapped(*args, **kwargs)

  File "/app/.heroku/python/lib/python2.7/site-packages/
django/contrib/admin/options.py", line 372, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", 
line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File "/app/.heroku/python/lib/python2.7/site-packages/
django/views/decorators/cache.py", line 89, in _wrapped_view_func
response = view_func(request, *args, **kwargs)

  File "/app/.heroku/python/lib/python2.7/site-packages/
django/contrib/admin/sites.py", line 202, in inner
return view(request, *args, **kwargs)

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", 
line 25, in _wrapper
return bound_func(*args, **kwargs)

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", 
line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py", 
line 21, in bound_func
return func(self, *args2, **kwargs2)

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", 
line 223, in inner
return func(*args, **kwargs)

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", 
line 217, in __exit__
self.exiting(exc_value, self.using)

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", 
line 281, in exiting
commit(using=using)

  File 
"/app/.heroku/python/lib/python2.7/site-packages/django/db/transaction.py", 
line 152, in commit
connection.commit()

  File "/app/.heroku/python/lib/python2.7/site-packages/
django/db/backends/__init__.py", line 241, in commit
self._commit()

  File "/app/.heroku/python/lib/python2.7/site-packages/
django/db/backends/postgresql_psycopg2/base.py", line 242, in _commit
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), 
sys.exc_info()[2])

  File "/app/.heroku/python/lib/python2.7/site-packages/
django/db/backends/postgresql_psycopg2/base.py", line 240, in _commit
return self.connection.commit()

  File "/app/.heroku/python/lib/python2.7/site-packages/
newrelic-1.10.0.28/newrelic/hooks/database_dbapi2.py", line 68, in commit
return self._nr_connection.commit()

IntegrityError: insert or update on table "django_admin_log" violates 
foreign key constraint "django_admin_log_user_id_fkey"
DETAIL:  Key (user_id)=(2) is not present in table "auth_user".

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Does Django support general reusable UI widgets?

2013-02-28 Thread Dong Wang
It seems "django.forms.widgets" is designed to support only reusable input 
widgets used in forms, does Django support general reusable UI widgets like 
tornado.web.UIModule ?

Thanks,
Dong

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: default filtering model admin (crud) using user obj attribute

2013-02-28 Thread Bino Oetomo


On Thursday, February 28, 2013 2:37:54 PM UTC+7, Bino Oetomo wrote:
>
> My question is how to make : 
> 1. Car list : Only show cars with company_id=myuser.company_id 
>
Question #1 is solved 

> 2. Create/Update : 'Company choice list' locked to the one with 
> value=myuser.company_id
>

I Found the way to set initial value, but still don't know how to make this 
field displayed-but-un_editable 

>
> 3. Delete : Only posible for Car.company_id=myuser.company_id 
>
> Kindly please give me any of your enlighten. 
>
> Sincerely
-bino- 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




problem in displaying data on html

2013-02-28 Thread Avnesh Shakya
hi i have one problem, i want to display data from database on html page
all data is displaying but one attribute(university name) which i defined
as models.ManyToManyField(University) is not being displyed, it's not
generating error but it showing msz on html page-

instead of showing university name

plz help me...
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: problem in displaying data on html

2013-02-28 Thread Roberto López López

If you just output a m2m field that's normal. If you rather prefer to
iterate over it and show all the related objects, use a for loop...


On 02/28/2013 02:43 PM, Avnesh Shakya wrote:
> hi i have one problem, i want to display data from database on html page
> all data is displaying but one attribute(university name) which i
> defined as models.ManyToManyField(University) is not being displyed,
> it's not generating error but it showing msz on html page-
> 
> instead of showing university name
> 
> plz help me...
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Roberto López López

I don't understand exactly what do you mean, but if those images are
uploaded by the user (for example, using the admin app), they should be
"{{ MEDIA_URL }}{{ marke.marke }}" instead of "{{ STATIC_URL }}images/{{
marke.marke }}.jpg"



On 02/28/2013 12:06 PM, Maria wrote:
> Hello everyone,
>  
> I have a variable I want to have access to in my Django template. But
> somehow I can't manage to do that.
>  
> I got *Django/mytemplates/polls/detail.html (template) *where I want to
> insert an image:
>  
> 
> {% load staticfiles %}
> 
> 
> 
>  type="text/css" media="screen" />
> 
> 
> 
>   alt="Picture" />
>  
> 
>  
>  
> and
>  
> *Django/mysite/polls/marke.py* :
>  
> 
> from choice import*
> 
> global marke
> marke = read_m()
> 
> The value of marke is *marke3 *and I have an image marke3.jpg. I
> successfully used another variable to insert an image (poll.id) but this
> time it wont work.
> The folder 'polls' is in my INSTALLED_APPS.
>  
> What can I do?
>  
>  
>  
>  
>  
> 
> -- 
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Roberto López López

of course, your model should be something like this:

class Marke(models.Model):
marke = models.ImageField(upload_to="images/")

or wherever you prefer to put your images into the media folder




On 02/28/2013 12:06 PM, Maria wrote:
> Hello everyone,
>  
> I have a variable I want to have access to in my Django template. But
> somehow I can't manage to do that.
>  
> I got *Django/mytemplates/polls/detail.html (template) *where I want to
> insert an image:
>  
> 
> {% load staticfiles %}
> 
> 
> 
>  type="text/css" media="screen" />
> 
> 
> 
>   alt="Picture" />
>  
> 
>  
>  
> and
>  
> *Django/mysite/polls/marke.py* :
>  
> 
> from choice import*
> 
> global marke
> marke = read_m()
> 
> The value of marke is *marke3 *and I have an image marke3.jpg. I
> successfully used another variable to insert an image (poll.id) but this
> time it wont work.
> The folder 'polls' is in my INSTALLED_APPS.
>  
> What can I do?
>  
>  
>  
>  
>  
> 
> -- 
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Does Django support general reusable UI widgets?

2013-02-28 Thread Tom Evans
On Thu, Feb 28, 2013 at 10:46 AM, Dong Wang  wrote:
> It seems "django.forms.widgets" is designed to support only reusable input
> widgets used in forms, does Django support general reusable UI widgets like
> tornado.web.UIModule ?
>

Yes, Django allows you to define custom template tags that can do
anything you want. The closest equivalent to a UIModule is a template
inclusion tag, which allows you to define a context and a template
that uses that context.

https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Problem with two databases

2013-02-28 Thread MoonWolf
I'm making simple application to manage equipment. I've 
used django-ldapdb 
(http://opensource.bolloretelecom.eu/projects/django-ldapdb/) for user 
management (not for authentication, for which i'm using PAM). After 
heavy googling i've managed to connect all this together - LDAP as 
second database), so i can use LDAP-based users as owners of equipment 
(here are most important parts of models):

class LdapUser(ldapdb.models.Model):
"""
Class for representing an LDAP user entry.
"""
class Meta:
managed = False
[...]
full_name = CharField(db_column='cn')
username = CharField(db_column='uid', primary_key=True)

class Equipment(models.Model):
number = models.CharField(unique=True, max_length=13)
state = models.ForeignKey(State)
model = models.CharField(max_length=255)
owner = ForeignKeyAcrossDb(LdapUser)
description = models.CharField(blank=True, max_length=255)
type = models.ForeignKey(Type)
place = models.ForeignKey(Place)

def __unicode__(self):
return u"%s (%s)" % (self.type, self.number)

i googled out ForeignKeyAcrossDb, it's not my code. Also i have googled 
out database router (for main database):

class DefRouter(object):
def db_for_read(self, model, **hints):
if model._meta.app_label == 'equipment_control':
return 'default'
return None

def db_for_write(self, model, **hints):
if model._meta.app_label == 'equipment_control':
return 'default'
return None

def allow_relation(self, obj1, obj2, **hints):
if obj1._meta.app_label == 'equipment_control' or 
obj2._meta.app_label == 'equipment_control':
return True
return None

def allow_syncdb(self, db, model):
if db == 'default':
if model._meta.app_label == 'equipment_control':
return True
elif model._meta.app_label == 'equipment_control':
return False
return None

And basically it works - i can edit users and also i can use LDAP-based 
users in my Equipments. But there are some issues:

* i can't filter Equipments using 'owner' field:
Equipment.objects.filter(owner__full_name__contains="name")
ERROR:  relation "equipment_control_ldapuser" does not exists
(which is true of course, because engine tries to find name in database 
- postgresql in my example)

* i can't customize Admin panel - for example (in admin.py):

class EquipmentModelAdmin(reversion.VersionAdmin):
list_display = ("owner", "type", "number", "description")

and i have "ERROR:  relation "equipment_control_ldapuser" does not 
exists" error.

Is there any possibility to use LDAP transparently? Or maybe some 
workaround exists? I'm pretty new to Django (it's my first "true" 
application) and my knowledge of python is not very high also, so i 
can't figure out any solution. Thanks in advance for any help.

-- 
<:>Roger, MoonWolf Out   <:>|This is the face that'll never change
(::)(::)|
(:) JID:moonw...@jabberpl.org(:)| http://karakkhaz.prv.pl

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: default filtering model admin (crud) using user obj attribute

2013-02-28 Thread Tom Evans
On Thu, Feb 28, 2013 at 7:37 AM, Bino Oetomo  wrote:
> Dear All..
>
> Currently I have custom authentication backend,
> This backend return user-object with additional attributes
>
> START
> Python 2.7.3 (default, Aug  1 2012, 05:16:07)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
 from l2auth.models import Company
 from csm.models import L2User, L2Group
 from l2auth.backends import L2Backend
 myauth = L2Backend()
 myauth.authenticate('user02@binonet','')
> L2Backend => user02@binonet 
> ['user02', 'binonet']
> company_id => 1
> user==> user02
> 
 myuser=myauth.authenticate('user02@binonet','')
> L2Backend => user02@binonet 
> ['user02', 'binonet']
> company_id => 1
> user==> user02
 myuser.company_id
> 

 myuserdict=myuser.__dict__
 myuserdict
> {'username': u'user02', 'first_name': u'user 02', 'last_name': u'of
> binonet', '_state':  0xa7890ac>, '_company_id_cache': , 'company_id_id':
> 1, 'email': u'', 'is_active': True, 'is_superuser': False, 'is_staff':
> False, 'last_login': datetime.datetime(2013, 2, 28, 7, 1, 41, 521980,
> tzinfo=), 'password': u'pbkdf2_sha256$1$0NrkpAjo4osS
> $nFdAVaH9mlAbE9vzAvlj+aQeTP7gQsUpFZLZTYOVggs=', 'id': 2,
> 'date_joined': datetime.datetime(2013, 2, 28, 6, 58, 41,
> tzinfo=)}
 myuser.company_id_id
> 1
> STOP-
>
> My concern is 'myuser.company_id', this attribute is a ForeignKey to
> 'Company' model.
>
> I also have 'Car' model like :
> --START
> class Car(models.Model) :
> company_id = models.ForeignKey()
> badge = models.CharField('Badge', max_length=10)
> --STOP-
>
> By Default, every user login .. he/she have full access (CrUD) to all
> cars, including other company's car.
>
> My question is how to make :
> 1. Car list : Only show cars with company_id=myuser.company_id
> 2. Create/Update : 'Company choice list' locked to the one with
> value=myuser.company_id
> 3. Delete : Only posible for Car.company_id=myuser.company_id
>
> Kindly please give me any of your enlighten.
>
> Sincerely
> -bino-
>

It seems like you are asking how to do multi-tenancy in the stock django admin?

Multi tenancy is tricky in django. Is there any reason you are not
using one of the already existing multi-tenancy efforts?

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Problem with two databases

2013-02-28 Thread Tom Evans
On Thu, Feb 28, 2013 at 1:45 PM, MoonWolf  wrote:
> I'm making simple application to manage equipment. I've
> used django-ldapdb
> (http://opensource.bolloretelecom.eu/projects/django-ldapdb/) for user
> management (not for authentication, for which i'm using PAM). After
> heavy googling i've managed to connect all this together - LDAP as
> second database), so i can use LDAP-based users as owners of equipment
> (here are most important parts of models):
>
> class LdapUser(ldapdb.models.Model):
> """
> Class for representing an LDAP user entry.
> """
> class Meta:
> managed = False
> [...]
> full_name = CharField(db_column='cn')
> username = CharField(db_column='uid', primary_key=True)
>
> class Equipment(models.Model):
> number = models.CharField(unique=True, max_length=13)
> state = models.ForeignKey(State)
> model = models.CharField(max_length=255)
> owner = ForeignKeyAcrossDb(LdapUser)
> description = models.CharField(blank=True, max_length=255)
> type = models.ForeignKey(Type)
> place = models.ForeignKey(Place)
>
> def __unicode__(self):
> return u"%s (%s)" % (self.type, self.number)
>
> i googled out ForeignKeyAcrossDb, it's not my code. Also i have googled
> out database router (for main database):
>
> class DefRouter(object):
> def db_for_read(self, model, **hints):
> if model._meta.app_label == 'equipment_control':
> return 'default'
> return None
>
> def db_for_write(self, model, **hints):
> if model._meta.app_label == 'equipment_control':
> return 'default'
> return None
>
> def allow_relation(self, obj1, obj2, **hints):
> if obj1._meta.app_label == 'equipment_control' or
> obj2._meta.app_label == 'equipment_control':
> return True
> return None
>
> def allow_syncdb(self, db, model):
> if db == 'default':
> if model._meta.app_label == 'equipment_control':
> return True
> elif model._meta.app_label == 'equipment_control':
> return False
> return None
>
> And basically it works - i can edit users and also i can use LDAP-based
> users in my Equipments. But there are some issues:
>
> * i can't filter Equipments using 'owner' field:
> Equipment.objects.filter(owner__full_name__contains="name")
> ERROR:  relation "equipment_control_ldapuser" does not exists
> (which is true of course, because engine tries to find name in database
> - postgresql in my example)
>
> * i can't customize Admin panel - for example (in admin.py):
>
> class EquipmentModelAdmin(reversion.VersionAdmin):
> list_display = ("owner", "type", "number", "description")
>
> and i have "ERROR:  relation "equipment_control_ldapuser" does not
> exists" error.
>
> Is there any possibility to use LDAP transparently? Or maybe some
> workaround exists? I'm pretty new to Django (it's my first "true"
> application) and my knowledge of python is not very high also, so i
> can't figure out any solution. Thanks in advance for any help.
>

I'd do this in a different way, I'd have the user model in the main
database, with an attribute named 'cn', reflecting their LDAP cn.
Authentication is done against LDAP, but using an LDAP auth backend,
rather than trying to pretend LDAP is a django-supported DB. (In fact,
where I have done LDAP auth, I have done it exactly like this)

Any LDAP properties that you require could be added as python
properties to the user model, looking up the info in LDAP on demand,
perhaps caching it.

You then do not need any complex routing or multi DB weirdness.

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Maria
No I dont have a problem to find the images, i already used a variable to 
insert images from the static folder. Its just that I cant use my "marke" 
variable because it is in an external .py file and I would like to learn 
how to use that external variable in my template.

On Thursday, February 28, 2013 12:06:02 PM UTC+1, Maria wrote:
>
> Hello everyone,
>  
> I have a variable I want to have access to in my Django template. But 
> somehow I can't manage to do that.
>  
> I got *Django/mytemplates/polls/detail.html (template) *where I want to 
> insert an image: 
>  
>
>> {% load staticfiles %}
>>
>> 
>> 
>> > media="screen" />
>> 
>> 
>>  
>>  
>>
>  
>  
> and
>  
> *Django/mysite/polls/marke.py* :
>  
>
>> from choice import*
>>
>> global marke
>> marke = read_m()
>>
> The value of marke is *marke3 *and I have an image marke3.jpg. I 
> successfully used another variable to insert an image (poll.id) but this 
> time it wont work. 
> The folder 'polls' is in my INSTALLED_APPS.
>  
> What can I do?
>  
>  
>  
>  
>  
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Tom Evans
On Thu, Feb 28, 2013 at 2:40 PM, Maria  wrote:
> No I dont have a problem to find the images, i already used a variable to
> insert images from the static folder. Its just that I cant use my "marke"
> variable because it is in an external .py file and I would like to learn how
> to use that external variable in my template.
>

Put the variable in the context that you use to render the template.
The variables available in your template are the variables in the
context you supply when rendering your template.

All the template rendering functions take both a Context object and a
raw dictionary. The Context object is created if none is supplied, and
updated with the values in the dictionary (and any template context
processors if using a RequestContext). Eg for the render() shortcut:

https://docs.djangoproject.com/en/1.4/topics/http/shortcuts/#render

If it is still clear, this concept is explained further in the tutorial.

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Announcement: django-quickview 0.3 - putting the nitro in rapid web development

2013-02-28 Thread Tom Evans
On Wed, Feb 27, 2013 at 7:39 PM, Thomas Weholt  wrote:
> pypi : https://pypi.python.org/pypi/django-quickview/
> Source at https://bitbucket.org/weholt/django-quickview
>
> Documentation and tutorial at
> https://bitbucket.org/weholt/django-quickview/src/fde97a0a0befaeda0ab2317035f8e7cd9c311511/docs/basic.md?at=default
> for details.
>
> Bring on the flames ;-)
>

Not a flame :)

It would be cooler if you did not have to pollute model classes by
decorating them with view information. I'd prefer to denote that
FooModel has fast views *not* in models.py :)

For updating instances, you could make it compulsory to list the
changed attributes. Then, only the listed attributes are updated.

Apart from that, looks great. Will probably use this as scaffolding in
my next HTML5 app.

Cheers

Tom

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Bill Freeman
To make a variable visible in a template you must explicitly add it to the
template context.  In the traditional function based view you pass a
Context or RequestContext instance to the template renderer or shortcut.
The constructor for the context accepts a mapping (e.g.: a dict) whose keys
are the names that will be made available in the template, and whose values
will be the values in the template.  So, assuming your marke module, in
your views.py you would import marke, and then, in your view function:

c = RequestContext(request, dict(
marke=marke,
# other stuff, like:
form=from,
...
   ))

That's just an example.  There are lots of ways to build up the context
("c" above) that you will pass to, for example, render_to_response.

Bill

On Thu, Feb 28, 2013 at 9:40 AM, Maria  wrote:

> No I dont have a problem to find the images, i already used a variable to
> insert images from the static folder. Its just that I cant use my "marke"
> variable because it is in an external .py file and I would like to learn
> how to use that external variable in my template.
>
>
> On Thursday, February 28, 2013 12:06:02 PM UTC+1, Maria wrote:
>>
>> Hello everyone,
>>
>> I have a variable I want to have access to in my Django template. But
>> somehow I can't manage to do that.
>>
>> I got *Django/mytemplates/polls/detail.html (template) *where I want to
>> insert an image:
>>
>>
>>> {% load staticfiles %}
>>>
>>> 
>>> 
>>> >> media="screen" />
>>> 
>>> 
>>>  
>>>
>>>
>>
>>
>> and
>>
>> *Django/mysite/polls/marke.py* :
>>
>>
>>> from choice import*
>>>
>>> global marke
>>> marke = read_m()
>>>
>> The value of marke is *marke3 *and I have an image marke3.jpg. I
>> successfully used another variable to insert an image (poll.id) but this
>> time it wont work.
>> The folder 'polls' is in my INSTALLED_APPS.
>>
>> What can I do?
>>
>>
>>
>>
>>
>>
>  --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: I need a form that allows users to select from a list of choices, or add a new choice.

2013-02-28 Thread Mark London
Great.  Thanks very much!

On Wednesday, February 27, 2013 6:13:05 PM UTC-5, Rainy wrote:
>
>
>
>
> On Wednesday, February 27, 2013 11:28:50 AM UTC-5, Mark London wrote:
>>
>> I need a widget or a method that allows users to select items from a list 
>> of choices, or add a new choice.   Someone on stackoverflow asked the same 
>> question, and got a kludgy answer:
>>
>>
>> http://stackoverflow.com/questions/14802167/how-do-i-make-a-django-choicefield-accept-both-preset-choices-and-the-addition-
>>
>> There should be a better way than this.  Thanks.
>>
>> - Mark 
>>
>
>
>
> Take a look at SelectOrCreateField (and its widget) here:
>
> http://lightbird.net/dbe2/issues.html#selectorcreatefield
>
>
> The screenshot is here:
>
> http://lightbird.net/dbe2/issues.html#addissues-template
>
>
>  -ak 
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Announcement: django-quickview 0.3 - putting the nitro in rapid web development

2013-02-28 Thread Thomas Weholt
On Thu, Feb 28, 2013 at 4:10 PM, Tom Evans  wrote:
> On Wed, Feb 27, 2013 at 7:39 PM, Thomas Weholt  
> wrote:
>> pypi : https://pypi.python.org/pypi/django-quickview/
>> Source at https://bitbucket.org/weholt/django-quickview
>>
>> Documentation and tutorial at
>> https://bitbucket.org/weholt/django-quickview/src/fde97a0a0befaeda0ab2317035f8e7cd9c311511/docs/basic.md?at=default
>> for details.
>>
>> Bring on the flames ;-)
>>
>
> Not a flame :)
>
> It would be cooler if you did not have to pollute model classes by
> decorating them with view information. I'd prefer to denote that
> FooModel has fast views *not* in models.py :)

There's an option NOT to use the decorator and keep the ModelViews in
views.py allready as shown in the documentation. I'm going to improve
the decorating options a little bit, but I agree it's nicer to
seperate code related to model and view.

>
> For updating instances, you could make it compulsory to list the
> changed attributes. Then, only the listed attributes are updated.

I've updated the api today so that you can provide just the params you
want to update. It requires a call to the server to get the existing
values, but that can also be avoided by providing the update-call with
a dictionary with the existing values.

>
> Apart from that, looks great. Will probably use this as scaffolding in
> my next HTML5 app.

That's great news. It's still bit of a proof-of-concept thing, but it
has allready saved me lots of time and the coming improvements planned
for version 0.4 will make it even nicer, especially for HTML5 apps
focusing heavy on javascript and dynamic web pages.

My two main concerns are speed and if there are any part of the
implementation that's dangerous in regards to threads, concurrency
etc.

>
> Cheers
>
> Tom



-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Maria
Can you tell me where exactly to insert that Variable?


def detail(request, poll_id):
> p = get_object_or_404(Poll, pk=poll_id)
> return render_to_response('polls/detail.html', {'poll': p},
> context_instance=RequestContext(request))
>

Also, do I have to create a class "marke"? Because up until now I only have:

from choice import*
>
> global marke
> *marke* = read_m()
>
>  
This variable reads an image name. I want to use it for {{ marke }}.jpg




On Thursday, February 28, 2013 12:06:02 PM UTC+1, Maria wrote:
>
> Hello everyone,
>  
> I have a variable I want to have access to in my Django template. But 
> somehow I can't manage to do that.
>  
> I got *Django/mytemplates/polls/detail.html (template) *where I want to 
> insert an image: 
>  
>
>> {% load staticfiles %}
>>
>> 
>> 
>> > media="screen" />
>> 
>> 
>>  
>>  
>>
>  
>  
> and
>  
> *Django/mysite/polls/marke.py* :
>  
>
>> from choice import*
>>
>> global marke
>> marke = read_m()
>>
> The value of marke is *marke3 *and I have an image marke3.jpg. I 
> successfully used another variable to insert an image (poll.id) but this 
> time it wont work. 
> The folder 'polls' is in my INSTALLED_APPS.
>  
> What can I do?
>  
>  
>  
>  
>  
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Shawn Milochik
On Thu, Feb 28, 2013 at 11:30 AM, Maria  wrote:
> Can you tell me where exactly to insert that Variable?

Have a look at this page in the tutorial:
https://docs.djangoproject.com/en/1.5/intro/tutorial03/

See how a variable in the view is added to the context? Exactly like that.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Possible bug with Form Wizard and condition_dict?

2013-02-28 Thread Arild Haugstad
When "starting" the wizard, the "current" step is the *first* step.
The "first" step is the first in the list of *currently enabled* steps.
The list of "currently enabled" steps is constructed by checking each step 
wrt. condition_dict.

In other words; obtaining the current step implicitly runs the callables in 
condition_dict, so doing that from one of the callables leads to infinite 
recursion.

Personally, I'm not sure whether this should be considered a bug; the 
wizard implementation could probably be reorganised to only check 
condition_dict until a "first" step was found; but the resulting behaviour 
would be somewhat difficult to describe; accessing wizard.steps.current 
from the callables in condition_dict would still be unsafe from those 
callables checked in order to find the "first"; i.e. in the general case, 
the problem cannot be solved.  On the other hand, the current 
behaviour/limitation does not appear to be documented...

I have a hard time imagining a scenario where checking the current step 
makes sense for determining what steps are available --- the step being 
checked for would clearly not be visited on every run-through of the 
wizard, but if that step is enabled based on some different conditional, 
reusing that might make more sense?  (... or at least work with the current 
wizard.)

A possible workaround may be to store some data on an instance member on 
the wizard object --- or on the wizard objects storage --- in 
process_step(), and then check that in the callable.



On Friday, 5 October 2012 17:16:02 UTC+2, Scott Woodall wrote:
>
> I searched the bug tracker and the django users with no results, so is 
> what I'm seeing a bug?
>
> I have a form wizard that is using a callable within condition_dict. If I 
> try to access "wizard.steps.current" inside the callable, I get the 
> following error:
>
> "maximum recursion depth exceeded in __instancecheck__"
> Exception Location: 
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py
>  
> in _reconstruct, line 307
>
> Just trying to figure out if I should file a bug report or I'm doing 
> something wrong?
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: blank and null with Oracle

2013-02-28 Thread Ian
On Wednesday, February 27, 2013 3:31:20 PM UTC-7, Skylar Saveland wrote:
>
> Some odd behavior with Oracle involving blank and null.
>
> blank is True on this field:
> my_auto = models.AutoField(blank=False, null=False, primary_key=True)
>
> null is True on this field:
> uncles = models.ManyToManyField(Uncle, blank=False, null=False)
>

These two have nothing to do with Oracle specifically.  AutoFields are 
coerced to blank=True regardless of backend.  You can see that here:

https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L534

I don't know exactly why this is done, but I would guess it is because the 
point of the AutoField is that it can be left blank and automatically be 
filled in.  If you don't want that, then you probably want an IntegerField 
instead.

I'm not sure where null=True is getting set on the ManyToManyField, but I 
guess that the reason for this is that null=False represents a database 
constraint, and there is no way to actually set that constraint because the 
field does not map to an actual column in the model table; it maps to an 
intermediate relational table instead.

null is True on this field:
> photo = models.ImageField(upload_to="uploads/") 
>

This one is due to Oracle, because ImageField is a string-based field (it 
stores the filename where the image is stored).  A null value here in 
Oracle is equivalent to an empty filename in another backend.
 

> And, then, as documented null=True on CharFields.
>

Note that the docs say, "fields that have the empty string as a possible 
value", not specifically CharFields.  This is because it also includes 
things like FileField, ImageField, CommaSeparatedIntegerField, 
GenericIPAddressField, etc.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Bill Freeman
In the lines:

return render_to_response('polls/detail.html', {'poll': p},
   context_instance=RequestContext(request))

you have two choices.  Both:

return render_to_response('polls/detail.html', {'poll': p, 'marke':
marke},
   context_instance=RequestContext(request))

and

return render_to_response('polls/detail.html', {'poll': p},
   context_instance=RequestContext(request),
dict(marke=marke))

will work.  Also, in both places you have the choice of the dictionary
literal syntax: {...}
or the type constructor syntax: dict(...) -- it's a matter of tast, so long
as the keys are
legal python identifiers.  That is, the second example could also be
written as:

return render_to_response('polls/detail.html', {'poll': p},
   context_instance=RequestContext(request),
{'marke': marke})

The second argument of render_to_response is used to update the
context_instance,
or to initialize a new one if context_instance is not provided.

As to where marke comes from, my suggestions were written from the point of
view
that your marke.py worked, and that you had done:

import marke

Higher in the file.  Since I don't understand the purpose of marke (versus
a constant
string, or an attribute of an image field on one of your models, I can't
help you with
it.  Perhaps you could better describe why this is a variable, and from
where its
contents are intended to come?

Bill

On Thu, Feb 28, 2013 at 11:30 AM, Maria  wrote:

> Can you tell me where exactly to insert that Variable?
>
>
> def detail(request, poll_id):
>> p = get_object_or_404(Poll, pk=poll_id)
>> return render_to_response('polls/detail.html', {'poll': p},
>> context_instance=RequestContext(request))
>>
>
> Also, do I have to create a class "marke"? Because up until now I only
> have:
>
>
> from choice import*
>>
>> global marke
>> *marke* = read_m()
>>
>>
> This variable reads an image name. I want to use it for {{ marke }}.jpg
>
>
>
>
> On Thursday, February 28, 2013 12:06:02 PM UTC+1, Maria wrote:
>
>> Hello everyone,
>>
>> I have a variable I want to have access to in my Django template. But
>> somehow I can't manage to do that.
>>
>> I got *Django/mytemplates/polls/detail.html (template) *where I want to
>> insert an image:
>>
>>
>>> {% load staticfiles %}
>>>
>>> 
>>> 
>>> >> media="screen" />
>>> 
>>> 
>>>  
>>>
>>>
>>
>>
>> and
>>
>> *Django/mysite/polls/marke.py* :
>>
>>
>>> from choice import*
>>>
>>> global marke
>>> marke = read_m()
>>>
>> The value of marke is *marke3 *and I have an image marke3.jpg. I
>> successfully used another variable to insert an image (poll.id) but this
>> time it wont work.
>> The folder 'polls' is in my INSTALLED_APPS.
>>
>> What can I do?
>>
>>
>>
>>
>>
>>
>  --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Use variable in my template?

2013-02-28 Thread Bill Freeman
By the way, in your marke.py, the "global" declaration doesn't do what you
seem to think,
and may be a syntax error.  I know that in some other languages, "global"
is used to make
a variable available to all code.  This is not the case in python.  Without
the "global"
declaration, any piece of code can do:

import marke

and then reference your variable as marke.marke .

The top level variables of a module which has been imported can be
referenced by the
same "." syntax as is used to reference the attributes of classes and class
instances.

In python "global" is used inside of a function definition to allow the
function (or method)
to write to (set the value of) a variable in the global namespace (the top
level of the
module in almost all cases).  The function can read from (use the current
value of) a
global (module top level) variable without using any special syntax.  But
while python
is internalizing (compiling) the function definition, if it sees you
setting a variable which
you have not declared global within that function body, it makes a variable
that is local
to the function.  If this variable has the same name as a global variable,
the global
variable is hidden from that function body.  The global declaration tells
python that
you really do want to use the global variable, even if you are setting it.

Bill

On Thu, Feb 28, 2013 at 11:57 AM, Bill Freeman  wrote:

> In the lines:
>
>
> return render_to_response('polls/detail.html', {'poll': p},
>context_instance=RequestContext(request))
>
> you have two choices.  Both:
>
> return render_to_response('polls/detail.html', {'poll': p, 'marke':
> marke},
>context_instance=RequestContext(request))
>
> and
>
>
> return render_to_response('polls/detail.html', {'poll': p},
>context_instance=RequestContext(request),
> dict(marke=marke))
>
> will work.  Also, in both places you have the choice of the dictionary
> literal syntax: {...}
> or the type constructor syntax: dict(...) -- it's a matter of tast, so
> long as the keys are
> legal python identifiers.  That is, the second example could also be
> written as:
>
>
> return render_to_response('polls/detail.html', {'poll': p},
>context_instance=RequestContext(request),
> {'marke': marke})
>
> The second argument of render_to_response is used to update the
> context_instance,
> or to initialize a new one if context_instance is not provided.
>
> As to where marke comes from, my suggestions were written from the point
> of view
> that your marke.py worked, and that you had done:
>
> import marke
>
> Higher in the file.  Since I don't understand the purpose of marke (versus
> a constant
> string, or an attribute of an image field on one of your models, I can't
> help you with
> it.  Perhaps you could better describe why this is a variable, and from
> where its
> contents are intended to come?
>
> Bill
>
> On Thu, Feb 28, 2013 at 11:30 AM, Maria  wrote:
>
>> Can you tell me where exactly to insert that Variable?
>>
>>
>> def detail(request, poll_id):
>>> p = get_object_or_404(Poll, pk=poll_id)
>>> return render_to_response('polls/detail.html', {'poll': p},
>>> context_instance=RequestContext(request))
>>>
>>
>> Also, do I have to create a class "marke"? Because up until now I only
>> have:
>>
>>
>> from choice import*
>>>
>>> global marke
>>> *marke* = read_m()
>>>
>>>
>> This variable reads an image name. I want to use it for {{ marke }}.jpg
>>
>>
>>
>>
>> On Thursday, February 28, 2013 12:06:02 PM UTC+1, Maria wrote:
>>
>>> Hello everyone,
>>>
>>> I have a variable I want to have access to in my Django template. But
>>> somehow I can't manage to do that.
>>>
>>> I got *Django/mytemplates/polls/detail.html (template) *where I want to
>>> insert an image:
>>>
>>>
 {% load staticfiles %}

 
 
 >>> media="screen" />
 
 
  >>> />


>>>
>>>
>>> and
>>>
>>> *Django/mysite/polls/marke.py* :
>>>
>>>
 from choice import*

 global marke
 marke = read_m()

>>> The value of marke is *marke3 *and I have an image marke3.jpg. I
>>> successfully used another variable to insert an image (poll.id) but
>>> this time it wont work.
>>> The folder 'polls' is in my INSTALLED_APPS.
>>>
>>> What can I do?
>>>
>>>
>>>
>>>
>>>
>>>
>>  --
>> 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?hl=en.
>> 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 unsubsc

Re: StreamingHttpResponse into a Template

2013-02-28 Thread Sam Solomon
Not sure if this is what you meant by "we'll probably keep the javascript 
reloading to process junks, waiting for the support of celery", but one 
option without celery is to have the initial request save a bunch of 
"PendingEmail" objects in the database and then redirect you to a 
"send_queued_emails" page that sends as many emails as it can in 5 seconds 
and then returns a page telling you how many it needs to send remaining and 
javascript to refresh the page immediately (if you use browsers that will 
show a blank page as soon as the refresh is initiated, you can use ajax or 
something for these requests).

Something somewhat closer to the celery option, but possible to set up on 
slightly more restrictive systems is to do the same thing with 
"PendingEmail" objects and set up a cron job to run a django management 
command every minute that consumes as many PendingEmail objects it can in 
55 seconds.

For either of these solutions, make sure autocommit is enabled for those 
functions and that you mark an email as sent before you start the api call 
otherwise if somehow two things are consuming from the same queue you could 
send duplicate emails. Alternatively (or additionally) you could even 
create a lock-file or some similar thing to make sure only one thing is 
consuming from the queue at a time.

On Thursday, February 28, 2013 1:31:29 AM UTC-8, Stefano Tranquillini wrote:
>
> Yes, you are perfectly right about the fact that this is a bad 
> implementation.
> the fact is that where i host the code it does not support celery (so 
> far). so i've to find out a workaround to be able to process a bunch 
> of external APIs Call (that include the one for sending email). 
> we'll probably keep the javascript reloading to process junks, waiting for 
> the support of celery.
>
> BTW: the StreamingHttpResposnse, when should it be used? i get the example 
> on the docs about writing a cvs, pdf or similar, but, what else?
>
> Thanks for the help.
>
> On Wednesday, February 27, 2013 6:23:52 PM UTC+1, Stefano Tranquillini 
> wrote:
>>
>> Django 1.5 is just came out and it ships the StreamingHttpResponse. 
>>
>> What i want to do is to print the output of a stream response into a 
>> template, having for example a bar that grows based on the streamed data 
>> (something similar to a loading bar).
>>
>> so far i've found a solution that basically is to write the pieces of the 
>> final html page into the generator function, so each yield does a 
>> render_to_text of a piece of the final html page (i splitted it manually) 
>> putting each time the data just processed. 
>>
>> The problem of this solution is that i can't have the loading bar. What 
>> I'm able to have are incremental data, so i can print out the list of 
>> processed data, but it's different to what i want to do.
>>
>> Is there a way to do what i would like to do? 
>>
>> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[ANN] Django Endless Pagination v2.0

2013-02-28 Thread Francesco Banconi
Hi all,

I just released Endless Pagination v2.0: Django pagination tools supporting
Ajax, multiple and lazy pagination, Twitter-style and Digg-style pagination.

New features include Python 3 support, Javascript improvements, code clean 
up
and many other bug fixes and changes.
If you are interested, please take a look at the complete Changelog here:
https://django-endless-pagination.readthedocs.org/en/latest/changelog.html

Code and documentation:
Git: https://github.com/frankban/django-endless-pagination
Mercurial: https://bitbucket.org/frankban/django-endless-pagination
Docs: http://django-endless-pagination.readthedocs.org

How to contribute:
https://django-endless-pagination.readthedocs.org/en/latest/contributing.html

Many 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Daemonize django server

2013-02-28 Thread Tim Johnson
I'm having a hell of a time getting fastcgi to work on my mac, so
for the time being I'll just stick with using the django server.

Is it possible to daemonize the server? I would prefer that in some
cases.

>From https://docs.djangoproject.com/en/dev/ref/django-admin/
I see daemonize as an option for runfcgi but not for runserver.

thanks
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Daemonize django server

2013-02-28 Thread Josh Cartmell
This (http://software.clapper.org/daemonize/) may do what you want and
can be installed with homebrew on a mac, but if this is in any way a
production setting, I wouldn't do it.  The dev server hasn't gone
through any security audits and could and probably does have unknown
weaknesses in that regard, more info here:
https://docs.djangoproject.com/en/dev/ref/django-admin/#runserver-port-or-address-port

On Feb 28, 10:23 am, Tim Johnson  wrote:
> I'm having a hell of a time getting fastcgi to work on my mac, so
> for the time being I'll just stick with using the django server.
>
> Is it possible to daemonize the server? I would prefer that in some
> cases.
>
> Fromhttps://docs.djangoproject.com/en/dev/ref/django-admin/
> I see daemonize as an option for runfcgi but not for runserver.
>
> thanks
> --
> Tim
> tim at tee jay forty nine dot com or akwebsoft dot comhttp://www.akwebsoft.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Daemonize django server

2013-02-28 Thread Tim Johnson
* Josh Cartmell  [130228 09:48]:
> This (http://software.clapper.org/daemonize/) may do what you want and
> can be installed with homebrew on a mac, but if this is in any way a
> production setting, I wouldn't do it.  The dev server hasn't gone
> through any security audits and could and probably does have unknown
> weaknesses in that regard, more info here:
> https://docs.djangoproject.com/en/dev/ref/django-admin/#runserver-port-or-address-port

  Thanks Josh. Any deployment I would do would be on fastcgi or some
  other recommended method in a linux environ. It is just that I
  have failed to get fastcgi working on my mac and I presume that in
  time, my feet will be wet enough to resolve those issues. In the meantime, 
  I may look into that. 

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Ivo Brodien
Hello,

in the Django Docs for Class Based Views[1] it says under the green box:

This approach applies the decorator on a per-instance basis. If you want every 
instance of a view to be decorated, you need to take a different approach.

I don't quite get that, since "per instance" and "every instance" is for me the 
same, although in the context above it is used as if they were different in 
order to make you use a different approach.

My English is probably not good enough to get the difference so it would be 
nice if someone could explain it to me!

Thanks! 

[1]https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-in-urlconf

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Tomas Neme
> This approach applies the decorator on a per-instance basis. If you want
> every instance of a view to be decorated, you need to take a different
> approach.

This means that with "this approach" you have to apply the decorator
in every instance you want modified, that is, every time you have this

url(, YourView.as_view(),...)

and want it decorated, you need to wrap it, individually, like

url(, decorator(YourView.as_view()), )

and if you want to define the entire view as decorated, so you don't
need to decorate it every time you use it in an urlpattern, because it
ALWAYS needs, e.g., to be login_required, you'll need to take a
different approach.

With function views, this was the normal case, because you did

@decorator
def my_view(request, *args, **kwargs):
..

and you didn't need to add anything in the urls, with class-based
views, you need to do this:
https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class


--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Ivo Brodien
Thanks Tomas,

now I got it! Still the original usage of "per" and "every" sounds strange to 
me.. it should be more like "per instance within a URL pattern", but I am not a 
native in English, so nevermind.

Thanks!

On Feb 28, 2013, at 8:54 PM, Tomas Neme wrote:

>> This approach applies the decorator on a per-instance basis. If you want
>> every instance of a view to be decorated, you need to take a different
>> approach.
> 
> This means that with "this approach" you have to apply the decorator
> in every instance you want modified, that is, every time you have this
> 
> url(, YourView.as_view(),...)
> 
> and want it decorated, you need to wrap it, individually, like
> 
> url(, decorator(YourView.as_view()), )
> 
> and if you want to define the entire view as decorated, so you don't
> need to decorate it every time you use it in an urlpattern, because it
> ALWAYS needs, e.g., to be login_required, you'll need to take a
> different approach.
> 
> With function views, this was the normal case, because you did
> 
> @decorator
> def my_view(request, *args, **kwargs):
> ..
> 
> and you didn't need to add anything in the urls, with class-based
> views, you need to do this:
> https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class
> 
> 
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
> 
> |_|0|_|
> |_|_|0|
> |0|0|0|
> 
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
> 
> -- 
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Tomas Neme
your view class is.. well, that, just a class.

Every time you use it in an urlpattern, calling .as_view() a new
instance object of that class is created. So the "per instance" should
be pretty much self explanatory

On Thu, Feb 28, 2013 at 5:04 PM, Ivo Brodien  wrote:
> Thanks Tomas,
>
> now I got it! Still the original usage of "per" and "every" sounds strange to 
> me.. it should be more like "per instance within a URL pattern", but I am not 
> a native in English, so nevermind.
>
> Thanks!
>
> On Feb 28, 2013, at 8:54 PM, Tomas Neme wrote:
>
>>> This approach applies the decorator on a per-instance basis. If you want
>>> every instance of a view to be decorated, you need to take a different
>>> approach.
>>
>> This means that with "this approach" you have to apply the decorator
>> in every instance you want modified, that is, every time you have this
>>
>> url(, YourView.as_view(),...)
>>
>> and want it decorated, you need to wrap it, individually, like
>>
>> url(, decorator(YourView.as_view()), )
>>
>> and if you want to define the entire view as decorated, so you don't
>> need to decorate it every time you use it in an urlpattern, because it
>> ALWAYS needs, e.g., to be login_required, you'll need to take a
>> different approach.
>>
>> With function views, this was the normal case, because you did
>>
>> @decorator
>> def my_view(request, *args, **kwargs):
>> ..
>>
>> and you didn't need to add anything in the urls, with class-based
>> views, you need to do this:
>> https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class
>>
>>
>> --
>> "The whole of Japan is pure invention. There is no such country, there
>> are no such people" --Oscar Wilde
>>
>> |_|0|_|
>> |_|_|0|
>> |0|0|0|
>>
>> (\__/)
>> (='.'=)This is Bunny. Copy and paste bunny
>> (")_(") to help him gain world domination.
>>
>> --
>> 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?hl=en.
>> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Wording in Djang Docs: "per instance" vs "every instance"

2013-02-28 Thread Ivo Brodien
yeah, you are right, now I see it too…I shouldn't start reading django docs at 
the end of a working day…
cheers and thanks again!

On Feb 28, 2013, at 9:09 PM, Tomas Neme wrote:

> your view class is.. well, that, just a class.
> 
> Every time you use it in an urlpattern, calling .as_view() a new
> instance object of that class is created. So the "per instance" should
> be pretty much self explanatory
> 
> On Thu, Feb 28, 2013 at 5:04 PM, Ivo Brodien  wrote:
>> Thanks Tomas,
>> 
>> now I got it! Still the original usage of "per" and "every" sounds strange 
>> to me.. it should be more like "per instance within a URL pattern", but I am 
>> not a native in English, so nevermind.
>> 
>> Thanks!
>> 
>> On Feb 28, 2013, at 8:54 PM, Tomas Neme wrote:
>> 
 This approach applies the decorator on a per-instance basis. If you want
 every instance of a view to be decorated, you need to take a different
 approach.
>>> 
>>> This means that with "this approach" you have to apply the decorator
>>> in every instance you want modified, that is, every time you have this
>>> 
>>> url(, YourView.as_view(),...)
>>> 
>>> and want it decorated, you need to wrap it, individually, like
>>> 
>>> url(, decorator(YourView.as_view()), )
>>> 
>>> and if you want to define the entire view as decorated, so you don't
>>> need to decorate it every time you use it in an urlpattern, because it
>>> ALWAYS needs, e.g., to be login_required, you'll need to take a
>>> different approach.
>>> 
>>> With function views, this was the normal case, because you did
>>> 
>>> @decorator
>>> def my_view(request, *args, **kwargs):
>>> ..
>>> 
>>> and you didn't need to add anything in the urls, with class-based
>>> views, you need to do this:
>>> https://docs.djangoproject.com/en/1.5/topics/class-based-views/intro/#decorating-the-class
>>> 
>>> 
>>> --
>>> "The whole of Japan is pure invention. There is no such country, there
>>> are no such people" --Oscar Wilde
>>> 
>>> |_|0|_|
>>> |_|_|0|
>>> |0|0|0|
>>> 
>>> (\__/)
>>> (='.'=)This is Bunny. Copy and paste bunny
>>> (")_(") to help him gain world domination.
>>> 
>>> --
>>> 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?hl=en.
>>> 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>> 
>> 
> 
> 
> 
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
> 
> |_|0|_|
> |_|_|0|
> |0|0|0|
> 
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
> 
> -- 
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How to redirect to same page on failed login

2013-02-28 Thread Suneil Rudra
Hi, I'm quite new to using Django, and I've searched around for a while for 
a solution but haven't really found anything useful.

I'm using a context processor to make my login form available from 
base.html. When I login in with valid details, it redirects me to the the 
page I logged in from as expected. However when I enter incorrect 
credentials it redirects me to /login/. I've tried using HttpResponse 
Redirect which will redirect me back to the referring page but then my form 
is empty so it no longer displays the field error messages. I've tried 
using render_to_response which gives me the field error messages but on 
/login/ rather than on the original page.

Any help would be much appreciated,
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to redirect to same page on failed login

2013-02-28 Thread Rafael E. Ferrero
Are you tried Login Redirect ?

2013/2/28 Suneil Rudra 

> Hi, I'm quite new to using Django, and I've searched around for a while
> for a solution but haven't really found anything useful.
>
> I'm using a context processor to make my login form available from
> base.html. When I login in with valid details, it redirects me to the the
> page I logged in from as expected. However when I enter incorrect
> credentials it redirects me to /login/. I've tried using HttpResponse
> Redirect which will redirect me back to the referring page but then my form
> is empty so it no longer displays the field error messages. I've tried
> using render_to_response which gives me the field error messages but on
> /login/ rather than on the original page.
>
> Any help would be much appreciated,
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



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

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to redirect to same page on failed login

2013-02-28 Thread Suneil Rudra
Do you mean the LOGIN_REDIRECT_URL setting?

On Thursday, February 28, 2013 9:01:40 PM UTC, vicherot wrote:
>
> Are you tried Login Redirect ?
>
> 2013/2/28 Suneil Rudra >
>
>> Hi, I'm quite new to using Django, and I've searched around for a while 
>> for a solution but haven't really found anything useful.
>>
>> I'm using a context processor to make my login form available from 
>> base.html. When I login in with valid details, it redirects me to the the 
>> page I logged in from as expected. However when I enter incorrect 
>> credentials it redirects me to /login/. I've tried using HttpResponse 
>> Redirect which will redirect me back to the referring page but then my form 
>> is empty so it no longer displays the field error messages. I've tried 
>> using render_to_response which gives me the field error messages but on 
>> /login/ rather than on the original page.
>>
>> Any help would be much appreciated,
>> 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Rafael E. Ferrero
> Claro: (03562) 15514856 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Daemonize django server

2013-02-28 Thread carlos
you try http://gunicorn.org/ is fast and easy to deploy

Cheers


On Thu, Feb 28, 2013 at 1:22 PM, Tim Johnson  wrote:

> * Josh Cartmell  [130228 09:48]:
> > This (http://software.clapper.org/daemonize/) may do what you want and
> > can be installed with homebrew on a mac, but if this is in any way a
> > production setting, I wouldn't do it.  The dev server hasn't gone
> > through any security audits and could and probably does have unknown
> > weaknesses in that regard, more info here:
> >
> https://docs.djangoproject.com/en/dev/ref/django-admin/#runserver-port-or-address-port
>
>   Thanks Josh. Any deployment I would do would be on fastcgi or some
>   other recommended method in a linux environ. It is just that I
>   have failed to get fastcgi working on my mac and I presume that in
>   time, my feet will be wet enough to resolve those issues. In the
> meantime,
>   I may look into that.
>
> --
> Tim
> tim at tee jay forty nine dot com or akwebsoft dot com
> http://www.akwebsoft.com
>
> --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Daemonize django server

2013-02-28 Thread Tim Johnson
* carlos  [130228 13:15]:
> you try http://gunicorn.org/ is fast and easy to deploy
> 
> Cheers
  Thank you! That looks great.
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Daemonize django server

2013-02-28 Thread Tim Johnson
* carlos  [130228 13:15]:
> you try http://gunicorn.org/ is fast and easy to deploy
 :) It was as simple as easy_install gunicorn
 then switch to the app directory and
 ran
 gunicorn_django --daemon --pid djpid --bind=127.0.0.1:8001
 I have a daemonized process at localhost:8001
 and to shut it down 
 kill $(cat djpid)  ## Assuming still in the app directory
 I wish it could be that easy on hostmonster 
 thanks again carlos :: good tip
-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: default filtering model admin (crud) using user obj attribute

2013-02-28 Thread Bino Oetomo
Dear Tom and all

I really appreciate your response

On Thursday, February 28, 2013 9:13:56 PM UTC+7, Tom Evans wrote:
>
> It seems like you are asking how to do multi-tenancy in the stock django 
> admin? 
>
> Yes, excatly 

> Multi tenancy is tricky in django. Is there any reason you are not 
> using one of the already existing multi-tenancy efforts? 
>
> I took a look on some existing multi-tenancy efforts, but most (all ?) of 
them share the same Idea that there is no bussiness relation between tenant.

I need to build a solution to let tenant do business between them.

'Car' is just an example-case to make it easy to post to this group.
Let's say it's a network of Rent-Car companies , that can rent each other 
cars to be re-rented to the end user.
1. I want each company to be able to manage their own staff, but don't want 
the to touch the real 'User' model/table.
2. I want each company to be able to manage (CrUD) thei asset, but only 
'See' their partner asset.
3. I want all company to do business betwen them.

Sincerely
-bino-

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: password encryption

2013-02-28 Thread Russell Keith-Magee
Hi Tomas,

If you dig into Django's password tools, you'll discover that we use PBKDF2
by default, and have an option to use bcrypt. We also have a pluggable
backend that allows you to define your own hashing algorithm if you'd
prefer something harder, or if something emerges that supersedes PBKDF2.

We haven't used SHA-based or MD5-based hashing for some time.

Yours,
Russ Magee %-)

On Wed, Feb 27, 2013 at 11:36 PM, Tomas Neme  wrote:

> and here it presses an even stronger case about NOT using bcrypt but
> something even slower
>
> http://www.unlimitednovelty.com/2012/03/dont-use-bcrypt.html
>
> On Wed, Feb 27, 2013 at 12:33 PM, Tomas Neme 
> wrote:
> > I just ran into this. It presses a pretty strong case...
> >
> > http://codahale.com/how-to-safely-store-a-password/
> >
> > --
> > "The whole of Japan is pure invention. There is no such country, there
> > are no such people" --Oscar Wilde
> >
> > |_|0|_|
> > |_|_|0|
> > |0|0|0|
> >
> > (\__/)
> > (='.'=)This is Bunny. Copy and paste bunny
> > (")_(") to help him gain world domination.
>
>
>
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
>
> --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Problem with 'ModelForm' vs 'Permission'

2013-02-28 Thread Bino Oetomo
Dear All.

I've something like this :
START-
class L2GroupForm(ModelForm):
#Try to lock ForeignKey field to single value
class Meta:
model = L2Group
widgets = {
'company_id': TextInput(),
}


class L2GroupAdmin(admin.ModelAdmin):
#Choose the Form
form = L2GroupForm()
#Filtering Listed groups, only to which have right company_id 
def queryset(self, request):
requserid =request.session.get('_auth_user_id', None)
qs = self.model._default_manager.get_query_set()

if not requserid is None :
company_filter = L2User.objects.get(pk=requserid).company_id
if not company_filter is None:
qs = qs.filter(company_id=company_filter)
print qs
return qs

#Try to set 'company_id' field initial value
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'company_id':
requserid =request.session.get('_auth_user_id', None)
if not requserid is None :
company_filter = L2User.objects.get(pk=requserid).company_id
if not company_filter is None:
kwargs['initial'] = company_filter
return db_field.formfield(**kwargs)
return super(L2GroupAdmin, self).formfield_for_foreignkey(
db_field, request, **kwargs
)

l2admin.register(L2Group, L2GroupAdmin)

STOP--

Problem is :
1. When I loged in (as superuser), it says that I've no right to edit 
anything, but
2. When I commented the ' form = L2GroupForm()' , all is works but the 
company_id field not locked to single choice ... yes the initial value 
setup is work.

Kindly please give me your enlighten to lock a ForeignKey field to single 
choice.

Sincerely
-bino-

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: HTML5 Offline apps with Django 1.4

2013-02-28 Thread Russell Keith-Magee
Hi Ranjith,

Perhaps I've confused things here -- when you're serving offline HTML5, you
need to serve (at least) 2 pages -- a page with html, and a *completely
separate* second page containing the manifest. The manifest file has a
content type of text/cache-manifest; your HTML is served with a normal
text/html content type.

>From what you describe, it sounds like you're just serving the HTML as
text/cache-manifest.

Yours,
Russ Magee %-)

On Tue, Feb 26, 2013 at 10:34 AM, Ranjith Chaz  wrote:

> Thanks for the reply, Russell. I had tried it already. What I get when I
> do this is, the html source instead of the web page. That is, the complete
> html code gets printed out in the browser and it happens in all browsers
> irrespective of mobile, desktop.
>
>
> On Thursday, February 21, 2013 1:08:16 PM UTC+5:30, Ranjith Chaz wrote:
>>
>> Trying to implement *offline** *feature of *HTML5*.  Deployed in *
>> apache2.2* with mod_wsgi plugin.
>> It works as expected (i.e., loads the cached page when offline) in
>> chrome, Opera (using window.openDatabase) and other desktop browsers.
>> However it doesn't work in Android 2.x, iPhone default browsers. Strangely,
>> it works with Android 4.0 browser!!
>> Here is the code:
>>
>> *HTML*
>>
>> 
>> 
>>
>>   
>>   MyHomeStuff
>>   > >
>>   
>>
>>
>>  .
>>
>> 
>>
>>
>> *Apache conf\mime.types**text/cache-manifest manifest*
>>
>> *
>> *
>>
>> *\Python27\Lib\mimetypes.py*
>> Added *'.manifest': 'text/cache-manifest'*, into *types_map *dict
>>
>> (With the above addition to mimetypes.py, it started working for android 4.0)
>>
>>
>> *cache.manifest*CACHE MANIFEST
>> CACHE:index.htmlMyHomeStuff.js
>>
>>
>> *views.py:*
>>
>> def offlineApp(request):
>> t = get_template('index.html')
>> html = 
>> t.render(Context({'MEDIA_URL':**'http://myDomain.com/site_**media/ 
>> '}))
>> return HttpResponse(html)
>>
>>
>> *Is it required to use any specific module/middleware to handle 
>> text/manifest in django ?*
>>
>> Any help is appreciated. Already spent a lot of time on this!
>>
>>
>>  --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: problem in displaying data on html

2013-02-28 Thread Avnesh Shakya
thanks i got it
thanks

On Thu, Feb 28, 2013 at 7:19 PM, Roberto López López
wrote:

>
> If you just output a m2m field that's normal. If you rather prefer to
> iterate over it and show all the related objects, use a for loop...
>
>
> On 02/28/2013 02:43 PM, Avnesh Shakya wrote:
> > hi i have one problem, i want to display data from database on html page
> > all data is displaying but one attribute(university name) which i
> > defined as models.ManyToManyField(University) is not being displyed,
> > it's not generating error but it showing msz on html page-
> > 
> > instead of showing university name
> >
> > plz help me...
> > 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?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
> --
> Kind regards,
>
> Roberto López López
>
>
> System Developer
> Parallab, Uni Computing
> Høyteknologisenteret, Thormøhlensgate 55
> N-5008 Bergen, Norway
> Tel:(+47) 555 84091
>
> --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Best practices for 1.5 configurable user model and profiles

2013-02-28 Thread Russell Keith-Magee
Hi Doug,

Shawn has hit the "whys" fairly well -- the three arguments he gave are
definitely the top three. Covering authentication via other sources (e.g.,
OAuth, etc) was another use case (although this use case would also be a
candidate for a plugin app)

Taking avatar as an example -- I'd frame the question like this:

 * Could your project function without the concept of an avatar? You might
need to use some other drop-in graphic in place of an avatar instead, but
would the absence of an avatar fundamentally stop other parts of your site
from working? On your site, is the concept of an avatar so tightly bound to
a User that there's no practical way you could put that functionality in a
separate model? Again, without knowing specifics, I can't say for certain,
but generally, I'd say the answer is no - The fact that the default new
user won't have an avatar is proof of this. This means that the avatar is a
good candidate for *not* being on your User model, and being kept in a
separate avatar management app.

 * In practice, does the database overhead for your website mean the join
to the "avatar" table is prohibitively costly? Is this something you can't
overcome by caching the path to the avatar graphic on a per-user basis?
This is something I can't answer canonically without seeing your server
logs, but I'd be willing to wager the answer is "probably not".

Yours,
Russ Magee %-)

On Thu, Feb 28, 2013 at 1:05 AM, Doug  wrote:

> Russ,
>
> Thanks so much for your reply. I guess the confusion is around the
> subjectivity of what is considered "identifying the user". In my case, the
> additional data is not application related, it is project related and would
> be part of a "Profile" that is used throughout the site across many
> applications.
>
> I guess the more specific question would be: should user data be limited
> to data necessary for _authentication_. This makes sense when you take into
> account that the app it is a part of is "auth".
> So when you say "core identifying information", do you mean authentication
> information? In this case, avatar would not fit the description, in much
> the same way that bio or location would not.
>
> Perhaps I am overcomplicating things, but I want to create a solution that
> is as simple as possible without limiting flexibility.
>
> I guess what would help is an idea of what the primary reason was for the
> change to the user model in 1.5. Was it primarily to address the issue of
> an easier way to provide alternative authentication (versus writing a
> separate backend)? Or was it also to make it easier to create the concept
> of a "profile"?
>
> On Saturday, February 23, 2013 11:15:20 PM UTC-5, Russell Keith-Magee
> wrote:
>
>> Hi Doug,
>>
>> Obviously, it's still early days, so "best practice" hasn't really
>> evolved yet. However, based on what I've done with custom user models so
>> far, my advice would be to only put on the User model those things that are
>> part of identifying the User, and maintain a profile for any
>> application-related information that is user specific.
>>
>> So - things like a username, primary contact email address, and an avatar
>> would be reasonable things to have on the User model.
>>
>> Phone number *might* be appropriate for the User model -- depending on
>> whether a phone number is something that is core identifying information
>> for users of you project, or just additional profile information.
>>
>> Things like a biography or current location aren't key concepts for a
>> user -- they're something that can be isolated as part of a profile that is
>> contained in one or many separate user-related applications.
>>
>> In many respects, this is exactly the same story that Django has always
>> maintained -- the difference is that now you have more control over exactly
>> what is considered "core" identifying information.
>>
>> Of course, there are exceptions to every rule -- and the one exception
>> that exists here is performance based. Using profile objects requires the
>> use of a join, and if you're doing a *lot* of profile joins, you might find
>> that denormalizing that join, and putting profile information on the base
>> user object may be worthwhile.
>>
>> However, this should be considered a potential performance enhancement,
>> not architectural advice -- IMHO, most users won't be dealing with enough
>> query volume to be affected by this problem, and should be using profile
>> objects rather than denormalizing.
>>
>> Yours,
>> Russ Magee %-)
>>
>> On Fri, Feb 22, 2013 at 11:10 PM, Doug  wrote:
>>
>>> I am curious how people are handling the new 1.5 user model with regard
>>> to User Profiles. Is it best to add all profile information to a custom
>>> user model? Or keep the user model for authentication information only and
>>> create a one-to-on or foreign key to a profile model (similar to the
>>> pre-1.5 best practice)?
>>>
>>> In my case, users will have an avatar, a bio, a location, and other
>>> profile type inf

error in filling data in dtabase through admin page..

2013-02-28 Thread Avnesh Shakya
hi, i have got one error during adding data in database though admin page, 
actually it was working fine, but i made some attributes optional, now it's 
generating error..
i m adding m models.py ,plz help me..
thanks in advance

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


from django.db import models
from PIL import Image
from lrntkr.managers import CourseManager

class University(models.Model):
	name= models.CharField(max_length=70)
	address = models.CharField(max_length=120,blank=True,null=True)
	country = models.CharField(max_length=30)
	website = models.URLField()
	def __unicode__(self):
		return (self.name)
	
	
class Instructor(models.Model):
	name = models.CharField(max_length=70)
	specilist= models.CharField(max_length=120)
	about= models.CharField(max_length=200,blank=True,null=True)
	email= models.EmailField()
	universities = models.ManyToManyField(University)
	def __unicode__(self):
		return self.name

class Course(models.Model):
	title   = models.CharField(max_length=70)
	stream  = models.CharField(max_length=70)
	universities = models.ManyToManyField(University)
	instruct= models.ManyToManyField(Instructor)
	description = models.CharField(max_length=70,blank=True, null=True)
	start_date  = models.CharField(max_length=30)
	work_load   = models.CharField(max_length=30)
	logo= models.ImageField(upload_to='logos',blank=True,null=True)
	intro   = models.URLField(verify_exists = False, max_length = 225,blank=True,null=True)
	initiative  = models.URLField(verify_exists = False, max_length = 225,blank=True,null=True)
	initiator   = models.CharField(max_length=50,blank=True,null=True) 
	courseinfo  = models.BooleanField(db_index=True,default=True)
	
	objects = CourseManager()
	
	def save(self, size=(200, 200)):
		if not self.id and not self.logo:
			return
		
		super(Course, self).save()
		
		pw = self.logo.width
		ph = self.logo.height
		nw = size[0]
		nh = size[1]
		
		# only do this if the image needs resizing
		if (pw, ph) != (nw, nh):
			filename = str(self.logo.path)
			image = Image.open(filename)
			pr = float(pw) / float(ph)
			nr = float(nw) / float(nh)
			
			if pr > nr:
# photo aspect is wider than destination ratio
tw = int(round(nh * pr))
image = image.resize((tw, nh), Image.ANTIALIAS)
l = int(round(( tw - nw ) / 2.0))
image = image.crop((l, 0, l + nw, nh))
			elif pr < nr:
# photo aspect is taller than destination ratio
th = int(round(nw / pr))
image = image.resize((nw, th), Image.ANTIALIAS)
t = int(round(( th - nh ) / 2.0))
print((0, t, nw, t + nh))
image = image.crop((0, t, nw, t + nh))
			else:
# photo aspect matches the destination ratio
image = image.resize(size, Image.ANTIALIAS)

			image.save(filename)
	def __unicode__(self):
		return self.title
		
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
		
class Student(models.Model):
	name   = models.CharField(max_length=70)
	birth_date = models.DateField(blank=True, null=True)
	email_id   = models.EmailField()
	contact_no = models.IntegerField(blank=True,null=True)
	address= models.CharField(max_length=120,blank=True, null=True)
	gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
	courses= models.ManyToManyField(Course)
	
	def __unicode__(self):
		return self.name
		


error in filling data in database through admin page

2013-02-28 Thread Avnesh Shakya
hi, 
 i have got one error during adding data in database though admin page, 
actually it was working fine, but i made some attributes optional, now it's 
generating error..
i m adding m models.py ,
error--  

" needs to have a value for field "course" before 
this many-to-many relationship can be used.

plz help me..

thanks in advance

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: 1.5 custom user model: Add User with default UserCreationForm results in "no such table: auth_user"

2013-02-28 Thread Russell Keith-Magee
On Thu, Feb 28, 2013 at 5:11 AM, Eric Psalmond  wrote:

> "UserCreationForm
>
> Depends on the 
> User
>  model.
> Must be re-written for any custom user model."
> I swore I RTM'ed :).  Thanks!
>
> I think it really doesn't depend on the User model - my class inherits
> from AbstractUser.  I think with the one modification I made, it works
> fine.  I think just a check in the form to see if AUTH_USER_MODEL is
> defined, and if so use that class instead of direct references to the User
> class would make it work 100% for any class that inherits from AbstractUser.
>

You'd think so, wouldn't you :-)

Internally, it's a little more complicated than that, because of the way
that the currently defined User is determined at runtime. Due to the way
that Python and Django load modules, there's no guarantee that the models
you need will exist at the time the form is loaded, which can lead to some
interesting circular dependencies. This is the major reason why
UserCreationForm and UserChangeForm are bound to the User model
specifically.

The good news is that you can still re-use the form logic in those two
forms -- a form is just a class, so you can subclass them. If you User
model subclasses AbstractUser, all the core fields have the same name and
constraints, so all you need to do is redeclare the Meta portion of the
class definition (to bind your subclass to your actual User model). This
way you get all the logic for password/username checks, and the custom
save() methods, but against your own model and field list.

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.