urls spanning different apps

2009-06-17 Thread C. Feldmann
Good morning, I was wondering how to implement the following without having to hardcode each url. I have different apps like i.e. books, authors, magazines, etc. Normally I would call upon default views by using something like: http://localhost/books/James_and_the_Giant_Peach or

Re: ModelForm, foreignkey, and hidden fields is null

2009-06-17 Thread Rochak Neupane
just tried it out. worked perfectly. thanks! On Tue, Jun 16, 2009 at 3:18 PM, Rochak Neupane wrote: > ohh, thanks, Daniel! I like your way. and i don't even my to expose the > user_id in a form.I'll try that. > > > On Mon, Jun 15, 2009 at 10:55 PM, Daniel Roseman

Re: urls spanning different apps

2009-06-17 Thread Daniel Roseman
On Jun 17, 7:39 am, "C. Feldmann" wrote: > Good morning, > > I was wondering how to implement the following without having to > hardcode each url. > I have different apps like i.e. books, authors, magazines, etc. > Normally I would call upon default views by using

Installing 'south' on windows

2009-06-17 Thread vishy
Hi, I have installed migration tool 'south' on windows.In settings.py, what path I will have to give in installed apps? I just gave 'south'. I got this error - AttributeError: 'module' object has no attribute 'adminsouth' thanks --~--~-~--~~~---~--~~ You received

Re: Installing 'south' on windows

2009-06-17 Thread vishy
k, got it working forgot a comma in setting file On Jun 17, 2:35 pm, vishy wrote: > Hi, > > I have installed migration tool 'south' on windows.In settings.py, > what path I will have to give in installed apps? I just gave 'south'. > I got this error - > AttributeError:

Re: How do I get a field value instead of in an admin selectbox?

2009-06-17 Thread Daniel Roseman
On Jun 17, 3:52 am, DaveB wrote: > I have what must be a common problem: there are three master files, > and a transaction in my admin site involves selecting an item from > each of these files. The field in the Transaction table is a foreign > key pointer to the master

Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread Richard Colley
I have a need to define 2 models, both with a large number of fields in common, but where in once case these common fields are completely optional, and in the other case they are mandatory. class XYZTemplate(Model): field_a = TextField( blank=True) field_b = TextField( blank=True)

really weird: App in INSTALLED_APPS, but django doesn't think so

2009-06-17 Thread Flavio Curella
I have built much time ago an app in Django (it was still pre-nfa era, django 0.96) now i'm updating it for django 1.1, but when I try to _reset_ the db schema, django can't find it in the INSTALLED_APPS setting, but it's actually there. Any idea about what could it be? Thanks, Flavio Curella.

Re: Building a widget from zero

2009-06-17 Thread Jonathan Buchanan
On Tue, Jun 16, 2009 at 4:43 PM, MiratCanBayrak wrote: > > Hi i wrote an application called category. As you guess it an > application to hold categories. Than i wanted to use it on my site. I > wrote a function that builds html code for displaying categories, but > now

Re: really weird: App in INSTALLED_APPS, but django doesn't think so

2009-06-17 Thread Flavio Curella
Nevermind. Messy code :P On Jun 17, 12:22 pm, Flavio Curella wrote: > I have built much time ago an app in Django (it was still pre-nfa era, > django 0.96) > > now i'm updating it for django 1.1, but when I try to _reset_ the db > schema, django can't find it in the

Re: Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread Richard Colley
Ok, after looking through the django wiki entries for AuditTrail (http://code.djangoproject.com/wiki/AuditTrail) and DynamicModels (http://code.djangoproject.com/wiki/DynamicModels), I guess I can see that there is a potential solution there. But I'd still appreciate any comments on the

Re: urls spanning different apps

2009-06-17 Thread C. Feldmann
Yup. That is exactly what I wanted to do... I hadn't made up my mind onto wether I wanted to force a redirect or stick with the original URL. But as you mentioned the SEO aspect is important and an added bonus would be that a canonical url would "feel" more structured. Thanks for the quick

Gallery album restricted to certain users

2009-06-17 Thread pagetribe
Hi, I have been creating a gallery, which has albums. I would like to restrict the albums, say album1 to a set of users, say userA and userB and album2 to userC. So userA & userB cannot view album2 and userC cannot view album1. >From the documentation it says: "Permissions are set globally per

Re: urls spanning different apps

2009-06-17 Thread James Gregory
On Jun 17, 7:39 am, "C. Feldmann" wrote: > Good morning, > > I was wondering how to implement the following without having to > hardcode each url. > I have different apps like i.e. books, authors, magazines, etc. > Normally I would call upon default views by

order by count of related object

2009-06-17 Thread R C
Hi, I would like to be able to select objects and order them by the count of a related field For example, I have 2 models: class Author(models.Model) name = models.Charfield(max_length=20) class Article(models.Model) author = models.ForeignKey(Author) content = models.TextField()

Re: Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread TiNo
You can acces a models field through Model._meta.fields. You can probably loop through these fields in your Model's __init__ method, and change their blank attribute to false. TiNo On Wed, Jun 17, 2009 at 13:32, Richard Colley wrote: > > Ok, after looking through the

Re: Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread Richard Colley
Thanks TiNo, Are there any caveats with this? e.g. to make syncdb etc. work correctly? On Jun 17, 10:13 pm, TiNo wrote: > You can acces a models field through Model._meta.fields. You can probably > loop through these fields in your Model's __init__ method, and change their >

Lighttpd rewrite and django login next

2009-06-17 Thread steveneo
I am quite new on all these things - lighttpd(1.4.18), django(ver 1.0.2 final) and python:(. My lighttpd and django are ready. One problem I got is the login next URL is always append to lighttpd rewrite URL. Here is detail of my question: My lighttpd uses fastcgi for multiple sites:

Re: order by count of related object

2009-06-17 Thread Daniel Roseman
On Jun 17, 1:12 pm, R C wrote: > Hi, > > I would like to be able to select objects and order them by the count > of a related field > > For example, I have 2 models: > > class Author(models.Model) >     name = models.Charfield(max_length=20) > > class Article(models.Model)

Branding block tag missing for login in Grappelli?

2009-06-17 Thread Brandon Taylor
Hi everyone, I'm looking into Grappelli's awesome admin interface, but my login is missing any sort of branding, and it looks like I'd have to override their template and add some CSS to fix it. Am I just missing something? or are other people seeing the same thing? Kind regards, Brandon

Re: How do I get a field value instead of in an admin selectbox?

2009-06-17 Thread DaveB
> Your question is very difficult to read - needs paragraphs. > > But I think the answer to your problem is to define a __unicode__ > method on the target model. > -- > DR. I will try to be clearer and briefer: Django's built-in admin system automatically generates data-entry forms for the

Re: How do I get a field value instead of in an admin selectbox?

2009-06-17 Thread Richard Colley
The answer was given to you in the previous post. Whatever __unicode__() returns from your model is what will be displayed. So, on your model, define a __unicode__ method: e.g. class Person(...): def __unicode__(self): return self.name On Jun 18, 12:03 am, DaveB

Re: Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread TiNo
On Wed, Jun 17, 2009 at 14:42, Richard Colley wrote: > > Thanks TiNo, > > Are there any caveats with this? e.g. to make syncdb etc. work > correctly? I don't know, as I never tried, and I am not very experienced with messing with the inner meta class, but: blank has

Re: Abstract models and 'blank' (etc.) constraints

2009-06-17 Thread Richard Colley
Yeah, I stripped out the nulls=True/False out of the example. I do want the database to enforce this constraint. I'll give it a try tomorrow and report back whether syncdb etc. are happy. If anyone has any wise words in the meantime... :) On Jun 18, 12:20 am, TiNo wrote: >

change list multi-field sort?

2009-06-17 Thread Joshua Russo
Is there a generally accepted workaround for the problem of sorting relational models by more than one field? I have a model that represents recurring payments between a person and an object and it would be really nice to order by the object, year, and creation date in the admin app change list.

Re: change list multi-field sort?

2009-06-17 Thread Joshua Russo
On Jun 17, 1:25 pm, Joshua Russo wrote: > Is there a generally accepted workaround for the problem of sorting > relational models by more than one field? I have a model that > represents recurring payments between a person and an object and it > would be really nice to

Re: Images not uploading in the admin tool

2009-06-17 Thread mmarshall
On Jun 9, 9:19 am, Sean Brant wrote: > "Did MediaTemple change something about the file system you have > access to?  It sounds like they must have changed something so that > the file locking code that used to work for your setup is no longer > working." > > That is what

Re: Images not uploading in the admin tool

2009-06-17 Thread Sean Brant
Nope, there customer support takes to long so I just gave up. Please post if you have any updates. Last I remember it might be a NFS issue on there end. Not really sure. On Jun 17, 2009, at 9:43 AM, mmarshall wrote: > > On Jun 9, 9:19 am, Sean Brant

Re: order by count of related object

2009-06-17 Thread R C
Thanks for your fast reply I realize that there is no "count" field in my article model. However in my templates I am able to do things like: Author.article_set.count I just can't do the same thing in my views when building a queryset.I would really like to be able to select Authors

Re: Images not uploading in the admin tool

2009-06-17 Thread mmarshall
Well, here's what I know: I had this issue several months back and 'solved' it by disabling the in memory upload handler. I wrote a little about it at the bottom of this thread: https://forums.mediatemple.net/viewtopic.php?id=2514 But it looks like in Django 1.1beta the

Re: order by count of related object

2009-06-17 Thread Alex Gaynor
On Wed, Jun 17, 2009 at 10:00 AM, R C wrote: > > Thanks for your fast reply > > I realize that there is no "count" field in my article model. However > in my templates I am able to do things like: > Author.article_set.count > > I just can't do the same thing in my

Re: order by count of related object

2009-06-17 Thread R C
Thanks, it worked! Both of you have been very helpful. On Jun 17, 5:04 pm, Alex Gaynor wrote: > On Wed, Jun 17, 2009 at 10:00 AM, R C wrote: > > > Thanks for your fast reply > > > I realize that there is no "count" field in my article model.  

Re: django "Unknown column 'inventory_machine.serial_num error

2009-06-17 Thread Dan Sheffner
This was because I had bad sys.path.append directories hidden in a global file. Fixed this to point to right directory and all problems went away. Wish I had the last 24 hrs back though :( On Tue, Jun 16, 2009 at 6:26 PM, thesheff wrote: > I have cleaned up my model view

Does Django have to run with Python-2.5 ?

2009-06-17 Thread Shuge Lee
Does Django have to run with Python-2.5 ? l...@lab ~/online $ python2.6 manage.py runserver Traceback (most recent call last): File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management l...@lab ~/online $

Re: Does Django have to run with Python-2.5 ?

2009-06-17 Thread Alex Gaynor
On Wed, Jun 17, 2009 at 11:44 AM, Shuge Lee wrote: > > Does Django have to run with Python-2.5 ? > > > l...@lab ~/online $ python2.6 manage.py runserver > Traceback (most recent call last): > File "manage.py", line 2, in >from django.core.management import

Does Django have to run with Python-2.5 ?

2009-06-17 Thread Shuge Lee
Does Django have to run with Python-2.5 ? l...@lab ~/online $ python2.6 manage.py runserver Traceback (most recent call last): File "manage.py", line 2, in from django.core.management import execute_manager ImportError: No module named django.core.management l...@lab ~/online $

Re: Does Django have to run with Python-2.5 ?

2009-06-17 Thread Michael
On Wed, Jun 17, 2009 at 12:44 PM, Shuge Lee wrote: > > Does Django have to run with Python-2.5 ? > > > l...@lab ~/online $ python2.6 manage.py runserver > Traceback (most recent call last): > File "manage.py", line 2, in >from django.core.management import

confusion using defer() or only()

2009-06-17 Thread felix
Django 1.1 rev 11018 stores = ReleaseStoreLink.objects.filter(release=self) \ .select_related('store','store__contact') \ .only('url','store__name','store__contact__url') ss = stores[0] ReleaseStoreLink has a method logo, it is not a db field when using

Saving Foreign Key Help

2009-06-17 Thread Dan Sheffner
I have this in my model: class Machine(models.Model): name = models.CharField(max_length=100) cpuInfo = models.ForeignKey(Cpu, blank=True, null=True) class Cpu(models.Model): l = models.CharField(max_length=50) num = models.IntegerField() so basically I add machines to the

Re: Make a "save and preview" button in admin.

2009-06-17 Thread Liam Chasteen
Check out the article on developerworks: http://www.ibm.com/developerworks/opensource/library/os-django-admin/index.html The method they show changes the redirect after saving changes, but should be easily modifiable to simply create a popup preview window when the user clicks the "Save and

Scientific Data Frontend with Django

2009-06-17 Thread blaine
Hey guys, I have a lot of data from various testing samples (simple 2D plotting points) in .csv format. I am looking to design a system to manage things like plotting, calculations, selecting individual samples and tests, etc. by creating a data manager with an intuitive interface. My

Re: Saving Foreign Key Help

2009-06-17 Thread J. Cliff Dyer
On Wed, 2009-06-17 at 12:55 -0500, Dan Sheffner wrote: > I have this in my model: > > class Machine(models.Model): > name = models.CharField(max_length=100) > cpuInfo = models.ForeignKey(Cpu, blank=True, null=True) > > class Cpu(models.Model): > l = models.CharField(max_length=50)

Re: Saving Foreign Key Help

2009-06-17 Thread Dan Sheffner
Yes so I start with machines and then I find out what CPU's they have and add them to the database. I get this error: TypeError: 'Cpu' object is not iterable So this is what I have so far: def processor(self): self.machineList = Machine.objects.values_list('name',

TypeError : expected string or buffer when saving model object

2009-06-17 Thread dj
Defined the this model: class ModifyGroup(models.Model): user = models.ForeignKey(User, verbose_name='User', related_name='group_mod_request', null=True, blank=True) #account to be modified date = models.DateField('Request Date', auto_now_add=True) group_from = models.CharField('From

Re: Saving Foreign Key Help

2009-06-17 Thread Dan Sheffner
ok Fixed it. Thanks for the help your example def helped. I have been banging my head for awhile :) def processor(self): self.machineList = Machine.objects.values_list('name', flat=True).filter(typeInfo__l__exact="Linux Server") for server in self.machineList:

Re: TypeError : expected string or buffer when saving model object

2009-06-17 Thread Karen Tracey
On Wed, Jun 17, 2009 at 2:46 PM, dj wrote: > > Defined the this model: > > [snip] > When the data table (sqlite) is empty, I can save an instance of this > object with no errors. > However, once there is an existing instance of the object in the data > table, saving

django admin delete oneToOneField ?

2009-06-17 Thread Dan Sheffner
ok so I have a list of servers that have a one to one relationship with a table called cpu. When I delete a server from the server table it should also delete it one to one relationship with the cpu entry. right? do I need to pass something extra in the models.py to have this happen?

WebFaction + Django Fixture: Help?

2009-06-17 Thread Keyton Weissinger
I have a nice test fixture that loads my local database without incident. I'm using postgresql 8.3 at home on ubuntu. I use the fixture at home all the time. Trying to run it on webfaction, I get the following error: [key...@web58 schoolicity]$ python2.5 manage.py loaddata full_load.json

Re: WebFaction + Django Fixture: Help?

2009-06-17 Thread Andy McKay
On 17-Jun-09, at 12:48 PM, Keyton Weissinger wrote: > backends/util.py", line 19, in execute >return self.cursor.execute(sql, params) > DataError: value too long for type character varying(4) > > > Any ideas? The unhelpful answer is that the field is too long. One way to get this is to

SMTPDataError with mail_admins, no problem with send_mail

2009-06-17 Thread ozgurisil
Hello, When I try to send an e-mail via mail_admins method, I receive an SMTPDataError with the value: (503, '5.5.1 RCPT first. e9sm3788894muf. 32'). Here is the code: def send_mail(self): from django.core.mail import mail_admins, send_mail

Re: Make a "save and preview" button in admin.

2009-06-17 Thread Rodrigo Cea
Thanks, I'll look into it and post back if I solve this. Rodrigo On Jun 17, 1:32 pm, Liam Chasteen wrote: > Check out the article on developerworks: > > http://www.ibm.com/developerworks/opensource/library/os-django-admin/... > > The method they show changes the

Re: Django gives little information about custom raised exceptions

2009-06-17 Thread Ben Davis
This is just a shot in the dark, but you might try setting the "message" property on your exception object. It could be that django's pretty exception printing is calling that directly instead of casting to a string. If that's the case, you should file a bug because Exception.message is

Re: Template Question

2009-06-17 Thread Ben Davis
Nope, you'll need to set a variable in your view. You can also try creating your own filter such that {% if friend|is_in_group %} would work (it's pretty easy to do, just check out the docs for custom template filters) On Tue, Jun 16, 2009 at 2:40 PM, CrabbyPete wrote: >

Re: Gallery album restricted to certain users

2009-06-17 Thread Rajesh D
On Jun 17, 7:41 am, pagetribe wrote: > Hi, > > I have been creating a gallery, which has albums. I would like to > restrict the albums, say album1 to a set of users, say userA and userB > and album2 to userC. So userA & userB cannot view album2 and userC > cannot view

Re: WebFaction + Django Fixture: Help?

2009-06-17 Thread Keyton Weissinger
Thanks, Andy. New problem... I've recreated the problem locally on postgres. But I've gone back to sqlite3 and the loaddata works from scratch. Is there a way I can tell which items from the sqlite3 db is giving me problems in postgres? Thank you! Keyton On Jun 17, 3:51 pm, Andy McKay

Re: Template Question

2009-06-17 Thread Steve Howell
Another option is to install the snippet below, which supports "in": http://www.djangosnippets.org/snippets/1350/ On Jun 17, 1:53 pm, Ben Davis wrote: > Nope, you'll need to set a variable in your view.  You can also try creating > your own filter such that {% if

ANN: elif added to smart_if tag

2009-06-17 Thread Steve Howell
For those of you who, like me, have enjoyed SmileyChris's excellent smart if tag, you may find the following extension useful: http://www.djangosnippets.org/snippets/1572/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: change list multi-field sort?

2009-06-17 Thread Rajesh D
Hi Josh, On Jun 17, 10:25 am, Joshua Russo wrote: > Is there a generally accepted workaround for the problem of sorting > relational models by more than one field? I have a model that > represents recurring payments between a person and an object and it > would be

Re: Alternate authentication

2009-06-17 Thread Ben Davis
I believe what you are looking for is a custom authentication backend. I had to do this for one of my sites that used an XMLRPC api to authenticate against a remote server. You'll want to create a class that extends django.contrib.auth.backends.ModelBackend , and add it to the

Re: Scientific Data Frontend with Django

2009-06-17 Thread Rajesh D
On Jun 17, 2:06 pm, blaine wrote: > Hey guys, >   I have a lot of data from various testing samples (simple 2D > plotting points) in .csv format.  I am looking to design a system to > manage things like plotting, calculations, selecting individual > samples and tests, etc.

One to Many+foreign key Query: best way to build the optimal result

2009-06-17 Thread Sam Walters
Here is the essentials from my models.py file: class Event (models.Model): contact = models.CharField(max_length=100) email = models.CharField(max_length=100) url =

Reverse DB lookup returns too many instances

2009-06-17 Thread IanR
I've recreated this behavior with the following examples. (using 1.0) #models.py class Building(models.Model): name = models.CharField(max_length=10) floors = models.IntegerField() class Unit(models.Model): unit_number = models.IntegerField() bedrooms = models.IntegerField()

Re: Reverse DB lookup returns too many instances

2009-06-17 Thread Alex Gaynor
On Wed, Jun 17, 2009 at 8:49 PM, IanR wrote: > > I've recreated this behavior with the following examples. (using > 1.0) > > #models.py > class Building(models.Model): > name = models.CharField(max_length=10) > floors = models.IntegerField() > > class

Re: Gallery album restricted to certain users

2009-06-17 Thread pagetribe
I would prefer my own views. On Jun 18, 6:58 am, Rajesh D wrote: > On Jun 17, 7:41 am, pagetribe wrote: > > > Hi, > > > I have been creating a gallery, which has albums. I would like to > > restrict the albums, say album1 to a set of users, say

Re: How do I get a field value instead of in an admin selectbox?

2009-06-17 Thread DaveB
Awesome, __unicode__() works fine. Thanks very much for your help! -Dave --~--~-~--~~~---~--~~ 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

Re: Scientific Data Frontend with Django

2009-06-17 Thread Vincent
That sounds like a great idea. Something i have been meaning to try for a while but haven't gotten around to. For a class website i did try to use matplotlib to create graphs from user provided data within django but couldn't figure out how to get it to work smoothly. Ended up using Jacobs

How to preset a foreign key choice field in a ModelaaForm?

2009-06-17 Thread adelaide_mike
if request.method == 'GET': if listing_id > '0': listing=Listing.objects.get(pk=listing_id) form = ListingForm(instance=listing) else: print "In listings GET source=",

Re: Scientific Data Frontend with Django

2009-06-17 Thread Nick Fishman
A friend of mine is using Django with matplotlib to create graphs from CSV files, and it's turning out pretty well. I haven't yet tried googlecharts, but it looks promising. The main difficulty he had with Matplotlib was transitioning to Apache/mod_python after working with the Django development

Re: How to preset a foreign key choice field in a ModelaaForm?

2009-06-17 Thread adelaide_mike
Oops werong action - incomplete message. I have a ModelForm: class ListingForm(ModelForm): class Meta: model = Listing that has a method that, for a new record, should set the ForeighKey field "source" to an object identified in the UserProfile. The "date" value is