Re: How can i populate app engine(production environment) database with local sdk database
Please help me out On Mar 29, 11:04 pm, Eximius wrote: > Hi all, > I have created a django application using app engine sdk, and have > stored data in database using forms. But the problem i am getting when > i deploy it, the data I stored is not there in the app engine > datastore. > So how can i populate app engine database with local database/data and > also vice-versa . > I am a newbie to django. I hope you will help me out > 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
display user.email in a custom model
Hi, I've this model: -- class Person(models.Model): user = models.ForeignKey(User) Can I display the user.email or user.first_name in the admin site administration? I try this: --- def __unicode__(self): return u"%s %s" % (self.user, self.user.first_name) but don't work. Thanks, Alfredo -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How do I properly unit test a Django session?
Le mercredi 31 mars 2010 05:40:43, adambossy a écrit : > The behavior of Django sessions changes between "standard" views code > and test code, making it unclear how test code is written for > sessions. Googling this yields two relevant discussions about this > issue: > > 1. "Easier manipulation of sessions by test client" [http:// > code.djangoproject.com/ticket/10899] > 2. "test.Client.session.save() raises error for anonymous > users" [http://code.djangoproject.com/ticket/11475] > > I'm confused because both tickets have different ways of dealing with > this problem and they were both Accepted. I assume this means they > were patched and the behavior is now different. I also don't know to > which versions these patches would pertain. > > If I'm writing a unit test in Django 1.0, how would I set up my > session store for sessions to work as they do in the browser? > Hi, Perhaps, you should be more explicit with your problem. I am using the client and there is no problem at all. For instance; class GeneriqueTestCases(TestCase): def test_login_admin(self): self.failUnlessEqual(self.client.login(username='admin',password='admin'),True) self.client.logout() response=self.client.get("/accounts/accueil/") self.assertRedirects(response,'/accounts/login/?login=/accounts/accueil/') def test_login_domaine(self): self.client.login(username='admin', password='admin') response=self.client.get('/accounts/accueil/') self.assertEqual(response.context['user'].username, 'admin') d=Domaine.objects.get(nom='DomaineAdmin') self.assertEqual(self.client.session.get('domaine'),d) In the last test, I am explicitely using informations stored in a session. (However, I have searched a long time before I understand that some variables was set in the accounts/accueil/ page :-( ) Thierry -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
RPC4Django - can't pass Boolean args nor Keyword args
Hi, anyone using RPC4Django has faced this https://bugs.launchpad.net/rpc4django/+bug/552437 ? Cheers, SimO -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
rpc4django - passing keyword arguments or boolean arguments
Hi, anybody using rpc4django has faced this? https://bugs.launchpad.net/rpc4django/+bug/552437 Cheers, SimO -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
after except IntegrityError no database values are returned anymore
Dear Django Users, There is a part in my code where i check if there is an IntegrityError on certain values and is so the error is caught and saved in a list. To be able to do this i imported from psycopg2 the IntegrityError. This all does work like it should the only thing is that after that i caught the integrityerror and i want to access other data from the database no values are returned as if there are no values present. does anybody have a clue what's going on and how i could solve it. best regards, Richard -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Apache hang-up after booting
Hi everybody, I'm using django (integrated in an application, omero) as a production server with mod_python (v3.3.1-147.35) and apache (v2.2.10-2.8.1). Unfortunately after rebooting the server apache seems to hang-up. When opening the website I just see the progress-indicator gif. When restarting the apache server by hand or disabling mod_python redirect everything works fine. My mod_python (located in /etc/apache2/conf.d/) script looks like this: SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE omeroweb.settings PythonDebug On PythonPath "['/srv/omero/omero_dist/lib/python', '/srv/omero/ omero_dist/lib/python/omeroweb'] + sys.path" The apache error_log: [Wed Mar 31 14:13:23 2010] [notice] caught SIGTERM, shutting down [Wed Mar 31 14:14:28 2010] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads. [Wed Mar 31 14:14:28 2010] [notice] mod_python: using mutex_directory / tmp [Wed Mar 31 14:14:28 2010] [notice] Apache/2.2.10 (Linux/SUSE) PHP/ 5.2.11 with Suhosin-Patch mod_python/3.3.1 Python/2.6 mod_wsgi/2.5 configured -- resuming normal operations Has anyone an idea what could lead to the error when rebooting? -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: auth.Message ignores directions from database router - Possible RelatedManager bug
On Mon, Mar 29, 2010 at 9:28 AM, xin wrote: > I am unsure if this a bug in Django, or django-multidb-router, or > something I've done wrong. > > I'm using django-multidb-router from here: > http://github.com/jbalogh/django-multidb-router > With two database definitions, a read_only_user and a read_write_user > (with the intentions of having multiple read-only definitions) > > As far as I can tell, all reads get directed to the read_only_user and > all writes get detected to read_write_user. That is, until > contrib.Admin tries to create a new user message for a save() which > for tries to write with the read_only_user and fails. > > When overriding auth.Message.save() with an empty function, the admin > interface resumes working as expected, with reads and writes being > sent to the appropriate databases. > > > From what I guess by looking at the traceback, `RelatedManager` is > overriding `get_query_set()` to set the query-set's DB. But when the > `create()` call gets down to `models.query.QuerySet.create()`, > `obj.save()` (line 350) is called, and forces `using` to self.db, > negating any direction from the Router. Apologies for not replying sooner - this message was on my todo list, but got buried in other stuff. I presume you are the person behind #13250 -- in which case, I just committed a fix in r12895. It turns out it was an error in the way routing information was used when calling create() on a foreign key (in this case, user.message_set.create()). I've corrected the error; let me know if you have any more problems. 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Passing hidden foreign key to form as initial value
Displayed fields resolve as expected, hidden fields cause errors. This works: in the model CourseBook has a foreign key to Course In the view: course = Course.objects.get(pk=whatever) form = CouseBook(initial = {'course': course}) in the Form: class CourseBook(ModelForm): class Meta: model = CourseBooking The web page now displays a picklist of courses with the initial value highlighted. I can now do a form.save() no problem. However, if I make the course a hidden field, which is what I want. class CourseBook(ModelForm): course = forms.CharField(widget=forms.HiddenInput()) class Meta: model = CourseBooking then when I come to save() I get a ValueError, unable to assign "My course" etc. as it tries to put the name of the course into the foreign key instead of a course instance. I can work around this putting a save method on the form, but it seems to me django should resolve this for me -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Hotmail contacts using python hotmail sdk
i have the SDK with me, source code for getting hotmail contacts in DJANGO environment: -- from lib.WindowsLiveLogin import ConsentToken import urllib, urllib2 def hotmail_login(request): wll = WindowsLiveLogin(appid=settings.WINDOWS_APPID,secret=settings.WINDOWS_SECRET,policyurl='') url = wll.getConsentUrl("Contacts.View") return redirect(url) def hotmail_callback(request): wll = WindowsLiveLogin(appid=settings.WINDOWS_APPID,secret=settings.WINDOWS_SECRET, policyurl='') class Obj(object): pass fs = {} for var in request.POST: fs[var] = Obj() fs[var].value = request.POST.get(var) consent_token = wll.processConsent(fs) if consent_token and consent_token.isValid(): lid = consent_token.getLocationID() lid16 = int(lid, 16) to_signed_64 = lambda x: x < 2**63 and x or x - 2**64 lid_s64 = to_signed_64(lid16) url = 'https://livecontacts.services.live.com/users/@c...@%s/rest/ invitationsbyemail' % lid_s64 req = urllib2.Request(url) req.add_header('Authorization', 'DelegatedToken dt="%s"' %urllib.unquote(consent_token.getDelegationToken())) response = urllib2.build_opener().open(req) the_page = response.read() when i am trying to run the above script in the lib path ,shows error: from lib.WindowsLiveLogin import ConsentToken ImportError: No module named lib.WindowsLiveLogin Also i need a console script without django framework,can anybody tell me on what should i modify on the above script. -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Hotmail contacts using python library
can anybody tell me how to write a script to import hotmail contacts with windowslivelogin.py library,i have a web based script used for django environment brlow: from lib.WindowsLiveLogin import ConsentToken import urllib, urllib2 def hotmail_login(request): wll = WindowsLiveLogin(appid=settings.WINDOWS_APPID,secret=settings.WINDOWS_SECRET,policyurl='') url = wll.getConsentUrl("Contacts.View") return redirect(url) def hotmail_callback(request): wll = WindowsLiveLogin(appid=settings.WINDOWS_APPID,secret=settings.WINDOWS_SECRET, policyurl='') class Obj(object): pass fs = {} for var in request.POST: fs[var] = Obj() fs[var].value = request.POST.get(var) consent_token = wll.processConsent(fs) if consent_token and consent_token.isValid(): lid = consent_token.getLocationID() lid16 = int(lid, 16) to_signed_64 = lambda x: x < 2**63 and x or x - 2**64 lid_s64 = to_signed_64(lid16) url = 'https://livecontacts.services.live.com/users/@c...@%s/rest/ invitationsbyemail' % lid_s64 req = urllib2.Request(url) req.add_header('Authorization', 'DelegatedToken dt="%s"' %urllib.unquote(consent_token.getDelegationToken())) response = urllib2.build_opener().open(req) the_page = response.read() How this can be achieved in python console script with delauth-python 1.2 lib but no djago environment? thanx 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Model field default value and form field weirdness
Hi guys, I'm working on a cms running over django1.1.1 and I'm facing a weird problem. I have a BlogPost model that uses a callable (datetime.datetime.now) as default value for some field. I created my own views for manage blog posts. The view make use of a BlogPostForm ModelForm class, defined on another module. My code is organized in 3 files: models.py, views.py and forms.py. When I instantiate the BlogPostForm class, it expand the default value and the unbound form get his fields filled with the callable. If the callable is "datetime.datetime.now", the field is filled with the now value. The problem is that this expanding of callables are done on "formfield" method of the field class and this method is called in the form instantiation. This cause the default value to be expanded a first_time and stay the same for the next hits. Did you undestand what I meant? I think this is a bug. Did someone faced a similar problem? Best regards, -- Michel Sabchuk Brasil -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
modelform validation
Hi all! I have a modelform and I want to customize validation. I'm overriding the method clean_(). When I'm saving the form I want to see if a specific user has been already assigned to a project. The only way he can ben assigned again is if he's an inactive user, so: models.py Class User(models.Model): name = models.CharField(...) active = models.BooleanField() ... Class Project(models.Model): user = models.ForeignKey(User) ** forms.py Class ProjectForm(ModelForm) def clean_name(self): user = self.cleaned_data['user'] if User.objecs.filter(user.id, active=True): raise forms.ValidationError(_("This man has been already assign to a partner")) return user When I'm creating a new project it works fine (I believe, haven't been tested yet), but when editing it throws an error because the user already exists, and that's obvious. So, I want to be able to verify if it is a new instance or if it is an instance being edited. 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Model field default value and form field weirdness
> The problem is that this expanding of callables are done on > "formfield" method of the field class and this method is called in the Sorry by this email guys, I just found a ticket talking about it: http://code.djangoproject.com/ticket/11940 It seems the problem is fixed. Thanks! -- Michel Sabchuk Brasil -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
script to import hotmail contacts with python hotmail contacts api
can anybody tell me how to write a script to import hotmail contacts with windowslivelogin.py library,i have a web based script used for django environment below: from lib.WindowsLiveLogin import ConsentToken import urllib, urllib2 def hotmail_login(request): wll = WindowsLiveLogin(appid= settings.WINDOWS_APPID,secret=settings.WINDOWS_SECRET,policyurl='') url = wll.getConsentUrl("Contacts.View") return redirect(url) def hotmail_callback(request): wll = WindowsLiveLogin(appid=settings.WINDOWS_APPID,secret=settings.WINDOWS_SECRET, policyurl='') class Obj(object): pass fs = {} for var in request.POST: fs[var] = Obj() fs[var].value = request.POST.get(var) consent_token = wll.processConsent(fs) if consent_token and consent_token.isValid(): lid = consent_token.getLocationID() lid16 = int(lid, 16) to_signed_64 = lambda x: x < 2**63 and x or x - 2**64 lid_s64 = to_signed_64(lid16) url = 'https://livecontacts.services.live.com/users/@c...@%s/rest/ invitationsbyemail' % lid_s64 req = urllib2.Request(url) req.add_header('Authorization', 'DelegatedToken dt="%s"' %urllib.unquote(consent_token.getDelegationToken())) response = urllib2.build_opener().open(req) the_page = response.read() How this can be achieved in python console script with delauth-python 1.2 lib but no djago environment? thanx 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
modelform validation
Hi all! I have a modelform and I want to customize validation. I'm overriding the method clean_(). When I'm saving the form I want to see if a specific user has been already assigned to a project. The only way he can ben assigned again is if he's an inactive user, so: models.py Class User(models.Model): name = models.CharField(...) active = models.BooleanField() ... Class Project(models.Model): user = models.ForeignKey(User) ** forms.py Class ProjectForm(ModelForm) def clean_name(self): user = self.cleaned_data['user'] if User.objecs.filter(user.id, active=True): raise forms.ValidationError(_("This man has been already assign to a partner")) return user When I'm creating a new project it works fine (I believe, haven't been tested yet), but when editing it throws an error because the user already exists, and that's obvious. So, I want to be able to verify if it is a new instance or if it is an instance being edited. 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Error in image upload while copying file
On Mar 30, 10:53 am, bruno desthuilliers wrote: > Uh. Oh, well - then you indeed have a problem :( > Hum... Is that legacy code ? Looks pretty ugly to me - wouldn't pass a > code review here. > Well, assuming you're using at least Django 1.0, I suggest you get rid > of this mess and make appropriate use of FileField / > ImageField.upload_to: > > http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mod... Thanks, Bruno, that gives me a toehold. Yes, that's legacy code; I'm guessing it was originally written for a pre-1.0 Django, and as noted above the original developers suggested that downgrading Python to 2.4 would solve the problem. (Ugh.) I'll follow up on the ImageField.upload_to and see how that does. Thanks, pjm -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
"format" error with django-piston
Hi everyone, I know there's a Google Group for django-piston, but there's not very much conversation on that group, so I'm re-posting here as well. I'm getting an error when running the "blogserver" example site included with Piston: AttributeError at /api/posts/ 'Blogpost' object has no attribute 'format' Googling this has turned up one post on the Bitbucket site: http://bitbucket.org/jespern/django-piston/issue/54/got-an-error-on-piston-022-blogpost-object-has-no-attribute, which says there's a patch, like 9 months ago, but that the patch doesn't work. The problem seems related to the @classmethod resource_uri, but I'm uncertain as to how to fix this. Kind regards, Brandon -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passing hidden foreign key to form as initial value
Hi there, Instead of using the course object in your initial data, which will pass in the __unicode__ representation of the object, pass in the id: form = CouseBook(initial = {'course': course.id}) That should get you the numeric id, but you'll also need to override your save method to get the course object to assign when you save your CourseBook form, as you can't assign an integer (coming from your hidden form field) to the value of a ForeignKey field on a model. HTH, Brandon On Mar 31, 8:20 am, phoebebright wrote: > Displayed fields resolve as expected, hidden fields cause errors. > > This works: > > in the model > CourseBook has a foreign key to Course > > In the view: > > course = Course.objects.get(pk=whatever) > form = CouseBook(initial = {'course': course}) > > in the Form: > > class CourseBook(ModelForm): > class Meta: > model = CourseBooking > > The web page now displays a picklist of courses with the initial value > highlighted. I can now do a form.save() no problem. > > However, if I make the course a hidden field, which is what I want. > > class CourseBook(ModelForm): > course = forms.CharField(widget=forms.HiddenInput()) > > class Meta: > model = CourseBooking > > then when I come to save() I get a ValueError, unable to assign "My > course" etc. as it tries to put the name of the course into the > foreign key instead of a course instance. > > I can work around this putting a save method on the form, but it seems > to me django should resolve this for me -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: modelform validation
Hi there, When calling def clean_name(self):, you can see if your instance has an id or not: def clean_name(self): if not self.id: #this would be a new record else: #this would be an existing record HTH, Brandon On Mar 31, 9:24 am, Emanuel wrote: > Hi all! > > I have a modelform and I want to customize validation. > > I'm overriding the method clean_(). > > When I'm saving the form I want to see if a specific user has been already > assigned to a project. The only way he can ben assigned again is if he's an > inactive user, so: > > models.py > Class User(models.Model): > name = models.CharField(...) > active = models.BooleanField() > ... > > Class Project(models.Model): > user = models.ForeignKey(User) > > ** > > forms.py > Class ProjectForm(ModelForm) > > def clean_name(self): > user = self.cleaned_data['user'] > if User.objecs.filter(user.id, active=True): > raise forms.ValidationError(_("This man has been > already assign > to a partner")) > return user > > When I'm creating a new project it works fine (I believe, haven't been tested > yet), but when editing it throws an error because the user already exists, and > that's obvious. So, I want to be able to verify if it is a new instance or if > it is an instance being edited. > > 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: modelform validation
Test if self.instance.user is not None, if so, change the queryset to exclude the self.instance.user: http://gist.github.com/350440 __ Vinícius Mendes Solucione Sistemas http://solucione.info/ On Wed, Mar 31, 2010 at 11:24 AM, Emanuel wrote: > Hi all! > > I have a modelform and I want to customize validation. > > I'm overriding the method clean_(). > > When I'm saving the form I want to see if a specific user has been already > assigned to a project. The only way he can ben assigned again is if he's an > inactive user, so: > > models.py > Class User(models.Model): >name = models.CharField(...) >active = models.BooleanField() >... > > Class Project(models.Model): >user = models.ForeignKey(User) > > ** > > forms.py > Class ProjectForm(ModelForm) > >def clean_name(self): >user = self.cleaned_data['user'] >if User.objecs.filter(user.id, active=True): >raise forms.ValidationError(_("This man has been > already assign > to a partner")) >return user > > > When I'm creating a new project it works fine (I believe, haven't been > tested > yet), but when editing it throws an error because the user already exists, > and > that's obvious. So, I want to be able to verify if it is a new instance or > if > it is an instance being edited. > > > 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-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: display user.email in a custom model
Hmm, you should be able to do that. I do exactly that in one of my models. The only I differences I see between yours and mine is that you return a unicode string, rather than just a string, and you wrote self.user, rather than self.user.something. -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Getting strange email from "dreamhost"
Hi guys, I've gotten two emails from "Mail Delivery Subsystem " with the subject "Your message was NOT received by django-us...@googlegroups.com!". The body is below. Anyone know why I'm getting these? Is anyone else getting them? I have no affiliation with Dreamhost or at all, so this is...strange. We're sorry.. your email was unable to be processed by our automatic support system, and so is being returned to you. We could not find your email address in our customer database and so couldn't accept your email. Due to the HUGE volume of spam we receive at this address, we've been forced to implement this new policy. Therefore, please just re-submit your message at: http://www.dreamhost.com/contact.cgi All messages submitted through that form are guaranteed to be received, even if you aren't currently a customer! Our apologies for the inconvenience, -- The Happy DreamHost Support Team! -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting strange email from "dreamhost"
I'm getting those from this forum as well. On Mar 31, 10:13 am, Wiiboy wrote: > Hi guys, > I've gotten two emails from "Mail Delivery Subsystem > " with the subject "Your message was NOT > received by django-us...@googlegroups.com!". > The body is below. Anyone know why I'm getting these? Is anyone else > getting them? I have no affiliation with Dreamhost or at all, so this > is...strange. > > We're sorry.. your email was unable to be processed by our automatic > support system, and so is being returned to you. > > We could not find your email address in our customer database and so > couldn't accept your email. Due to the HUGE volume of spam we receive > at this address, we've been forced to implement this new policy. > > Therefore, please just re-submit your message at: > > http://www.dreamhost.com/contact.cgi > > All messages submitted through that form are guaranteed to be > received, > even if you aren't currently a customer! > > Our apologies for the inconvenience, > -- > The Happy DreamHost Support Team! -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: transactions
On 31 Mar, 06:04, Continuation wrote: > On Mar 30, 8:33 am, Tomasz Zieliñski > > wrote: > > If you take a look at TransactionMiddleware source: > > >http://code.djangoproject.com/browser/django/tags/releases/1.1.1/djan... > > > then you'll see that it's just commit_on_success in disguise: > > >http://code.djangoproject.com/browser/django/tags/releases/1.1.1/djan... > > So that means I don't need TransactionMiddleware if I use > @transaction.commit_on_success, right? If you put @transaction.commit_on_success explicitly in your code, then you're doing TransactionMiddleware manually, so the answer is yes. > > > Also, you can take a look at my post here, to avoid some transaction- > > related problems in future: > > >http://stackoverflow.com/questions/2235318/how-do-i-deal-with-this-ra... > > Thanks. > > I assume that calling transaction.commit() after the IntegrityError > exception is to refresh the frozen view. But I'm not sure I understand > why transaction.commit() would do that. Can you elaborate? Because on default MySQL isolation level, i.e. REPEATABLE READ, view (or snapshot) of db table is frozen after first access to it (there are some more detail's to it). To get new snapshot you have to open new transaction, and that's what commit do. http://dev.mysql.com/doc/refman/5.0/en/set-transaction.html#isolevel_repeatable-read (Note that in above link they say about SELECT, and I don't remember if create() also SELECTs or it's INSERT that freezes table, but the fact is table become frozen for transaction). > > Also in your stackoverflow answer you said the default for MySQL is > AUTOCOMMIT=OFF. but in the Django doc (http://docs.djangoproject.com/ > en/dev/topics/db/transactions/) it was stated that > > "Django's default behavior is to run with an open transaction which it > commits automatically... This is much like the auto-commit setting for > most databases." > > So is auto-commit on or off by default? It's the tricky part. There are *two* auto-commits - one is in DB, and second one is in Django. Autocommit in DB is OFF by default (according to Python DB API spec, and Django doesn't seem to change that), whereas Django autocommit is turned ON by default (and documentation is not clear here). DB autocommit is something you can read about in DB docs, (for MySQL Innodb: http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-model.html) where as Django autocommit is simple mechanism that calls db COMMIT after each query that modifies db (e.g. INSERT caused by save()) - and that's the whole magic. -- Tomasz Zielinski http://pyconsultant.eu -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passing hidden foreign key to form as initial value
Brandon, Thanks for your suggestion. I tried passing it an ID, but as you say, I also have to override the save. What I don't understand is why it does it fine if the form includes the foreign key in a popup? They are both passing back integers after all. Also failed to get the save method working, tried to pass in the course instance, but it still ends up trying to save with the id of the course. Is it not using cleaned_data? def save(self, course=False, force_insert=False, force_update=False, commit=True): if course: self.cleaned_data['course'] = course return super(CourseBook, self).save(commit=commit) Any suggestions welcome as I've spent the whole afternoon on this - I won't go through the many other workarounds that havn't worked! Phoebe. On Mar 31, 4:02 pm, Brandon Taylor wrote: > Hi there, > > Instead of using the course object in your initial data, which will > pass in the __unicode__ representation of the object, pass in the id: > > form = CouseBook(initial = {'course': course.id}) > > That should get you the numeric id, but you'll also need to override > your save method to get the course object to assign when you save your > CourseBook form, as you can't assign an integer (coming from your > hidden form field) to the value of a ForeignKey field on a model. > > HTH, > Brandon > > On Mar 31, 8:20 am, phoebebright wrote: > > > Displayed fields resolve as expected, hidden fields cause errors. > > > This works: > > > in the model > > CourseBook has a foreign key to Course > > > In the view: > > > course = Course.objects.get(pk=whatever) > > form = CouseBook(initial = {'course': course}) > > > in the Form: > > > class CourseBook(ModelForm): > > class Meta: > > model = CourseBooking > > > The web page now displays a picklist of courses with the initial value > > highlighted. I can now do a form.save() no problem. > > > However, if I make the course a hidden field, which is what I want. > > > class CourseBook(ModelForm): > > course = forms.CharField(widget=forms.HiddenInput()) > > > class Meta: > > model = CourseBooking > > > then when I come to save() I get a ValueError, unable to assign "My > > course" etc. as it tries to put the name of the course into the > > foreign key instead of a course instance. > > > I can work around this putting a save method on the form, but it seems > > to me django should resolve this for me > > -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: word processing django apps
At The Texas Tribune (texastribune.org), we use a combination of TinyMCE and django-reversion. It doesn't track changes between versions, but it maintains a history table of each previous version of our main content types. Cheers, Brandon On Mar 30, 4:18 pm, John Griessen wrote: > Some potential Django site users I know asked for word processing with > revisions > for group writing they do. > > Is there a web hostable word processor with savable version history that is > easy to integrate with Django? > > A web based editor search turns up > wymeditor > TinyMCE > > Anyone integrated these along with versions? > > etherpad looks interesting. Anyone using it along side Django? > If so, what's that like? > > John -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting strange email from "dreamhost"
I getting those too. __ Vinícius Mendes Solucione Sistemas http://solucione.info/ On Wed, Mar 31, 2010 at 12:14 PM, Brandon Taylor wrote: > I'm getting those from this forum as well. > > On Mar 31, 10:13 am, Wiiboy wrote: > > Hi guys, > > I've gotten two emails from "Mail Delivery Subsystem > > " with the subject "Your message was NOT > > received by django-us...@googlegroups.com!". > > The body is below. Anyone know why I'm getting these? Is anyone else > > getting them? I have no affiliation with Dreamhost or at all, so this > > is...strange. > > > > We're sorry.. your email was unable to be processed by our automatic > > support system, and so is being returned to you. > > > > We could not find your email address in our customer database and so > > couldn't accept your email. Due to the HUGE volume of spam we receive > > at this address, we've been forced to implement this new policy. > > > > Therefore, please just re-submit your message at: > > > > http://www.dreamhost.com/contact.cgi > > > > All messages submitted through that form are guaranteed to be > > received, > > even if you aren't currently a customer! > > > > Our apologies for the inconvenience, > > -- > > The Happy DreamHost Support Team! > > -- > 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-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin Add Page
You can extend the change_form.html and change_list.html templates for those views, or the base_site.html template. Look in your: django/contrib/admin/templates/admin/ folder to see all of the templates. Also, check out the documentation at: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-template Cheers, Brandon On Mar 30, 1:16 pm, Asim Yuksel wrote: > I want to use a custom admin add page with custom admin look and feel. > What is the template to extend? I want to use something like this > > http://picasaweb.google.com/110428031719333287170/BaslKsZAlbum#545448... > > I tried to hack the html by viewing the source but it is time > consuming and it always show a message "This field is required.". I > want to show this message when I click save. -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin Add Page
Thanks but I get error when I try to extend it it says:Caught an exception while rendering: opts and it highlights {% submit_row %} Any ideas? On 31 Mart, 11:23, Brandon Taylor wrote: > You can extend the change_form.html and change_list.html templates for > those views, or the base_site.html template. > > Look in your: django/contrib/admin/templates/admin/ folder to see all > of the templates. Also, check out the documentation > at:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs... > > Cheers, > Brandon > > On Mar 30, 1:16 pm, Asim Yuksel wrote: > > > I want to use a custom admin add page with custom admin look and feel. > > What is the template to extend? I want to use something like this > > >http://picasaweb.google.com/110428031719333287170/BaslKsZAlbum#545448... > > > I tried to hack the html by viewing the source but it is time > > consuming and it always show a message "This field is required.". I > > want to show this message when I click save. -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is it possible to change the width of the boxes displayed by the filter_horizontal in Django admin interface?
Walt, Thanks for the clarification. That helped a lot. I did get this working. Yeah! Had to do a slight tweak to the surrounding elements on the page to get it to look right (minor change to widgets.css). Now I can see all of the data for the profiles. Seems like there should be a way to auto scale the width based on data, but that's for another time. Thanks for your help. Reed On Mar 26, 10:43 am, Walt wrote: > I'm sorry I wasn't more clear, the class Media just gets > added to your existing admin class. The path to the css > should be the path that is appended to your SETTINGS.PY > media path to reach the css file. The class ResizeFilterAdmin > was just an example name. > > In other words, if your media path is: /var/www/media > and your css file is stored in /var/www/media/css/bisite.css > then your Media entry would be: > > css = { 'all': ('/media/css/bisite.css',)} > > So the full entry would be: > > class ProfileAdmin(admin.ModelAdmin): > search_fields = ('profile_name',) > ordering = ('profile_name',) > filter_horizontal= ('profile_test',) > > class Media: > css = { > 'all':('/media/css/bisite.css',) > } > > Does that make more sense? Again, I apologize for the > miscommunication! > > Thanks, > Walt > > -~ -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Table in models.py not being created during syncdb
Hi, I'm using the django app, django-schedule (http://github.com/thauber/ django-schedule) and am adding an additional table to map users to calendars (see line 253 on dpaste). When I run syncdb it completely ignores my table and doesn't through any errors. Can anyone shed any light on way it might be being igored? My models file is available here: http://dpaste.com/178158/ Thanks in advance Wes -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: RPC4Django - can't pass Boolean args nor Keyword args
Apparently the question has been answered. On Mar 31, 1:51 am, Simone Orsi wrote: > anyone using RPC4Django has faced > thishttps://bugs.launchpad.net/rpc4django/+bug/552437? Toodle-loo. creecode -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: "format" error with django-piston
I ended up using jezdez's fork of Piston, and it works as expected: https://bitbucket.org/jezdez/django-piston/ On Mar 31, 9:57 am, Brandon Taylor wrote: > Hi everyone, > > I know there's a Google Group for django-piston, but there's not very > much conversation on that group, so I'm re-posting here as well. > > I'm getting an error when running the "blogserver" example site > included with Piston: > > AttributeError at /api/posts/ > 'Blogpost' object has no attribute 'format' > > Googling this has turned up one post on the Bitbucket > site:http://bitbucket.org/jespern/django-piston/issue/54/got-an-error-on-p..., > which says there's a patch, like 9 months ago, but that the patch > doesn't work. > > The problem seems related to the @classmethod resource_uri, but I'm > uncertain as to how to fix this. > > Kind regards, > Brandon -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting strange email from "dreamhost"
Hello all, I just posted a reply to a message here via the web interface and got an email like this. Toodle-lo.. creecode -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Probably a very basic data modeling question
Hi everyone, I am still having issues with my data models. I can't tell if the underlying problem is my model definitions or my inability to do the queries to manipulate my models to get the output that I want. Could someone please tell me if this is the right way to do it in my models.py? Again, what I want is: sample1 disease = asthma gender = male race = white sample2 disease = diabetes gender = female race = black sample3 disease = asthma race = white cell = lung sample4 disease = breast cancer gender = female race = hispanic So, each sample is described by one or more facets (i.e., tags) like disease, race, cell, gender, etc. Each facet (tag) will have one value at any one time. So do I have the following relations? sample has a many to many relationship with facets. facets have a 1 to many relationship with values. I'm kind of unsure if Sample should have just a Facet field, and then Facet should have a Value field; or if Sample should have a Facet field and also a Value field, both in a many to many relationship with Sample. Finally, here is my code: from django.db import models class Value(models.Model): name = models.CharField(max_length=60) def __unicode__(self): return self.name class Facet(models.Model): name = models.CharField(max_length=60) value = models.ForeignKey(Value) def __unicode__(self): return self.name class Sample(models.Model): number = models.CharField(max_length=30) facets = models.ManyToManyField(Facet) description = models.TextField() def __unicode__(self): return u'%s' %(self.number,) class Meta: ordering = ['number'] Thanks so much! On Mar 28, 7:52 am, Daniel Roseman wrote: > On Mar 28, 2:28 am, Daniel wrote: > > > > > Hi all, > > > I'd appreciate it if you could help me out with something. > > > I am trying to build a way to use faceted browsing through a database > > of biological samples. > > > what I want to model is this: > > > Sample 1 > > race = white > > age = adult > > gene = XCFR2 > > disease = cancer > > Sample 2 > > race = white > > age = child > > gene = 343GS > > disease = stroke > > date = 2010 > > country = Netherlands > > > So each sample could contain many tags. And each tag should have one > > value at a time. A tag is a category (like race, age, gene, disease), > > and a value is for lack of a better word, the choice or free text that > > is entered to the right of the ='s sign. TAG = race, then value = > > white > > > So does each sample have a many to many relationship with tags? And > > then tags have a many to many relationship with values? > > > Each sample can have many tags (race, age, gene, disease, ...etc). > > Each tag can have many diff values (race could be white, black, > > hispanic, asian, etc...) BUT only one at a time > > Each value should be mapped to one tag at a time. But I guess a value > > could be reused, like the value XCFR2 could be a valid in gene = XCFR2 > > and discovered_information = XCFR2. > > > I think I'm making it too hard, but if someone can help, I would be > > happy > > Perhaps you want some kind of machinetags implementation? In other > words, tag a sample with things like "race:white, gene:XCFR2" and so > on. > > I've not used it, but there is a branch of django-tagging that > supports machinetags > here:https://code.launchpad.net/~gregor-muellegger/django-tagging/machinet... > -- > DR. -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Passing hidden foreign key to form as initial value
Final approach: in the forms.py excluded the courses foreign key field in models.py made courses blank and nullable didn't pass any initial values to the form in the view, saved the form like this: item = Courses.objects.get(pk=whatever) obj = form.save(commit=False) obj.course = item obj.save() This doesn't feel very tidy to me, I think the form should have the hidden values, but it works! On Mar 31, 4:15 pm, phoebebright wrote: > Brandon, Thanks for your suggestion. > I tried passing it an ID, but as you say, I also have to override the > save. What I don't understand is why it does it fine if the form > includes the foreign key in a popup? They are both passing back > integers after all. > > Also failed to get the save method working, tried to pass in the > course instance, but it still ends up trying to save with the id of > the course. Is it not using cleaned_data? > > def save(self, course=False, force_insert=False, > force_update=False, commit=True): > if course: > self.cleaned_data['course'] = course > return super(CourseBook, self).save(commit=commit) > > Any suggestions welcome as I've spent the whole afternoon on this - I > won't go through the many other workarounds that havn't worked! > > Phoebe. > > On Mar 31, 4:02 pm, Brandon Taylor wrote: > > > Hi there, > > > Instead of using the course object in your initial data, which will > > pass in the __unicode__ representation of the object, pass in the id: > > > form = CouseBook(initial = {'course': course.id}) > > > That should get you the numeric id, but you'll also need to override > > your save method to get the course object to assign when you save your > > CourseBook form, as you can't assign an integer (coming from your > > hidden form field) to the value of a ForeignKey field on a model. > > > HTH, > > Brandon > > > On Mar 31, 8:20 am, phoebebright wrote: > > > > Displayed fields resolve as expected, hidden fields cause errors. > > > > This works: > > > > in the model > > > CourseBook has a foreign key to Course > > > > In the view: > > > > course = Course.objects.get(pk=whatever) > > > form = CouseBook(initial = {'course': course}) > > > > in the Form: > > > > class CourseBook(ModelForm): > > > class Meta: > > > model = CourseBooking > > > > The web page now displays a picklist of courses with the initial value > > > highlighted. I can now do a form.save() no problem. > > > > However, if I make the course a hidden field, which is what I want. > > > > class CourseBook(ModelForm): > > > course = forms.CharField(widget=forms.HiddenInput()) > > > > class Meta: > > > model = CourseBooking > > > > then when I come to save() I get a ValueError, unable to assign "My > > > course" etc. as it tries to put the name of the course into the > > > foreign key instead of a course instance. > > > > I can work around this putting a save method on the form, but it seems > > > to me django should resolve this for me > > -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to display a _unicode_ string when involving a many to many relationship?
Hi guys, I'd appreciate a little advice on the following: I'm trying to get a unicode string representation of my model named Sample. But that Sample model has a many to many relationship with another model, Facet. So Sample's unicode method: def __unicode__(self): return u'%s' %(self.Facet.name,) This will not work in the __unicode__ method, but can someone tell me how to represent this? I also want to use list_display inside a SampleAdmin class to allow the admin site to show all the fields of my Sample model, but so far I can't display any many to many fields. Thanks 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
RE: Displaying the fields of two tables on the same admin page
> > I am entering them on the same page otherwise I will have to note down > the ids of people and publications table and then go to bridge table > and insert the ids there. So the reason I want to enter in the same > page is I will insert the ids into bridge table whenever I click save. > I am not allowed to change the db design by the way and it sucks :) > Does this not work the way you expect? class People(models.Model): other fields publications = models.ManyToManyField('Publication', through='PeoplePublication', ) class Publication(models.Model): other fields class PeoplePublication(models.Model): people = models.ForeignKey('People',...) publication = models.ForeignKey('Publication',...) in admin.py: class PublicationInline(admin.TabularInline): model = PeoplePublication extra = 1 class PeopleAdmin(admin.ModelAdmin): inlines = [PublicationInline] admin.site.register(People, PeopleAdmin) -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How do I properly unit test a Django session?
Thierry, Thanks for the response and the code sample. To be clear, the "variables" in accounts/accueil/ are session variables? I assume your view for that URL looks like this: def accueil(request): ... request.session['domaine'] = Domaine.objects.get(nom='DomaineAdmin') ... My problem is that I am trying to _write_ session variables before calling my view. For example: def view(request): if 'foo' not in request.session: return HttpResponseRedirect('failure') return HttpResponse('success') class SessionTestCase(TestCase): def test_view(self): self.client.session['foo'] = 'bar' self.client.get('view') self.assertEqual(self.client.status_code, 200) This fails because Django doesn't properly pass the session to 'view,' and I'm wondering what the best way is to ensure it's passed. On Mar 31, 12:42 am, Thierry Chich wrote: > Le mercredi 31 mars 2010 05:40:43, adambossy a écrit : > > > > > The behavior of Django sessions changes between "standard" views code > > and test code, making it unclear how test code is written for > > sessions. Googling this yields two relevant discussions about this > > issue: > > > 1. "Easier manipulation of sessions by test client" [http:// > > code.djangoproject.com/ticket/10899] > > 2. "test.Client.session.save() raises error for anonymous > > users" [http://code.djangoproject.com/ticket/11475] > > > I'm confused because both tickets have different ways of dealing with > > this problem and they were both Accepted. I assume this means they > > were patched and the behavior is now different. I also don't know to > > which versions these patches would pertain. > > > If I'm writing a unit test in Django 1.0, how would I set up my > > session store for sessions to work as they do in the browser? > > Hi, > Perhaps, you should be more explicit with your problem. I am using the client > and there is no problem at all. > > For instance; > class GeneriqueTestCases(TestCase): > def test_login_admin(self): > > self.failUnlessEqual(self.client.login(username='admin',password='admin'),T > rue) > self.client.logout() > response=self.client.get("/accounts/accueil/") > > self.assertRedirects(response,'/accounts/login/?login=/accounts/accueil/') > > def test_login_domaine(self): > self.client.login(username='admin', password='admin') > response=self.client.get('/accounts/accueil/') > self.assertEqual(response.context['user'].username, 'admin') > d=Domaine.objects.get(nom='DomaineAdmin') > self.assertEqual(self.client.session.get('domaine'),d) > > In the last test, I am explicitely using informations stored in a session. > (However, I have searched a long time before I understand that some variables > was set in the accounts/accueil/ page :-( ) > > Thierry -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to display a _unicode_ string when involving a many to many relationship?
On Mar 31, 8:26 pm, Daniel wrote: > Hi guys, > > I'd appreciate a little advice on the following: > > I'm trying to get a unicode string representation of my model named > Sample. But that Sample model has a many to many relationship with > another model, Facet. > > So Sample's unicode method: > > def __unicode__(self): > return u'%s' %(self.Facet.name,) > > This will not work in the __unicode__ method, but can someone tell me > how to represent this? I also want to use list_display inside a > SampleAdmin class to allow the admin site to show all the fields of my > Sample model, but so far I can't display any many to many fields. > > Thanks again You need to think about exactly you want to display here. You have a manytomany relationship. That means that each Sample has multiple Facets. So what do you want to show for each facet? You could join all the facets for each sample into a comma-separated list: return u', '.join(self.facet.all()) Is that what you want? -- DR. -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
JOIN instead of multiple SELECT
Hello to all, has been a while i've been wondering how to optimize Django's queries to the database, for example by setting it to use JOIN to retrieve foreign keys instead of multiple selects. for example if I have a blog object that has a category foreign key and I write in a template {{ blog.category.slug }} I get another query to select the category. Is there a way I can use a JOIN instead to avoid multiple queries? Does this have sense for performance optimization? Thanks Federico -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to display other field(not the foreign key) in admin dropdown list
I have a people table and a bridge table which are related. bridge table has a foreignkey field for people table. When I click add from django admin it shows the peopleid in a drop down list. What I want to do is I want to show the people.name field instead of peopleid foreignkey field? How can I do this? -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Displaying the fields of two tables on the same admin page
The people and publication are not related so I cant use manytomany On 31 Mart, 15:30, "Giovannetti, Mark" wrote: > > I am entering them on the same page otherwise I will have to note down > > the ids of people and publications table and then go to bridge table > > and insert the ids there. So the reason I want to enter in the same > > page is I will insert the ids into bridge table whenever I click save. > > I am not allowed to change the db design by the way and it sucks :) > > Does this not work the way you expect? > > class People(models.Model): > > other fields > > publications = models.ManyToManyField('Publication', > through='PeoplePublication', > ) > > class Publication(models.Model): > > other fields > > class PeoplePublication(models.Model): > > people = models.ForeignKey('People',...) > publication = models.ForeignKey('Publication',...) > > in admin.py: > > class PublicationInline(admin.TabularInline): > model = PeoplePublication > extra = 1 > > class PeopleAdmin(admin.ModelAdmin): > inlines = [PublicationInline] > > admin.site.register(People, PeopleAdmin) -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: JOIN instead of multiple SELECT
On Wed, Mar 31, 2010 at 3:30 PM, Federico Capoano wrote: > Hello to all, > > has been a while i've been wondering how to optimize Django's queries > to the database, for example by setting it to use JOIN to retrieve > foreign keys instead of multiple selects. > > for example if I have a blog object that has a category foreign key > and I write in a template > > {{ blog.category.slug }} > > I get another query to select the category. > > Is there a way I can use a JOIN instead to avoid multiple queries? select_related() ? http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4 ~Rolando -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to display other field(not the foreign key) in admin dropdown list
Okey I want to answer this :) just add a unicode method to your model something like this def __unicode__(self): return "%s" % self.name On 31 Mart, 16:37, Asim Yuksel wrote: > I have a people table and a bridge table which are related. bridge > table has a foreignkey field for people table. > > When I click add from django admin it shows the peopleid in a drop > down list. What I want to do is I want to show the people.name field > instead of peopleid foreignkey field? How can I do this? -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: JOIN instead of multiple SELECT
Thanks, how many things i've learnt today, to optimize the number and length of query by using: * select_related * only * extra Do you think the performance gain is worth the work? And I've a curiosity more to ask: If I use the cache framework, once the results are cached the will the database be hit again? Best Regards Federico On Mar 31, 10:49 pm, Rolando Espinoza La Fuente wrote: > On Wed, Mar 31, 2010 at 3:30 PM, Federico Capoano > > wrote: > > Hello to all, > > > has been a while i've been wondering how to optimize Django's queries > > to the database, for example by setting it to use JOIN to retrieve > > foreign keys instead of multiple selects. > > > for example if I have a blog object that has a category foreign key > > and I write in a template > > > {{ blog.category.slug }} > > > I get another query to select the category. > > > Is there a way I can use a JOIN instead to avoid multiple queries? > > select_related() ? > > http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4 > > ~Rolando -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Select previous and next from a table
Hello, I'm trying to figure out a simple way to get a known record from a database but also get the "previous" and "next" records too. My model is a Photo table with user's votes : ID Votes 1 24 2 5 3 102 4 21 5 10 So, if I query for the photo with ID=4 (21 votes) I'd like to get the next photo in the votes rank (ID=1 with 24 votes) and the previous photo in the rank (ID=5 with 10 votes). Can I do this with only one query to the database? Ideas? Thanks in advance. Cheers! -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: JOIN instead of multiple SELECT
On Wed, Mar 31, 2010 at 5:22 PM, Federico Capoano wrote: > Thanks, > > how many things i've learnt today, to optimize the number and length > of query by using: > > * select_related > * only > * extra > > Do you think the performance gain is worth the work? Yes. Specially in loops where you have: # in your view posts = Post.objects.all()[:20] # in your template {% for post in posts %} {{ post.title }} {{ post.category.name }} {{ post.owner.username }} {% endfor %} post.category and post.owner will hit the database each loop. > And I've a curiosity more to ask: > If I use the cache framework, once the results are cached the will the > database be hit again? No. But you need to take care of invalidation. There are few apps that provide drop-out solution for caching at orm level: * cache machine - http://jbalogh.me/2010/02/09/cache-machine/ * cachebot - http://blog.davidziegler.net/post/429237463/announcing-django-cachebot * johnny cache - http://jmoiron.net/blog/is-johnny-cache-for-you/ Regards, ~Rolando -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Select previous and next from a table
I know how to do this with 3 queries: object = Model.objects.filter(pk=pk) previous = Model.objects.filter(votes__lt=object.votes).order_by('-votes')[:1][0] next = Model.objects.filter(votes__gt=object.votes).order_by('votes')[:1][0] My only problem with this is if there is any object with the same value for votes. __ Vinícius Mendes Solucione Sistemas http://solucione.info/ On Wed, Mar 31, 2010 at 7:45 PM, x13 wrote: > Hello, > > I'm trying to figure out a simple way to get a known record from a > database but also get the "previous" and "next" records too. My model > is a Photo table with user's votes : > > ID Votes > > 1 24 > 2 5 > 3 102 > 4 21 > 5 10 > > > So, if I query for the photo with ID=4 (21 votes) I'd like to get the > next photo in the votes rank (ID=1 with 24 votes) and the previous > photo in the rank (ID=5 with 10 votes). Can I do this with only one > query to the database? Ideas? > > Thanks in advance. > Cheers! > > > > > -- > 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-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Table in models.py not being created during syncdb
On Thu, Apr 1, 2010 at 1:16 AM, wchildsuk wrote: > Hi, > > I'm using the django app, django-schedule (http://github.com/thauber/ > django-schedule) and am adding an additional table to map users to > calendars (see line 253 on dpaste). When I run syncdb it completely > ignores my table and doesn't through any errors. Can anyone shed any > light on way it might be being igored? The most likely cause - a table of that name already exists. Django uses the existence of the table as a mark for whether the table needs to be created at all. If a table of the required name (yourapp_calendarusers) already exists -- either because of a clash with an existing project, or because you ran syncdb previously and have an old version of the table -- Django won't create or update the table. 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting strange email from "dreamhost"
On Wed, Mar 31, 2010 at 11:13 PM, Wiiboy wrote: > Hi guys, > I've gotten two emails from "Mail Delivery Subsystem > " with the subject "Your message was NOT > received by django-us...@googlegroups.com!". > The body is below. Anyone know why I'm getting these? Is anyone else > getting them? I have no affiliation with Dreamhost or at all, so this > is...strange. The problem is that somebody has subscribed to django-users with an email address at dreamhost, but their spam policy doesn't allow mail from the group, so their spam blocker is helpfully returning the mail. For bonus points, the bounce mail doesn't seem to provide any indication *who* has subscribed. It's annoying, and I'm trying to find out whose subscription is responsible so I can block it. Your patience while we sort this out is appreciated. 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
ckeditor and ckfinder
I'm trying to get ckfinder to integrate with ckeditor. I can go directly to the ckfinder sample standalone and it uploads to the right directory and everything so I know that ckfinder is configured properly... anyone know how to get the upload tab on the image popup with ckeditor so that ckfinder works in an integrated form? -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ckeditor and ckfinder
On 1 April 2010 13:05, Bobby Roberts wrote: > I'm trying to get ckfinder to integrate with ckeditor. I can go > directly to the ckfinder sample standalone and it uploads to the right > directory and everything so I know that ckfinder is configured > properly... anyone know how to get the upload tab on the image popup > with ckeditor so that ckfinder works in an integrated form? Not quite sure how ckfinder works, but to integrate a file browser into ckeditor so it appears when you click the 'upload' button, you need to set the 'filebrowserBrowseUrl' setting in the editor configuration. I have a JSON string with all these settings in it which I write to the template, the template then contains JS code that uses the config when calling CKEDITOR.replace(textarea_id, config_dict); > -- > 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-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ckeditor and ckfinder
thanks for your reply... your tip got me thinking and I found the docs at: http://docs.cksource.com/CKFinder/Developers_Guide/PHP/CKEditor_Integration under manual integration On Mar 31, 10:16 pm, Sam Lai wrote: > On 1 April 2010 13:05, Bobby Roberts wrote: > > > I'm trying to get ckfinder to integrate with ckeditor. I can go > > directly to the ckfinder sample standalone and it uploads to the right > > directory and everything so I know that ckfinder is configured > > properly... anyone know how to get the upload tab on the image popup > > with ckeditor so that ckfinder works in an integrated form? > > Not quite sure how ckfinder works, but to integrate a file browser > into ckeditor so it appears when you click the 'upload' button, you > need to set the 'filebrowserBrowseUrl' setting in the editor > configuration. > > I have a JSON string with all these settings in it which I write to > the template, the template then contains JS code that uses the config > when calling CKEDITOR.replace(textarea_id, config_dict); > > > -- > > 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-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
admin inline objects: replicated insertions on first save
hi all, i'm building an application that models the literature, biology and ecology of a group of insects. i have been playing around with the admin site and have noticed some odd behavior. For example, I have a class for species names, that has several inline model objects in the admin - one for the name of the author of the species, one for the name of the collection where the type material of the species is found etc. When i enter data for a new species and hit save the first time, the data that i have entered in the inline objects are replicated once or twice, i.e. instead of having inserted on species author record with the value 'Kondo,' it will insert two species record objects with the value 'Kondo.' Sometimes it will automatically insert an additional value that I had inserted for another name entirely. If i click the check boxes to delete those automaticaly inserted records and save again it fixes it. any idea what is going on here? thanks, nate -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting strange email from "dreamhost"
On Thu, Apr 1, 2010 at 7:55 AM, Russell Keith-Magee wrote: > On Wed, Mar 31, 2010 at 11:13 PM, Wiiboy wrote: >> Hi guys, >> I've gotten two emails from "Mail Delivery Subsystem >> " with the subject "Your message was NOT >> received by django-us...@googlegroups.com!". >> The body is below. Anyone know why I'm getting these? Is anyone else >> getting them? I have no affiliation with Dreamhost or at all, so this >> is...strange. > > The problem is that somebody has subscribed to django-users with an > email address at dreamhost, but their spam policy doesn't allow mail > from the group, so their spam blocker is helpfully returning the mail. > > For bonus points, the bounce mail doesn't seem to provide any > indication *who* has subscribed. > > It's annoying, and I'm trying to find out whose subscription is > responsible so I can block it. > > Your patience while we sort this out is appreciated. This is a test email to see if we're still getting the bounce messages... apologies for the noise. 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting strange email from "dreamhost"
Hehe, that's kinda funny...Thanks for your help Russell. =) -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
form object has no attribute 'cleaned_data'
so i've searched high and low on this error. lots of answers about having used old versions of django. i did this: j...@earth:/home/samba/raymour/v1/rrsite$ django-admin.py --version 1.1.1 then a lot of stuff about python path having been done with an easy installer and having an 'egg' in it. doesn't seem i have that problem: ['/home/samba/ray/v1/rrsite', '/usr/lib/python2.6', '/usr/lib/ python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/ python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/ python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/Numeric', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist- packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/ python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/ gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.6-gtk2-unicode', '/ usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode', '/usr/local/lib/ python2.6/dist-packages'] i just used the version on ubuntu. here is my form: from django import forms class SymForm(forms.Form): sym1=forms.CharField() sym2=forms.CharField() and view: def add_pair(request): # these are the basic locals we need to set for the template to populate page_title='Add a Pair' if request.method == 'POST': form=SymForm(request.POST) if form.is_valid: s1=form.cleaned_data['sym1'] #form.cleaned_data['subject'] #s2=form.clean_sym2 s=Pair(sym1=s1,sym2=s2) s.save() return HttpResponseRedirect('/sym/added/') please can you offer any suggestions??? thanks in advance. and the traceback: Environment: Request Method: POST Request URL: http://192.168.1.80:8080/add/pair/ Django Version: 1.1.1 Python Version: 2.6.4 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'rrsite.pairs01'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/home/samba/ray/v1/rrsite/../rrsite/pairs01/views.py" in add_pair 38. s1=form.cleaned_data['sym1'] #form.cleaned_data['subject'] Exception Type: AttributeError at /add/pair/ Exception Value: 'SymForm' object has no attribute 'cleaned_data' -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: form object has no attribute 'cleaned_data'
On Wed, Mar 31, 2010 at 9:09 PM, jeff wrote: > >page_title='Add a Pair' >if request.method == 'POST': >form=SymForm(request.POST) >if form.is_valid: is_valid is a call - you want this: if form.is_valid(): Nick -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How do I properly unit test a Django session?
adambossy wrote: > My problem is that I am trying to _write_ session variables before > calling my view. For example: Django really falls down here, especially compared to Brand X. Stuff a session like this: def assemble_session(self, dictionary): from django.conf import settings from django.utils.importlib import import_module engine = import_module(settings.SESSION_ENGINE) store = engine.SessionStore() store.save() # we need to make load() work, or the cookie is worthless self.client.cookies[settings.SESSION_COOKIE_NAME] = store.session_key session = self.client.session session.update(dictionary) session.save() # and now remember to re-login! -- Phlip http://c2.com/cgi/wiki?ZeekLand -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to display a _unicode_ string when involving a many to many relationship?
return u', '.join(self.facet.all()) does not work. I believe from Dive into Python .join expects a String: "join works only on lists of strings; it does not do any type coercion. Joining a list that has one or more non-string elements will raise an exception." But in the Python docs it says .join() takes an iterable parameter.self.facets.all() is a querySet, which is definitely iterable. Basically I would like to display every field of my Sample class in the admin view, like so: Sample1 tag1 value1 tag2 value2 tag3 value3 sample2 tag1value4 tag2value5 Sample and tag are manytomany, and each tag should have one value at a time. It's this many to many relationship that I'm having trouble with. Am I to use inlines, the "through" attribute, write a custom method, or do I need to hack the Admin to do something which I'm thinking should be a very common thing. Thanks! On Mar 31, 3:40 pm, Daniel Roseman wrote: > On Mar 31, 8:26 pm, Daniel wrote: > > > > > Hi guys, > > > I'd appreciate a little advice on the following: > > > I'm trying to get a unicode string representation of my model named > > Sample. But that Sample model has a many to many relationship with > > another model, Facet. > > > So Sample's unicode method: > > > def __unicode__(self): > > return u'%s' %(self.Facet.name,) > > > This will not work in the __unicode__ method, but can someone tell me > > how to represent this? I also want to use list_display inside a > > SampleAdmin class to allow the admin site to show all the fields of my > > Sample model, but so far I can't display any many to many fields. > > > Thanks again > > You need to think about exactly you want to display here. You have a > manytomany relationship. That means that each Sample has multiple > Facets. So what do you want to show for each facet? You could join all > the facets for each sample into a comma-separated list: > > return u', '.join(self.facet.all()) > > Is that what you want? > -- > DR. -- 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-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.