Re: Schema Evolution code
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 seeking is under development in the schema >> evolution >> branch. I don't know the status of this branch for certain; it was >> the >> subject of a Google 'summer of code' project, and I believe that the >> engineering work is complete, but requires feedback and review before >> it is >> committed to the trunk (I could be wrong on this - anybody in the >> loop on >> this stream care to comment?) >> >> Anyway - the wiki describes what was intended for this stream: >> >> http://code.djangoproject.com/wiki/SchemaEvolution I get the impression that there's not a lot of momentum behind the schema evolution branch at the moment. It seems it hasn't been brought up to date with head in a while. My status query on the developer list didn't result in any replies. I'm kind of surprised at this, since I think its a pretty frequently requested feature. Does anyone here who has tried the schema evolution branch care to comment? Does it have a realistic chance of being accepted into core if it's found to be bug free? Is it fully documented? Is the design controversial or does it follow a community consensus? Thanks, Steve --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: a problem of setup.py
大熊 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] ... >>> dirnames ['.bar'] please replace with something like: dirnames[:] = [d for d in dirnames if not d.startswith(".")] --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms: MultipleChoiceField with CheckboxSelectMultiple
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 | djangoproject.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Get all *_set's from a model?
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 all stored in the _meta member of any object/model. For example: article._meta.fields is the list of normal fields, including ForeignKeys article._meta.many_to_many is the list of m2m fields article._meta.get_all_related_objects() returns the list of all related objects - i.e., the objects that have a foreign key on Article article._meta.get_all_related_many_to_many_objects() returns the list of all related m2m objects - i.e., the objects that define an m2m field relating to Article. The implementaiton of lookup_inner() in query.py gives a good idea of how to traverse relations using members of _meta. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
send_mass_mail() on save
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_mail when the writer saves a new entry in the model Publication. Can anyone explain to me how I have to go forward to do this? The models below: class Subscriber(models.Model): name = models.CharField(maxlength=128) email = models.EmailField() def __str__(self): return self.name class Admin: pass class Publications(models.Model): title = models.CharField(maxlength=192) content = models.TextField() signature = models.TextField(default='Best wishes, Henrik Lied') def __str__(self): return self.title class Admin: pass Thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
a problem of setup.py
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 = dirpath[len_root_dir:].lstrip('/').replace('/', '.') packages.append(package) else: data_files.append((dirpath, [os.path.join(dirpath, f) for f in filenames])) But it seemed that it could work correctly in windows, so I do a fix: 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] relate_path = dirpath[len_root_dir+1:] if '__init__.py' in filenames: packages.append(relate_path.replace(os.sep, '.')) else: data_files.append((relate_path, [os.path.join(dirpath, f) for f in filenames])) I have not tested under linux, bu I think it can work. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Advice on model-design
> 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 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: alternatives to edit_inline
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 bummed to find that methods that I'm using in my list_display cannot be sorted or filtered. Is there a workaround for that? The more I think about it the more likelihood I'll write my own views. Maybe try to use the generic views, but since I'm already familiar with creating my own views it's probably easier. I've been leaning towards writing my own views because I keep thinking I'm not familiar enough with generic views and will only hit a limitation sooner or later. Maybe on the next project I will look more at generic views. -- Milan --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: alternatives to edit_inline
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) admin_links.allow_tags = True admin_links.short_description = 'Actions' Mind the indentation :-) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Advice on model-design
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 in the > admin panel? Sounds like you want a ForeignKey. Check the model API for details. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
help with tagging app
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 now I'm on it: can related tags for a given model be used in the admin app? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Zip Code Locator
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 last one, if it works out I'll post my results as a Django app somewhere for someone else to use. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: union of two QuerySets
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 for a way to combine "a" and "b" without going into their > > filters. > > QuerySets are lazy. There's no downside to combining two > arbitrarily-complex querysets either before or after the filter > call(s). > > > > -- Honza Král E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420 606 678585 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Advice on model-design
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 booking-object creation I want in the admin, but i want them to only answer to that reservation, so when i make a second reservation, the bookings from the last reservation wont show in the bookings-list. Any ideas? - K -- Mvh Kristian Klette «Programs for sale: Fast, Reliable, Cheap: choose two.» --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Zip Code Locator
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 in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: cyrillic text garbled if used as question in polls example
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 line (the one with question marks) looks like this: > name="question" size="30" value="??? ?" maxlength="200" /> Could you please od the value part, to eliminate the possibility of the terminal - shell - catting tool chain scrambling the output? > mysql> select * from polls_poll; ... > | 3 | ??? ? | 2006-12-09 12:24:13 | ... > the third row was inserted via admin interface and as you can see it's > just question marks. Could you please od this, too? > then I tried to ran the following SQL: > mysql> insert into polls_poll (`question`, `pub_date`) values ('Ты > используешь Джанго?', NOW()); > > now it's displayed ok in the mysql client, but the admin interface > shows a different style garbled text instead: > Ты иÑпользуешь > Джанго? Aha. So, what is the output of "locale" in the shell you started mysql in? Does mysql inherit it? What is the encoding of the database you are writing to? With kind regards, -- Baurzhan Ismagulov http://www.kz-easy.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: forcing UTF8 data inside django
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 got some weird requirement to do otherwise. vic On 12/12/06, favo <[EMAIL PROTECTED]> wrote: > > I think you'd better enforce de/encoding to settings.DEFAULT_CHARSET in > the middleware. not hardcode utf8. > > > > > -- "Never attribute to malice that which can be adequately explained by stupidity." - Hanlon's Razor --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
My client is looking for a Django developer for ongoing tweaks/new web host
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 hours per month. There are both admin issues and front end tweaks that need to be done, as well as recommending and moving webhosts. Please contact me offlist: deezthugs AT gmail.com Thanks, David --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django email
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 wrong for reverse DNS -- I think this is either a bug in python's email module or confusion about /etc/mailname : http://wiki.debian.net/?EtcMailName x message id missing (new in django dev trunk) x recipient whitelisting (nothing to be done about that) x too many links in email. Any other thoughts on causes? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django email
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 to distribute the emails in chunks. On Dec 12, 8:03 pm, "Ramdas S" <[EMAIL PROTECTED]> wrote: > 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 these database which means a mailer campaign > can run between 1000 and 70,000 users. > > Question is does Django's built-in mail component scale to handle such > loads. Can we use it to send such huge volumes of emails in a single day? > > Ramdas --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
alternatives to edit_inline
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 Review(models.Model): reviewer = models.ForeignKey(User) application = models.ForeignKey(Application) rating = models.IntegerField( choices = ( (1,1), (2,2), (3,3), (4,4), (5,5), ) ) ... Initially I created Review.application with edit_inline and could add/modify reviews when viewing an application. But this is causing a few problems, one is I can't save the review without also re-saving the application. This doesn't work for me because I'm allowing applications to be saved without validation, so people can return to their applications at a later time to complete them. So I was thinking to have a link in the applications list view of the admin that has a link "add a review" for each application. This would send a GET to a create view for reviews with the foreignkey application already chosen through the GET. Does this sound like the right path? Is there any examples or documentation you can provide that would help me accomplish this? This will be my first dive into molding the admin, any help or advice is greatly appreciated. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin login problem
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.com/dj/Admin/ The login form that comes up has action="/admin/" (not "/dj/admin"), so the post goes to http://mydomain.com/admin which is not the Django site. Somehow the /dg/ subdirectory info is not prefixed to the form action. Is there a configuration with the main site prefix that I'm missing somwhere, I ony see path to media to be set in tte seetings? 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help with get absolute url
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.1:8000/categories/1/k/ > > Using the URLconf defined in kvn.urls, Django tried these URL patterns, > in this order: > >1. ^$ >2. ^kvn/$ >3. ^kvn/(?P\d+)/$ >4. ^r/ >5. kvn/add/$ >6. ^admin/ >7. ^feeds/(?P.*)/$ >8. ^categories/$ >9. ^categories/(?P\d+)/$ > > The current URL, /categories/1/k/, didn't match any of these. Errr, well it won't, the closest is 9... but you'd need something more like: ^categories/(?P\d+)/(?P\w+)/$ Cheers, -- Brett Parker --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help with get absolute url
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 tried these URL patterns, in this order: 1. ^$ 2. ^kvn/$ 3. ^kvn/(?P\d+)/$ 4. ^r/ 5. kvn/add/$ 6. ^admin/ 7. ^feeds/(?P.*)/$ 8. ^categories/$ 9. ^categories/(?P\d+)/$ The current URL, /categories/1/k/, didn't match any of these. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django email
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 these database which means a mailer campaign can run between 1000 and 70,000 users. Question is does Django's built-in mail component scale to handle such loads. Can we use it to send such huge volumes of emails in a single day? Ramdas --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Property overrides
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 != self.posted: > self.post_date = datetime.datetime.now() Sorry if something like this post comes through twice. Google's pretty slow, but a message I sent subsquently came through and I may not have sent this. The models.Model's metaclass needs to be able to see the models.BooleanField(...) value in order to work it's magic. Setting a property subsequently overwrites that, so the model never sees "posted" at all. As a consequence, I don't see any way to avoid adding a hook to the Fields themselves to check for an override. A Getter override should receive the "default" get value and what is returned by the getter should be what is returned to the user. A Setter override should recieve what the user is trying to set, and what is returned by the override should be what is set. The only question then is whether it should work via an explicit name in the models.*Field(...) specification, i.e., "visible = models.BooleanField(setter='check_visible')", or try to pick it up automatically via convention (look for a set_visible method on the object.) I'm inclined toward the former, although it is a small change. I'm willing to go ahead and put some time into investigating this, to see if there's a relatively easy way to fix it; if I'm lucky there's some sort of universal "get" and/or "set" routines that I can just hook into. Then maybe instead of a kvetch, I'll offer a patch. (Then everybody wins. :) ) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: changing values just before saving
> 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 content items (poll, page etc) in the val:val form. With the selected value I want to set the appropriate fields using split. This way it may be possible to create menuitems for the various content. Cheers, Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Mocking The DB
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. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Mocking The DB
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 > my way into the Models class to get to something I can mock. 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. I then use my NonMockObjects (http://www.jerf.org/programming/nonMockObjects.html) to test with real data inserted into the test DB. The provided test client takes care of the hardest part, which is initializing the new database and pointing all your connections at it. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Property overrides
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]) -- Random fortune: The trouble with a lot of self-made men is that they worship their creator. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: forcing UTF8 data inside django
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 django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Changemanipulator and follow true
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(Company, edit_inline=models.TABULAR) status_id = models.IntegerField(null=True, blank=True) ... class Company(models.Model): company_id = models.AutoField(primary_key=True) parent_company = models.ForeignKey("self",null=True,blank=True) ### address = models.ForeignKey(Address) company_name = models.CharField(blank=True, maxlength=150) ... I had no problem with ChangeManipulator (and with a custom manipulator too). Moreover you don't need to specify the follow argument. If you want to keep the foreign key on Company I suppose you must use the Address ChangeManipulator and specify the edit_inline argument. In the template you have to add a 0 (zero) to identify the first address. If you want only one Address per Company you can make the relation one to one adding unique=True to the company field. Street #:{{ form.address.0.street_number }} If you want more documentation, search edit_inline here http://www.djangoproject.com/documentation/model_api/#relationships Hope this helps you. Massimiliano --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: changing values just before saving
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 choices. Choices can be a list as well as tuple, so you don't need to convert them to the tuple. And if you still want to use your hackerish solution, try self.content_type_id = int(content_type_id) when your purpose is to change the relation instead of the id of the related ContentType object. Regards, Aidas Bendoraitis On 12/12/06, Rob Slotboom <[EMAIL PROTECTED]> wrote: > > 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 which returns a tuple > for every stored (in this case) Poll in the form of 13:xxx where xxx is > the poll_id. Just before saving the data I split the two parts in > content_type_id and content_id. Then I want to hand them over to the > corresponding values. This way it must be possible to add some kind of > menu_app to django which works within the admin interface. > > def get_available_content(): >available_content_list = [('13','testpoll')] >from mysite.polls.models import Poll >polls_list = Poll.objects.all().order_by('-question') >for poll in polls_list: > key = '13:%s' % poll.id > caption = poll.question > poll_tup = ( key, caption ) > available_content_list.append(poll_tup) >return available_content_list > > The only thing I can't get working is setting the new value befor > saving > > content_type_id, object_id = self.content_type_id.split(':', 1) > self.content_type.id = int(content_type_id) > self.object_id = int(object_id) > > Maybe someone has an idea??? > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
changing values just before saving
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 which returns a tuple for every stored (in this case) Poll in the form of 13:xxx where xxx is the poll_id. Just before saving the data I split the two parts in content_type_id and content_id. Then I want to hand them over to the corresponding values. This way it must be possible to add some kind of menu_app to django which works within the admin interface. def get_available_content(): available_content_list = [('13','testpoll')] from mysite.polls.models import Poll polls_list = Poll.objects.all().order_by('-question') for poll in polls_list: key = '13:%s' % poll.id caption = poll.question poll_tup = ( key, caption ) available_content_list.append(poll_tup) return available_content_list The only thing I can't get working is setting the new value befor saving content_type_id, object_id = self.content_type_id.split(':', 1) self.content_type.id = int(content_type_id) self.object_id = int(object_id) Maybe someone has an idea??? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Mocking The DB
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 > my way into the Models class to get to something I can mock. Install SQLite and delete/create/sqlall. It's not the same as your prod db, but a heck of a lot faster for read operations and more real than any mock you'd stub out. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem on Display Image
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 email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Property overrides
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): > post_date = models.DateTimeField(...) > posted = models.BooleanField(...) > > def get_posted(self): > return self.posted > > def set_posted(self, new_value): > if new_value != self.posted: > self.post_date = datetime.datetime.now() > > posted = property(get_posted, set_posted) Ah, right, good catch! Thanks for pointing out my mistake. Adrian -- Adrian Holovaty holovaty.com | djangoproject.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: help with pagination and other vars...
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 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problem with django settings module
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 properties -> Advanced -> Evironment variables I have added the following system variables: PYTHONPATH = c:\temp DJANGO_SETTINGS_MODULE = mysite.settings (solving my previously mentioned errors) probably not solving my problems, but maybe useful To add to the sys.path of Python: Create a .PTH file within a directory on sys.path (pref. .../python/lib/site-packages) To add to PYTHONPATH Edit the registry key: HKEY-LOCAL/SOFTWARE/PYTHON/PYTHONCORE/2.5/PYTHONPATH/(default) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Property overrides
> 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): > post_date = models.DateTimeField(...) > posted = models.BooleanField(...) > > def set_posted(self, new_value): > if new_value != self.posted: > self.post_date = datetime.datetime.now() > posted = property(set_posted) 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): post_date = models.DateTimeField(...) posted = models.BooleanField(...) def get_posted(self): return self.posted def set_posted(self, new_value): if new_value != self.posted: self.post_date = datetime.datetime.now() posted = property(get_posted, set_posted) I'm also not sure how Django would interact with having the posted model field effectively masked by the new property, so you might want to call your property w/ extra set functionality something different. YMMV. Nathan > > ...and any time you set the "posted" attribute, it would call > set_posted() behind the scenes. Like I said, though, I'm not sure > whether that would work with the way models are currently implemented. > (But if not, let's go ahead and fix that!) > > Adrian > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: static files
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 the subject) but it still will not > > serve images or stylesheets. > > The strange thing is I do not get 404's anymore since I configured > > things the way it should be done. So I started debugging .. Then I > > noticed the file views\static.py (where django.views.static.serve > > lives) isn't byte compiled !? > ... > > So obvious something is very wrong with > > my cvs checkout (downloaded two weeks ago). > > That's not obvious to me. > > Make sure that you have write permissions for the directory the pyc > should be created in. > Make sure you're importing django where you think you are, using the > same version of python you're using when you runserver. > (Make sure "manage.py" uses the same python as "python manage.py" would.) > Delete *.pyc from the django tree and run again. > Do a find for *.pyc anywhere on your machine. > > I'm pretty sure one of these things will turn something up. :) > > > > I'm sorry for the confusement, this was my mistake. The development server was serving the app version from the production (Apache) tree, because of something on the Python path. I now use two different pythons for production and development and everything is HUNKY-DORY. Anyhow thanks for the quick reply. G.J.Souverein. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem on Display Image
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 specify: MEDIA_URL = "http://127.0.0.1:8000/upload/"; Nathan [1] http://www.python.org/doc/lib/module-urlparse.html wangml wrote: > Hi, > > I meet a problem with ImageField when display the image it contains. > > > I defined an ImageField in myobject like this: > attachment = models.ImageField(upload_to='attachments') > > > I set the variables > # > MEDIA_ROOT = 'c:/myproject/upload' > MEDIA_URL = 'http://127.0.0.1:8000/upload' > # > in settings.py. And it succeed when uploading an attachment for an > object. The attachments were placed in folder > "c:/myproject/upload/attachments" > > > But when i was displaying the image, i did not get the right url of > attachment. > In my template, i put down > {{myobject.get_attachment_url}} > > > Unfortunately, the variable {{ myobject.get_attachment_url }} in > template did not return the right value. It returns like this, > "http://127.0.0.1:8000/attachments/0001.TIF";. But i expect > "http://127.0.0.1:8000/upload/attachments/0001.TIF";. > > What is wrong with myobject.get_attachment_url? As if it did not use > MEDIA_URL in my settings. > > > Thanks! > > > Minglei Wang > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Help with get absolute url
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 generic object detail page. At the moment, all I have defined for the get_absolute urls for both categories and organisations is the slug: nothing else. The urls return as follows( all using generic views): By category list: http://127.0.0.1:8000/categories/ By category detail: http://127.0.0.1:8000/categories/1/ (at the moment using the object_id) By organisation in category detail: http://127.0.0.1:8000/categories/1/k/ (where I've used the get_absolute_url method in the template, and 'k' is the organisation slug). Could someone please lend me a hand? A billion thanks in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Mocking The DB
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 mock. Cheers Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---