Mocking The DB

2006-12-12 Thread Rob Young
Hi, How do I go about mocking the database for efficiently unit testing my models? When writing my own projects I would simply create a mock db interface but if I'm using Django I'd like to do things 'the Django way' rather than hacking my way into the Models class to get to something I can mo

Help with get absolute url

2006-12-12 Thread conrad22
Hi Hopefully someone can step in here before I go totally mad... I am trying to define the absolute_url and/or the urls.py file to arrive at the following: A list of categories, which leads to a list of organisations in each category. I want then each organisation in the list to go to its generi

Re: Problem on Display Image

2006-12-12 Thread Nathan R. Yergler
Django uses the urljoin function in the Python standard library urlparse module[1] to join the MEDIA_URL to the image file path. If the MEDIA_URL specifies a directory and does not have a trailing slash, the directory portion is dropped. So to get Django to generate the correct URLs, you need to

Re: static files

2006-12-12 Thread G.J. Souverein
2006/12/12, Jeremy Dunck <[EMAIL PROTECTED]>: > > > On 12/11/06, snippetcreator <[EMAIL PROTECTED]> wrote: > > > > I have a problem with the development server not serving static files. > > I configured everything as explained in static_files.txt (I also have > > read all the postings here about th

Re: Property overrides

2006-12-12 Thread Nathan R. Yergler
> This won't work with the admin interface, because it wouldn't know > about your set_posted() method. With that said, you might be able to > use Python properties, but I have never tried that and am not sure > whether it would work. If it did work, you could do this: > > class Entry(models.Model

Re: problem with django settings module

2006-12-12 Thread Snirp
Baurzhan Ismagulov schreef: > [...]you need to have the following environment variables set: > > PYTHONPATH = c:/temp > DJANGO_SETTINGS_MODULE = mysite.settings I did just that and it works now, thx. To recap and potentially make this post even more useful, what i learned so far: In: System p

Re: help with pagination and other vars...

2006-12-12 Thread flynnguy
Thanks, this seems to work, now I just have to change the paginator.py template tag to accept a parameter (as the extra_context info doesn't seem to be available to it) -Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goog

Re: Property overrides

2006-12-12 Thread Adrian Holovaty
On 12/12/06, Nathan R. Yergler <[EMAIL PROTECTED]> wrote: > Note that the property built-in takes the "getter" as the first, > required argument and the "setter" as the optional, second argument. So > if you were going to do this with properties you'd want to do: > > class Entry(models.Model): >

Re: Problem on Display Image

2006-12-12 Thread wangml
Thanks Nathan, I think my mistake is quite common when starting learn django. Now it is done. Thanks again. Minglei --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

Re: Mocking The DB

2006-12-12 Thread Jeremy Dunck
On 12/12/06, Rob Young <[EMAIL PROTECTED]> wrote: > > Hi, > > How do I go about mocking the database for efficiently unit testing my models? > When writing my own projects I would simply create a mock db interface but if > I'm using Django I'd like to do things 'the Django way' rather than hacking

changing values just before saving

2006-12-12 Thread Rob Slotboom
In a model I feed a contenttype form field some initial data to choose from. class MenuItem(models.Model): CONTENT_TYPE_CHOICES = tuple(get_available_content()) content_type = models.ForeignKey(ContentType, choices=CONTENT_TYPE_CHOICES) The data is provided using the folowing function whic

Re: changing values just before saving

2006-12-12 Thread Aidas Bendoraitis
Your solution seems to be some misunderstanding :) If you set a foreign key to ContentType, then it already gets the choices from the relation. If you want to limit the choices, use limit_choices_to. If your purpose is to save just the id, use some IntegerField or PositiveIntegerField with the cho

Re: Changemanipulator and follow true

2006-12-12 Thread Massimiliano Ravelli
I hope I understood your problem (as my english is ugly). I have a similar application: note that I put the foreign key on Address. class Address(models.Model): address_id = models.AutoField(primary_key=True) # Here's the foreign key (note the edit_inline) company = models.ForeignKey(

Re: forcing UTF8 data inside django

2006-12-12 Thread favo
I think you'd better enforce de/encoding to settings.DEFAULT_CHARSET in the middleware. not hardcode utf8. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Property overrides

2006-12-12 Thread John Lenton
On 12/12/06, Nathan R. Yergler <[EMAIL PROTECTED]> wrote: > > Note that the property built-in takes the "getter" as the first, > required argument and the "setter" as the optional, second argument. A nit: none of the arguments of property are required. -- John Lenton ([EMAIL PROTECTED]) -- Rand

Re: Mocking The DB

2006-12-12 Thread jerf
On Dec 12, 5:50 am, Rob Young <[EMAIL PROTECTED]> wrote: > How do I go about mocking the database for efficiently unit testing my models? > When writing my own projects I would simply create a mock db interface but if > I'm using Django I'd like to do things 'the Django way' rather than hacking >

Re: Mocking The DB

2006-12-12 Thread Jeremy Dunck
On 12/12/06, jerf <[EMAIL PROTECTED]> wrote: > I can't speak for "the Django way", but I use the provided Django test > client in the subversion repository, which I believe is important > enough to upgrade for. /me wishes he could use trunk. --~--~-~--~~~---~--~~

Re: changing values just before saving

2006-12-12 Thread Rob Slotboom
> Your solution seems to be some misunderstanding :) > If you set a foreign key to ContentType, then it already gets the > choices from the relation. Dear Aidas, I know, I know. The point is that I want to be able to use the damn generic relation in admin. I abuse the given field to collect real

Re: Property overrides

2006-12-12 Thread jerf
On Dec 12, 1:02 am, "Adrian Holovaty" <[EMAIL PROTECTED]> wrote: > You can simply write a set_posted() method, like so: > > class Entry(models.Model): > post_date = models.DateTimeField(...) > posted = models.BooleanField(...) > > def set_posted(self, new_value): > if new_value

Django email

2006-12-12 Thread Ramdas S
I am seriously getting a client to consider Django for a CRM web site of a client. Django templating language is the reason, since each campaign needs to be heavily customized from a database. Problem is they have a customer base of 100,000 registered users, and each campaign goes to a subset of

Re: Help with get absolute url

2006-12-12 Thread conrad22
Woops..see, I am already mad, as I have not communicated the actual problem.. The last bit - 'categories/1/k/' returns a page/url not found error, as follows: Request Method: GET Request URL:http://127.0.0.1:8000/categories/1/k/ Using the URLconf defined in kvn.urls, Django tri

Re: Help with get absolute url

2006-12-12 Thread Brett Parker
On Tue, Dec 12, 2006 at 11:13:52AM -0800, conrad22 wrote: > > Woops..see, I am already mad, as I have not communicated the actual > problem.. > > The last bit - 'categories/1/k/' returns a page/url not found error, > as follows: > > Request Method: GET > Request URL: http://127.0.0.

Admin login problem

2006-12-12 Thread Yatla
Newbie here - saw that the same question was asked earlier but not answered, and the post was locked so I could not reply. I have a Django site in a subdirectory as follows (via fcgi) - (using ver 0.96 pre via svn) http://mydomain.com/dj When I go into the Admin area as follows http://mydomain

alternatives to edit_inline

2006-12-12 Thread Milan Andric
Hello, I'm working out a problem I'm experiencing when using edit_inline with my application in the admin interface. I have Application and Review classes among others: class Application(models.Model): workshop = models.ForeignKey(Workshop) user = models.ForeignKey(User) ... class

Re: Django email

2006-12-12 Thread [EMAIL PROTECTED]
We have been sending bulk mail (error logs) to gmail for the past few weeks, but it hasnt been working too well :) On that note though, I don't think the question is whether django can, or should, handle something like that itself, as its not a CMS. You will most likely need to build a mail app t

Re: Django email

2006-12-12 Thread Jeremy Dunck
On 12/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > We have been sending bulk mail (error logs) to gmail for the past few > weeks, but it hasnt been working too well :) We've run into some delivery problems w/ email, too. Causes I've found so far: x SPF not configured x hostname w

My client is looking for a Django developer for ongoing tweaks/new web host

2006-12-12 Thread [EMAIL PROTECTED]
A client of mine is looking for someone to maintain a Django site. I just do not have the time anymore. I was a freelancer, and now am too busy with a full time job and other obligations. My client is an antiques dealer in Chicago, and would prefer a local candidate. This is going to be several h

Re: forcing UTF8 data inside django

2006-12-12 Thread Victor Ng
Unfortunately, not all charsets will support all unicode characters, so really, the fact that DEFAULT_CHARSET configurable is mostly a moot point for me. For example, latin1 won't let me encode asian characters. I honestly can't think of a good reason to do anything other than UTF8 unless you've

Re: cyrillic text garbled if used as question in polls example

2006-12-12 Thread Baurzhan Ismagulov
On Mon, Dec 11, 2006 at 10:32:20AM -, mezhaka wrote: > question=%D0%9A%D0%B0%D0%B3+%D0%B4%D0%B8%D0%BB%D0%B0%2C+%D0%BA%D1%80%D0%BE%D1%81%D0%B0%D1%84%D1%87%D0%B5%D0%93%3F This looks good, at least I have no problems with Cyrillic characters passed to the server in that way. > The troubled lin

Zip Code Locator

2006-12-12 Thread [EMAIL PROTECTED]
Has anyone done any sort of store locator by zip code functionality in Django/Python? There are tons of pre-built zip code products out there for PHP and the like but are there any good Python implementations? If someone could point me in the right direction it would be much appreciated. Thanks

Advice on model-design

2006-12-12 Thread Kristian Klette
Hi all. Im currently making a room-reservation system in django, but i have one small question. Is there any right way of making one model (reservation), have many bookings, ie a OneToMany relation, and have it being easily set up in the admin panel? If I use a manytomany-field i get the kind of

Re: union of two QuerySets

2006-12-12 Thread Honza Král
if you want a true union, use chain from itertools on the two querysets... On 12/11/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > > On 12/11/06, Rares Vernica <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I know the Q way, but actually the filter contains already a lot of Qs. > > > > I am looking

Re: Zip Code Locator

2006-12-12 Thread [EMAIL PROTECTED]
I guess I should have kept looking before posting to the list, but here are the best things I found: http://zips.sourceforge.net/ http://www.zachary.com/s/blog/2005/01/12/python_zipcode_geo-programming http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/393241 Looks like I'm going with the l

help with tagging app

2006-12-12 Thread Rob Slotboom
I installed Luke Plant's Tagging App and started reading the README file and the comments provided in the source. Compared to the marvelous Django Book and -tutorial this reading isn't very funny :-) Has someone a simple example for how to include a tag in another model, say Poll or Article? And

Re: Advice on model-design

2006-12-12 Thread Russell Keith-Magee
On 12/13/06, Kristian Klette <[EMAIL PROTECTED]> wrote: > > Hi all. > Im currently making a room-reservation system in django, but i have one small > question. Is there any right way of making one model (reservation), have many > bookings, ie a OneToMany relation, and have it being easily set up i

Re: alternatives to edit_inline

2006-12-12 Thread Rob Slotboom
Maybe this may be of any help. In the model you can add adminlinks like this: class Admin: fields = ( ) list_display = ('name', 'admin_links') def admin_links(self): return 'edit | view | delete' % (self.id, self.get_absolute_url(), self.id)

Re: alternatives to edit_inline

2006-12-12 Thread Milan Andric
Rob, Thanks for this idea/example, but I don't think it addresses the problem of telling the Review create view which Application I'm referencing. Do you know of a way to either pre-select the foreign key in the drop down or embed it as a hidden variable somehow? On a different note, I was bum

Re: Advice on model-design

2006-12-12 Thread Kristian Klette
> Sounds like you want a ForeignKey. Check the model API for details. Ok, thats just embarrassing, heh. Thanks :) -- Mvh Kristian Klette «Programs for sale: Fast, Reliable, Cheap: choose two.» --~--~-~--~~~---~--~~ You received this message because you are su

a problem of setup.py

2006-12-12 Thread 大熊
I found the setup.py has been modified in r4114: for dirpath, dirnames, filenames in os.walk(django_dir): # Ignore dirnames that start with '.' for i, dirname in enumerate(dirnames): if dirname.startswith('.'): del dirnames[i] if '__init__.py' in filenames: package = di

send_mass_mail() on save

2006-12-12 Thread [EMAIL PROTECTED]
I have two models, Subscriber, which has a front-end userface where people can sign up for a newsletter and Publication, which has an admin interface for writing the newsletters. What I want to do is to have the ability to fetch the rows in Subscriber and use these as the datatuple for send_mass_

Re: Get all *_set's from a model?

2006-12-12 Thread Russell Keith-Magee
On 12/12/06, Adam Seering <[EMAIL PROTECTED]> wrote: > > Hi, > I know Django keeps track of connections like this somehow, for the > *_set properties. Is there a way to get at that information > somehow?, or does anyone have a better idea on how to do this? The details you are after are

Re: newforms: MultipleChoiceField with CheckboxSelectMultiple

2006-12-12 Thread Adrian Holovaty
On 12/10/06, Ceph <[EMAIL PROTECTED]> wrote: > Ah. I was hoping wrongly that newforms would be able to handle getting > passed POST instead of having the parse the data manually into a dict. This has been fixed as of [4196], thanks to a patch from Honza. Adrian -- Adrian Holovaty holovaty.com

Re: a problem of setup.py

2006-12-12 Thread Fredrik Lundh
大熊 wrote: > # Ignore dirnames that start with '.' > for i, dirname in enumerate(dirnames): > if dirname.startswith('.'): del dirnames[i] Argh! >>> dirnames = [".foo", ".bar"] >>> for i, dirname in enumerate(dirnames): ... if dirname.startswith("."): del dirnames[i] ... >>

Re: Schema Evolution code

2006-12-12 Thread Steve Hutton
On 2006-12-11, Victor Ng <[EMAIL PROTECTED]> wrote: > Hi Russ, > > I've got a rough version of schema evolution working now. > > The basic implementation is what the SoC project was trying to do. [...] > On 12/3/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: [...] >> The behaviour you are seek