How to load fixtures only once in django unit tests?

2009-06-22 Thread Rama Vadakattu

In unit tests i need to load few fixtures  i have done as below

   class TestQuestionBankViews(TestCase):

#load this fixtures
fixtures = ['qbank',]

def setUp(self):
login = self.client.login
(email="m...@gmail.com",password="welcome")


def test_starting_an_exam_view(self):
candidate = Candidate.objects.get(email="m...@gmail.com")
...etc


def test_review_view(self):
self.assertTrue(True)
.

   def test_review_view2(self):
self.assertTrue(True)


Problem:

These fixtures are loading for every test (i.e) before
test_review_view, test_review_view2 etc... as django flushes the
database after every test

How can i prevent that as it is taking lots of time?

Can't i load in setUp and flush them out while exit but not between
every test and still inheriting django.test.TestCase ?

I can do this using unittest.TestCase but i could not able to  access
all the convenient methods like
 assertTemplateUsed , assertTemplateNotUsed , assertFormError etc..

Hope the problem is clear

One more thing i felt is:
a.In django.test.TestCase it would be good if user has the provision
to say whether he want database flush after
every test case or not.

b.Also there should very good line of separation between
initialization of object vs initialization before every method
  at present setUp method trying to do both the things


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



Re: Request aware template loader

2009-06-22 Thread Rama Vadakattu

have you gone through the below url:

http://www.b-list.org/weblog/2007/nov/01/django-tips-template-loading-and-rendering/

On Jun 22, 5:49 pm, z0n3z00t  wrote:
> I have a common site that is used by different clients.  Each client
> wants to be able to custom-brand the site to their liking.
>
> How it works: I provide a default theme for the site, i.e. templates
> and media, that clients can easily export and customise to their
> liking.  All default template files are stored in a templates/default
> directory on the server, and all default media inside a media/default
> directory.
>
> When they've done their customisations, clients use a form to upload
> an archive that contains all the template and media files that they
> want to override.  These uploaded theme archives are extracted using
> this convention:  Each customer's overridden templates and media would
> be extracted to templates/custXXX and media/custXXX.
>
> I quite like the way that the django template loaders are chained
> together in a sequence to find a specific template file - this is
> exactly the way I want my templates to load:  try to find the client's
> custom template inside the client's template folder and, failing that,
> load the default template.
>
> To do this the template loader needs access to the request object to
> determine request.user and work out which company he belongs to.
> (Only the login page is common across all clients, since the client
> can't be established)
>
> The problem is that the request object is not passed to the template
> loaders.  John Boxall posted a possible work-around using middleware
> and threading to store the request object 
> here:http://groups.google.co.za/group/django-users/browse_thread/thread/cb...
>
> What I like about this is that it doesn't touch the framework.  What I
> don't like is the fact that it's such an ugly hack.
>
> Does anyone know of a more elegant solution?  I'd appreciate any ideas
> on how to achieve this without hacking the framework.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Installation error

2009-06-22 Thread 78fxs

Upon further reading I decided that while I do need the developer
tools, that wasn't keeping me from doing this. (still downloading, by
the way.)

I ran the command: sudo python setup.py install

it ran fine, and among the things it told me:
copying build/scripts-2.5/django-admin.py -> /usr/local/bin

then i started python in my root directory, imported django and then
checked the version: 1.0.2

Success!

from here, the startproject command works.

I think I'm good. Hey, thanks for the help. It was good to struggle
through this.

Steve

On Jun 22, 11:48 pm, 78fxs  wrote:
> I decided to start over. Threw out the Python and Django folders, re-
> downloaded Python and read the instructions on installing again. When
> I ran the ./configure command, I got the error that there is no
> acceptable C compiler in the $PATH. I looked around online and the
> problem may be that I don't have the developer tools. I don't see any
> development tools in my applications/installers folder. I am
> downloading it now (massive). (I also learned how to add a directory
> to my path, which was nice, though it didn't help me.)
>
> So once I get that installed, I'll see what happens when i run the
> configure command again. Now, I was able to run python before, so
> perhaps I am wasting some effort. I don't know if that error would
> have prevented me from running it or not.
>
> Either way, I did not use sudo with the setup.py install, so I'll have
> to do that next time.
>
> On Jun 21, 8:02 am, Tino de Bruijn  wrote:
>
> > On 21 jun 2009, at 05:20, 78fxs  wrote:
>
> > > Thanks for your responses. I think I did run setup.py install, but i
> > > can't remember -- there were a few rounds of this. I will use this as
> > > a guide to see what I did incorrectly.
>
> > You have to run this as admin, so using sudo. There are quite a few  
> > ways of setting this up, so you might also want to Google it, and see  
> > how others have done it / what works best for you.
>
> > > Appreciate it,
>
> > > On Jun 20, 10:31 pm, TiNo  wrote:
> > >> On Sat, Jun 20, 2009 at 02:18, 78fxs  wrote:
>
> > >>> All righty...not only am i new to django and python, i am new to  
> > >>> using
> > >>> the terminal on my mac. so this is going to be mickey mouse stuff.
>
> > >>> i have a few things going on:
>
> > >>> 1. i think some of my confusion is knowing where these django and
> > >>> python folders should be. after i install python and django,  
> > >>> should i
> > >>> move the "djanjo-1.0.2-final" and "python 2.6.2" folders to my
> > >>> applications folder?
>
> > >> No, usually Python gets installed in /Library/Python/2.x ... or in
> > >> /Library/Frameworks/Python.framework/2.x.. There is no need to move  
> > >> them
> > >> afterwards.
>
> > >> 2. when i installed django i was told that permission was denied to
>
> > >>> create /usr/local/bin. i think that is creating a problem for me  
> > >>> now.
> > >>> at one point as i tried to troubleshoot the problem below, i  
> > >>> manually
> > >>> created the directories: ~user/usr/local/bin . Now, that's not where
> > >>> my Python or django folders are - they're in the applications  
> > >>> folder.
> > >>> i don't know if that helped or just screwed it up. is usr/local/bin
> > >>> supposed to be in my root user directory?
>
> > >> How did you install django? And what version do you want to use  
> > >> (1.0 or
> > >> trunk?)?
> > >> When you run the python setup.py install command under sudo (so  
> > >> sudo python
> > >> setup.py install), you will be able to create the djangoadmin.py  
> > >> file in
> > >> /usr/local/bin
>
> > >>> 3. when i type the command "django-admin.py startproject mysite" i  
> > >>> get
> > >>> command not found. i believe that is due to django-admin.py not  
> > >>> being
> > >>> on my system path (page 14 of the django book). so, i need to use  
> > >>> this
> > >>> "sudo ln ... " command, right? i found out out where my python site
> > >>> directory is, using this command from Webmonkey:
> > >>> python -c "from distutils.sysconfig import get_python_lib; print
> > >>> get_python_lib()"
>
> > >> This is correct, this is because you didn't have permission to  
> > >> install
> > >> django-admin.py in /usr/local/bin, now it is not installed anywhere.
>
> > >> I get this result: /Library/Python/2.5/site-packages
>
> > >> This is where all your python site-packages can be placed, like  
> > >> django :D.
> > >> They should go there when you run python setup.py install..
>
> > >> I've tried a bunch of ways to do the sudo ln command but i can't get
>
> > >>> it to work. sometimes it says "file already exists" and other times
> > >>> "no such user or directory" or an "illegal option." what is the
> > >>> correct way to enter that command? And do i need to enter my  
> > >>> password
> > >>> for that command, as the Webmonkey tutorial says?
>
> > >>> By the way,
> > >>> when i type 

Re: Django 1.0.2 foreign key display puzzle

2009-06-22 Thread Kenneth Gonsalves

On Tuesday 23 June 2009 09:14:01 adelaide_mike wrote:
> form = MyModelForm(initial={'myforeignkeyfieldname': myvalue})

assuming the foreignkey value exists, then you would have to insert it's id 
into the field myforeignkeyfieldname_id.
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: Django 1.0.2 foreign key display puzzle

2009-06-22 Thread Rama Vadakattu


Usually Foreign keys are displayed as drop down select list where user
can choose one is multiple options.

Foreign keys are usually initialized with list of tuples [(internal
value,display),(interavalue1,displayvalue2)..]

if you want to present just prepare the list of tuples and give it to
the 'myforeignkeyfieldname'


On Jun 23, 8:44 am, adelaide_mike  wrote:
> Having failed to get any takers to my earlier posts on this, I will
> keep it v. short:
>
> How do I preset a foreign key value in a Model Form?
>
> form = MyModelForm(initial={'myforeignkeyfieldname': myvalue})
>
> does not do it.
>
> Surely this can be done?
>
> 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-users@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: Installation error

2009-06-22 Thread 78fxs

I decided to start over. Threw out the Python and Django folders, re-
downloaded Python and read the instructions on installing again. When
I ran the ./configure command, I got the error that there is no
acceptable C compiler in the $PATH. I looked around online and the
problem may be that I don't have the developer tools. I don't see any
development tools in my applications/installers folder. I am
downloading it now (massive). (I also learned how to add a directory
to my path, which was nice, though it didn't help me.)

So once I get that installed, I'll see what happens when i run the
configure command again. Now, I was able to run python before, so
perhaps I am wasting some effort. I don't know if that error would
have prevented me from running it or not.

Either way, I did not use sudo with the setup.py install, so I'll have
to do that next time.


On Jun 21, 8:02 am, Tino de Bruijn  wrote:
> On 21 jun 2009, at 05:20, 78fxs  wrote:
>
> > Thanks for your responses. I think I did run setup.py install, but i
> > can't remember -- there were a few rounds of this. I will use this as
> > a guide to see what I did incorrectly.
>
> You have to run this as admin, so using sudo. There are quite a few  
> ways of setting this up, so you might also want to Google it, and see  
> how others have done it / what works best for you.
>
> > Appreciate it,
>
> > On Jun 20, 10:31 pm, TiNo  wrote:
> >> On Sat, Jun 20, 2009 at 02:18, 78fxs  wrote:
>
> >>> All righty...not only am i new to django and python, i am new to  
> >>> using
> >>> the terminal on my mac. so this is going to be mickey mouse stuff.
>
> >>> i have a few things going on:
>
> >>> 1. i think some of my confusion is knowing where these django and
> >>> python folders should be. after i install python and django,  
> >>> should i
> >>> move the "djanjo-1.0.2-final" and "python 2.6.2" folders to my
> >>> applications folder?
>
> >> No, usually Python gets installed in /Library/Python/2.x ... or in
> >> /Library/Frameworks/Python.framework/2.x.. There is no need to move  
> >> them
> >> afterwards.
>
> >> 2. when i installed django i was told that permission was denied to
>
> >>> create /usr/local/bin. i think that is creating a problem for me  
> >>> now.
> >>> at one point as i tried to troubleshoot the problem below, i  
> >>> manually
> >>> created the directories: ~user/usr/local/bin . Now, that's not where
> >>> my Python or django folders are - they're in the applications  
> >>> folder.
> >>> i don't know if that helped or just screwed it up. is usr/local/bin
> >>> supposed to be in my root user directory?
>
> >> How did you install django? And what version do you want to use  
> >> (1.0 or
> >> trunk?)?
> >> When you run the python setup.py install command under sudo (so  
> >> sudo python
> >> setup.py install), you will be able to create the djangoadmin.py  
> >> file in
> >> /usr/local/bin
>
> >>> 3. when i type the command "django-admin.py startproject mysite" i  
> >>> get
> >>> command not found. i believe that is due to django-admin.py not  
> >>> being
> >>> on my system path (page 14 of the django book). so, i need to use  
> >>> this
> >>> "sudo ln ... " command, right? i found out out where my python site
> >>> directory is, using this command from Webmonkey:
> >>> python -c "from distutils.sysconfig import get_python_lib; print
> >>> get_python_lib()"
>
> >> This is correct, this is because you didn't have permission to  
> >> install
> >> django-admin.py in /usr/local/bin, now it is not installed anywhere.
>
> >> I get this result: /Library/Python/2.5/site-packages
>
> >> This is where all your python site-packages can be placed, like  
> >> django :D.
> >> They should go there when you run python setup.py install..
>
> >> I've tried a bunch of ways to do the sudo ln command but i can't get
>
> >>> it to work. sometimes it says "file already exists" and other times
> >>> "no such user or directory" or an "illegal option." what is the
> >>> correct way to enter that command? And do i need to enter my  
> >>> password
> >>> for that command, as the Webmonkey tutorial says?
>
> >>> By the way,
> >>> when i type echo $PATH i get:
> >>> /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
>
> >>> No idea what that means.
>
> >> It means that you can run any of the 'programs' or commands in  
> >> there without
> >> typing the full path. So if django-admin.py is in one of these  
> >> directories,
> >> you could directly run django-admin.py.
>
> >> You could also do it like this guy does: [1], installing it in some
> >> directory (or checking out from trunk), and then simlinking it into  
> >> your
> >> PYTHONPATH and PATH.
>
> >> ln -s source target        creates a 'symbolic link' (shortcut)  
> >> from the
> >> target 'file' to a real source file or directory.
>
> >> PATH (check with echo $PATH): these are directories where the  
> >> system will
> >> check 

Django 1.0.2 foreign key display puzzle

2009-06-22 Thread adelaide_mike

Having failed to get any takers to my earlier posts on this, I will
keep it v. short:

How do I preset a foreign key value in a Model Form?

form = MyModelForm(initial={'myforeignkeyfieldname': myvalue})

does not do it.

Surely this can be done?

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-users@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 unicode model pickle problem

2009-06-22 Thread Rodrigo Cea

I am having trouble pickling, and then saving to the DB, django models
with Unicode text in them. The site is for Spanish speakers, so we
need our ñs, és and ös.

I implemented an unlimited undo feature for a Django site, using this
PickleField snippet:

http://www.djangosnippets.org/snippets/513/.

I created a model that holds each object's state at a certain
datetime, like so:

from fields import PickledObjectField

class UndoRecord(models.Model):
user = models.ForeignKey(User)
pickle = PickledObjectField()
date = models.DateTimeField(auto_now_add=True)

and then in my views, whenever a user changes something, I save an
UndoRecord like so:

undo = UndoRecord(user=request.user, pickle=obj)
undo.save()

This works fine, except when the object that I am saving has non-ASCII
characters in it, which case I get a lovely:

DjangoUnicodeDecodeError: 'utf8' codec can't decode bytes in position
372-373: invalid data. You passed in "crbml_core.models\nMusico\np1\n
(tRp2\n(dp3\nS'foto'\np4\nccopy_reg\n_reconstructor\np5\n
(cdjango.db.models.fields.files\nImageFieldFile\np6\nc__builtin__
\nobject\np7\nNtRp8\n
(dp9\nS'_committed'\np10\nI01\nsS'_file'\np11\nNsS'name'\np12\nVuploads/
musicos/235470296_54ae5af3e9_o.jpg
\np13\nsS'closed'\np14\nI00\nsbsS'user_id'\np15\nNsS'visible'\np16\nI1\nsS'influencias'\np17\nVFaith
No More\np18\nsS'nombre'\np19\nV\xd1\xed\xfa\xf6\np20\nsS'id'\np21\nL2L
\nsb." ()

I have been trying to fix this using the approach show here:
http://www.mail-archive.com/django-users@googlegroups.com/msg67883.html,
but no such luck.

Unicode errors are my particular achilles' heel, so any help is much
appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Internationalization in django and search engine indexing

2009-06-22 Thread yml

This is the motivation for me to write this piece of middleware :
http://yml-blog.blogspot.com/search/label/Internationalisation
--yml

On Jun 22, 5:52 pm, Olivier  wrote:
> Hello everyone,
>
> I'm currently using django localization on my site to manage both
> english and french. I'm using template tags blocktrans and block but
> both the french & english pages have the same url. I'm wondering if
> the search engines can work with this configuration and index the two
> versions or should I use different url ?
>
> I first tried to find if the question was already solved in a
> different topic but I didn't see it, sorry if I'm wrong.
>l
> Thanks in advance,
>
> Olivier
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need to upload outside of MEDIA_ROOT, but I get SuspiciousOperation error

2009-06-22 Thread patrick

Have you tried creating a symbolic link from within the MEDIA_ROOT to
the directory you want to use?

On Jun 22, 5:04 pm, Nick  wrote:
> Hi,
>
> I need to be able to upload using the admin interface to outside of
> MEDIA_ROOT.  For example, my MEDIA_ROOT is "/home/site.com/media/" but
> I want to upload to "/home/uploads/".  Whenever I try to do this by
> setting an absolute upload path I get a SuspiciousOperation error.
> I'd like to do this so all uploaded files are contained outside of
> SVN's version control.
>
> Is this possible?  I've tried "chown"ing my uploads directory to
> apache:apache but this didn't help.  Any ideas?
>
> Thanks,
> Nick

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



GeoDjango/Maxmind GeoIP on Windows

2009-06-22 Thread Leo Shklovskii

Has anyone gotten the MaxMind GeoIP functionality working on Windows?

I'm having a tough time getting the dll compiled from source and can't
seem to find it anywhere.

--
--Leo



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



Re: Extending Django User model using add_to_class()

2009-06-22 Thread James Bennett

On Mon, Jun 22, 2009 at 5:30 PM, pr wrote:
> Yes, I know what you mean, but It's small project with one programmer.
> I want to know about speed and stability in production mode above
> rules of 'programming-tao' :-)

Well, there's also the fact that:

1. Using a profile means relying on documented, guaranteed-stable
behavior in Django.
2. Using the add_to_class trick means relying on undocumented
internals which have no stability guarantee whatsoever, and which are
subject to change without warning.

Seriously: there's a documented and supported method for storing
additional information related to users. Please take advantage of it.

(and, really I speak from experience regarding other ways to do this;
I have hacked up Django in just about every way possible, and I
remember back when you could do things like outright replace models
with your own definitions, and all of it was a freaking nightmare for
maintainability)


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: Extending Django User model using add_to_class()

2009-06-22 Thread pr

On 22 Cze, 23:14, James Bennett  wrote:
> No, it's a very bad method. Consider what happens if two people want
> to add fields of the same name; trying to stick them in the User model
> will obviously fail and break at least one person's code.
Yes, I know what you mean, but It's small project with one programmer.
I want to know about speed and stability in production mode above
rules of 'programming-tao' :-)

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



Diffents admin sites into the same project

2009-06-22 Thread KrcK

Hi group!

I've a problem with AdminSite. I don't know how can I get 3 admin sites 
differents and if it's posible to do it.

I've a project with two applications, and I want one admin site for each one 
and the other to manage the project and applications (at the project level).

I've been reading the AdminSite objects part into the Chapter The Django Admin 
Site, but I don't understand it very well.

Thanks!

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



Re: Extending Django User model using add_to_class()

2009-06-22 Thread James Bennett

On Mon, Jun 22, 2009 at 4:01 PM, pr wrote:
> Is it a good way to extend Django User model using add_to_class()?
> I have to add only two extra fields to the User model and I think that
> using Profile Model to do this is unnecessary.

No, it's a very bad method. Consider what happens if two people want
to add fields of the same name; trying to stick them in the User model
will obviously fail and break at least one person's code. Using the
standard method of a related profile model keeps them neatly
namespaced.

As a general rule, consider code in other people's applications
(including applications in django.contrib) to be read-only.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Extending Django User model using add_to_class()

2009-06-22 Thread pr

Hi,

Is it a good way to extend Django User model using add_to_class()?
I have to add only two extra fields to the User model and I think that
using Profile Model to do this is unnecessary.

My way:

# Accounts models.py
User.add_to_class('field1', models.CharField(max_length=255))
User.add_to_class('field2', models.CharField(max_length=255))

# Accounts admin.py

class CustomUserAdmin(UserAdmin):
fieldsets = (
(None, {'fields': ('username', 'password')}),
(_('Personal info'), {'fields': ('email',)}),
(_('Permissions'), {'fields': ('is_staff', 'is_active',
'is_superuser', 'user_permissions')}),
(_('Important dates'), {'fields': ('last_login',
'date_joined')}),
(_('Groups'), {'fields': ('groups',)}),
(_('MyExtraFields'), {'fields': ('field1', 'field2')}),
)

admin.site.unregister(User)
admin.site.register(User, CustomUserAdmin)

Finally:
> python manage.py syncdb

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



Re: manytomany field override on save

2009-06-22 Thread hadaraz

Oh yes, I should have known that:

* you must have inlines for this to work.
* the if line should be:   if formset.cleaned_data[0]['yourfield'] ==
yourfield_value:

end of update...


On Jun 22, 1:11 pm, hadaraz  wrote:
> Hi,
>
> I recently needed to override a manytomany field on the save_model()
> method in the admin. However, this is not possible because it will get
> overwritten later with the original values. I asked if this will
> change in the future on the django-developers 
> list:http://groups.google.com/group/django-developers/msg/180d491dc781be49
> Never got an answer...
> Anyway, here is how I solved it. If you look at django/contrib/admin/
> options.py, you will see that the order of saving is this:
>
> 1. save_model()
> 2. save_m2m()
> 3. save_formset()
>
> So, overriding the save_formset() method (I'm using inlines anyway,
> but I think it would work without them as well) enables me change the
> way manytomany behaves. Example use in my MyAdmin.py:
>
>  def save_formset(self, request, form, formset, change):
>         "override the manytomany field"
>         super(MyAdmin, self).save_formset(request, form, formset,
> change)
>         if formset.field == something:   # see note later on
>              # form.instance is your model
>              ...do something with form.instace
>              
>              form.instance.save()
>
> Note: this function will run as many times as the inline forms you
> have, so make sure it only happens once, maybe using an if statement
> to check something on your formset, as done above.
>
> hope it helps someone,
> hadaraz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom filter on join

2009-06-22 Thread Alex Gaynor
On Mon, Jun 22, 2009 at 3:36 PM, nevvkid  wrote:

>
> Hello together,
> i wonder if it's possible to add a custom filter to a join "ON". E.g.
> a query:
>
> SELECT * FROM `table` INNER JOIN `table_attribute` ON (`table`.`id` =
> `table_attribute`.`lamp_id` AND foo=bar);
>
> Please have a look at "foo=bar".
>
> There is a method "filter" for django models, but that's not what i
> need... :)
>
> Any hints?
>
> Thanks and best regards,
> Johannes
>
> >
>
No, currently there is no way to add extra join conditions (this will likely
be addressed in some way during the 1.2 timeine since it is needed for this
ticket: http://code.djangoproject.com/ticket/10870 to be solved).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



custom filter on join

2009-06-22 Thread nevvkid

Hello together,
i wonder if it's possible to add a custom filter to a join "ON". E.g.
a query:

SELECT * FROM `table` INNER JOIN `table_attribute` ON (`table`.`id` =
`table_attribute`.`lamp_id` AND foo=bar);

Please have a look at "foo=bar".

There is a method "filter" for django models, but that's not what i
need... :)

Any hints?

Thanks and best regards,
Johannes

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



Re: Gettext needs iconv.dll but I only have libiconv2.dll

2009-06-22 Thread Joshua Russo

On Jun 20, 3:35 pm, Ramiro Morales  wrote:
> On Fri, Jun 19, 2009 at 5:15 PM, Joshua Russo wrote:
>
> > When I installed Libiconv (1.9.2)  and gettext (0.13) on my XP Pro
> > machine and tried to run makemessages it initially gave me an error
> > message saying that it could not find iconv.dll. I went to the install
> > directory and I had a libiconv2.dll but no iconv.dll. I tried copying
> > and renaming the file and it seemed to work. Is this common or is
> > there something that I did wrong in the install process?
>
> > I used the exe installer for Libiconv because the zip download was not
> > working from SourceForge. I wouldn't image that that would make any
> > difference, but I thought I'd mention it anyway.
>
> I would recommend going straight to use a version of gettext tools win32
> binaries equal or greater to 0.15 (currently 0.17 is available) instead.
>
> For this, follow the modified instructions proposed by this
> documentation patch attached to ticket  #10741:
>
> http://code.djangoproject.com/attachment/ticket/10741/10741-updated-w...
>
> If you decide to do so, please post back your experiences with
> the new instructions. This will help us to decide if offering
> these updated instructions would be a documentation change
> worth doing.
>
> Regards,
>
> --
> Ramiro Moraleshttp://rmorales.net

One thing you may want to add to the documentation is adding the bin
directory to the system path. I did it out of reflex and so I'm not
sure if it's needed our not but it seems to make sense.

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



Re: ANDing together results from ManyToMany Field not working

2009-06-22 Thread Alex Gaynor
On Mon, Jun 22, 2009 at 3:04 PM, IanR  wrote:

>
> I have a model with a ManyToManyField.  I want to return all the
> instances where this M2M field has specific instances of the table
> that the M2M field points at.
>
> For example.  Model.objects.filter(m2mfield__id=1,m2mfield__id=2), so
> in theory this would return results in which the objects with primary
> id=1 and primary id=2 were added to the models m2m field.  However
> this query always returns 0 results.  (Looking at the raw SQL, it will
> never turn any results because its looking for an impossible result, a
> number with 2 values)
>
> I noticed that there is an "IN" function, Model.objects.filter
> (m2mfield__in=[1,2]).  However this returns instances when object 1 OR
> 2 has been added.  I want only instances where object 1 AND 2 have
> been added.
>
> Any ideas?
> >
>
Your problem is that when you do 2 filters on a multi-value relationship in
a single filter() they operate on the same obj, but if you split them into
seperate calls to filter() it will do just what you want:

Model.objects.filter(related_value__id=1).filter(related_value__id=2)

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



ANDing together results from ManyToMany Field not working

2009-06-22 Thread IanR

I have a model with a ManyToManyField.  I want to return all the
instances where this M2M field has specific instances of the table
that the M2M field points at.

For example.  Model.objects.filter(m2mfield__id=1,m2mfield__id=2), so
in theory this would return results in which the objects with primary
id=1 and primary id=2 were added to the models m2m field.  However
this query always returns 0 results.  (Looking at the raw SQL, it will
never turn any results because its looking for an impossible result, a
number with 2 values)

I noticed that there is an "IN" function, Model.objects.filter
(m2mfield__in=[1,2]).  However this returns instances when object 1 OR
2 has been added.  I want only instances where object 1 AND 2 have
been added.

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



Need to upload outside of MEDIA_ROOT, but I get SuspiciousOperation error

2009-06-22 Thread Nick

Hi,

I need to be able to upload using the admin interface to outside of
MEDIA_ROOT.  For example, my MEDIA_ROOT is "/home/site.com/media/" but
I want to upload to "/home/uploads/".  Whenever I try to do this by
setting an absolute upload path I get a SuspiciousOperation error.
I'd like to do this so all uploaded files are contained outside of
SVN's version control.

Is this possible?  I've tried "chown"ing my uploads directory to
apache:apache but this didn't help.  Any ideas?

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



Re: Gettext needs iconv.dll but I only have libiconv2.dll

2009-06-22 Thread Joshua Russo

On Jun 20, 3:35 pm, Ramiro Morales  wrote:
> On Fri, Jun 19, 2009 at 5:15 PM, Joshua Russo wrote:
>
> > When I installed Libiconv (1.9.2)  and gettext (0.13) on my XP Pro
> > machine and tried to run makemessages it initially gave me an error
> > message saying that it could not find iconv.dll. I went to the install
> > directory and I had a libiconv2.dll but no iconv.dll. I tried copying
> > and renaming the file and it seemed to work. Is this common or is
> > there something that I did wrong in the install process?
>
> > I used the exe installer for Libiconv because the zip download was not
> > working from SourceForge. I wouldn't image that that would make any
> > difference, but I thought I'd mention it anyway.
>
> I would recommend going straight to use a version of gettext tools win32
> binaries equal or greater to 0.15 (currently 0.17 is available) instead.
>
> For this, follow the modified instructions proposed by this
> documentation patch attached to ticket  #10741:
>
> http://code.djangoproject.com/attachment/ticket/10741/10741-updated-w...
>
> If you decide to do so, please post back your experiences with
> the new instructions. This will help us to decide if offering
> these updated instructions would be a documentation change
> worth doing.
>
> Regards,
>
> --
> Ramiro Moraleshttp://rmorales.net

That works perfectly. Thanks!

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



Re: QuerySet question, getting latest 3 objects filtered by a key.

2009-06-22 Thread Alex Gaynor
On Mon, Jun 22, 2009 at 1:58 PM, Sean Brant  wrote:

>
> This is best explained with an example.
>
> i have a model for Stats
>
> class Stat(models.Model):
>key = models.CharField(max_length=50)
>value = models.TextField()
>pub_date = models.DateTimeField()
>
> so if i create a few stat objects lets say these.
>
> stat1 = Stat(key='total_books_sold', value=100,
> pub_date=datetime.datetime.now())
> stat2 = Stat(key='total_books_returned', value=10,
> pub_date=datetime.datetime.now())
> stat3 = Stat(key='avg_foos', value=2.6,  pub_date=datetime.datetime.now
> ())
>
> i would like to be able to one query and get the latest stat per key
> so the query should only return. Even if we insert stats every hour.
> It should only return 2 (the latest unique for key).
>
> [, ,  avg_foos>]
>
> I hope that makes sense. I'll do multiple queries if need be.
>
> >
>
It sounds like all you're trying to do is order by the primary key and then
do a limit, so it would be:

Stat.objects.order_by('-id')[:3]

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



QuerySet question, getting latest 3 objects filtered by a key.

2009-06-22 Thread Sean Brant

This is best explained with an example.

i have a model for Stats

class Stat(models.Model):
key = models.CharField(max_length=50)
value = models.TextField()
pub_date = models.DateTimeField()

so if i create a few stat objects lets say these.

stat1 = Stat(key='total_books_sold', value=100,
pub_date=datetime.datetime.now())
stat2 = Stat(key='total_books_returned', value=10,
pub_date=datetime.datetime.now())
stat3 = Stat(key='avg_foos', value=2.6,  pub_date=datetime.datetime.now
())

i would like to be able to one query and get the latest stat per key
so the query should only return. Even if we insert stats every hour.
It should only return 2 (the latest unique for key).

[, , ]

I hope that makes sense. I'll do multiple queries if need be.

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



How to use Sum function with expression

2009-06-22 Thread pr

Hi,

I want to get total price (quantity*price) in this example for objest
list (not one) of A class

class A(models.Model)
  name = models.CharField(max_length=255)

class B(models.Model)
  quantity = models.PositiveIntegerField()
  price = models.DecimalField(max_digits=10, decimal_places=2)
  a = models.ForeignKey(A)

I try:
A.objects.all().select_related().annotate(my_sum=Sum
('b__price*b__quantity'))
but it doesn't work...

Please help.

Thank You,
regards.

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



How to use Sum function with expression

2009-06-22 Thread pr

Hi,

I want to get total price (quantity*price) in this example for objest
list (not one) of A class

class A(models.Model)
  name = models.CharField(max_length=255)

class B(models.Model)
  quantity = models.PositiveIntegerField()
  price = models.DecimalField(max_digits=10, decimal_places=2)
  a = models.ForeignKey(A)

I try:
A.objects.all().select_related().annotate(my_sum=Sum
('b__price*b__quantity'))
but it doesn't work...

Please help.

Thank You,
regards.

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



Re: Empty [] using objects.all() on legacy database

2009-06-22 Thread Erik Vorhes

On Mon, Jun 22, 2009 at 12:52 PM, Greg Corey wrote:
> Karen, the double % ( i.e. 'discount%%') worked. Is this a big enough bug
> that it should be reported? I'm not sure what is a bug and what is just my
> ignorance. Thank you sooo much for the help.

The first % escapes the second % sign, and thus allows for the actual
symbol to display. This is because Python uses % to include variables,
etc., into a string. So it's not a bug at all.

Erik Vorhes

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



Re: Question IMAGE in Django

2009-06-22 Thread Mike Ramirez
On Monday 22 June 2009 10:27:22 am Vlad(L) wrote:
> Mike, excuse that I occupy your time.
>
> All has made also, but is not present Image.
> I will write more in detail. When I instal, for example,  "{{MEDIA_URL}} {{art.image}}" width=200;/> image it is not displayed
> on html page, but the place under a figure and together with a red
> dagger in a corner is displayed. If here it is possible to load a page-
> screenshot - I would send.

First verify that the generated url is correct, that django is producing the 
right url with the context.  Then it would now be a problem of the image not 
being were you expect it or a misconfiguration of your urls.py.  I would 
suspect the latter first, so you need to check that.  For this, depending on 
your setup, you'll want to look at setting up django serve static files[1]. 
If you're using apache, you should follow the mod_python instructions [2]. 
For a seperate media server (url points to another domain such as 
media.yourdomain.com), then you should have your MEDIA_ROOT pointed to that 
domains document root.  

If this doesn't help and you are serving your media correctly, then you'll 
want to check your paths and make sure the actual file exists on the file 
system, where it should be.  

If all this is correct and you can view the image by itself in your browser, 
then follow the path of the earlier suggestions.

Mike

[1] 
http://docs.djangoproject.com/en/dev/howto/static-files/#howto-static-files
[2] http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1
-- 
Is it NOUVELLE CUISINE when 3 olives are struggling with a scallop in a
plate of SAUCE MORNAY?


signature.asc
Description: This is a digitally signed message part.


Re: Empty [] using objects.all() on legacy database

2009-06-22 Thread Greg Corey
Karen, the double % ( i.e. 'discount%%') worked. Is this a big enough bug
that it should be reported? I'm not sure what is a bug and what is just my
ignorance. Thank you sooo much for the help.

Greg

On Fri, Jun 19, 2009 at 8:09 PM, Greg Corey  wrote:

> I will try that tomorrow and let you know.
>
> The DB is an old Microsoft Access database that was then migrated to MySQL.
> It was designed by a definite novice so it has quirks, but it still pumps
> along. It is a DB of testing results for our small laboratory.
>
> Greg
>
>
> On Fri, Jun 19, 2009 at 8:00 PM, Karen Tracey  wrote:
>
>> On Fri, Jun 19, 2009 at 4:41 PM, geraldcor  wrote:
>>
>>>
>>> Ok, so I feel a bit silly, but it was because I had a column name in
>>> my db called Discount% and I am assuming the % is screwing it up.
>>>
>>> Now the question becomes how do I escape the % or do I have to rename
>>> my db column (please god not the latter as that would entail a whole
>>> mess of rewriting stuff). I already tried some unicode stuff but I'm
>>> fairly untrained in that area. Any ideas?
>>>
>>
>> Interesting.  Try doubling the % when you specify it in db_column.  I
>> rather think you shouldn't need to do that, though, so this may be a bug in
>> Django.  BTW, what DB?
>>
>> Karen
>>
>> >>
>>
>

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



Transaction scope in multiple functions

2009-06-22 Thread Antonios Anastasiadis

Hi.

I want group many functions in a single transaction. Let's say that I
have a function that calls other functions that manipulate some
database objects. If I catch an exception in the first function, I
want to rollback all changes made by this function as well as the
changes made by the called functions to the database.

Is this achieved by simply decorating the first function with
@transaction.commit_manually and then rolling back the transaction
when an exception is handled? Or is there another way to achieve the
behavior I want?

Thanks,
Antonios.

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



Re: Question IMAGE in Django

2009-06-22 Thread Vlad(L)

Mike, excuse that I occupy your time.

All has made also, but is not present Image.
I will write more in detail. When I instal, for example,  image it is not displayed
on html page, but the place under a figure and together with a red
dagger in a corner is displayed. If here it is possible to load a page-
screenshot - I would send.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to use email instead of username for user authentication?

2009-06-22 Thread bvemu

Hi

Further to the above discussion,
  I did implement the code and it worked for me for the authentication
while using the email id as the username
(username=emailid ; valid_user = authenticate (username=username,
password=password  )

# django-admin.py --version
1.1 beta 1 SVN-10957

1.) The problem is in the admin interface "@" is not accepted as
username while I can populate the same from the view.py
Is this an expected behaviour or should I raise a ticket ( if at all
it doesnt exists )

2.) Do we have a configuration file or so where we can define these
constraints like max_length of user name, accepted characters set  in
the user name and others.
I can very well change the code in django-trunk of my web server,  but
I dont want to do that since I want to avoid the overhead of re-doing
the svn tasks

Thanks
Vemu


On Apr 13, 11:22 am, Praveen  wrote:
> You please check the satchmo package there they are using email as
> username in satchmo-registration using
> user=generate_id(email,firstname)
>
> On Apr 13, 9:44 am, pkenjora  wrote:
>
> > Malcolm,  <- Remembered the 'l' this time!
>
> > To keep things simple and avoid fragmenting this discussion into a
> > million different dead end tit for tats , I'll try to reign in the
> > main points.
>
> > 1. The default authentication method in Django should have no inherent
> > restrictions.  Such as blocking '@' in the username.  This leaves the
> > default framework open and free of workarounds.  This approach would
> > not preclude any project specific requirements.
>
> > 2. Any authentication method having restrictions should be an opt in
> > method.  The current method is a restrictive authentication method,
> > one that does not allow email, and should be made optional.
>
> > 3. When you boil down the hundreds of specific use cases out there you
> > still end up with the above two points.  In which case I would make
> > the argument that if you need to block emails as user names then it is
> > you who should write a new authentication handler.  In your own words,
> > the framework allows this and its only a few lines of code.
>
> > Now for the dead end tit for tat... this is really project philosophy
> > not framework philosophy... hence I feel like it is circular
> > discussion that distracts from the main point...
>
> > Authenticating by email does not require me to check my email every
> > time I log in.  So if my email is no longer accessible (left my job) I
> > can simply log in and change it to a new one.  If changing the
> > username requires checking my email then I will have the same problem
> > if I use email as my username or not.
>
> > You yourself identify the username as mainly an authentication
> > mechanism not necessarily a display value.  Thats all the more reason
> > to have a robust restriction free out of the box implementation of
> > authentication.
>
> > Thanks for reading the feedback, I still fail to see how you can
> > include project specific requirements in a framework? The
> > implementation you are advocating is a subset of the general
> > implementation I would like to see bundled out of the box.  Why not
> > move it into an optional module?
>
> > -Paul
>
> > On Apr 11, 4:13 pm, Malcolm Tredinnick 
> > wrote:
>
> > > On Sat, 2009-04-11 at 07:52 -0700, pkenjora wrote:
> > > > Malcom,
>
> > > Well, I'm not "Malcom" (sic), but I'll reply anyway.
>
> > > >    Google, FaceBook, and LinkedIn have been using email authentication
> > > > for how long now?  With the default constraints you've put on Django a
> > > > developer would have to "work around" the out of the box code to make
> > > > the project behave like the big 3 names on the web.
>
> > > There's some assumption there that what they're doing is a good idea.
> > > Their systems have the usability problems I've mentioned. It's also not
> > > clear their authentication methods are the best around. In any case, as
> > > I note below (and have written elsewhere), you're simply not restricted
> > > from using this system and can do so without patching Django, if that's
> > > the way you want to go. There's no restriction in place here!
>
> > > The combined size of forums and social networking sites not pretending
> > > that my "handle" is an email address is, I'll wager, larger than
> > > Facebook or LinkedIn, certainly. Which has precisely the same small
> > > weight as your examples. The point being that there are valid use-cases
> > > in both directions and you'll notice that that's never been disputed.
>
> > > [...]
>
> > > >   As far as your reasons go, I'm fairly sure its just as easy to
> > > > change the email as it is the username,
>
> > > I'm sorry you feel that way. It's patently false. The username is only
> > > used on the site you are creating an account for. Your email address has
> > > much wider usage and creating a new one isn't always possible or
> > > desirable (signing up to 

Re: Question IMAGE in Django

2009-06-22 Thread Mike Ramirez
On Monday 22 June 2009 09:14:41 am Vlad(L) wrote:
> art.html
>
> {% for art in art %}
> {{ art.title }}
> {{art.anonce }}
>  
>
> {% endfor %}
>
>

  

This will add the media url that you set for MEDIA_URL in settings.py (as long 
as the context processor for media is also set) 

an example of mine:

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n", 
"django.core.context_processors.media",
}


As long as the url generated points to the image, this should work.

Mike


-- 
Ever get the feeling that the world's on tape and one of the reels is missing?
-- Rich Little


signature.asc
Description: This is a digitally signed message part.


Re: djangoplugables.com is down ?

2009-06-22 Thread Andy McKay

Fortunately there other sites that offer a list of plugins, for  
example: http://djangozen.com/plugins and http://djapp.org. The former  
has every plugin from djangoplugables on it.

On 22-Jun-09, at 8:25 AM, Dunsun wrote:

>
> Hi,
>
> I am not able to access djangoplugables.com.
> It has been down for 2 days.
>
>
> >


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



Internationalization in django and search engine indexing

2009-06-22 Thread Olivier

Hello everyone,

I'm currently using django localization on my site to manage both
english and french. I'm using template tags blocktrans and block but
both the french & english pages have the same url. I'm wondering if
the search engines can work with this configuration and index the two
versions or should I use different url ?

I first tried to find if the question was already solved in a
different topic but I didn't see it, sorry if I'm wrong.

Thanks in advance,

Olivier

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



djangoplugables.com is down ?

2009-06-22 Thread Dunsun

Hi,

I am not able to access djangoplugables.com.
It has been down for 2 days.


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



Re: Question IMAGE in Django

2009-06-22 Thread Vlad(L)

Ok!

views.py

from booksite.books.models import Article
from django.template import RequestContext

def art(request):
art = Article.objects.all()
return render_to_response('art.html', {'art': art},
context_instance=RequestContext(request))


art.html

{% for art in art %}
{{ art.title }}
{{art.anonce }}
 

{% endfor %}



I have made by your example, but all the same image is not displayed
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question IMAGE in Django

2009-06-22 Thread Mike Ramirez
On Monday 22 June 2009 08:06:25 am Vlad(L) wrote:
> Mike, I work on Django 1.0.2 - in this version in settings.py is not
> mentioned at all about Media context processor and RequestContext. To
> me they need to be added in addition most???

It's not mentioned in the settings.py file, but that's why django has great 
documentation available for it.  See the link I posted before on how to use 
the context processors.  If you scroll up a little bit, the same page will 
show you how to use the RequestContext class to your benefit.

In my case I use the render_to_response shortcut in my views and pass the 
context_instance variable set as such: 

context_instance=RequestContext(request)

Full use is 

sample from views.py

from sample.models import News

from django.template import RequestContext

def index(request):
qs = News.objects.all()[:5]
return render_to_response('index.html', 
   {'items': qs},
   context_instance=RequestContext(request)
)

Doing so, django will apply the context processors to your request object, 
adding the contexts for use in your views.

I'm going to make a small suggestion, while the books are a great resource, 
they should be used in addition to the actual documentation available, not 
instead of.  

Mike.

-- 
A sense of humor keen enough to show a man his own absurdities will keep
him from the commission of all sins, or nearly all, save those that are
worth committing.
-- Samuel Butler


signature.asc
Description: This is a digitally signed message part.


Re: Feedbacks and recommendations about test coverage tools

2009-06-22 Thread Michelschr

Hi,

It's easy to receive test coverage information from Django tests. (See
below if you search for a solution...)

But is it possible to receive the same kind of coverage information
from test tools like Windmill (or Selenium)?

I believe, it's probably difficult because these tools execute against
a server which is not in the thread covered by the testing process...

Could someone give me light?

Thanks in advance,

Michel
__
Below, you have my solution for normal test coverage:
1) You should install the very last version of coverage.py (see the
reference in the previous mails-It includes colouring feature now...)
2) You should change your test runner in your setting.py:
TEST_RUNNER = 'cov_runner.run_tests'
COVERAGE_MODULES =
('general.views','general.utilities','goals.views','goals.models') #
adapt to your stuff here...
3) Here is the content of my test runner (you can adapt to your
configuration)
# -*- coding: utf-8 -*-
import os

from django.db.models import get_app
from django.conf import settings

import coverage

def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=
[]):
"""
Run the unit tests for all the test labels in the provided list.
Labels must be of the form:
 - app.TestClass.test_method
Run a single specific test method
 - app.TestClass
Run all the test methods in a given class
 - app
Search for doctests and unittests in the named application.

When looking for tests, the test runner will look in the models
and
tests modules for the application.

A list of 'extra' tests may also be provided; these tests
will be added to the test suite.

If the settings file has an entry for COVERAGE_MODULES or
test_labels is true it will prints the
coverage report for modules/apps

Returns number of tests that failed.
"""
do_coverage = hasattr(settings, 'COVERAGE_MODULES') or bool
(test_labels)
if do_coverage:
#coverage.erase() # remove from old version
cov = coverage.coverage()
cov.start()

from django.test import simple

#
os.environ['SERVER_NAME'] = 'localhost'
#

retval = simple.run_tests(test_labels, verbosity, interactive,
extra_tests)

if do_coverage:
cov.stop()
print
'--'

# try to import all modules for the coverage report.
modules = []
if getattr(settings, 'COVERAGE_MODULES', None):
modules = [__import__(module, {}, {}, ['']) for module in
settings.COVERAGE_MODULES]

elif test_labels:
modules = []
for label in test_labels:
pkg = _get_app_package(label)
modules.extend(_package_modules(*pkg))

cov.html_report(modules, directory='../logs/covhtml')
cov.report(modules) # , show_missing=1

return retval

def _get_app_package(label):
"""Get the package of an imported module"""
imp, app = [], get_app(label)
path = os.path.dirname(app.__file__)
path_list = path.split(os.sep)
path_list.reverse()
for p in path_list:
imp.insert(0, p)
try:
pkg = __import__('.'.join(imp), {}, {}, [''])
return pkg, '.'.join(imp)
except ImportError:
continue

def _package_modules(pkg, impstr):
"""Get all python modules in pkg including subpackages
impstr represents the string to import pkg
"""
modules = []
path = pkg.__path__[0]
for f in os.listdir(path):
if f.startswith('.'):
continue
if os.path.isfile(path + os.sep + f):
name, ext = os.path.splitext(f)
if ext != '.py':
continue
#python module
modules.append(__import__(impstr + '.' + name, {}, {},
['']))
elif os.path.isdir(path + os.sep + f):
#subpackage
imp = impstr+ '.' + f
try:
spkg = __import__(imp, {}, {}, [''])
modules.extend(_package_modules(spkg, imp))
except ImportError:
pass
return modules

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



Re: admin access in https redirect in http

2009-06-22 Thread hiphoox

Thank you guys!

Graham,

I tried the conf you described and it is working great :)
I'm also found this thread where you also participated and was very
useful:
http://markmail.org/message/62cb2sdj54yey7qz#query:wsgi.url_scheme+page:1+mid:l72acuzuldfpmbdw+state:results

Kenneth,

thanks for the link, I'm going to evaluate some of those hosting
services.

Regards,

Norberto Ortigoza

On Jun 21, 10:11 pm, Kenneth Gonsalves  wrote:
> On Monday 22 June 2009 07:32:41 hiphoox wrote:
>
> > Could you recommend me any VPS?
> > I still have the option to move to another one.
>
> look at djangofriendly.com
> --
> regards
> kghttp://lawgon.livejournal.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Question IMAGE in Django

2009-06-22 Thread Vlad(L)

Mike, I work on Django 1.0.2 - in this version in settings.py is not
mentioned at all about Media context processor and RequestContext. To
me they need to be added in addition most???
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Makemessages not finding strings in my templates?

2009-06-22 Thread Joshua Russo

On Jun 19, 7:08 pm, Joshua Russo  wrote:
> I'm trying to use the makemessages command to create .po files and I'm
> running into a problem scanning .html files. I'm running XP Pro and
> using libiconv (1.9.2) and gettext (0.13).
>
> None of the {% trans 'text' %} entries are being picked up in the
> scan. I'm loading the I18n library in all of my templates, though I'm
> not sure it matters for gettext. The command I'm using is:
>
> manage.py makemessages -l pt -e=html,py
>
> It's picking up the strings in the code but not the templates. Oh ya,
> and the template directory is within the directory structure from
> where I'm running makesmessages.

For whatever reason, it seems that the -e option I used actually broke
makemessages. If you simply leave off the -e option everything works
fine and it searches both code files and templates.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to run just ONE test?

2009-06-22 Thread patrickk

another note: it doesn´t matter if I restrict the tests to "myapp" or
any other app (e.g. "tagging" or "sorl-thumbnail") I´ve installed.
with every test, all tables are created/removed.



On 22 Jun., 14:50, patrickk  wrote:
> unfortunately, I´m still stuck with it ...
>
> here´s my tests.py:
>
> import unittest, os
>
> class BaseTest(unittest.TestCase):
>     def setUp(self):
>         pass
>
>     def tearDown(self):
>         pass
>
>     def test_fileobject(self):
>         pass
>
> even with this stripped-down version, _all_ tests are performed.
> btw, models.py is empty (I don´t need that file for my app).
>
> thanks,
> patrick
>
> On 22 Jun., 13:55, patrickk  wrote:
>
> > that´s it. thanks a lot.
>
> > On 22 Jun., 13:28, Russell Keith-Magee  wrote:
>
> > > On Mon, Jun 22, 2009 at 6:42 PM, patrickk wrote:
>
> > > > this is the first time I´m using the test-framework, so it might be a
> > > > really stupid question.
>
> > > > when using
> > > > python manage.py test myapp
> > > > or
> > > > python manage.py test myapp.BaseTest
> > > > I´m getting lots of output for other apps than "myapp" - it seems that
> > > > tests are running for every installed app (and not just the one I
> > > > need).
>
> > > If this is happening, I can only presume that you're doing something
> > > unusual with your imports. The syntax you have provided should
> > > restrict the test cases that are run (only the tests in myapp in the
> > > first instance; only the BaseTest tests in the second).
>
> > > I'm going to guess that you're doing two things here:
>
> > > 1) You've got your unit tests defined in models.py
> > > 2) the models.py for myapp has "from otherapp.models import *" in it.
>
> > > When you restrict the tests that are executed, Django's test discovery
> > > mechanism looks for all tests defined in a given application (in this
> > > case, myapp). However, when you use "from otherapp.models import *',
> > > any tests in otherapp's namespace are brought into the namespace of
> > > 'myapp'.
>
> > > If you move the unit tests to a separate tests.py module, you should
> > > be able to avoid this problem (since you generally won't have cause to
> > > 'from otherapp.tests import *').
>
> > > If this isn't what is happening, your problem may require some
> > > additional investigation. A cut-down sample project with myapp,
> > > BaseTest, etc would help establish what exactly is going on.
>
> > > Yours,
> > > Russ Magee %-)
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



manytomany field override on save

2009-06-22 Thread hadaraz

Hi,

I recently needed to override a manytomany field on the save_model()
method in the admin. However, this is not possible because it will get
overwritten later with the original values. I asked if this will
change in the future on the django-developers list:
http://groups.google.com/group/django-developers/msg/180d491dc781be49
Never got an answer...
Anyway, here is how I solved it. If you look at django/contrib/admin/
options.py, you will see that the order of saving is this:

1. save_model()
2. save_m2m()
3. save_formset()

So, overriding the save_formset() method (I'm using inlines anyway,
but I think it would work without them as well) enables me change the
way manytomany behaves. Example use in my MyAdmin.py:

 def save_formset(self, request, form, formset, change):
"override the manytomany field"
super(MyAdmin, self).save_formset(request, form, formset,
change)
if formset.field == something:   # see note later on
 # form.instance is your model
 ...do something with form.instace
 
 form.instance.save()

Note: this function will run as many times as the inline forms you
have, so make sure it only happens once, maybe using an if statement
to check something on your formset, as done above.

hope it helps someone,
hadaraz

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



Re: how to run just ONE test?

2009-06-22 Thread patrickk

unfortunately, I´m still stuck with it ...

here´s my tests.py:

import unittest, os

class BaseTest(unittest.TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test_fileobject(self):
pass

even with this stripped-down version, _all_ tests are performed.
btw, models.py is empty (I don´t need that file for my app).

thanks,
patrick



On 22 Jun., 13:55, patrickk  wrote:
> that´s it. thanks a lot.
>
> On 22 Jun., 13:28, Russell Keith-Magee  wrote:
>
> > On Mon, Jun 22, 2009 at 6:42 PM, patrickk wrote:
>
> > > this is the first time I´m using the test-framework, so it might be a
> > > really stupid question.
>
> > > when using
> > > python manage.py test myapp
> > > or
> > > python manage.py test myapp.BaseTest
> > > I´m getting lots of output for other apps than "myapp" - it seems that
> > > tests are running for every installed app (and not just the one I
> > > need).
>
> > If this is happening, I can only presume that you're doing something
> > unusual with your imports. The syntax you have provided should
> > restrict the test cases that are run (only the tests in myapp in the
> > first instance; only the BaseTest tests in the second).
>
> > I'm going to guess that you're doing two things here:
>
> > 1) You've got your unit tests defined in models.py
> > 2) the models.py for myapp has "from otherapp.models import *" in it.
>
> > When you restrict the tests that are executed, Django's test discovery
> > mechanism looks for all tests defined in a given application (in this
> > case, myapp). However, when you use "from otherapp.models import *',
> > any tests in otherapp's namespace are brought into the namespace of
> > 'myapp'.
>
> > If you move the unit tests to a separate tests.py module, you should
> > be able to avoid this problem (since you generally won't have cause to
> > 'from otherapp.tests import *').
>
> > If this isn't what is happening, your problem may require some
> > additional investigation. A cut-down sample project with myapp,
> > BaseTest, etc would help establish what exactly is going on.
>
> > Yours,
> > Russ Magee %-)
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Request aware template loader

2009-06-22 Thread z0n3z00t

I have a common site that is used by different clients.  Each client
wants to be able to custom-brand the site to their liking.

How it works: I provide a default theme for the site, i.e. templates
and media, that clients can easily export and customise to their
liking.  All default template files are stored in a templates/default
directory on the server, and all default media inside a media/default
directory.

When they've done their customisations, clients use a form to upload
an archive that contains all the template and media files that they
want to override.  These uploaded theme archives are extracted using
this convention:  Each customer's overridden templates and media would
be extracted to templates/custXXX and media/custXXX.

I quite like the way that the django template loaders are chained
together in a sequence to find a specific template file - this is
exactly the way I want my templates to load:  try to find the client's
custom template inside the client's template folder and, failing that,
load the default template.

To do this the template loader needs access to the request object to
determine request.user and work out which company he belongs to.
(Only the login page is common across all clients, since the client
can't be established)

The problem is that the request object is not passed to the template
loaders.  John Boxall posted a possible work-around using middleware
and threading to store the request object here:
http://groups.google.co.za/group/django-users/browse_thread/thread/cb92339600e6f75e/d221d2eded2de47d?hl=en=gst=request+aware+template+loader

What I like about this is that it doesn't touch the framework.  What I
don't like is the fact that it's such an ugly hack.

Does anyone know of a more elegant solution?  I'd appreciate any ideas
on how to achieve this without hacking the framework.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to run just ONE test?

2009-06-22 Thread patrickk

that´s it. thanks a lot.


On 22 Jun., 13:28, Russell Keith-Magee  wrote:
> On Mon, Jun 22, 2009 at 6:42 PM, patrickk wrote:
>
> > this is the first time I´m using the test-framework, so it might be a
> > really stupid question.
>
> > when using
> > python manage.py test myapp
> > or
> > python manage.py test myapp.BaseTest
> > I´m getting lots of output for other apps than "myapp" - it seems that
> > tests are running for every installed app (and not just the one I
> > need).
>
> If this is happening, I can only presume that you're doing something
> unusual with your imports. The syntax you have provided should
> restrict the test cases that are run (only the tests in myapp in the
> first instance; only the BaseTest tests in the second).
>
> I'm going to guess that you're doing two things here:
>
> 1) You've got your unit tests defined in models.py
> 2) the models.py for myapp has "from otherapp.models import *" in it.
>
> When you restrict the tests that are executed, Django's test discovery
> mechanism looks for all tests defined in a given application (in this
> case, myapp). However, when you use "from otherapp.models import *',
> any tests in otherapp's namespace are brought into the namespace of
> 'myapp'.
>
> If you move the unit tests to a separate tests.py module, you should
> be able to avoid this problem (since you generally won't have cause to
> 'from otherapp.tests import *').
>
> If this isn't what is happening, your problem may require some
> additional investigation. A cut-down sample project with myapp,
> BaseTest, etc would help establish what exactly is going on.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to run just ONE test?

2009-06-22 Thread Russell Keith-Magee

On Mon, Jun 22, 2009 at 6:42 PM, patrickk wrote:
>
> this is the first time I´m using the test-framework, so it might be a
> really stupid question.
>
> when using
> python manage.py test myapp
> or
> python manage.py test myapp.BaseTest
> I´m getting lots of output for other apps than "myapp" - it seems that
> tests are running for every installed app (and not just the one I
> need).

If this is happening, I can only presume that you're doing something
unusual with your imports. The syntax you have provided should
restrict the test cases that are run (only the tests in myapp in the
first instance; only the BaseTest tests in the second).

I'm going to guess that you're doing two things here:

1) You've got your unit tests defined in models.py
2) the models.py for myapp has "from otherapp.models import *" in it.

When you restrict the tests that are executed, Django's test discovery
mechanism looks for all tests defined in a given application (in this
case, myapp). However, when you use "from otherapp.models import *',
any tests in otherapp's namespace are brought into the namespace of
'myapp'.

If you move the unit tests to a separate tests.py module, you should
be able to avoid this problem (since you generally won't have cause to
'from otherapp.tests import *').

If this isn't what is happening, your problem may require some
additional investigation. A cut-down sample project with myapp,
BaseTest, etc would help establish what exactly is going on.

Yours,
Russ Magee %-)

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



Re: Question IMAGE in Django

2009-06-22 Thread Mike Ramirez
On Monday 22 June 2009 03:04:03 am Vlad(L) wrote:
> Unfortunately, it is impossible. Through a browser has looked html
> code -   p>
>
> And how should be correctly registered MEDIA_URL in my case if I work
> on built in server Django?

In your settings.py check the context processors and make sure the 
Media context processor[1] is set and you pass the request object to your 
RequestContext[2]

Mike

[1] 
http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-media

[2] http://docs.djangoproject.com/en/dev/ref/templates/api/#id1
-- 
We secure our friends not by accepting favors but by doing them.
-- Thucydides


signature.asc
Description: This is a digitally signed message part.


Re: Question IMAGE in Django

2009-06-22 Thread ankit rai
def art(request):
art = Article.object.all()
retrun  % (art)
 art.allow_tags = True

try this .Add this in your model or if in admin then pass object .then use
list_display to display the image.see docs for more help:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/

On Mon, Jun 22, 2009 at 4:11 PM, Vlad(L)  wrote:

>
> It so needs to be made?
>
>
> def art(request):
>art = Article.objects.all()
>return render_to_response('art.html', {'art': art})
>
> art.allow_tags = True
>
> I so have written, but all the same it is impossible
> http://127.0.0.1:8000/article/media/1.jpg
>
> It can is necessary to make, that the path was
> http://127.0.0.1:8000/media/1.jpg
> ?
>
>
> >
>

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



how to run just ONE test?

2009-06-22 Thread patrickk

this is the first time I´m using the test-framework, so it might be a
really stupid question.

when using
python manage.py test myapp
or
python manage.py test myapp.BaseTest
I´m getting lots of output for other apps than "myapp" - it seems that
tests are running for every installed app (and not just the one I
need).

I´ve read the django-docs on testing a couple of times now, but I don
´t understand what´s happening here.

thanks,
patrick


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



Re: Question IMAGE in Django

2009-06-22 Thread Vlad(L)

It so needs to be made?


def art(request):
art = Article.objects.all()
return render_to_response('art.html', {'art': art})

art.allow_tags = True

I so have written, but all the same it is impossible
http://127.0.0.1:8000/article/media/1.jpg

It can is necessary to make, that the path was http://127.0.0.1:8000/media/1.jpg
?


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



Re: Question IMAGE in Django

2009-06-22 Thread ankit rai
not got ur question.If u want to display image then set allow_tags=True.

On Mon, Jun 22, 2009 at 3:34 PM, Vlad(L)  wrote:

>
> Unfortunately, it is impossible. Through a browser has looked html
> code -   p>
>
> And how should be correctly registered MEDIA_URL in my case if I work
> on built in server Django?
> >
>

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



Re: Question IMAGE in Django

2009-06-22 Thread Vlad(L)

Unfortunately, it is impossible. Through a browser has looked html
code -  

And how should be correctly registered MEDIA_URL in my case if I work
on built in server Django?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Integrity error in get_or_create

2009-06-22 Thread Alessandro Ronchi
2009/6/21 Alessandro Ronchi 

>
> it gets into the except and tries to open another User with the same id!
>


It seemed to be a very big int for uid that caused a truncation when saving
into database.
-- 
Alessandro Ronchi
Skype: aronchi

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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



Re: Anyway to render a template without inheritance?

2009-06-22 Thread Tim Sawyer

Yes, just don't do the extends and include all the HTML you need in the
template.


Tim.

>
> Hello.
>
> Is there any way to render a template, omitting the "extends" tag?
> >
>



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



Anyway to render a template without inheritance?

2009-06-22 Thread [CPR]-AL.exe

Hello.

Is there any way to render a template, omitting the "extends" tag?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



custom field in ModelAdmin

2009-06-22 Thread Andrés Otárola

Hi

I need to do a slight hack in my model's form, its a model with a one
to many relationship with the same.

this is roughly my model (recursive one to many relationship):

class Product(models.Model)
bar_code = models.CharField(max_length=100,unique=True)
compose = models.ForeignKey('Product',null=True,blank=True)


So in my admin model form, I have a resulting foreign key combo box,
but I want that to be a textbox widget to input a unique number
"bar_code" ( not the parent's id ! ), so  when I have to save/update
the relationship, with the unique number I'll need to do a look up to
get the corresponding "id" and save the relationship. Well, that's my
idea.

It's a indirect relationship in the form model.

how can I achieve that using ModelAdmin ?, is there another
alternative way? (is not a solution for me use "bar_code" as
primary_key and then in ModelAdmin use the "raw_id_fields", altought I
want that same effect)

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