Re: General question about NOT EXISTS...

2010-12-06 Thread andy
Sorry for the double post. The table should have been A = Blog, B =
blogentry and C = entry

On Dec 7, 1:12 am, andy  wrote:
> Well django has a ISNULL which I guess could be use to get the result
> that you want. I'm a bit new to django and have not done any many-to-
> many relationships as yeah but I'm guessing you could do something
> like this:
>
> Lest say table A = Blog, B = entry and C = blogentry
>
> Blog.objects.filter(entry__isnull=True) If I am correct this should
> return a list of blogs that does not have any entires.
>
> On Dec 7, 12:06 am, Wes Wagner  wrote:
>
> > This is a generic question because I am a newbie and things are not
> > gelling quite 100% on how to write Q statements to get a filter to do
> > everything one wants.
>
> > Let's say you have Table A and Table B and Table C, where Table B has
> > a foreign key to table A and Table C (a manually constructed many to
> > many because it has extra data elements)
>
> > Now I want to build a list of all elements from table A, where not
> > exists a record in Table B that is related to table A and also has a
> > couple values = to something, and related to a particular table C
> > record)
>
> > In SQL this would look like:
>
> > select * from a where not exists (select * from B,C where
> > a.id=b.aforeignkey and c.id=b.cforeignkey and b.filter1=blah and
> > c.filter2=blah)
>
> > How does that look when you are building an object list in the Q( )...
> > style format? Where I am hung up is finding syntax examples of how to
> > do the functional equivalent of a sql where not exists clause.
>
> > Is there a way to do this without using .extra() and using just normal
> > django?
>
> > -Wes Wagner

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



Re: General question about NOT EXISTS...

2010-12-06 Thread andy
Well django has a ISNULL which I guess could be use to get the result
that you want. I'm a bit new to django and have not done any many-to-
many relationships as yeah but I'm guessing you could do something
like this:

Lest say table A = Blog, B = entry and C = blogentry

Blog.objects.filter(entry__isnull=True) If I am correct this should
return a list of blogs that does not have any entires.

On Dec 7, 12:06 am, Wes Wagner  wrote:
> This is a generic question because I am a newbie and things are not
> gelling quite 100% on how to write Q statements to get a filter to do
> everything one wants.
>
> Let's say you have Table A and Table B and Table C, where Table B has
> a foreign key to table A and Table C (a manually constructed many to
> many because it has extra data elements)
>
> Now I want to build a list of all elements from table A, where not
> exists a record in Table B that is related to table A and also has a
> couple values = to something, and related to a particular table C
> record)
>
> In SQL this would look like:
>
> select * from a where not exists (select * from B,C where
> a.id=b.aforeignkey and c.id=b.cforeignkey and b.filter1=blah and
> c.filter2=blah)
>
> How does that look when you are building an object list in the Q( )...
> style format? Where I am hung up is finding syntax examples of how to
> do the functional equivalent of a sql where not exists clause.
>
> Is there a way to do this without using .extra() and using just normal
> django?
>
> -Wes Wagner

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



Re: General question about NOT EXISTS...

2010-12-06 Thread andy
Well django has a ISNULL which I guess could be use to get the result
that you want. I'm a bit new to django and have not done any many-to-
many relationships as yeah but I'm guessing you could do something
like this:

Lest say table A = Blog, B = entry and C = blogentry

Blog.objects.filter(entry__isnull=True) If I am correct this should
return a list of blogs that does not have any entires.

On Dec 7, 12:06 am, Wes Wagner  wrote:
> This is a generic question because I am a newbie and things are not
> gelling quite 100% on how to write Q statements to get a filter to do
> everything one wants.
>
> Let's say you have Table A and Table B and Table C, where Table B has
> a foreign key to table A and Table C (a manually constructed many to
> many because it has extra data elements)
>
> Now I want to build a list of all elements from table A, where not
> exists a record in Table B that is related to table A and also has a
> couple values = to something, and related to a particular table C
> record)
>
> In SQL this would look like:
>
> select * from a where not exists (select * from B,C where
> a.id=b.aforeignkey and c.id=b.cforeignkey and b.filter1=blah and
> c.filter2=blah)
>
> How does that look when you are building an object list in the Q( )...
> style format? Where I am hung up is finding syntax examples of how to
> do the functional equivalent of a sql where not exists clause.
>
> Is there a way to do this without using .extra() and using just normal
> django?
>
> -Wes Wagner

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



admin view

2010-12-06 Thread commonzenpython
hey guys, im trying to get a script to  run, like a view after a user
in the admin interface checks a box and saves the object, is there any
way of accomplishing this without having to rewrite the add_view, and
edit_view ?

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



General question about NOT EXISTS...

2010-12-06 Thread Wes Wagner
This is a generic question because I am a newbie and things are not
gelling quite 100% on how to write Q statements to get a filter to do
everything one wants.

Let's say you have Table A and Table B and Table C, where Table B has
a foreign key to table A and Table C (a manually constructed many to
many because it has extra data elements)

Now I want to build a list of all elements from table A, where not
exists a record in Table B that is related to table A and also has a
couple values = to something, and related to a particular table C
record)

In SQL this would look like:

select * from a where not exists (select * from B,C where
a.id=b.aforeignkey and c.id=b.cforeignkey and b.filter1=blah and
c.filter2=blah)

How does that look when you are building an object list in the Q( )...
style format? Where I am hung up is finding syntax examples of how to
do the functional equivalent of a sql where not exists clause.

Is there a way to do this without using .extra() and using just normal
django?

-Wes Wagner

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



Re: Django based issue tracker

2010-12-06 Thread zodman
django-projector

On Wed, Nov 10, 2010 at 2:05 PM, Toby Champion  wrote:
> I don't know of a Django-based issue tracker that's in active
> development, but I'd suggest you first try using a web-based, hosted
> tool. If your project is simple enough, something like 
> http://www.unfuddle.com/
> might meet your needs. Accounts are free for very small projects, and
> include a SVN or Git repository. Otherwise Trac, which is of course
> used for tracking issues in Dango itself at http://code.djangoproject.com/,
> so at least you know there's knowledge in the community. It's written
> in Python, too, so if you enjoy working in Python even without Django,
> you're onto a winner.
>
> On Nov 10, 12:12 am, Joakim Hove  wrote:
>> Hello,
>>
>> I am setting up a bug/issue tracker - the project is quite small and I
>> do not have complex needs. As I enjoy working with Django I was
>> looking for a Django based solution. Can someone reccomend a Django
>> based issue tracker?
>>
>> In case I fail finding something based on Django I think I will use
>> Trac which seems quite nice.
>>
>> Joakim
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Andres Vargas
www.zodman.com.mx

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



Re: Project management software

2010-12-06 Thread zodman
are you try django-projector ?
http://www.django-projector.org/

On Sat, Dec 4, 2010 at 1:52 PM, tiemonster  wrote:
> Is that specifically for software development? For people looking for
> time tracking, SCRUM, etc, that might be a good option.
>
> I was looking to specifically develop project management software that
> business users can utilize to manage projects not necessarily related
> to software development. I wanted to build something that is way
> easier to use than Microsoft Project, and can be accessed over the
> web.
>
> -Mark
>
>
>
>
> On Dec 3, 11:28 pm, ydjango  wrote:
>>  tryhttp://www.agilewrap.com
>>
>> written in Django. It is commercial tool but Free for open source and
>> non profit. Also free for up to 5 users for commercial orgs.
>>
>> On Dec 3, 1:21 pm, tiemonster  wrote:> I've done the 
>> initial checkin under LGPL license as agreed. Anyone
>> > that is interested in contributing, let me know your Google Code login
>> > and I'll give you commit access to the svn repo. Any further questions
>> > or comments can probably be directed to me personally instead of on-
>> > list. Thanks!
>>
>> >http://code.google.com/p/django-project-manager/
>>
>> > -Mark
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Andres Vargas
www.zodman.com.mx

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



Re: How to save data in the model in the second step of a 2-step form?

2010-12-06 Thread Wayne Smith
>
> Thanks, that's fine, but I was wondering if there was a more scalable
> way. I have more fields than just "description", so it would be nice
> if they could be all saved with one method call, so I don't have to
> maintain this code in case I change the model.
>
>
If you have multiple fields describing your image, and you are concerned
that more fields will be added/removed at a later time and don't want to
fiddle with your Image model fields, then it would probably be prudent to
factor out these fields to their own model, and hold a relationship (1-to-1,
probably) from the image model to the description model.


> > By the way, your overridden save() method looks a bit odd.  It needs to
> call
> > save() on its superclass as well.
>
> But I do:
> models.Model.save(self)
>
> Isn't that what you meant?
>

You're correct in that you call the superclass, I looked over it too
quickly.  However, the way you are doing it won't pass any of the args or
kwargs up to the superclass, and will probably give you problems.  Look here
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methodsto
get an example.


> And how do I get that information provided by the user?
> Something like:
> Image i = ImageUploadDetailsForm.save(commit=False)
> ?
>

You get the info from the user by accessing the values in request.POST,
which is a dictionary-like object with all the POST parameters.  If you are
using a ModelForm, you might be able to get some things "automagically", but
you can always access them in request.POST no matter how the form is set
up.

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



Re: django auth for existing cgi

2010-12-06 Thread Wayne Smith
On Mon, Dec 6, 2010 at 4:42 PM, bc  wrote:

> Is there any simple way to use django authentication/authorization to
> control access to an existing (not django) cgi?
>
> I could use subprocess.Popen to invoke the cgi after checking
> authorization, but the environment needs to be set up to look like a
> cgi call (setting QUERY_STRING, etc.). Is there a better way?
>
>
I don't know if you could do some special trick with an HttpRequest or some
kind of redirect from one view to hit the cgi script with the automatically
created (HttpRequest) data.  I'm guessing the answer is no or more trouble
than it would be worth, but that's just a guess.

I would say you really have two options.

1.  Implement the script in Python, and bring it in under Django.

2.  Craft your own Http Request header with Python's libraries and point it
to the cgi script.


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

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



Re: Generic ForeignKey in Database Queries

2010-12-06 Thread andy
>From the django doc "Due to the way GenericForeignKey is implemented,
you cannot use such fields directly with filters (filter() and
exclude(), for example) via the database API. They aren't normal field
objects."

http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations

On Dec 6, 6:24 pm, Katrina  wrote:
> I have a model set up thusly:
>
> from django.contrib.contenttypes.models import ContentType
> from django.contrib.contenttypes import generic
>
> Item(models.Model):
>     content_type = models.ForeignKey(ContentType)
>     object_id = models.PositiveIntegerField()
>     object = generic.GenericForeignKey()
>
> If I try to perform queries in the format
> Item.objects.filter(object=some-object), I raise a FieldError: "Cannot
> resolve keyword 'object' into field".  But if I have some instance of
> Item and I call item-instance.object, it returns the object correctly.
>
> Is this a behavioral malfunction, or are Generic ForeignKeys not meant
> to be used in database queries?  If they are not, is there any real
> advantage to having one?

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



Generic ForeignKey in Database Queries

2010-12-06 Thread Katrina
I have a model set up thusly:

from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

Item(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
object = generic.GenericForeignKey()

If I try to perform queries in the format
Item.objects.filter(object=some-object), I raise a FieldError: "Cannot
resolve keyword 'object' into field".  But if I have some instance of
Item and I call item-instance.object, it returns the object correctly.

Is this a behavioral malfunction, or are Generic ForeignKeys not meant
to be used in database queries?  If they are not, is there any real
advantage to having one?

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



Re: Error when running python manage.py loaddata datadump.json

2010-12-06 Thread andy
Generally when I get an error similar to that(not necessarily when
using django) It means that I have violated some field that has a
unique constraint. Look in you database and see if you have a
constrain on that table.

On Dec 6, 2:55 pm, jc  wrote:
> I'm migrating my Django database from sqlite to mysql. I've done the
> following with no problems:
> python manage.py dumpdata > datadump.json Changed my settings.py to
> the mysql database.
>
> But when I issue the following command python manage.py loaddata
> datadump.json I get this error:
> IntegrityError: (1062, "Duplicate entry '13-13' for key
> 'from_category_id'")
>
> How do I go go about fixing this issue so that I can run the command
> again and hopefully load my data into my site?
>
> thanks,
> j.

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



django auth for existing cgi

2010-12-06 Thread bc
Is there any simple way to use django authentication/authorization to
control access to an existing (not django) cgi?

I could use subprocess.Popen to invoke the cgi after checking
authorization, but the environment needs to be set up to look like a
cgi call (setting QUERY_STRING, etc.). Is there a better way?

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



Is their much benefit In using a second hidden salt

2010-12-06 Thread andy
So I was having a bit of confusion over the method that django uses to
protect passwords. The issues I had was that It seen unsecured to have
the salt publicly available in the database since anyone who gets hold
of the database would know the salt. After rereading the django book
and doing some additional research I discovered that this method was
particularly targeted at rainbow tables attacks and is indeed view by
many as a better option than a system wide hidden salt.

However I'm a bit curious about the significance of adding a second
salt to the password before it is hashed and then using the regular
per-user salt. Currently my opinion is that their is added benefit
since it make dictionary attacks more challenging and possibly almost
impossibly if the attacker does not know the hidden salt. Django has a
secretKey in the setting file I wondering why this could not have been
used as second salt in the authentication system.

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



Re: Getting started with generic relations

2010-12-06 Thread mack the finger
I did read the docs. The ubiquious 'TaggedItem' example I just
couldn't wrap my head around. I get it now though. For those who find
this looking for a solution:

Just add three fields to your model:

content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
item = generic.GenericForeignKey('content_type', 'object_id')

You can name them anything you want, as long as the names on the first
two lines match the names in the third line's constructor.

Basically the first line stores the type of object, the second line
stores the object's primarykey, and the third line is a helper thats
not even truly required, but makes it much much easier to use. Now you
can just go:

MyModel(item=WhateverModelInstanceYouWant, **other_opts)

and it should all magically work. The 'content_type' and 'object_id'
fields will be handled by the generic relation API.


On Dec 6, 4:34 am, bruno desthuilliers 
wrote:
> On 5 déc, 20:30, mack the finger  wrote:
>
> > I can't quite wrap my brain around how to do generic relations. I have
> > a `Receipt` model which is a receipt of a purchase. One of the fields
> > is `item` which is a foreign key to a product model. I want to be able
> > to not only have products, but other things that the user can buy.
>
> > What do I need to do here to allow me to link to other types? Just
> > change the ForeignKey('Product') to generic.GenericForeignKey()? Is
> > that it?
>
> Actually it's a bit more complicated - but the good news is that it's
> documented:http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generi...
>
> Please read the above doc first, then come back if you have problems ;)

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



Re: Main model name in Admin Site

2010-12-06 Thread Konrad Delong
On 6 December 2010 21:45, robos85  wrote:
> Is there any possibility to name the main model? I don't mean the each
> model class, but main wrapper for all classes in model. Now it takes
> the name from the application name. I want to name it by my own.

You can set verbose_name in your model's "Meta" class. As for the app
name (simple to mistake if your app name is same as model's) - there's
no simple way to customise it right now (possibly coming in Django
1.4). You would need to override the templates.

Konrad

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



Error when running python manage.py loaddata datadump.json

2010-12-06 Thread jc
I'm migrating my Django database from sqlite to mysql. I've done the
following with no problems:
python manage.py dumpdata > datadump.json Changed my settings.py to
the mysql database.

But when I issue the following command python manage.py loaddata
datadump.json I get this error:
IntegrityError: (1062, "Duplicate entry '13-13' for key
'from_category_id'")

How do I go go about fixing this issue so that I can run the command
again and hopefully load my data into my site?

thanks,
j.

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



Re: Authentication

2010-12-06 Thread Mike Hull
Thanks Tom,
Out of interest, is there a good way of testing this. I want to work
on my site until I push it to the server, is there someway I can use
the
development server, but get it to set REMOTE_USER for testing
purposes?

I tried the following:

urls.py:
p = (

 (r'^/?$', studentsite.views.viewIndex),
 (r'view_tutorial_sheet/(\d+)/$',
studentsite.views.viewTutorialSheet),
 (r'view_question/(\d+)/$', studentsite.views.viewQuestion),

 (r'upload_submission/$', studentsite.views.uploadSubmission),
 (r'view_submission_details/(\d+)/$',
studentsite.views.viewSubmissionDetails),

)



def decorateFunction(f):

def newFunc(request, *args,**kwargs):
request.META['REMOTE_USER'] = "mytestuser"
return f(request, *args,**kwargs)
return newFunc

p = tuple ( [ (url,decorateFunction(f)) for (url,f) in p] )


host = socket.gethostname()
if host == 'ubuntu-temp':
p = p + (
(r'^site_media/sphinx/(?P.*)$', 'django.views.static.serve',
{'document_root': '/home/michael/hw/infandango/src/labs/frontend/
infandango-fe/static/sphinx/'}),
(r'^site_media/simplebutcool/(?P.*)$',
'django.views.static.serve', {'document_root': '/home/michael/hw/
infandango/src/labs/frontend/infandango-fe/static/simplebutcool/'}),
)


urlpatterns = patterns('',*p)


in order to try and decorate each function so that I would manually
add the header to the request, but it doesn't seem to be working
If I look at the user object, it always seens to give an
AnnoymousUser.

Any suggestions would be greatly appreciated!

Thanks


Mike


On Dec 6, 4:00 pm, Tom Evans  wrote:
> On Mon, Dec 6, 2010 at 3:10 PM, Mike Hull  wrote:
> > Hi,
> > We are setting up a website using django and Cosign for
> > authentification, but I am not getting my head around django plays
> > withs apache user authentification, so I wonder if someone can shed
> > some light on how the pieces are supposed to fit together!
>
> > As I understand it; when Cosign is set-up, it sets a variable which
> > can be used in django: request.META["REMOTE_USER"]
> > What I dont understand is how does this fit in with the
> > auth.middleware. I read:
> >http://docs.djangoproject.com/en/dev/howto/auth-remote-user/
> > what I understand is that if I enable auth.middleware,
> > then this will set the User variable in the context processor, which I
> > can then use in templates.
> > But how would I access this variable in a python view function, would
> > I do something like:
>
> > user = User.objects.get(id=request.META["REMOTE_USER"])
>
> > to generate particular content for that user?? Or is there a simpler
> > solution?
>
> > Many thanks
>
> > Mike
>
> If you set up authentication as detailed in that article, then the
> current user is available as request.user, just as it is for all other
> auth backends.
>
> Cheers
>
> Tom

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



override django.forms with html5 forms

2010-12-06 Thread Alexandre González
Hi! Is any easy way to use html5 forms instead normal forms?

For example overriding the django.forms importing other package that
inherits all from it, except the widgets.

Thanks!
Álex González

-- 
@agonzalezro 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx

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



Main model name in Admin Site

2010-12-06 Thread robos85
Is there any possibility to name the main model? I don't mean the each
model class, but main wrapper for all classes in model. Now it takes
the name from the application name. I want to name it by my own.

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



Re: Distinguish between None and False/0/[] in a template?

2010-12-06 Thread Łukasz Rekucki
On 6 December 2010 20:31, Christophe Pettus  wrote:
> Pardon if this is a FAQ, but is there a built-in way of distinguishing 
> between None and the other typical false values (False/0/[]) in a template?  
> Something along the lines of:
>
>        {% if var == None %} ... {% endif %}
>

It's best to just try before asking if something works :) There is a
filter variant too:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#default-if-none

-- 
Łukasz Rekucki

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



Distinguish between None and False/0/[] in a template?

2010-12-06 Thread Christophe Pettus
Pardon if this is a FAQ, but is there a built-in way of distinguishing between 
None and the other typical false values (False/0/[]) in a template?  Something 
along the lines of:

{% if var == None %} ... {% endif %}

Thanks!
--
-- Christophe Pettus
   x...@thebuild.com

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



Re: 2 paypal forms in a view with django-paypal

2010-12-06 Thread Alexandre González
I'm using johnboxall django-paypal, I solved this problem creating a view
that only shows the form, and after it load this forms with 3 ajax
petitions.

Anyway, thanks for your help :)

On Tue, Nov 30, 2010 at 14:31, Venkatraman S  wrote:

> 2010/11/30 Alexandre González 
>
>> It always show two forms but with the last one (five_form) but the
>> update() works perfectly.
>>
>
> Try dcramer or johnboxall version of django-paypal - dcramer's is no more
> maintained i guess.
>
> On a different note : were you able to add multiple items to the dict?
> Also, i hear Encrypted form is better than PayPalPaymentsForm.
>
> -V-
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
@agonzalezro 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx

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



Video sitemaps

2010-12-06 Thread didier rano
Hi,

I need to publish a video sitemap (
http://www.google.com/support/webmasters/bin/answer.py?hl=en=80472)
Actually, I'm using sitemap framework. It is very useful, but I don't know
how to manage video sitemaps with it.

Before to go deeper in this module, I'd like to know opinions about others
django developers about how to do it.

Thanks

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



Re: ManytoMany initial values

2010-12-06 Thread Larry
Don't know if you've solved this already, but
This works for me and I think is what you're looking for


views.py
form.fields["groups"].queryset =
Groups.objects.filter(profile=profile)

I only display the groups that are associated with the profile.
My profile is attached to the user via request.user.get_profile()




On Oct 25, 7:50 am, Giancarlo Razzolini  wrote:
> Hi all,
>
>     I've been using django for some time now and I must say that it's my
> favorite framework. But lately I've run into a problem. Let's say I have
> the following models:
>
> class Contact(models.Model):
>         id = models.AutoField(primary_key=True)
>         user = models.ForeignKey(User, editable=False)
>         name = models.CharField(max_length=255, default='', null=True,
> blank=True)
>         groups = models.ManyToManyField('Group', null=True, blank=True)
>
>         class Meta:
>                 unique_together = ("user", "name")
>
>         def __unicode__(self):
>                 return u'%s' % (self.name)
>
> class Group(models.Model):
>         id = models.AutoField(primary_key=True)
>         user = models.ForeignKey(User, editable=False)
>         name = models.CharField(max_length=255, null=False, blank=False)
>
>         class Meta:
>                 unique_together = ("user", "name")
>
>         def __unicode__(self):
>                 return u'%s' % (self.name)
>
>     I'm using ModelForm to create the forms used to insert new instances
> of both these models into my database. But, as the models made clear, I
> want to have the contacts and the groups distinct to each user in
> django. This part is working. Now, when I'm going to add a new contact,
> for example, I want to set theinitialvalue of the field "groups",
> which is theManytoManyfield, to be only the groups belonging to that
> user. I've searched the mail list and saw that I had to pass a list of
> group id's to be theinitialvalue of the field:
>
>         group_ids = []
>         for group in Group.objects.filter(user=request.user):
>                 group_ids.append(group.id)
>
>     And then, create the form:
>
>     form = ContactForm(request.POST, request.FILES,initial={'groups':
> group_ids})
>
>     When I do this, the form will render ok, but, instead of only
> showing the groups belonging to that user, it will still show all the
> groups in the model(belonging to other users too), the only difference
> being that, the groups that belong to the request.user, showing already
> selected, and the other groups(the ones that shouldn't be showing) not
> selected. I don't know if this is possible without having to override
> the queryset that the modelform make. Any ideas?
>
> Thanks in advance,
>
> --
> Giancarlo Razzolinihttp://lock.razzolini.adm.br
> Linux User 172199
> Red Hat Certified Engineer no:804006389722501
> Verify:https://www.redhat.com/certification/rhce/current/
> Moleque Sem Conteudo Numero #002
> OpenBSD 4.5
> Ubuntu 9.04 Jaunty Jackalope
> 4386 2A6F FFD4 4D5F 5842  6EA0 7ABE BBAB 9C0E 6B85

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



Re: How to save data in the model in the second step of a 2-step form?

2010-12-06 Thread Salvatore Iovene
On Dec 6, 6:09 pm, Wayne Smith  wrote:
> > After the second form is done and valid, I would like to save the
> > information that comes to it to Image, in the same row that has the id
> > I was passing.
>
> > How can I do this?
>
> image.description = information user provided
> image.save()

Thanks, that's fine, but I was wondering if there was a more scalable
way. I have more fields than just "description", so it would be nice
if they could be all saved with one method call, so I don't have to
maintain this code in case I change the model.

> By the way, your overridden save() method looks a bit odd.  It needs to call
> save() on its superclass as well.

But I do:
models.Model.save(self)

Isn't that what you meant?

And how do I get that information provided by the user?
Something like:
Image i = ImageUploadDetailsForm.save(commit=False)
?

Thanks.

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



Re: doing validation in admin form

2010-12-06 Thread Wayne Smith
Then yes, in the clean() method of your Galeria form, you could check the
number of fotos present and then raise a ValidationError if it is too many,
along with a custom message for the user.

Is that what you wish to do?

On Mon, Dec 6, 2010 at 5:18 AM, Daniel Carvalho  wrote:

> On 12/06/2010 03:05 AM, Wayne Smith wrote:
> > It's hard to say, because I don't know what kind of "validation" or
> business
> > logic regarding it you are trying to accomplish/employ.
> >
>
>
> suppose I want a validation like this:
>
> the number of fotos in a galeria should be limited to a number, which
> depends on the user that created it (OR, depends on some values that are
> in the galeria object)
>
>
>
> > However, if you are wanting to ensure you validate a foto during a
> gallery
> > save, why not call an overridden fotos.save() from your custom
> > galeria.save()?
> >
>
>

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



Re: Beginner question on admin interface

2010-12-06 Thread Wayne Smith
>
> Okay, honestly I believe it will be easier to go from scratch. However
> I'd still like to ask, since the idea of having an almost-done admin
> interface is very neat.
>
>
>
As the other reply indicates, that is a very tall order for a beginner.  The
admin interface is functional for editing, but not necessarily the
prettiest.  The beauty of the admin interface lies in the heavy lifting it
does for you, and the fact that it is easily extendable--you can override
any of its templates to provide extra functionality and/or your own look and
feel, without having to re-invent the wheel.

I would advise to use it and learn to tweak it.  Once you finish and look
back, I think you will find you are glad you did.


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

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



Re: How to save data in the model in the second step of a 2-step form?

2010-12-06 Thread Wayne Smith
> After the second form is done and valid, I would like to save the
> information that comes to it to Image, in the same row that has the id
> I was passing.
>
> How can I do this?
>
>
>
image.description = information user provided
image.save()

By the way, your overridden save() method looks a bit odd.  It needs to call
save() on its superclass as well.


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

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



Re: Authentication

2010-12-06 Thread Tom Evans
On Mon, Dec 6, 2010 at 3:10 PM, Mike Hull  wrote:
> Hi,
> We are setting up a website using django and Cosign for
> authentification, but I am not getting my head around django plays
> withs apache user authentification, so I wonder if someone can shed
> some light on how the pieces are supposed to fit together!
>
> As I understand it; when Cosign is set-up, it sets a variable which
> can be used in django: request.META["REMOTE_USER"]
> What I dont understand is how does this fit in with the
> auth.middleware. I read:
> http://docs.djangoproject.com/en/dev/howto/auth-remote-user/
> what I understand is that if I enable auth.middleware,
> then this will set the User variable in the context processor, which I
> can then use in templates.
> But how would I access this variable in a python view function, would
> I do something like:
>
> user = User.objects.get(id=request.META["REMOTE_USER"])
>
> to generate particular content for that user?? Or is there a simpler
> solution?
>
> Many thanks
>
> Mike
>
>

If you set up authentication as detailed in that article, then the
current user is available as request.user, just as it is for all other
auth backends.

Cheers

Tom

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



Re: Problem with redirect

2010-12-06 Thread Wayne Smith
On Mon, Dec 6, 2010 at 7:00 AM, Quetzacotl  wrote:

> Hello, i want to make function that wraps all things related to
> comments, so there should be part that gets comments from database and
> part that checks if comment was added. Then i can simply write just
> one line of code in view where i want comments. Problem is that after
> successful comment post, view should make redirect, and as we know to
> redirect you need to return response instance. That one thing doesnt
> let me make wrap function for my comments, because i cant return
> response after post. thought I can make IF statement that checks if
> return value is response instance or not. But this is 4 lines of code
> instead of one, is there any other way?
>
> --
>

I must be missing something; why can't you return a response after a post?

When I run into a problem that doesn't appear to be easily solved, I often
check to make sure that I am not trying to combine separate pieces of logic
that shouldn't be combined.  If you have 2 different things that need to
happen that cannot normally happen together, then maybe they shouldn't be
combined.  Generally speaking, Django discourages the implementation of
business logic in the template.

Just a thought...



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

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



Authentication

2010-12-06 Thread Mike Hull
Hi,
We are setting up a website using django and Cosign for
authentification, but I am not getting my head around django plays
withs apache user authentification, so I wonder if someone can shed
some light on how the pieces are supposed to fit together!

As I understand it; when Cosign is set-up, it sets a variable which
can be used in django: request.META["REMOTE_USER"]
What I dont understand is how does this fit in with the
auth.middleware. I read:
http://docs.djangoproject.com/en/dev/howto/auth-remote-user/
what I understand is that if I enable auth.middleware,
then this will set the User variable in the context processor, which I
can then use in templates.
But how would I access this variable in a python view function, would
I do something like:

user = User.objects.get(id=request.META["REMOTE_USER"])

to generate particular content for that user?? Or is there a simpler
solution?

Many thanks

Mike




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



Re: Django in production on Windows

2010-12-06 Thread ashdesigner
Guys,

By the way. I've got an idea to run a small blog describing my
experience of Python/Django deployment (and study) from scratch on
Windows platform. It could be just notes of what I (personally) do
(and why) that way or another, with anyone commenting on my progress.

What do you say? I just see it as sharing of experience which might be
useful to someone like me, step-by-step.

Anthony

On Dec 6, 3:42 pm, "Sells, Fred"  wrote:
> FWIW we still use mod_python even though it's deprecated.  It's an easy 
> install and we have a low traffic site.
>
> Although I do not do this, I would recommend mod_wsgi and virtualenv based on 
> what others have told me.
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
> Behalf Of ashdesigner
> Sent: Monday, December 06, 2010 2:43 AM
> To: Django users
> Subject: Re: Django in production on Windows
>
> Thanks Fred, we'll try it.
>
> Anthony
>
> On Dec 5, 7:16 pm, "Sells, Fred"  wrote:
> > I don't know about IIS, but use django and windows with Apache.  See
> > "LAMP" for windows or just install pieces which is easy too.
>
> > -Original Message-
> > From: django-users@googlegroups.com
>
> > [mailto:django-us...@googlegroups.com] On Behalf Of ashdesigner
> > Sent: Wednesday, December 01, 2010 6:44 AM
> > To: Django users
> > Subject: Django in production on Windows
>
> > Hello,
>
> > I am absolutely new to Python/Django. Being responsible for a large
> > corporate startup project and having looked through a number of MVC/
> > MVT frameworks I decided to outsource the webproject in Django.
>
> > The only undiscovered issue to us is whether we can launch a heavy
> > loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> > any comment please.
>
> > Anthony
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Django in production on Windows

2010-12-06 Thread ashdesigner
Fred,

Yes, we'll use mod_wsgi, because it's told to be faster and (yes)
mod_python seems to be deprecated. Thank you for sharing your
experience!

Anthony

On Dec 6, 3:42 pm, "Sells, Fred"  wrote:
> FWIW we still use mod_python even though it's deprecated.  It's an easy 
> install and we have a low traffic site.
>
> Although I do not do this, I would recommend mod_wsgi and virtualenv based on 
> what others have told me.
>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
> Behalf Of ashdesigner
> Sent: Monday, December 06, 2010 2:43 AM
> To: Django users
> Subject: Re: Django in production on Windows
>
> Thanks Fred, we'll try it.
>
> Anthony
>
> On Dec 5, 7:16 pm, "Sells, Fred"  wrote:
> > I don't know about IIS, but use django and windows with Apache.  See
> > "LAMP" for windows or just install pieces which is easy too.
>
> > -Original Message-
> > From: django-users@googlegroups.com
>
> > [mailto:django-us...@googlegroups.com] On Behalf Of ashdesigner
> > Sent: Wednesday, December 01, 2010 6:44 AM
> > To: Django users
> > Subject: Django in production on Windows
>
> > Hello,
>
> > I am absolutely new to Python/Django. Being responsible for a large
> > corporate startup project and having looked through a number of MVC/
> > MVT frameworks I decided to outsource the webproject in Django.
>
> > The only undiscovered issue to us is whether we can launch a heavy
> > loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> > any comment please.
>
> > Anthony
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: DJANGO administration

2010-12-06 Thread mongoose
try this out
http://docs.djangoproject.com/en/dev/intro/tutorial02/#customize-the-admin-look-and-feel


On Dec 6, 12:21 pm, x_marine  wrote:
> Hi all,
>
> I have been using Django for a client. The client want the word "
> Django Administration "  to be change to " Amazonia Administration"
>
> Where do I find the html files and how do I change them?
>
> thanks

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



Problem with redirect

2010-12-06 Thread Quetzacotl
Hello, i want to make function that wraps all things related to
comments, so there should be part that gets comments from database and
part that checks if comment was added. Then i can simply write just
one line of code in view where i want comments. Problem is that after
successful comment post, view should make redirect, and as we know to
redirect you need to return response instance. That one thing doesnt
let me make wrap function for my comments, because i cant return
response after post. thought I can make IF statement that checks if
return value is response instance or not. But this is 4 lines of code
instead of one, is there any other way?

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



Re: Django FormWizard

2010-12-06 Thread Muhammed Abad
Managed to figure this out in the end:

def add_edit(request, id=None):
if id:
obj = get_object_or_404(Book, id=id)
return ResidentialListingWizard([ResidentialFormStep1,
ResidentialFormStep2])(request, instance=obj)
else:
return ResidentialListingWizard([ResidentialFormStep1,
ResidentialFormStep2])(request)

Once all my forms have been filled in, I guess the saving of the data
will be handled by my done() method. However, i did notice that in the
multi step forms, the names and id's of elements are named according
to the step index. for example, the "author" field in a normal django
form would have an id of 'id_author', but in the multistep form, if
the field is on the first step, the id is now 'id_0-author'. Can i
still save my data without modifying my field names in my model?

On Dec 6, 12:40 pm, Muhammed Abad  wrote:
> Hi,
>
> Using the Django FormWizard, is it possible to generate a set forms
> that work in an "edit" mode ? i.e. I have already saved some data
> using the multiple step form, now I would like to edit this data.
>
> Any help would be appreciated.
>
> Thanks

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



Re: css templates

2010-12-06 Thread het.oosten
Here you find a page about serving multiple templates on the same site
(and saving the preference in a session):
http://www.packtpub.com/article/multiple-templates-in-django

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



Re: Beginner question on admin interface

2010-12-06 Thread Robbington
Hi Stephan,

Sounds like a nice project, but unless you have a good deal of time
and a great amount of expiernce in programming + a entire development
team to back you up I would have to say that scripting your own
content management system from scratch may be slighty beyond you. If
of course that is what you meant.

If however you meant you were looking for some existing applications
for Django then you may want to look into these:

Self-Registration. Look into Django-registration
http://bitbucket.org/ubernostrum/django-registration/


Tagging: http://code.google.com/p/django-tagging/

Django-Cms: http://www.django-cms.org/ (although I have come across
some compatibilty issues using Django-cms and django-tagging together,
with regards to the Django version)

Good luck

Rob


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



Re: css templates

2010-12-06 Thread Shamail Tayyab
Hi,

   Well here is an approach, you can use the Django's template engine
for generating dynamic CSS as well...

lets assume your templates path is TEMPLATES

Now create a (minimal) file called style.css in your TEMPLATES like
this:

h1 {
   font-size: {{font_size}};
   text-decoration: {{text_decoration}};
}

Now create a view say, servestylesheet, map it like this:
(r'^css/(\d+).css$', servestylesheet)

In your view:
theme1 = {
   'font_size' : "12px",
   'text_decoration": "none",
}

theme2 = {
   'font_size' : "15px",
   'text_decoration": "underline",
}

# optionally use cache decorators here if you want to cache the CSS as
well, to avoid overloading
def servestylesheet ( request, css_code ):
   if css_code == 1:
  renderas = theme1# Load theme from where ever you desire
   else:
  renderas = theme2
   return render_to_response ( "style.css", renderas, "text/css" )


finally in your HTML, link to this stylesheet as:


or in general



This is a one way, I hope community has more and better ways of doing
this..

Thanks

On Dec 6, 5:33 pm, Jonas Geiregat  wrote:
> Hello,
>
> I'm developing a application that has the ability to be viewed with two 
> stylesheets.
> There are some differences between the stylesheets. It's not only a different 
> CSS file that is loaded but some pages also have different HTML output.
> How could something like this be implemented within the django framework ?
>
> Met vriendelijke groeten,
>
> Jonas Geiregat
> jo...@geiregat.org

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



RE: Django in production on Windows

2010-12-06 Thread Sells, Fred
FWIW we still use mod_python even though it's deprecated.  It's an easy install 
and we have a low traffic site.

Although I do not do this, I would recommend mod_wsgi and virtualenv based on 
what others have told me.

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of ashdesigner
Sent: Monday, December 06, 2010 2:43 AM
To: Django users
Subject: Re: Django in production on Windows

Thanks Fred, we'll try it.

Anthony

On Dec 5, 7:16 pm, "Sells, Fred"  wrote:
> I don't know about IIS, but use django and windows with Apache.  See
> "LAMP" for windows or just install pieces which is easy too.
>
> -Original Message-
> From: django-users@googlegroups.com
>
> [mailto:django-us...@googlegroups.com] On Behalf Of ashdesigner
> Sent: Wednesday, December 01, 2010 6:44 AM
> To: Django users
> Subject: Django in production on Windows
>
> Hello,
>
> I am absolutely new to Python/Django. Being responsible for a large
> corporate startup project and having looked through a number of MVC/
> MVT frameworks I decided to outsource the webproject in Django.
>
> The only undiscovered issue to us is whether we can launch a heavy
> loaded website in Django under Windows (IIS) + MSSQL. Would appreciate
> any comment please.
>
> Anthony
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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


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



css templates

2010-12-06 Thread Jonas Geiregat
Hello,

I'm developing a application that has the ability to be viewed with two 
stylesheets.
There are some differences between the stylesheets. It's not only a different 
CSS file that is loaded but some pages also have different HTML output.
How could something like this be implemented within the django framework ?


Met vriendelijke groeten,

Jonas Geiregat
jo...@geiregat.org




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



Django FormWizard

2010-12-06 Thread Muhammed Abad
Hi,

Using the Django FormWizard, is it possible to generate a set forms
that work in an "edit" mode ? i.e. I have already saved some data
using the multiple step form, now I would like to edit this data.

Any help would be appreciated.

Thanks

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



How to save data in the model in the second step of a 2-step form?

2010-12-06 Thread Salvatore Iovene
Hi,
I'm doing a 2-step form, so that in the first step, the user will
upload an image, and in the second step, she will fill in some details
about it.

My problem is that after the second step, the data is not saved in the
model.

Here's some relevant code.

The model:

class Image(models.Model):
uploaded = models.DateTimeField(editable=False)
description = models.TextField()

def save(self):
self.uploaded = datetime.now()
models.Model.save(self)

Two forms, one with an ImageField, and one connected to the Image
model:

class ImageUploadForm(forms.Form):
file = forms.ImageField()

class ImageUploadDetailsForm(forms.ModelForm):
class Meta:
model = Image


The relevant views:

def image_upload_process(request):
"""Process the form"""

form = ImageUploadForm(request.POST, request.FILES)
if not form.is_valid():
return render_to_response("image_upload.html", {"form":form})

file = request.FILES["file"]
s3_filename = str(uuid4()) + os.path.splitext(file.name)[1]
store_image_in_s3(file, s3_filename)

image = Image(filename = s3_filename)
image.save()

return render_to_response("image_upload_phase_2.html",
{"image":image,
 "s3_images_bucket":settings.S3_IMAGES_BUCKET,
 "s3_url":settings.S3_URL,
 "form":ImageUploadDetailsForm(),
},
context_instance=RequestContext(request))

def image_upload_process_details(request):
"""Process the second part of the form"""

form = ImageUploadDetailsForm(request.POST)
image_id = request.POST.get('image_id')
image = Image.objects.get(pk=image_id)

if not form.is_valid():
return render_to_response("image_upload_phase_2.html",
{"image":image,
 "s3_images_bucket":settings.S3_IMAGES_BUCKET,
 "s3_url":settings.S3_URL,
 "form":form,
},
context_instance=RequestContext(request))

return HttpResponseRedirect("/show/" + image_id)


As you can see, in the first of the two views, I take the uploaded
image from the request and save it to Amazon's S3. Then redirect to a
template that shows the second form (ImageUploadDetailsForm), plus an
hidden field with the Image's id.

After the second form is done and valid, I would like to save the
information that comes to it to Image, in the same row that has the id
I was passing.

How can I do this?

Thanks in advance!

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



Beginner question on admin interface

2010-12-06 Thread Scoox
Hi guys,
I hope this has not been asked yet, it's a total beginner question.

After finally getting Django and PyDev set up on my windows machine, I
am now going through the tutorial.

I am planning a kind of black board, where users can post entries
including things such as images.

Now my question is: Does it make sense to use the standard Django
admin here, or is it better to write your own admin?

Things I need are
- Self-Registration with e-mail validation
- Approval process (meaning if a user wants to post sth., I want to
approve it before it gets published)
- Neat Ajax Interface - e.g. the user should be able to upload as many
pictures as he want to, and when he does so each picture should be
showed as thumbnail right in the edit page. In the tutorial this would
mean that the user can not only add 3 choises to a poll, but an
unlimited number of choices.
- Does the admin interface some kind of tagging input? E.g. in some
blog software you can enter a word and it will offer similar tags
while typing.


Okay, honestly I believe it will be easier to go from scratch. However
I'd still like to ask, since the idea of having an almost-done admin
interface is very neat.



Kind Regards
Stephan

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



Re: doing validation in admin form

2010-12-06 Thread Daniel Carvalho
On 12/06/2010 03:05 AM, Wayne Smith wrote:
> It's hard to say, because I don't know what kind of "validation" or business
> logic regarding it you are trying to accomplish/employ.
> 


suppose I want a validation like this:

the number of fotos in a galeria should be limited to a number, which
depends on the user that created it (OR, depends on some values that are
in the galeria object)



> However, if you are wanting to ensure you validate a foto during a gallery
> save, why not call an overridden fotos.save() from your custom
> galeria.save()?
> 



signature.asc
Description: OpenPGP digital signature


Re: DJANGO administration

2010-12-06 Thread Konrad Delong
On 6 December 2010 11:21, x_marine  wrote:
> Hi all,
>
> I have been using Django for a client. The client want the word "
> Django Administration "  to be change to " Amazonia Administration"
>
>
> Where do I find the html files and how do I change them?

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

Konrad

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



DJANGO administration

2010-12-06 Thread x_marine
Hi all,

I have been using Django for a client. The client want the word "
Django Administration "  to be change to " Amazonia Administration"


Where do I find the html files and how do I change them?

thanks

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



Re: Getting started with generic relations

2010-12-06 Thread bruno desthuilliers
On 5 déc, 20:30, mack the finger  wrote:
> I can't quite wrap my brain around how to do generic relations. I have
> a `Receipt` model which is a receipt of a purchase. One of the fields
> is `item` which is a foreign key to a product model. I want to be able
> to not only have products, but other things that the user can buy.
>
> What do I need to do here to allow me to link to other types? Just
> change the ForeignKey('Product') to generic.GenericForeignKey()? Is
> that it?

Actually it's a bit more complicated - but the good news is that it's
documented:
http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#generic-relations

Please read the above doc first, then come back if you have problems ;)

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