defining models for unit testing only

2010-08-21 Thread mack the finger
I wrote a django 'app', thats basically just a class that takes a Queryset, some other information, and then outputs an HttpResponse object (it does some other things too). How do I write unit tests for this class? The app itself does not contain any models, yet the functionality of the class

Re: check email duplication at registration

2010-08-21 Thread Steve Holden
On 8/21/2010 10:32 PM, John Yeukhon Wong wrote: > Hi, sorry for the problem. > > Well, this is used in registration. As stated in the title, this is > used to prevent "duplication". > Let say an existing user in db, whose username is abc, and email is > 1...@acb.com > After testing, I can still

Re: check email duplication at registration

2010-08-21 Thread John Yeukhon Wong
Hi, sorry for the problem. Well, this is used in registration. As stated in the title, this is used to prevent "duplication". Let say an existing user in db, whose username is abc, and email is 1...@acb.com After testing, I can still register an account with the existing email address, which

Re: Trouble comparing variables in a view

2010-08-21 Thread Steve Holden
On 8/21/2010 8:35 PM, Kevin wrote: > I have attempted to troubleshoot this myself with no luck and am very > confused why a simple IF statement is not working. I have used if > statements in python before and never had such a problem. I am rather > glad to see that PRINT outputs to the console,

Re: check email duplication at registration

2010-08-21 Thread Steve Holden
On 8/21/2010 7:23 PM, John Yeukhon Wong wrote: > I don't think this code is working properly > That isn't a very helpful description. For better answers, please describe what it is doing that it should not (or what it is not doing that it should). > from django import forms > from

Re: Django on Mac OS X

2010-08-21 Thread AndrewK
I've had the same problem on my Mac just now. It seems like this is an issue with django-timezones Try to install dev version from here: pip install -e git://github.com/brosner/django-timezones.git#egg=django-timezones Andrew On Aug 9, 1:40 pm, Daniel França wrote: >

Re: Trouble comparing variables in a view

2010-08-21 Thread Felippe Bueno
did you tried int() ? just an idea ... On Sat, Aug 21, 2010 at 9:35 PM, Kevin wrote: > I have attempted to troubleshoot this myself with no luck and am very > confused why a simple IF statement is not working.  I have used if > statements in python before and never had such

Trouble comparing variables in a view

2010-08-21 Thread Kevin
I have attempted to troubleshoot this myself with no luck and am very confused why a simple IF statement is not working. I have used if statements in python before and never had such a problem. I am rather glad to see that PRINT outputs to the console, this helps a bit for troubleshooting.

Re: how to prepopulate admin form with default data?

2010-08-21 Thread widoyo
Hello Gondor, If you mean 'admin model' is http://localhost:8000/admin/ (Django Admin page) your problem solution is mentioned in this docs: http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#modeladmin-methods Widoyo On Aug 21, 2:57 pm, gondor wrote: > class

check email duplication at registration

2010-08-21 Thread John Yeukhon Wong
I don't think this code is working properly from django import forms from django.contrib.auth.models import User def clean_email(self): email = self.cleaned_data['email'] try: User.objects.get(email=email) except User.DoesNotExist: return email raise

Re: mutually referential models

2010-08-21 Thread widoyo
Just add quote into your model that you do not defined yet. On Aug 22, 12:26 am, Andy Howell wrote: > > class Computer(models.Model): >     name = models.CharField(max_length=80) >     description = models.CharField(max_length=80, null=True) >     interfaces =

Re: Touch-ing django.wsgi doesn't reliably reload source code

2010-08-21 Thread Graham Dumpleton
On Aug 22, 12:07 am, Jim wrote: > Hello, > > I have Django running under apache2 (the worker version, I believe, > with MaxRequestsPerChild set to the default, which is 0).  I am using > mod_wsgi in daemon mode.  I have checked that it is daemon mode using > the method

Re: searching stackedinline fields via search_fields in admin

2010-08-21 Thread gondor
Here is what i'm trying to do: I've looked at my code and I don't have a foreign key out reference from my model thus cannot find the inline fields. reverse reference doens't seem to work either class CarRadio(modesl.Model): name = models.ForeignKey('Car'); id =

Re: Need some help with URL layout

2010-08-21 Thread Uwe Schuerkamp
thanks for your comments guys, I guess I'm more or less on the right track! All the best, Uwe -- 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,

Re: Ability to use PSP templates with Django?

2010-08-21 Thread hcarvalhoalves
There are 2 approaches: - Think data structures instead, and put all this logic on your view, such that the template just needs to iterate thru one variable to build the menu. Something like passing in the template context: menu = [{'name': 'django', 'text': 'Official Django Site', 'url':

Re: Need some help with URL layout

2010-08-21 Thread Steve Holden
On 8/21/2010 1:39 PM, widoyo wrote: > It could be better if you omit '_ALL' at URL > > So: > /ranking/de/ # for Germany ranking Nation wide > /ranking/ # for all country > > can put summary of ranking for such URL, instead of list of all > ranking nation or all country. > The point being, you

Re: Ability to use PSP templates with Django?

2010-08-21 Thread Albert Hopkins
On Fri, 2010-08-20 at 14:00 -0700, Kevin wrote: > I come from the world of mod_python and really enjoyed the PSP > template system, where I can embed Python code directly in my template > for dynamically generating menus and such. > > What is the recommended method of calling a PSP template from

Re: Enter a field in the database after encryption

2010-08-21 Thread widoyo
refer to this docs: http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#modeladmin-methods Use def save_model(self, ...): mymodel.password = # put your md5 encrypted here ... mymodel.save() Widoyo On Aug 21, 11:05 pm, Amitanshu wrote: > Actually I

Re: mutually referential models

2010-08-21 Thread Karen Tracey
On Sat, Aug 21, 2010 at 1:26 PM, Andy Howell wrote: > Is there a way I can refer to a class not yet defined? Yes, see: http://docs.djangoproject.com/en/1.2/ref/models/fields/#module-django.db.models.fields.related The paragraph that starts "If you need to create a

Re: Need some help with URL layout

2010-08-21 Thread widoyo
It could be better if you omit '_ALL' at URL So: /ranking/de/ # for Germany ranking Nation wide /ranking/ # for all country can put summary of ranking for such URL, instead of list of all ranking nation or all country. Widoyo On Aug 21, 7:35 am, Uwe Schuerkamp wrote:

mutually referential models

2010-08-21 Thread Andy Howell
As a test application to learn Django, I'm trying to model a network of computers, switches, patch panels and the connections between them. As a start, I have: class Node(models.Model): name = models.CharField(max_length=80) description = models.CharField(max_length=80, null=True)

Re: Django-Cms Installation Error

2010-08-21 Thread Marek Dudek
You have django 1.2.1, now I noticed I wasn't able to install any version of django-cms with django 1.2.1 and I tried 2.0.0, 2.0.1, 2.0.2 and 2.1.0-beta3 Most up-to-date combination that I successfully installed is django 1.1.1 with django-cms 2.0.2. Hope this helps -- You received this

Re: Django-Cms Installation Error

2010-08-21 Thread Marek Dudek
Hello Your django version doesn't match django-cms version. You didn't specify which you are using so it's hard to say what you should change. I encountered this problem and written a message some time ago. It contains the table with matching versions that should help you. Marek Dudek -- You

Re: searching stackedinline fields via search_fields in admin

2010-08-21 Thread !!CONDORIOUS!!
Hello Karen, You are right. I'll try that when I get home. I knew that solution and even applied it in another model but because I was blinded by the stackedline. thank you both Condor On Sat, Aug 21, 2010 at 5:34 AM, Karen Tracey wrote: > On Sat, Aug 21, 2010 at 2:01

Re: Enter a field in the database after encryption

2010-08-21 Thread Amitanshu
Actually I missed something in my post, writing it again : -- 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

Enter a field in the database after encryption

2010-08-21 Thread Amitanshu
Hi All, I am new to Django and while making an app in Django I got stuck at one point. What I was trying to do is to have 3 fields in my app, username, password and age. I want that if I enter my password (through admin page of my app) it got entered in encrypted format (like md5). If

Touch-ing django.wsgi doesn't reliably reload source code

2010-08-21 Thread Jim
Hello, I have Django running under apache2 (the worker version, I believe, with MaxRequestsPerChild set to the default, which is 0). I am using mod_wsgi in daemon mode. I have checked that it is daemon mode using the method described on mod_wsgi's ReloadingSourceCode page. I need to do a

Re: Path mess

2010-08-21 Thread clochemer
Thanks a lot! I was lost with paths and all that. You really helped me to solve my problems! On Aug 21, 1:44 pm, Steve Holden wrote: > On 8/21/2010 4:52 AM, clochemer wrote: > > > > > Thanks for your quick replies. You helped me to understand what is > > happening. > > >

Re: Create files and directories from Django 1.2.1

2010-08-21 Thread Doug Blank
On Mon, Aug 16, 2010 at 8:51 PM, Mike Dewhirst wrote: > On 16/08/2010 10:22pm, Doug Blank wrote: >> >> On Mon, Aug 16, 2010 at 7:23 AM, Mark Mooij  wrote: >>> >>> Allright I tried a couple of things with your suggested appraoch: >>> > > > >> >> I doubt

Re: Django-Cms Installation Error

2010-08-21 Thread Karen Tracey
On Sat, Aug 21, 2010 at 7:11 AM, Jagdeep Singh Malhi < singh.malh...@gmail.com> wrote: > I try to Install the Django-Cms using this link > http://www.django-cms.org/en/documentation/2.0/installation/ > > I face this error. I am able understand this error > > ERROR is : - > { >

Re: searching stackedinline fields via search_fields in admin

2010-08-21 Thread Karen Tracey
On Sat, Aug 21, 2010 at 2:01 AM, Condorious wrote: > My goal is to add search to stackedinline in addition to the common > standard search fields. If admin model knows enough to stackinline the > right stackedinline model, we should be able to > Search it as well. I just

Need some help with URL layout

2010-08-21 Thread Uwe Schuerkamp
Hi folks, please excuse this long-winded post, but I'm a bit stuck with the layout of my urls.py. Let me try to explain what the site I'm using Django for does at the moment: Basically it's a website where local birdwatchers (the ones with feathers, not boobies ;-) can log their observations. By

Ability to use PSP templates with Django?

2010-08-21 Thread Kevin
I come from the world of mod_python and really enjoyed the PSP template system, where I can embed Python code directly in my template for dynamically generating menus and such. What is the recommended method of calling a PSP template from inside Django and rendering it? Here is a sniplet of code

Re: Path mess

2010-08-21 Thread Steve Holden
On 8/21/2010 4:52 AM, clochemer wrote: > Thanks for your quick replies. You helped me to understand what is > happening. > > However, I can not make all work together. Let me explain the problems > that I am having right now... > > I wrote a piece of code in a folder within my django project

Re: Django-Cms Installation Error

2010-08-21 Thread Jagdeep Singh Malhi
sorry, I am not able understand this error. -- 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-Cms Installation Error

2010-08-21 Thread Jagdeep Singh Malhi
I try to Install the Django-Cms using this link http://www.django-cms.org/en/documentation/2.0/installation/ I face this error. I am able understand this error ERROR is : - { ImproperlyConfigured at / 'PageAdmin.exclude' refers to field 'created_by' that is missing from the form. Request

Re: Path mess

2010-08-21 Thread clochemer
Thanks for your quick replies. You helped me to understand what is happening. However, I can not make all work together. Let me explain the problems that I am having right now... I wrote a piece of code in a folder within my django project path just like this:

how to prepopulate admin form with default data?

2010-08-21 Thread gondor
class Notes(models.Model): name = models.ForeignKey('name', blank=True, null=True) text = models.TextField('Text',blank=True) date = models.DateField(blank=True, default=datetime.date.today()); I have a simple admin model for inputting a note with a date into the database. date is

Prepopulate some fields in a admin add form

2010-08-21 Thread gondor
I have a simple admin model for inputting a note with a date into the database. In addition to that I want to prepopulate with the users name when the add new entry button is clicked. The users name is a foreign key to the user table. Does anyone know how to do that? Any help is appreciated.

Re: searching stackedinline fields via search_fields in admin

2010-08-21 Thread Condorious
My goal is to add search to stackedinline in addition to the common standard search fields. If admin model knows enough to stackinline the right stackedinline model, we should be able to Search it as well. I just need someone to point me in the right direction or some me some sample code that