Re: django.core.mail - DEFAULT_FROM_EMAIL not employed
I started experiencing this too... I can't tell if this is Gmail or not. I know I send email via SMTP from Gmail masqueraded with other aliases. So I feel that something is getting munged. Either in the mail library or with Gmail's servers. On Jan 28, 3:02 am, funkaziowrote: > Right! Thanks! > > The SERVER_EMAIL setting works properly with a NOT-authenticated smtp > server, yet using an authenticated server (at least the one I > tried: Gmail) the SERVER_EMAIL is overridden by the EMAIL_HOST_USER. > Maybe that should be properly verified with several server and > modified or documented in case it is not a gmail-specific behaviour. > > 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-users@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: django.core.mail - DEFAULT_FROM_EMAIL not employed
I started experiencing this too... I can't tell if this is Gmail or not. I know I send email via SMTP from Gmail masqueraded with other aliases. So I feel that something is getting munged. Either in the mail library or with Gmail's servers. On Jan 28, 3:02 am, funkaziowrote: > Right! Thanks! > > The SERVER_EMAIL setting works properly with a NOT-authenticated smtp > server, yet using an authenticated server (at least the one I > tried: Gmail) the SERVER_EMAIL is overridden by the EMAIL_HOST_USER. > Maybe that should be properly verified with several server and > modified or documented in case it is not a gmail-specific behaviour. > > 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-users@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: trying to get whether image is wider or deeper in templatetag
Hi Malcolm, Thanks for your patient guidance. I took your advice on a better name for the variable. Now it should return true if the image_is_vertical. I am getting a lot closer, but I think I am losing the photo's ID when I get to the templatetag in photos.py. Here's what debug tells me: ProgrammingError at /homepage/dmtest/ ERROR: invalid input syntax for integer: "homepage.get_piece_dict.lead_story.get_lead_photo" SELECT "photos"."id","photos"."creation_date","photos"."photographer_id","photos"."one_off_photographer","photos"."credit","photos"."caption","photos"."photo","photos"."width","photos"."height" FROM "photos" WHERE "photos"."id" = 'homepage.get_piece_dict.lead_story.get_lead_photo' here's the new code: class WideOrDeepNode(CachedNode): def __init__(self, photoobj, varname): self.photoobj = photoobj self.varname = varname photos.get_object(pk=photoobj) self.cache_timeout = 180 def get_cache_key(self, context): return "ellington.media.templatetags.photos.do_get_wideordeep: %s" % (SITE_ID) def get_content(self,context): context[self.varname] = self.photoobj.width <= self.photoobj.height return "" def do_get_wideordeep(parser, token): """ Checks to see if the photo is horizontal (or square) or vertical. Will return '1' if it is vertical. Otherwise returns '0'. Syntax:: {% get_wideordeep object.id [as varname] %} """ bits = token.contents.split() if len(bits) == 2: photoobj = bits[1] varname = 'image_is_vertical' elif len(bits) == 4: photoobj = bits[1] varname = bits[3] else: raise template.TemplateSyntaxError, "'%s' tag takes either one or two arguments" % bits[0] return WideOrDeepNode(photoobj,varname) Thanks again for your help. Take care, David On Feb 20, 12:18 am, Malcolm Tredinnickwrote: > On Thu, 2009-02-19 at 21:09 -0800, macdo...@gmail.com wrote: > > > I am trying to set up a templatetag that will give me a variable to > > use > > in templates so we can modify our presentation of stories depending > > upon > > whether the accompanying photo is horizontal or vertical. I am using > > 0.91 EllingtonCMS. > > > I've made a templatetag in /ellington/media/photos.py that looks like > > this: > > This is pretty close to correct. A couple of notes inline below... > > > > > > > class WideOrDeepNode(CachedNode): > > def __init__(self, photoobj, varname): > > self.photoobj = photoobj > > self.varname = varname > > self.cache_timeout = 180 > > > def get_cache_key(self, context): > > return > > "ellington.media.templatetags.photos.do_get_wideordeep:%s" % (SITE_ID) > > > def get_content(self, context): > > if self.photoobj.width <= self.photoobj.height: > > context[self.varname] = '0' > > else: > > context[self.varname] = '1' > > return "" > > This feels clunkier than it could be. You'd get the same result by > writing: > > def get_content(self, context): > context[self.varname] = self.photoobj.width > self.photoobj.height > return "" > > Since True == 1 and False == 0 in Python 2.x, you can see it's the same > result. Writing it as a boolean check looks a bit more natural to me, > however. > > Still, that's a minor point. > > > > > > > def do_get_wideordeep(parser, token): > > """ > > Checks to see if the photo object's width is greater than its > > length > > and will return '0' if it is. Otherwise returns '1'. > > > Syntax:: > > {% get_wideordeep object.id [as varname] %} > > """ > > bits = token.contents.split() > > if len(bits) == 2: > > photoobj = bits[1] > > varname = 'imageflag' > > elif len(bits) == 4: > > photoobj = bits[1] > > varname = bits[3] > > When you're setting up photoobj here, it will be string, since it's one > of the words passed in from the template tag. You need to convert that > string (the object id) into an object. I would probably do that in the > __init__ method of the Node class, but wherever you do it is up to you. > Something like > > Photo.objects.get(pk=photoobj) > > and be prepared to handle to DoesNotExist exception. > > > else: > > raise template.TemplateSyntaxError, "'%s' tag takes either one > > or two arguments" % bits[0] > > return WideOrDeepNode(photoobj,varname) > > > on the template, here is how I am asking for it: > > > {% get_wideordeep homepage.get_piece_dict.lead_story.get_lead_photo > > as > > imageflag %} > > {% ifequal imageflag 0 %} > > Since imageflag is True or False (or 1 or 0), {% if imageflag %} can be > used here (although you'll need to reverse the order of your blocks, > since the True case will now be first. > > That also raises one final little concern I would have with this: the > name. The template tag doesn't return "wide" or "deep".
url tag or get_absolute_url()
I have a a list that I generate using this code in a template: {% extends "base.html" %} {% block title %}Lobbyist by Country {% endblock %} {% block content %} Browse by County Click on one of the items below to get information about the firms {% for county in county_list %} {{ country.name }} {% endfor %} {% endblock %} I want to add a url and tried to use the get_absolute_url method of model: class Country(models.Model): name = models.CharField(max_length=80) slug = models.CharField(max_length=80) def __unicode__(self): return self.name def get_absolute_url(self): return "/country/%s/" % self.slug What I'd like to do is to be able to click on an object from my list in the template which would then go to a details page which looks like this: {% extends "base.html" %} {% block title %} Ujima Project {% endblock %} {% block content %} Country: {{country}} This table contains all firms and individuals who lobbied on behalf of the country. NameAddressClientCountyAmount {% for c in county %} {{c.name}} {{c.address}} {{c.client}} {{c.country}} {{c.dollar_amount}} {% endfor %} {% endblock %} I already have a view that gets to the last template, but I can figure out how to use the get_absolute_url to get their from the other template with the list. Here is my view for the last template: def country_detail(request, county): c = County.objects.get(slug=countr) clients= Company.objects.filter(county=c) return render_to_response('county/county_detail.html',{'county':c, 'client':clients}) and the url: r'^county/(?P[-a-z]+)/$', county_detail), So essentially I'd like to be able to provide hyperlinks to the objects in the first templates that would open up the second template when you click on it. Suggestions? Hope this is not too much code to post. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Removing fields in a form subclass
I would, but in this case, I want to remove a field in an external app (specifiaclly, django-registration). I suppose I could extract all the relevant parts out of the form class in django-registration and paste it into my own form, but that seems really redundant. Basically, the user's name is autogenerated from the email field, so I want to remove the username field from the django-registration form. Though I suppose if there's no good way of doing it, I'll just have to copy out the relevant bits into a new form. -- dz On Fri, Feb 20, 2009 at 7:20 PM, Malcolm Tredinnickwrote: > > On Fri, 2009-02-20 at 10:15 -0500, David Zhou wrote: >> Suppose I had this form: >> >> class BaseForm(forms.Form): >> field1 = forms.CharField(...) >> field2 = forms.Charfield(...) >> >> And then in a subclass, I had: >> >> class SubForm(BaseForm): >> field1 = forms.EmailField(...) >> >> What's a good way to remove field2 in SubForm? > > Wrong question. Reconsider your class structure. Inheritance says that > SubForm "is-a" version of BaseForm. However, your question is asking how > you can actually break that constraint by removing one of the necessary > parts of BaseForm. So it isn't really a subclass after all. > > If there are common elements between BaseForm and SubForm, then factor > out those common bits into a true base class that both BaseForm and > SubForm inherit from. > > Regards. > Malcolm > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Writing custom model fields with Multi-table inheritance
On Fri, Feb 20, 2009 at 6:14 PM, gordytwrote: > > Karen I made a small sample to illustrate the problem and posted it > here: > > http://dpaste.com/hold/123199/ > > It's an extremely simple test case and instructions are included in > the comments. I'm not sure if this error is related to the issue that > you told me about or if it is something new entirely. > > Thanks a bunch! > It's a different problem (the one I was thinking of was a problem on initial save, not save of an existing object), but I think it is the same as this one: http://code.djangoproject.com/ticket/8813 If you could attach the file you dpasted to that ticket and note that you see this problem in the admin, that would probably be useful, as recreating it in admin should be easier than recreating the user-defined form, view, and models involved in the initial report there. (I have not had time to look in any detail at that problem, but it looks the same root cause based on the traceback.) Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: HttpResponse post
On Fri, 2009-02-20 at 19:39 -0800, Devin wrote: > I have no problem pulling pages using httplib if the pages do not > require authentication. But now I want to pull pages only after > authenticating. Access is enforced by the contributed auth package. > > import httplib, urllib > params = urllib.urlencode({'this_is_the_login_form':1,'username': > 'myuser', 'password': 'test'}) > headers = {"Content-type": "application/x-www-form-urlencoded", > "Accept": "text/plain"} > conn = httplib.HTTPConnection("myserver") > conn.request("POST", "/login/", params, headers) > response = conn.getresponse() > print response.status, response.reason > > As I said, when hitting pages that do not require auth, I am > successful and get a 200 response code. But when auth is needed, I > get 302 for the code and "found" for the status. > > Any insights? So you need to act like a browser would. Submit the necessary authentication form variables, save the returned cookie and send it on subsequent requests. Not sure how this is related ot the original question in the thread, though, which was about redirecting what the user's browser retrieves, not retrieving web pages inside Python scripts. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Validation problems with formset_factory
On Fri, 2009-02-20 at 19:32 -0800, mediumgrade wrote: > So, I have a form like this: > > class AddUserForm(forms.Form): > username = forms.CharField(label='Username', required=False) > password1 = forms.CharField(label='Password', > widget=forms.PasswordInput) > password2 = forms.CharField(label='Password (Again)', > widget=forms.PasswordInput) > first_name = forms.CharField(label='First Name') > last_name = forms.CharField(label='Last Name') > email = forms.EmailField(label='Email') > group = forms.ModelChoiceField(label='Group', > queryset=Group.objects.all()) > team = forms.ModelChoiceField(label='Team', > queryset=Team.objects.all()) > > def save(self): > //Some custom procedures here > return u So in the interests of effective debugging, what happens when you reduce this to the simplest possible example? In this case, that would be a form with exactly one field. Say, the "username" field and nothing else. If that works, add in another field. Rinse, wash, repeat, until the problem appears. Then try to remove the fields that you already know work, etc. I would expect that you will be able to get it down to a form containing only one or two fields that demonstrates the problem. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: HttpResponse post
I have no problem pulling pages using httplib if the pages do not require authentication. But now I want to pull pages only after authenticating. Access is enforced by the contributed auth package. import httplib, urllib params = urllib.urlencode({'this_is_the_login_form':1,'username': 'myuser', 'password': 'test'}) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} conn = httplib.HTTPConnection("myserver") conn.request("POST", "/login/", params, headers) response = conn.getresponse() print response.status, response.reason As I said, when hitting pages that do not require auth, I am successful and get a 200 response code. But when auth is needed, I get 302 for the code and "found" for the status. Any insights? On Feb 17, 12:28 pm, Antoni Aloywrote: > 2009/2/17 Miguel :> thanks karen, that is what I meant. > > >>> importhttplib, urllib > >>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) > >>> headers = {"Content-type": "application/x-www-form-urlencoded", > > ... "Accept": "text/plain"} > > >>> conn =httplib.HTTPConnection("musi-cal.mojam.com:80") > >>> conn.request("POST", "/cgi-bin/query", params, headers) > >>> response = conn.getresponse() > >>> print response.status, response.reason > 200 OK > >>> data = response.read() > >>> conn.close() > > Hope it helps! > > -- > Antoni Aloy López > Blog:http://trespams.com > Site:http://apsl.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Validation problems with formset_factory
So, I have a form like this: class AddUserForm(forms.Form): username = forms.CharField(label='Username', required=False) password1 = forms.CharField(label='Password', widget=forms.PasswordInput) password2 = forms.CharField(label='Password (Again)', widget=forms.PasswordInput) first_name = forms.CharField(label='First Name') last_name = forms.CharField(label='Last Name') email = forms.EmailField(label='Email') group = forms.ModelChoiceField(label='Group', queryset=Group.objects.all()) team = forms.ModelChoiceField(label='Team', queryset=Team.objects.all()) def save(self): //Some custom procedures here return u And I use it in a view like so: AddUserFormset = formset_factory(AddUserForm, extra=10, max_num=0) if request.method == 'POST': formset = AddUserFormset(request.POST, request.FILES) #If formset is valid if formset.is_valid(): #Do some stuff with the forms return render_to_response('profiles/ profile_add_users.html', { 'formset':formset, }, context_instance=RequestContext(request)) #Something was wrong with the formset else: return render_to_response('profiles/ profile_add_users.html', { 'formset':formset }, context_instance=RequestContext(request)) For some reason, all of the fields in the forms I leave blank give me "This field is required" errors and formset.is_valid() keeps failing. Is there something I am missing? Isn't the formset supposed to be smart enough to see that forms will all empty fields should be ignored? Any ideas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: OperationalError 1366 Incorrect string value ... for column 'message'
On Fri, Feb 20, 2009 at 8:00 PM, SeanBwrote: > > I have an application that include Unicode strings (Greek and Hebrew), > running on a dev machine and an (inside the firewall) release machine > configured (to the best of my ability) with the same Python, Django, > MySql and connector. > > When editing an object containing one of these strings on the release > machine, in the admin interface, when i save i get: > OperationalError at /admin/realia/lemmarelation/1597/ > > (1366, "Incorrect string value: '\\xE1\\xBC\\x80\\xCE\\xAE\\xCF...' > for column 'message' at row 1") > > Request Method: POST > Request URL:http://debuild/admin/realia/lemmarelation/1597/ > Exception Type: OperationalError > Exception Value: > > (1366, "Incorrect string value: '\\xE1\\xBC\\x80\\xCE\\xAE\\xCF...' > for column 'message' at row 1") > > [snip] > > 'message' isn't in my model, so it's breaking somewhere in the Django > part, but i'm not sure why, or how to fix it. And i can't find > anything different about my two environments that explains why it > breaks on one machine, but works fine on the other. What seems like > the likely culprit is a UTF-8 string, whose collating method is > utf8_general_ci. It's not a single data value: attempting to edit any > object in this table seems to raise this error. > Check the auth_message table definition (output of create table in mysql) on the machine that works vs. the one that fails. It sounds like on the failing machine this table may have a default latin1 charset instead of utf8, so whenever the Django admin code attempts to insert a message (e.g. "XYZ was changed, you may edit it again below") that refers to an object where "XYZ" is going to contain chars not representable in latin1, you get an error. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem outputting date in template as timestamp
On Fri, 2009-02-20 at 19:45 -0500, Karen Tracey wrote: [...] > Near as I can tell, also, the "U" date-formatting implementation > doesn't work. It is: > > def U(self): > "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)" > off = self.timezone.utcoffset(self.data) > return int(time.mktime(self.data.timetuple())) + off.seconds * > 60 Wow, that code's really old (like 2005 old). Possibly marked as unimplemented because Adrian knew it was broken and wanted to fix it, or something. [...] > So this is what off winds up being: > > >>> off = df.timezone.utcoffset(x) > >>> off > datetime.timedelta(-1, 68400) > >>> off.days > -1 > >>> off.seconds > 68400 > > This is negative one day, plus 68,4000 seconds, equivalent to -18,000 > seconds, but the subsequent code: > > return int(time.mktime(self.data.timetuple())) + off.seconds * 60 > > doesn't consider the negative days value and just uses the 68,4000 > seconds value, so that's a problem. That's a lovely trap in the timedelta API that regularly catches people out (including me, regularly enough, when I forget it happens). When we were implementing timezone support for syndicated feeds at the Washington DC sprint last year, I seem to recall it took a large portion of the time spent on that issue just to get things working for timezones west of UTC due to that "feature". If somebody wants to fix this robustly, I'd strongly suggest swiping the offset computation code from django.utils.feedgenerator. Both the rfc822_date() and rfc3339_date() functions do the computation correctly. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: grouping save() queries into a single query
On Fri, 2009-02-20 at 16:08 +0100, Alessandro Ronchi wrote: > is it possible to group different model save() to avoid the > multiplication of db connections and queries? > > I need to make a lot of save() of different new models and it should > be very useful to find a way to group them and commit together. > > Is there any way to make persistant connections? Russell's already addressed most of your questions. I'll just add that a single request/response cycle uses only a single database connection. Multiple database statements can well be sent down that connection, but we open only a single connection (and then close it once the response has been sent). If you want connection pooling between requests because the database is over a slow network or has costly connection, then the solution is to use pooling support external to Django (e.g. pgpool for PostgreSQL). However, that's unlikely to be the real issue here. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: distinct values in list
Alex, Once again sir you have shown me the light. Thank you. On Feb 20, 7:59 pm, Alex Gaynorwrote: > On Fri, Feb 20, 2009 at 7:58 PM, nixon66 wrote: > > > tried > > > Place.objects.values_list('county', flat=true).distinct() > > > Now its not returning any values. > > > On Feb 20, 7:49 pm, Alex Gaynor wrote: > > > On Fri, Feb 20, 2009 at 7:46 PM, nixon66 wrote: > > > > > I'm using this in a template to get a list of items in the list. > > > > > > > > > {% for item in list %} > > > > {{ item.var }} > > > > {% endfor %} > > > > > > > > > The problem is that I get duplicate values when I do this. So if var1 > > > > appears in my database more than once, I get it as many times as it > > > > appears. I looked at using the distinct() function but could not quite > > > > figure out how to get it to work the way I want. Any suggestions? > > > > Thanks in advance. > > > > If you only want to print one value from the items you can do something > > > like: > > > > Model.objects.values_list('field', flat=True).distinct() > > > > that will return a list of all the values in that field, but distint of > > > course. > > > > Alex > > > > -- > > > "I disapprove of what you say, but I will defend to the death your right > > to > > > say it." --Voltaire > > > "The people's good is the highest law."--Cicero > > It doesn't return models anymore, it just returns the individual items so > isntead of > > {% for item in lst %} > {{ item.var }} > {% endfor %} > > you would do > > {% for item in lst %} > {{ item }} > {% endfor %} > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Grouping a list of entries by month name
On Fri, 2009-02-20 at 15:00 -0800, Marlun wrote: > I'm not sure the answers I'm sending from my email is working so I'm > reposting here on google groups. > > In my case I wanted to get something like this: > > January 2008 > > Post name > Post name > > December 2007 > > Post name > Post name > > > I can't figure out how to do it the way your are saying. I thought > about doing: > > {% for entry in monts %} > {% ifchanged %}{{ entry.pub_date|date:"F Y" }}{% > endifchanged %} > > > {{ entry.title }} on > {{ entry.pub_date|date:"l jS \o\f F Y" }} > > > {% endfor %} > > but that added for every post like: > > Post > Post Well, yes, because that's what you told it to do in the template: each time around the loop include the ul, the li, the content and then close them. You need to close any existing "ul" element and open a new one whenever something has changed. Except on the very first iteration, when there's nothing to close, so you only open one. Assuming your pub_date attribute is a proper datetime, this will do the job: {% for entry in months %} {% ifchanged entry.pub_date.month %} ... {% if forloop.first %}{% endif %} {% endifchanged %} {% endfor %} {% if months %}{% endif %} (I may have messed that up slightly somewhere, but if you try it out, you'll see the general idea, hopefully.) One plausible approach that won't work, due to a bug in Django that we'll fix shortly (in 1.1 most likely) is this: {% ifchanged entry.pub_date|date:"F Y" %}...{% endifchanged %} That's because ifchanged (and a bunch of other tags) cannot process filters in their argument lists. However, direct attribute and variable access (such as entry.pub_date.month) work fine. Hope that gives you some ideas about how to proceed. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
OperationalError 1366 Incorrect string value ... for column 'message'
I have an application that include Unicode strings (Greek and Hebrew), running on a dev machine and an (inside the firewall) release machine configured (to the best of my ability) with the same Python, Django, MySql and connector. When editing an object containing one of these strings on the release machine, in the admin interface, when i save i get: OperationalError at /admin/realia/lemmarelation/1597/ (1366, "Incorrect string value: '\\xE1\\xBC\\x80\\xCE\\xAE\\xCF...' for column 'message' at row 1") Request Method: POST Request URL:http://debuild/admin/realia/lemmarelation/1597/ Exception Type: OperationalError Exception Value: (1366, "Incorrect string value: '\\xE1\\xBC\\x80\\xCE\\xAE\\xCF...' for column 'message' at row 1") Exception Location: C:\Python24\Lib\site-packages\MySQLdb \connections.py in defaulterrorhandler, line 35 Python Executable: C:\Program Files\Apache Software Foundation \Apache2.2\bin\httpd.exe Python Version: 2.4.3 Python Path:['c:/design.ed/django/logos/', 'C:\\Python24\\lib\\site- packages\\setuptools-0.6c6-py2.4.egg', 'C:\\Python24\\Lib\\site- packages\\django', 'C:\\design.ed\\django', 'C:\\Program Files\\Apache Software Foundation\\Apache2.2', 'C:\\WINDOWS\\system32\ \python24.zip', 'c:\\python24\\lib\\site-packages', 'C:\\Python24\ \Lib', 'C:\\Python24\\DLLs', 'C:\\Python24\\Lib\\lib-tk', 'C:\\Program Files\\Apache Software Foundation\\Apache2.2\\bin', 'C:\\Python24', 'c: \\design.ed\\python\\libronix', 'C:\\Python24\\lib\\site-packages\ \win32', 'C:\\Python24\\lib\\site-packages\\win32\\lib', 'C:\\Python24\ \lib\\site-packages\\Pythonwin'] Server time:Fri, 20 Feb 2009 16:51:59 -0800 'message' isn't in my model, so it's breaking somewhere in the Django part, but i'm not sure why, or how to fix it. And i can't find anything different about my two environments that explains why it breaks on one machine, but works fine on the other. What seems like the likely culprit is a UTF-8 string, whose collating method is utf8_general_ci. It's not a single data value: attempting to edit any object in this table seems to raise this error. Here's the traceback: Environment: Request Method: POST Request URL: http://debuild/admin/realia/lemmarelation/1597/ Django Version: 1.0.2 final Python Version: 2.4.3 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'logos.lcv', 'logos.places', 'logos.names', 'logos.agents', 'logos.realia'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware') Traceback: File "C:\Python24\Lib\site-packages\django\core\handlers\base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "C:\Python24\Lib\site-packages\django\contrib\admin\sites.py" in root 157. return self.model_page(request, *url.split('/', 2)) File "C:\Python24\Lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "C:\Python24\Lib\site-packages\django\contrib\admin\sites.py" in model_page 176. return admin_obj(request, rest_of_url) File "C:\Python24\Lib\site-packages\django\contrib\admin\options.py" in __call__ 197. return self.change_view(request, unquote(url)) File "C:\Python24\Lib\site-packages\django\db\transaction.py" in _commit_on_success 238. res = func(*args, **kw) File "C:\Python24\Lib\site-packages\django\contrib\admin\options.py" in change_view 587. return self.response_change(request, new_object) File "C:\Python24\Lib\site-packages\django\contrib\admin\options.py" in response_change 454. self.message_user(request, msg + ' ' + _("You may edit it again below.")) File "C:\Python24\Lib\site-packages\django\contrib\admin\options.py" in message_user 363. request.user.message_set.create(message=message) File "C:\Python24\Lib\site-packages\django\db\models\fields \related.py" in create 310. return super(RelatedManager, self).create (**kwargs) File "C:\Python24\Lib\site-packages\django\db\models\manager.py" in create 99. return self.get_query_set().create(**kwargs) File "C:\Python24\Lib\site-packages\django\db\models\query.py" in create 319. obj.save(force_insert=True) File "C:\Python24\Lib\site-packages\django\db\models\base.py" in save 311. self.save_base(force_insert=force_insert, force_update=force_update) File "C:\Python24\Lib\site-packages\django\db\models\base.py" in save_base 383. result = manager._insert(values, return_id=update_pk) File "C:\Python24\Lib\site-packages\django\db\models\manager.py" in _insert 138. return insert_query(self.model,
Re: distinct values in list
On Fri, Feb 20, 2009 at 7:58 PM, nixon66wrote: > > tried > > Place.objects.values_list('county', flat=true).distinct() > > Now its not returning any values. > > On Feb 20, 7:49 pm, Alex Gaynor wrote: > > On Fri, Feb 20, 2009 at 7:46 PM, nixon66 wrote: > > > > > I'm using this in a template to get a list of items in the list. > > > > > > > > {% for item in list %} > > >{{ item.var }} > > > {% endfor %} > > > > > > > > The problem is that I get duplicate values when I do this. So if var1 > > > appears in my database more than once, I get it as many times as it > > > appears. I looked at using the distinct() function but could not quite > > > figure out how to get it to work the way I want. Any suggestions? > > > Thanks in advance. > > > > If you only want to print one value from the items you can do something > > like: > > > > Model.objects.values_list('field', flat=True).distinct() > > > > that will return a list of all the values in that field, but distint of > > course. > > > > Alex > > > > -- > > "I disapprove of what you say, but I will defend to the death your right > to > > say it." --Voltaire > > "The people's good is the highest law."--Cicero > > > It doesn't return models anymore, it just returns the individual items so isntead of {% for item in lst %} {{ item.var }} {% endfor %} you would do {% for item in lst %} {{ item }} {% endfor %} -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: distinct values in list
tried Place.objects.values_list('county', flat=true).distinct() Now its not returning any values. On Feb 20, 7:49 pm, Alex Gaynorwrote: > On Fri, Feb 20, 2009 at 7:46 PM, nixon66 wrote: > > > I'm using this in a template to get a list of items in the list. > > > > > {% for item in list %} > > {{ item.var }} > > {% endfor %} > > > > > The problem is that I get duplicate values when I do this. So if var1 > > appears in my database more than once, I get it as many times as it > > appears. I looked at using the distinct() function but could not quite > > figure out how to get it to work the way I want. Any suggestions? > > Thanks in advance. > > If you only want to print one value from the items you can do something > like: > > Model.objects.values_list('field', flat=True).distinct() > > that will return a list of all the values in that field, but distint of > course. > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: distinct values in list
On Fri, Feb 20, 2009 at 7:46 PM, nixon66wrote: > > I'm using this in a template to get a list of items in the list. > > > {% for item in list %} >{{ item.var }} > {% endfor %} > > > The problem is that I get duplicate values when I do this. So if var1 > appears in my database more than once, I get it as many times as it > appears. I looked at using the distinct() function but could not quite > figure out how to get it to work the way I want. Any suggestions? > Thanks in advance. > > > If you only want to print one value from the items you can do something like: Model.objects.values_list('field', flat=True).distinct() that will return a list of all the values in that field, but distint of course. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem outputting date in template as timestamp
On Fri, Feb 20, 2009 at 6:21 PM, Jeff FWwrote: > > I just tried running the code that the "U" date-formatting parameter > uses, and for me, it was off by about 11.5 days. According to the > documentation, the "U" parameter is not implemented: > http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now > > According to this ticket, someone might change the documentation soon, > so you might want to get a word in beforehand: > http://code.djangoproject.com/ticket/9850 > > I'd do it, but you already have the lovely test case :-) > Note that test case doesn't work on Windows, where strftime('%s') doesn't work the same as on Unix: Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import datetime >>> now = datetime.now() >>> now.strftime('%s') '' >>> quit() So we can't add a testcase that relies on strftime('%s') returning anything in particular. The Python docs note that anything outside of what is explicitly listed (and %s is not listed) is platform-dependent and may vary unpredictably. Near as I can tell, also, the "U" date-formatting implementation doesn't work. It is: def U(self): "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)" off = self.timezone.utcoffset(self.data) return int(time.mktime(self.data.timetuple())) + off.seconds * 60 If you break down what that's doing in a shell, considering an easy time like Jan 1 1970 on the dot in my tz: >>> import datetime >>> x = datetime.datetime(1970,1,1) >>> x.strftime('%s') '18000' That makes sense, midnight Jan 1 1970 in my timezone -> 5 hours (18000/60/60) UTC (or is it GMT?). Whichever, 5 hours sounds right. But the U formatter comes up with: >>> from django.utils.dateformat import format >>> format(x,'U') u'4122000' ? Not the same. U up there is method on a DateFormat object initialized with the datetime value: >>> from django.utils.dateformat import DateFormat >>> df = DateFormat(x) >>> df.data datetime.datetime(1970, 1, 1, 0, 0) >>> df.timezone EST So this is what off winds up being: >>> off = df.timezone.utcoffset(x) >>> off datetime.timedelta(-1, 68400) >>> off.days -1 >>> off.seconds 68400 This is negative one day, plus 68,4000 seconds, equivalent to -18,000 seconds, but the subsequent code: return int(time.mktime(self.data.timetuple())) + off.seconds * 60 doesn't consider the negative days value and just uses the 68,4000 seconds value, so that's a problem. Furthermore I don't understand why this code multiplies a seconds value by 60. You divide seconds by 60 to get minutes, and again to get hours, but why would you multiply seconds by 60? It may be related to the fact that the Ptyhon docs ( http://docs.python.org/library/datetime.html#datetime.tzinfo.utcoffset) say the timezone utcoffset is a minutes value, which is a bit confusing since in fact later on it says a timedelta should be returned. But surely it wouldn't be expected that the seconds value of the returned timedelta would contain a number of minutes? Finally, in fact, at least on my box, doing any adjustment to the first bit isn't going to result in a value that matches strftime('%s'), because the first part is already what we get with strftime('%s'): >>> int(time.mktime(x.timetuple())) 18000 So, that may be another problem with the testcase -- the strftime('%s') half is assuming the answer is in UTC while the "U" format seems to be trying to adjust the answer so that it is expressed in local time -- even if that was working properly the answers wouldn't match. But I'll admit trying to figure out datetimes and timezones, etc. in Python rather makes my head spin so I could be missing something here. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
distinct values in list
I'm using this in a template to get a list of items in the list. {% for item in list %} {{ item.var }} {% endfor %} The problem is that I get duplicate values when I do this. So if var1 appears in my database more than once, I get it as many times as it appears. I looked at using the distinct() function but could not quite figure out how to get it to work the way I want. Any suggestions? Thanks in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin permissions i18n
On Fri, 2009-02-20 at 11:04 -0800, eleom wrote: > Hello, does somebody know if there's a way to localize admin > permission names, so that, for example, in the user change form, > instead of 'Can add ' a localized version of it is showed? There isn't any way at the moment. Django itself does not provide any localisation of database content. Maybe one day, but not today. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Removing fields in a form subclass
On Fri, 2009-02-20 at 10:15 -0500, David Zhou wrote: > Suppose I had this form: > > class BaseForm(forms.Form): > field1 = forms.CharField(...) > field2 = forms.Charfield(...) > > And then in a subclass, I had: > > class SubForm(BaseForm): > field1 = forms.EmailField(...) > > What's a good way to remove field2 in SubForm? Wrong question. Reconsider your class structure. Inheritance says that SubForm "is-a" version of BaseForm. However, your question is asking how you can actually break that constraint by removing one of the necessary parts of BaseForm. So it isn't really a subclass after all. If there are common elements between BaseForm and SubForm, then factor out those common bits into a true base class that both BaseForm and SubForm inherit from. Regards. Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: file validation in admin form
Thanks for the pointer! The docs are at http://docs.djangoproject.com/en/dev/ref/forms/validation/#ref-forms-validation. I had been letting Django use the default forms, and hadn't read much about forms, so I'd missed that hook. I used a clean_() method and it works perfectly. The only thing left is deciding which files are dangerous, so if anyone has any tips on that topic please let me know. I'm really only a novice when it comes to web programming, so I'm not familiar with the different security threats that are out there. Thanks again! On Feb 20, 6:25 pm, Brielwrote: > Validation is a big subject, and the validation of files can be very > complex aswell. Anyways to validate you need to define a clean method > in your form. Here you put the code that can test things like file > types, and whatever you can think of using python. I can't get you the > link as I'm not at my laptop, but if you search the django docs for > "form validation" "clean" or "cleaned_data" you should be able to find > the right doc. You want to read about the clean method an is_valid(). > > On 20 Feb., 22:09, Michael Repucci wrote: > > > I'm totally new to Django and authorized/secure web apps, and really > > loving it for this. But I've got a few really novice questions. I've > > got a model with a FileField, to which users can upload an arbitrary > > file. In the model docs for the FileField it says, "Validate all > > uploaded files." And I'm not sure where to do this or how. Is this > > through the save_model method of the ModelAdmin class? If so, what is > > the basic format, because not executing obj.save() didn't seem to do > > the trick. > > > Also, as mentioned in the docs, I don't want to allow a user to upload > > a PHP script or similar, and execute it by visiting the link, but I > > would like users to be able to place any of various file types on the > > server so that other users can download them. Is it enough to just > > exclude files with certain extensions (e.g., PHP, CGI, etc.), and if > > so, is there a list of all the "dangerous" file extensions somewhere? > > > Thanks for your help in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Beginner URL question.
I would sugest that you look at named urls and the {% url %} template tag. That way you can generate urls with the use of args for year, month, date. On 20 Feb., 21:30, JoeGwrote: > I've tried to find this on Google but I don't know the terminology so > I don't know what to search for. It's more of an html question than a > Django one but since I'm trying to learn Django, I thought I'd give > this group a try. > > I'm developing a fiscal calendar application. The URL will > behttp://host/calendar_id/fiscal_year/fiscal_month/day > > The URL starts with just the year and appends the period and day as > you drill into the calendar. Here's and example to illustrate; > > http://localhost:8000/calview/1/2009 - Show the 2009 > fiscal year for calendar 1 > http://localhost:8000/calview/1/2009/02 - Show the second > period for FY 2009, calendar 1 > http://localhost:8000/calview/1/2009/02/20 - Show the 20th day of > the second period for the above > > I'm having trouble figuring out how to do the href. On the first page > above that shows the entire year, When I try to add on the period with > and href "02", the url becomes "http://localhost:8000/ > calview/1/02" instead of "http://localhost:8000/calview/1/2009/02;. > > If I end the top URL with a slash, it works correctly but without that > slash on the end, it replaces the year portion with the period instead > of appending the period to the end. > > I realize that I could put in the full URL but that seems like it > would be less flexible. I could also try and force the URL to always > end in a slash but I'm not sure how to go about that. Is there any > way to build a relative URL that appends onto the end of the URL in > the address bar without needing to have a backslash as the last > character? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Beginner URL question.
You could try using a tag to explicitly state what the base for relative URLs should be. --Ned. http://nedbatchelder.com JoeG wrote: > I've tried to find this on Google but I don't know the terminology so > I don't know what to search for. It's more of an html question than a > Django one but since I'm trying to learn Django, I thought I'd give > this group a try. > > I'm developing a fiscal calendar application. The URL will be > http://host/calendar_id/fiscal_year/fiscal_month/day > > The URL starts with just the year and appends the period and day as > you drill into the calendar. Here's and example to illustrate; > >http://localhost:8000/calview/1/2009 - Show the 2009 > fiscal year for calendar 1 >http://localhost:8000/calview/1/2009/02 - Show the second > period for FY 2009, calendar 1 >http://localhost:8000/calview/1/2009/02/20 - Show the 20th day of > the second period for the above > > I'm having trouble figuring out how to do the href. On the first page > above that shows the entire year, When I try to add on the period with > and href "02", the url becomes "http://localhost:8000/ > calview/1/02" instead of "http://localhost:8000/calview/1/2009/02;. > > If I end the top URL with a slash, it works correctly but without that > slash on the end, it replaces the year portion with the period instead > of appending the period to the end. > > I realize that I could put in the full URL but that seems like it > would be less flexible. I could also try and force the URL to always > end in a slash but I'm not sure how to go about that. Is there any > way to build a relative URL that appends onto the end of the URL in > the address bar without needing to have a backslash as the last > character? > > > > > -- Ned Batchelder, http://nedbatchelder.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: file validation in admin form
Validation is a big subject, and the validation of files can be very complex aswell. Anyways to validate you need to define a clean method in your form. Here you put the code that can test things like file types, and whatever you can think of using python. I can't get you the link as I'm not at my laptop, but if you search the django docs for "form validation" "clean" or "cleaned_data" you should be able to find the right doc. You want to read about the clean method an is_valid(). On 20 Feb., 22:09, Michael Repucciwrote: > I'm totally new to Django and authorized/secure web apps, and really > loving it for this. But I've got a few really novice questions. I've > got a model with a FileField, to which users can upload an arbitrary > file. In the model docs for the FileField it says, "Validate all > uploaded files." And I'm not sure where to do this or how. Is this > through the save_model method of the ModelAdmin class? If so, what is > the basic format, because not executing obj.save() didn't seem to do > the trick. > > Also, as mentioned in the docs, I don't want to allow a user to upload > a PHP script or similar, and execute it by visiting the link, but I > would like users to be able to place any of various file types on the > server so that other users can download them. Is it enough to just > exclude files with certain extensions (e.g., PHP, CGI, etc.), and if > so, is there a list of all the "dangerous" file extensions somewhere? > > Thanks for your help in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: grouping save() queries into a single query
On Sat, Feb 21, 2009 at 12:08 AM, Alessandro Ronchiwrote: > > is it possible to group different model save() to avoid the > multiplication of db connections and queries? > > I need to make a lot of save() of different new models and it should > be very useful to find a way to group them and commit together. Depends what you mean by "group them". If you mean "in a single transaction", then sure - Django has transaction support, and it's well documented. However, if you mean "in a single INSERT statement, then no, there isn't anything natively to help with this. If database writes are a point worth optimizing in your application, writing raw SQL is the solution. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem outputting date in template as timestamp
I just tried running the code that the "U" date-formatting parameter uses, and for me, it was off by about 11.5 days. According to the documentation, the "U" parameter is not implemented: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now According to this ticket, someone might change the documentation soon, so you might want to get a word in beforehand: http://code.djangoproject.com/ticket/9850 I'd do it, but you already have the lovely test case :-) -Jeff On Feb 20, 12:46 pm, Sean Brantwrote: > > I asked a similar question a while ago... turns out the server i'm > > using from godaddy was set for Arizona and was an additional 20 some > > minutes off... > > I checked my server and the timezone is set to US/CENTRAL and my > settings file is set to America/Chicago. So that should be the same. > Plus the time is off by ~14 days. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Writing custom model fields with Multi-table inheritance
Karen I made a small sample to illustrate the problem and posted it here: http://dpaste.com/hold/123199/ It's an extremely simple test case and instructions are included in the comments. I'm not sure if this error is related to the issue that you told me about or if it is something new entirely. Thanks a bunch! --gordy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: NoReverseMatch for a named URL
I've seen errors like this when an url is missing a view to link to. All urls defined must have a view aswell. Start checking there else look the problem could be that you are missing args for a url tag in your template. Some reverse matching need args to fill in the dynamic part of the url, like the pk of an object. That would be where I would start looking. On 20 Feb., 22:40, Philippe Clériéwrote: > I am working through the examples in Pratical Django Projects. I am > using Django 1.02 on Ubuntu Intrepid. I expected to find problems > because of version differences but in general I've been able to work > out a solution. This one has got me stumped. You see the named url > that is at fault is different depending on where it is placed in the > project's urls.py. > > Presently it's like this and the coltrane_category_list is the first > url in coltrane/urls/categories.py. > > url(r'^blog/categories/', include('coltrane.urls.categories')), > url(r'^blog/links/', include('coltrane.urls.links')), > url(r'^blog/tags/', include('coltrane.urls.tags')), > url(r'^blog/', include('coltrane.urls.entries')), > > If I move the fourth line up, then the problematic url becomes the > first one in coltrane/urls/entries.py. > > But I move the tags url (third from top) then they all work. Not for > long though. As soon as I added the urls for the contrib/comments > app, I got a problem again with a url in entries.py. > > As I said I'm stumped. Any help will be appreciated. > > I hope that was a clear description of the problem. Feel free to ask > for more info. > > Thanks in advance. > > -- > > Philippe > > -- > The trouble with common sense is that it is so uncommon. > > > > Request Method:GET > Request URL:http://denebola.logisys.ht:8000/blog/ > Exception Type: TemplateSyntaxError > Exception Value: Caught an exception while rendering: Reverse for > 'cms.coltrane_category_list' with arguments '()' and keyword > arguments '{}' not found. > > Original Traceback (most recent call last): > File "/var/lib/python-support/python2.5/django/template/debug.py", > line 71, in render_node > result = node.render(context) > File "/var/lib/python- > support/python2.5/django/template/defaulttags.py", line 378, in > render > args=args, kwargs=kwargs) > File "/var/lib/python- > support/python2.5/django/core/urlresolvers.py", line 254, in reverse > *args, **kwargs))) > File "/var/lib/python- > support/python2.5/django/core/urlresolvers.py", line 243, in reverse > "arguments '%s' not found." % (lookup_view, args, kwargs)) > NoReverseMatch: Reverse for 'cms.coltrane_category_list' with > arguments '()' and keyword arguments '{}' not found. > > Exception Location: > /var/lib/python-support/python2.5/django/template/debug.py in > render_node, line 81 > Python Executable: > /usr/bin/python > Python Version: > 2.5.2 > Python Path: > ['/home/philippe/prj/django/cms', '/home/philippe/prj/django', > '/home/philippe/prj/django/cms', '/usr/lib/python2.5', > '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', > '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site- > packages', '/usr/lib/python2.5/site-packages', '/var/lib/python- > support/python2.5'] > Server time: > Fri, 20 Feb 2009 16:23:46 -0500 > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Grouping a list of entries by month name
I'm not sure the answers I'm sending from my email is working so I'm reposting here on google groups. In my case I wanted to get something like this: January 2008 Post name Post name December 2007 Post name Post name I can't figure out how to do it the way your are saying. I thought about doing: {% for entry in monts %} {% ifchanged %}{{ entry.pub_date|date:"F Y" }}{% endifchanged %} {{ entry.title }} on {{ entry.pub_date|date:"l jS \o\f F Y" }} {% endfor %} but that added for every post like: Post Post -Martin On Feb 19, 8:54 am, Malcolm Tredinnickwrote: > On Wed, 2009-02-18 at 23:35 -0800, Marlun wrote: > > I believe this will work perfectly in my case. > > > To easy my curiosity, how would you do it differently if you wanted > > the sequence object to be grouped by date but have the month name > > instead of number? I mean right now I get alistof entry objects. How > > would you change your view code to retrieve a sequense sorted by month > > name and year in the template? > > The month or year are more presentation details than data retrieval > operations. You still sort the result set by date, which brings all > theentriesfor month X in a particular year together. Then, in your > template, you can format the display however you like (including using > the "ifchanged" template tag if you want to display some value only when > it changes). > > Use the "date" template filter to format the results: if "obj" is a date > object, the {{ obj|date:"M" }} will display the month name in a > template. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
No proxy server configured in FireFox 3. I'm stumped as well. Guess I need to have the Oracle people in my office get in touch with their support people. There is one other Django person here at the University that might be able to help. I'll post my findings here if we're able to come up with a solution. Many thanks to everyone for their help! b On Feb 20, 4:37 pm, Ian Kellywrote: > On Feb 20, 3:26 pm, Brandon Taylor wrote: > > > Yes, I'm just using the built-in server for local development. I've > > restarted it dozens of times, cleared my browser cache, etc. > > > Is the built-in server not compatible with Oracle? If not, I'll just > > get an Apache/mod_wsgi instance running on my MacBook and use that > > instead. Would be nice if I could just use the built-in server though. > > The development server should be fine. You might check whether your > browser is configured to use a proxy server, though. If it is, then I > suspect there may be some caching going on at the proxy server. > > If that's not the problem, then I'm stumped. > > Hope that helps, > Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
On Feb 20, 3:26 pm, Brandon Taylorwrote: > Yes, I'm just using the built-in server for local development. I've > restarted it dozens of times, cleared my browser cache, etc. > > Is the built-in server not compatible with Oracle? If not, I'll just > get an Apache/mod_wsgi instance running on my MacBook and use that > instead. Would be nice if I could just use the built-in server though. The development server should be fine. You might check whether your browser is configured to use a proxy server, though. If it is, then I suspect there may be some caching going on at the proxy server. If that's not the problem, then I'm stumped. Hope that helps, Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
On Feb 20, 3:14 pm, Brandon Taylorwrote: > I think I may have found the culprit (?), but I have no idea how to > fix this. In my project folder, there is a file called sqlnet.log. > Here's the last entry: > > Fatal NI connect error 12505, connecting to: > (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) > (HOST=devportal2.dcs.its.utexas.edu)(PORT=1521))(CONNECT_DATA= > (SID=viprt.dcs.its.utexas.edu)(CID=(PROGRAM=Python)(HOST=btaylor- > MacBook.local)(USER=root > > VERSION INFORMATION: > TNS for MacOS X Server: Version 10.2.0.4.0 - Production > TCP/IP NT Protocol Adapter for MacOS X Server: Version 10.2.0.4.0 - > Production > Time: 20-FEB-2009 14:00:59 > Tracing not turned on. > Tns error struct: > ns main err code: 12564 > TNS-12564: Message 12564 not found; No message file for > product=network, facility=TNS > ns secondary err code: 0 > nt main err code: 0 > nt secondary err code: 0 > nt OS err code: 0 > > Check out the last value in the connection: USER=root > When I start up my dev server, I usually override port 80 on my Mac, > so I can just run at : localhost/ > > Shouldn't the USER parameter be the DATABASE_USER from settings.py? or > am I smoking crack? I believe that's just the username of the client process. The login credentials shouldn't be included in the DSN. Based on the error code and timestamp, I think this is related to the original error you were getting (ORA-12505: TNS:listener does not currently know of SID) and not the current problem. Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
Yes, I'm just using the built-in server for local development. I've restarted it dozens of times, cleared my browser cache, etc. Is the built-in server not compatible with Oracle? If not, I'll just get an Apache/mod_wsgi instance running on my MacBook and use that instead. Would be nice if I could just use the built-in server though. On Feb 20, 4:20 pm, Ian Kellywrote: > On Feb 20, 3:01 pm, Brandon Taylor wrote: > > > Actually I was referring to my action in views.py to get the Category > > objects: > > > from activity_codes.models import * (this is the auto-generated > > models.py) > > > def home(request): > > categories = Categories.objects.all() > > return render_to_response('test.html', {'categories' : > > categories}) > > Have you restarted the web server since fixing the models? Is there > any caching going on in between your browser and the server? Those > are the only reasons I can think of why it would work in a manage.py > shell, but not in a view. Also, this may seem obvious, but are you > using the same settings and models modules in both places? > > Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
On Feb 20, 3:01 pm, Brandon Taylorwrote: > Actually I was referring to my action in views.py to get the Category > objects: > > from activity_codes.models import * (this is the auto-generated > models.py) > > def home(request): > categories = Categories.objects.all() > return render_to_response('test.html', {'categories' : > categories}) Have you restarted the web server since fixing the models? Is there any caching going on in between your browser and the server? Those are the only reasons I can think of why it would work in a manage.py shell, but not in a view. Also, this may seem obvious, but are you using the same settings and models modules in both places? Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
I think I may have found the culprit (?), but I have no idea how to fix this. In my project folder, there is a file called sqlnet.log. Here's the last entry: Fatal NI connect error 12505, connecting to: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=devportal2.dcs.its.utexas.edu)(PORT=1521))(CONNECT_DATA= (SID=viprt.dcs.its.utexas.edu)(CID=(PROGRAM=Python)(HOST=btaylor- MacBook.local)(USER=root VERSION INFORMATION: TNS for MacOS X Server: Version 10.2.0.4.0 - Production TCP/IP NT Protocol Adapter for MacOS X Server: Version 10.2.0.4.0 - Production Time: 20-FEB-2009 14:00:59 Tracing not turned on. Tns error struct: ns main err code: 12564 TNS-12564: Message 12564 not found; No message file for product=network, facility=TNS ns secondary err code: 0 nt main err code: 0 nt secondary err code: 0 nt OS err code: 0 Check out the last value in the connection: USER=root When I start up my dev server, I usually override port 80 on my Mac, so I can just run at : localhost/ Shouldn't the USER parameter be the DATABASE_USER from settings.py? or am I smoking crack? b On Feb 20, 4:01 pm, Brandon Taylorwrote: > Actually I was referring to my action in views.py to get the Category > objects: > > from activity_codes.models import * (this is the auto-generated > models.py) > > def home(request): > categories = Categories.objects.all() > return render_to_response('test.html', {'categories' : > categories}) > > On Feb 20, 3:34 pm, Ian Kelly wrote: > > > On Feb 20, 2:25 pm, Brandon Taylor wrote: > > > > however attempting to retrieve the Category objects from a view > > > results in: > > > DatabaseError: ORA-00942: table or view does not exist > > > > Thoughts? > > > You can definitely use views with Django (although inspectdb will > > blissfully ignore them). We do that all the time. Again, I'd need to > > see the models.py to understand what's going on. Or it could be that > > the Django user has permissions on the table, but not on the view. > > > Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Overriding ID Field
I solved it , thanks :) 20 Şubat 2009 Cuma 14:08 tarihinde Veeravendhan sakkarai < veeravend...@gmail.com> yazdı: > > You just define your primary key field in the models, you can over come. > Also we can auto generate UUID. like the autoincrimint id field. > > > > On Fri, Feb 20, 2009 at 3:41 PM, burcu hamamcıoğlu> wrote: > > I want to define a custom id field, that holds a guid (uuid). But how can > i > > override the default id field? I want it to modified as guid.. > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
Actually I was referring to my action in views.py to get the Category objects: from activity_codes.models import * (this is the auto-generated models.py) def home(request): categories = Categories.objects.all() return render_to_response('test.html', {'categories' : categories}) On Feb 20, 3:34 pm, Ian Kellywrote: > On Feb 20, 2:25 pm, Brandon Taylor wrote: > > > however attempting to retrieve the Category objects from a view > > results in: > > DatabaseError: ORA-00942: table or view does not exist > > > Thoughts? > > You can definitely use views with Django (although inspectdb will > blissfully ignore them). We do that all the time. Again, I'd need to > see the models.py to understand what's going on. Or it could be that > the Django user has permissions on the table, but not on the view. > > Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
NoReverseMatch for a named URL
I am working through the examples in Pratical Django Projects. I am using Django 1.02 on Ubuntu Intrepid. I expected to find problems because of version differences but in general I've been able to work out a solution. This one has got me stumped. You see the named url that is at fault is different depending on where it is placed in the project's urls.py. Presently it's like this and the coltrane_category_list is the first url in coltrane/urls/categories.py. url(r'^blog/categories/', include('coltrane.urls.categories')), url(r'^blog/links/', include('coltrane.urls.links')), url(r'^blog/tags/', include('coltrane.urls.tags')), url(r'^blog/', include('coltrane.urls.entries')), If I move the fourth line up, then the problematic url becomes the first one in coltrane/urls/entries.py. But I move the tags url (third from top) then they all work. Not for long though. As soon as I added the urls for the contrib/comments app, I got a problem again with a url in entries.py. As I said I'm stumped. Any help will be appreciated. I hope that was a clear description of the problem. Feel free to ask for more info. Thanks in advance. -- Philippe -- The trouble with common sense is that it is so uncommon. Request Method:GET Request URL: http://denebola.logisys.ht:8000/blog/ Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: Reverse for 'cms.coltrane_category_list' with arguments '()' and keyword arguments '{}' not found. Original Traceback (most recent call last): File "/var/lib/python-support/python2.5/django/template/debug.py", line 71, in render_node result = node.render(context) File "/var/lib/python- support/python2.5/django/template/defaulttags.py", line 378, in render args=args, kwargs=kwargs) File "/var/lib/python- support/python2.5/django/core/urlresolvers.py", line 254, in reverse *args, **kwargs))) File "/var/lib/python- support/python2.5/django/core/urlresolvers.py", line 243, in reverse "arguments '%s' not found." % (lookup_view, args, kwargs)) NoReverseMatch: Reverse for 'cms.coltrane_category_list' with arguments '()' and keyword arguments '{}' not found. Exception Location: /var/lib/python-support/python2.5/django/template/debug.py in render_node, line 81 Python Executable: /usr/bin/python Python Version: 2.5.2 Python Path: ['/home/philippe/prj/django/cms', '/home/philippe/prj/django', '/home/philippe/prj/django/cms', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site- packages', '/usr/lib/python2.5/site-packages', '/var/lib/python- support/python2.5'] Server time: Fri, 20 Feb 2009 16:23:46 -0500 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
On Feb 20, 2:25 pm, Brandon Taylorwrote: > however attempting to retrieve the Category objects from a view > results in: > DatabaseError: ORA-00942: table or view does not exist > > Thoughts? You can definitely use views with Django (although inspectdb will blissfully ignore them). We do that all the time. Again, I'd need to see the models.py to understand what's going on. Or it could be that the Django user has permissions on the table, but not on the view. Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
here's the inspectdb models.py file: from django.db import models class Subtypes(models.Model): id = models.DecimalField(decimal_places=0, max_digits=38, db_column='ID', primary_key=True) # Field name made lowercase. type_id = models.DecimalField(decimal_places=0, null=True, max_digits=38, db_column='TYPE_ID', blank=True) # Field name made lowercase. name = models.CharField(max_length=255, db_column='NAME', blank=True) # Field name made lowercase. created_at = models.DateField(null=True, db_column='CREATED_AT', blank=True) # Field name made lowercase. updated_at = models.DateField(null=True, db_column='UPDATED_AT', blank=True) # Field name made lowercase. class Meta: db_table = u'SUBTYPES' class Types(models.Model): id = models.DecimalField(decimal_places=0, max_digits=38, db_column='ID', primary_key=True) # Field name made lowercase. category_id = models.DecimalField(decimal_places=0, null=True, max_digits=38, db_column='CATEGORY_ID', blank=True) # Field name made lowercase. name = models.CharField(max_length=255, db_column='NAME', blank=True) # Field name made lowercase. created_at = models.DateField(null=True, db_column='CREATED_AT', blank=True) # Field name made lowercase. updated_at = models.DateField(null=True, db_column='UPDATED_AT', blank=True) # Field name made lowercase. class Meta: db_table = u'TYPES' class Categories(models.Model): id = models.DecimalField(decimal_places=0, max_digits=38, db_column='ID', primary_key=True) # Field name made lowercase. name = models.CharField(max_length=255, db_column='NAME', blank=True) # Field name made lowercase. created_at = models.DateField(null=True, db_column='CREATED_AT', blank=True) # Field name made lowercase. updated_at = models.DateField(null=True, db_column='UPDATED_AT', blank=True) # Field name made lowercase. class Meta: db_table = u'CATEGORIES' class Activities(models.Model): id = models.DecimalField(decimal_places=0, max_digits=38, db_column='ID', primary_key=True) # Field name made lowercase. category_id = models.DecimalField(decimal_places=0, null=True, max_digits=38, db_column='CATEGORY_ID', blank=True) # Field name made lowercase. type_id = models.DecimalField(decimal_places=0, null=True, max_digits=38, db_column='TYPE_ID', blank=True) # Field name made lowercase. subtype_id = models.DecimalField(decimal_places=0, null=True, max_digits=38, db_column='SUBTYPE_ID', blank=True) # Field name made lowercase. group_id = models.DecimalField(decimal_places=0, null=True, max_digits=38, db_column='GROUP_ID', blank=True) # Field name made lowercase. subgroup_id = models.DecimalField(decimal_places=0, null=True, max_digits=38, db_column='SUBGROUP_ID', blank=True) # Field name made lowercase. csu_id = models.CharField(max_length=255, db_column='CSU_ID', blank=True) # Field name made lowercase. code = models.CharField(max_length=255, db_column='CODE', blank=True) # Field name made lowercase. description = models.CharField(max_length=255, db_column='DESCRIPTION', blank=True) # Field name made lowercase. comments = models.TextField(db_column='COMMENTS', blank=True) # Field name made lowercase. created_at = models.DateField(null=True, db_column='CREATED_AT', blank=True) # Field name made lowercase. updated_at = models.DateField(null=True, db_column='UPDATED_AT', blank=True) # Field name made lowercase. class Meta: db_table = u'ACTIVITIES' class SchemaMigrations(models.Model): version = models.CharField(unique=True, max_length=255, db_column='VERSION') # Field name made lowercase. class Meta: db_table = u'SCHEMA_MIGRATIONS' On Feb 20, 3:26 pm, Matt Boersmawrote: > Ah...I think specifying db_table as "ACTIVITY_CODE.CATEGORIES" is the > problem. We don't really have schema support in Django (yes, there's > a bug recorded for this issue), and unfortunately the approach of > specifying "schema.table" as the table name will not work. > > You'll probably have to do something like: > CREATE OR REPLACE SYNONYM categories FOR activity_code.categories; > And repeat for the relevant tables, views, or sequences. > > This is particularly problematic for Oracle, which nearly always uses > multiple schemas and specific permission grants in Real World (tm) > schemas. We tried a couple quick, Oracle-specific fixes in the past, > but they were insufficient, and thus we're pinning our hopes on the > "general schema support" enhancement coming someday. > > Shorter me: "What Ian said." > > On Fri, Feb 20, 2009 at 2:15 PM, Brandon Taylor > wrote: > > > Ok, now I am absolutely confounded... > > > I ran: manage.py inspectdb > models.py > > > Then I tried to get objects from the models THAT IT CREATED FOR ME - > > same friggin' error! > > > What in the world is up with this thing? I'm at a loss. > > > b > > > On Feb 20, 3:08 pm, Brandon Taylor
Re: Oracle connection issue
Ah...I think specifying db_table as "ACTIVITY_CODE.CATEGORIES" is the problem. We don't really have schema support in Django (yes, there's a bug recorded for this issue), and unfortunately the approach of specifying "schema.table" as the table name will not work. You'll probably have to do something like: CREATE OR REPLACE SYNONYM categories FOR activity_code.categories; And repeat for the relevant tables, views, or sequences. This is particularly problematic for Oracle, which nearly always uses multiple schemas and specific permission grants in Real World (tm) schemas. We tried a couple quick, Oracle-specific fixes in the past, but they were insufficient, and thus we're pinning our hopes on the "general schema support" enhancement coming someday. Shorter me: "What Ian said." On Fri, Feb 20, 2009 at 2:15 PM, Brandon Taylorwrote: > > Ok, now I am absolutely confounded... > > I ran: manage.py inspectdb > models.py > > Then I tried to get objects from the models THAT IT CREATED FOR ME - > same friggin' error! > > What in the world is up with this thing? I'm at a loss. > > b > > On Feb 20, 3:08 pm, Brandon Taylor wrote: >> Hi Ian, >> >> Here's her's the quick model I wrote to try to select *something*: >> >> class TestCategory(models.Model): >> name = models.CharField(max_length=255) >> class Meta: >> db_table = 'ACTIVITY_CODE.CATEGORIES' >> >> If I connect via dbshell from my project, I can do: select * from >> categories; >> >> and I get 11 records back, which is correct. But, if I try to retrieve >> these via: >> >> from my_app.models import TestCategory >> from django.shortcuts import render_to_response >> >> def test(request): >> categories = TestCategory.objects.all() >> return render_to_response('test.html', {'categories' ; >> categories}) >> >> I get: DatabaseError: ORA-00942: table or view does not exist >> >> ? ? ? >> >> On Feb 20, 2:53 pm, Brandon Taylor wrote: >> >> > Hi Matt, >> >> > Thanks for the reply. Well, I can get connected via sqlplus and I can: >> > desc activities... not sure what's up from the Django side. The user >> > I'm connecting with has correct privileges; my Oracle person has >> > triple-checked. >> >> > If I try to run a syncdb, I get the Oracle environment handle error, >> > even though I've specified that in manage.py. I also have my Oracle >> > home spec'd in my .bashrc and .bash_profile. I have no idea what to >> > try next. ugh. >> >> > b >> >> > On Feb 20, 2:33 pm, Matt Boersma wrote: >> >> > > Sorry, ignore my previous reply since you figured it out. >> >> > > It sounds like you have the tnsnames.ora and environment set up >> > > correctly. (Basically, in settings.py, you should either specify just >> > > DATABASE_NAME, so Oracle will use the tnsnames.ora or other lookup >> > > mechainism based on that, or else specify all DATABASE_foo parameters >> > > including DATABASE_HOST and DATABASE_PORT, which effectively bypasses >> > > tnsnames.ora.) >> >> > > Did you run "manage.py syncdb" or create the necessary tables >> > > otherwise? Now Django is connecting to Oracle successfully, but >> > > simply running a query that references a table it can't find. >> >> > > You might try "manage.py dbshell" to drop you into Oracle's sqlplus >> > > command line with the same connection parameters Django's dev server >> > > would use. Then try "SELECT * FROM mytable" or "DESC mytable" to see >> > > what's visible to those credentials. If the tables live in a >> > > different schema, you may need to create private synonyms to them in >> > > the Django user's schema--we nearly always end up with that structure >> > > in our Django/Oracle apps. >> >> > > Hope this helps, >> >> > > Matt >> >> > > On Fri, Feb 20, 2009 at 12:50 PM, Brandon Taylor >> >> > > wrote: >> >> > > > OK, I am pretty sure I found out where to put the tns_names.ora file: >> > > > $ORACLE_HOME/network/admin >> >> > > > But, I'm confused as to how to specify the database name. From the >> > > > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ >> > > > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME >> > > > setting. >> >> > > > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I >> > > > get: >> >> > > > DatabaseError: ORA-00942: table or view does not exist >> >> > > > ? ? ? >> >> > > > b >> >> > > > On Feb 20, 1:21 pm, Brandon Taylor wrote: >> > > >> Hi Matt, >> >> > > >> Ok, I modified manage.py to add two environ variables: >> >> > > >> import os >> > > >> oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' >> > > >> os.environ['ORACLE_HOME'] = oracle_home >> > > >> os.environ['DYLD_LIBRARY_PATH'] = oracle_home >> >> > > >> Now I'm getting an error: >> > > >> DatabaseError: ORA-12505: TNS:listener does not currently know of SID >> > > >> given in connect descriptor >> >> > >
Re: Oracle connection issue
On Feb 20, 2:08 pm, Brandon Taylorwrote: > Hi Ian, > > Here's her's the quick model I wrote to try to select *something*: > > class TestCategory(models.Model): > name = models.CharField(max_length=255) > class Meta: > db_table = 'ACTIVITY_CODE.CATEGORIES' Don't include the schema name in the db_table setting. Django expects just a table name, and it will quote that and look for a table named "ACTIVITY_CODE.CATEGORIES", which doesn't exist since the table's name is just "CATEGORIES". If the table resides in a different schema, the best approach is to create a private synonym for the table and point Django to the synonym (as I think Matt already mentioned). On Feb 20, 2:15 pm, Brandon Taylor wrote: > Ok, now I am absolutely confounded... > > I ran: manage.py inspectdb > models.py > > Then I tried to get objects from the models THAT IT CREATED FOR ME - > same friggin' error! > > What in the world is up with this thing? I'm at a loss. Could you please post the contents of the models.py that it created? Otherwise, I have no idea what's going on here. Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
Alright, this is what I *am* able to do... manage.py shell (from my project folder) from my_project.models import * categories = Categories.objects.all() print categories (and I get 11 Category objects - woohoo!) from django.db import connection print connection.queries [{'time': '0.007', 'sql': u'SELECT * FROM (SELECT ROWNUM AS "_RN", "_SUB".* FROM (SELECT "CATEGORIES"."ID", "CATEGORIES"."NAME", "CATEGORIES"."CREATED_AT", "CATEGORIES"."UPDATED_AT" FROM "CATEGORIES") "_SUB" WHERE ROWNUM <= 21) WHERE "_RN" > 0'}, {'time': '0.004', 'sql': u'SELECT "CATEGORIES"."ID", "CATEGORIES"."NAME", "CATEGORIES"."CREATED_AT", "CATEGORIES"."UPDATED_AT" FROM "CATEGORIES"'}] however attempting to retrieve the Category objects from a view results in: DatabaseError: ORA-00942: table or view does not exist Thoughts? On Feb 20, 3:15 pm, Brandon Taylorwrote: > Ok, now I am absolutely confounded... > > I ran: manage.py inspectdb > models.py > > Then I tried to get objects from the models THAT IT CREATED FOR ME - > same friggin' error! > > What in the world is up with this thing? I'm at a loss. > > b > > On Feb 20, 3:08 pm, Brandon Taylor wrote: > > > Hi Ian, > > > Here's her's the quick model I wrote to try to select *something*: > > > class TestCategory(models.Model): > > name = models.CharField(max_length=255) > > class Meta: > > db_table = 'ACTIVITY_CODE.CATEGORIES' > > > If I connect via dbshell from my project, I can do: select * from > > categories; > > > and I get 11 records back, which is correct. But, if I try to retrieve > > these via: > > > from my_app.models import TestCategory > > from django.shortcuts import render_to_response > > > def test(request): > > categories = TestCategory.objects.all() > > return render_to_response('test.html', {'categories' ; > > categories}) > > > I get: DatabaseError: ORA-00942: table or view does not exist > > > ? ? ? > > > On Feb 20, 2:53 pm, Brandon Taylor wrote: > > > > Hi Matt, > > > > Thanks for the reply. Well, I can get connected via sqlplus and I can: > > > desc activities... not sure what's up from the Django side. The user > > > I'm connecting with has correct privileges; my Oracle person has > > > triple-checked. > > > > If I try to run a syncdb, I get the Oracle environment handle error, > > > even though I've specified that in manage.py. I also have my Oracle > > > home spec'd in my .bashrc and .bash_profile. I have no idea what to > > > try next. ugh. > > > > b > > > > On Feb 20, 2:33 pm, Matt Boersma wrote: > > > > > Sorry, ignore my previous reply since you figured it out. > > > > > It sounds like you have the tnsnames.ora and environment set up > > > > correctly. (Basically, in settings.py, you should either specify just > > > > DATABASE_NAME, so Oracle will use the tnsnames.ora or other lookup > > > > mechainism based on that, or else specify all DATABASE_foo parameters > > > > including DATABASE_HOST and DATABASE_PORT, which effectively bypasses > > > > tnsnames.ora.) > > > > > Did you run "manage.py syncdb" or create the necessary tables > > > > otherwise? Now Django is connecting to Oracle successfully, but > > > > simply running a query that references a table it can't find. > > > > > You might try "manage.py dbshell" to drop you into Oracle's sqlplus > > > > command line with the same connection parameters Django's dev server > > > > would use. Then try "SELECT * FROM mytable" or "DESC mytable" to see > > > > what's visible to those credentials. If the tables live in a > > > > different schema, you may need to create private synonyms to them in > > > > the Django user's schema--we nearly always end up with that structure > > > > in our Django/Oracle apps. > > > > > Hope this helps, > > > > > Matt > > > > > On Fri, Feb 20, 2009 at 12:50 PM, Brandon Taylor > > > > > wrote: > > > > > > OK, I am pretty sure I found out where to put the tns_names.ora file: > > > > > $ORACLE_HOME/network/admin > > > > > > But, I'm confused as to how to specify the database name. From the > > > > > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ > > > > > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME > > > > > setting. > > > > > > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I > > > > > get: > > > > > > DatabaseError: ORA-00942: table or view does not exist > > > > > > ? ? ? > > > > > > b > > > > > > On Feb 20, 1:21 pm, Brandon Taylor wrote: > > > > >> Hi Matt, > > > > > >> Ok, I modified manage.py to add two environ variables: > > > > > >> import os > > > > >> oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' > > > > >> os.environ['ORACLE_HOME'] = oracle_home > > > > >> os.environ['DYLD_LIBRARY_PATH'] = oracle_home > > > > > >> Now I'm getting an error: > > > > >> DatabaseError: ORA-12505: TNS:listener does not currently know of SID > >
Re: Oracle connection issue
Ok, now I am absolutely confounded... I ran: manage.py inspectdb > models.py Then I tried to get objects from the models THAT IT CREATED FOR ME - same friggin' error! What in the world is up with this thing? I'm at a loss. b On Feb 20, 3:08 pm, Brandon Taylorwrote: > Hi Ian, > > Here's her's the quick model I wrote to try to select *something*: > > class TestCategory(models.Model): > name = models.CharField(max_length=255) > class Meta: > db_table = 'ACTIVITY_CODE.CATEGORIES' > > If I connect via dbshell from my project, I can do: select * from > categories; > > and I get 11 records back, which is correct. But, if I try to retrieve > these via: > > from my_app.models import TestCategory > from django.shortcuts import render_to_response > > def test(request): > categories = TestCategory.objects.all() > return render_to_response('test.html', {'categories' ; > categories}) > > I get: DatabaseError: ORA-00942: table or view does not exist > > ? ? ? > > On Feb 20, 2:53 pm, Brandon Taylor wrote: > > > Hi Matt, > > > Thanks for the reply. Well, I can get connected via sqlplus and I can: > > desc activities... not sure what's up from the Django side. The user > > I'm connecting with has correct privileges; my Oracle person has > > triple-checked. > > > If I try to run a syncdb, I get the Oracle environment handle error, > > even though I've specified that in manage.py. I also have my Oracle > > home spec'd in my .bashrc and .bash_profile. I have no idea what to > > try next. ugh. > > > b > > > On Feb 20, 2:33 pm, Matt Boersma wrote: > > > > Sorry, ignore my previous reply since you figured it out. > > > > It sounds like you have the tnsnames.ora and environment set up > > > correctly. (Basically, in settings.py, you should either specify just > > > DATABASE_NAME, so Oracle will use the tnsnames.ora or other lookup > > > mechainism based on that, or else specify all DATABASE_foo parameters > > > including DATABASE_HOST and DATABASE_PORT, which effectively bypasses > > > tnsnames.ora.) > > > > Did you run "manage.py syncdb" or create the necessary tables > > > otherwise? Now Django is connecting to Oracle successfully, but > > > simply running a query that references a table it can't find. > > > > You might try "manage.py dbshell" to drop you into Oracle's sqlplus > > > command line with the same connection parameters Django's dev server > > > would use. Then try "SELECT * FROM mytable" or "DESC mytable" to see > > > what's visible to those credentials. If the tables live in a > > > different schema, you may need to create private synonyms to them in > > > the Django user's schema--we nearly always end up with that structure > > > in our Django/Oracle apps. > > > > Hope this helps, > > > > Matt > > > > On Fri, Feb 20, 2009 at 12:50 PM, Brandon Taylor > > > > wrote: > > > > > OK, I am pretty sure I found out where to put the tns_names.ora file: > > > > $ORACLE_HOME/network/admin > > > > > But, I'm confused as to how to specify the database name. From the > > > > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ > > > > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME > > > > setting. > > > > > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I > > > > get: > > > > > DatabaseError: ORA-00942: table or view does not exist > > > > > ? ? ? > > > > > b > > > > > On Feb 20, 1:21 pm, Brandon Taylor wrote: > > > >> Hi Matt, > > > > >> Ok, I modified manage.py to add two environ variables: > > > > >> import os > > > >> oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' > > > >> os.environ['ORACLE_HOME'] = oracle_home > > > >> os.environ['DYLD_LIBRARY_PATH'] = oracle_home > > > > >> Now I'm getting an error: > > > >> DatabaseError: ORA-12505: TNS:listener does not currently know of SID > > > >> given in connect descriptor > > > > >> Everything I've found online seems to point to a "tnsnames.ora" file > > > >> that describes the connection information. A co-worker sent me their > > > >> "tnsnames.ora" file, but I'm unsure where to put this in OS X. > > > > >> My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2" > > > > >> Thoughts? > > > >> Brandon > > > > >> On Feb 20, 11:04 am, Matt Boersma wrote: > > > > >> > Brandon, > > > > >> > Usually that error arises from cx_Oracle when the ORACLE_HOME > > > >> > environment variable isn't set. Try doing "manage.py shell" and > > > >> > looking at what's in os.environ--if you don't see ORACLE_HOME set to > > > >> > the correct location there, try fixing that first. > > > > >> > Matt > > > > >> > On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor > > > >> > wrote: > > > > >> > > Hi everyone, > > > > >> > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X > > > >> > > 10.5.6 (Intel), Python 2.6.1
Re: Oracle connection issue
Could it be the case that your Django/Oracle user has the correct privileges, but the tables aren't in the user's default schema/tablespace? Django queries won't prepend the schema name, ever, so you need to ensure that either the tables were created or owned by the connecting user, or that synonyms exist so that "SELECT * FROM mytable" works, not just "SELECT * FROM myschema.mytable". Did you use sqlplus itself, or get there through "manage.py dbshell"? The latter way should ensure that you're connecting exactly as Django itself does. You could also do "manage.py shell," then run "Activity.objects.all()" or somesuch query, then: "from django.db import connection" "print connection.queries" That will show you the exact SQL that seems to be failing, which hopefully provides us a clue. I can't imagine why you'd get the environment error only when running syncdb, if other manage.py commands work. One other thing you could perhaps check is ensuring that the directory with the Oracle libraries is included in LD_LIBRARY_PATH--I know that's sometimes necessary. I do have a similar setup working on my MacBook Pro, but it's at home unfortunately so I can't examine my environment directly right now. Matt On Fri, Feb 20, 2009 at 1:53 PM, Brandon Taylorwrote: > > Hi Matt, > > Thanks for the reply. Well, I can get connected via sqlplus and I can: > desc activities... not sure what's up from the Django side. The user > I'm connecting with has correct privileges; my Oracle person has > triple-checked. > > If I try to run a syncdb, I get the Oracle environment handle error, > even though I've specified that in manage.py. I also have my Oracle > home spec'd in my .bashrc and .bash_profile. I have no idea what to > try next. ugh. > > b > > On Feb 20, 2:33 pm, Matt Boersma wrote: >> Sorry, ignore my previous reply since you figured it out. >> >> It sounds like you have the tnsnames.ora and environment set up >> correctly. (Basically, in settings.py, you should either specify just >> DATABASE_NAME, so Oracle will use the tnsnames.ora or other lookup >> mechainism based on that, or else specify all DATABASE_foo parameters >> including DATABASE_HOST and DATABASE_PORT, which effectively bypasses >> tnsnames.ora.) >> >> Did you run "manage.py syncdb" or create the necessary tables >> otherwise? Now Django is connecting to Oracle successfully, but >> simply running a query that references a table it can't find. >> >> You might try "manage.py dbshell" to drop you into Oracle's sqlplus >> command line with the same connection parameters Django's dev server >> would use. Then try "SELECT * FROM mytable" or "DESC mytable" to see >> what's visible to those credentials. If the tables live in a >> different schema, you may need to create private synonyms to them in >> the Django user's schema--we nearly always end up with that structure >> in our Django/Oracle apps. >> >> Hope this helps, >> >> Matt >> >> On Fri, Feb 20, 2009 at 12:50 PM, Brandon Taylor >> >> wrote: >> >> > OK, I am pretty sure I found out where to put the tns_names.ora file: >> > $ORACLE_HOME/network/admin >> >> > But, I'm confused as to how to specify the database name. From the >> > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ >> > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME >> > setting. >> >> > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I >> > get: >> >> > DatabaseError: ORA-00942: table or view does not exist >> >> > ? ? ? >> >> > b >> >> > On Feb 20, 1:21 pm, Brandon Taylor wrote: >> >> Hi Matt, >> >> >> Ok, I modified manage.py to add two environ variables: >> >> >> import os >> >> oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' >> >> os.environ['ORACLE_HOME'] = oracle_home >> >> os.environ['DYLD_LIBRARY_PATH'] = oracle_home >> >> >> Now I'm getting an error: >> >> DatabaseError: ORA-12505: TNS:listener does not currently know of SID >> >> given in connect descriptor >> >> >> Everything I've found online seems to point to a "tnsnames.ora" file >> >> that describes the connection information. A co-worker sent me their >> >> "tnsnames.ora" file, but I'm unsure where to put this in OS X. >> >> >> My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2" >> >> >> Thoughts? >> >> Brandon >> >> >> On Feb 20, 11:04 am, Matt Boersma wrote: >> >> >> > Brandon, >> >> >> > Usually that error arises from cx_Oracle when the ORACLE_HOME >> >> > environment variable isn't set. Try doing "manage.py shell" and >> >> > looking at what's in os.environ--if you don't see ORACLE_HOME set to >> >> > the correct location there, try fixing that first. >> >> >> > Matt >> >> >> > On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor >> >> > wrote: >> >> >> > > Hi everyone, >> >> >> > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X >>
file validation in admin form
I'm totally new to Django and authorized/secure web apps, and really loving it for this. But I've got a few really novice questions. I've got a model with a FileField, to which users can upload an arbitrary file. In the model docs for the FileField it says, "Validate all uploaded files." And I'm not sure where to do this or how. Is this through the save_model method of the ModelAdmin class? If so, what is the basic format, because not executing obj.save() didn't seem to do the trick. Also, as mentioned in the docs, I don't want to allow a user to upload a PHP script or similar, and execute it by visiting the link, but I would like users to be able to place any of various file types on the server so that other users can download them. Is it enough to just exclude files with certain extensions (e.g., PHP, CGI, etc.), and if so, is there a list of all the "dangerous" file extensions somewhere? Thanks for your help in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
Hi Ian, Here's her's the quick model I wrote to try to select *something*: class TestCategory(models.Model): name = models.CharField(max_length=255) class Meta: db_table = 'ACTIVITY_CODE.CATEGORIES' If I connect via dbshell from my project, I can do: select * from categories; and I get 11 records back, which is correct. But, if I try to retrieve these via: from my_app.models import TestCategory from django.shortcuts import render_to_response def test(request): categories = TestCategory.objects.all() return render_to_response('test.html', {'categories' ; categories}) I get: DatabaseError: ORA-00942: table or view does not exist ? ? ? On Feb 20, 2:53 pm, Brandon Taylorwrote: > Hi Matt, > > Thanks for the reply. Well, I can get connected via sqlplus and I can: > desc activities... not sure what's up from the Django side. The user > I'm connecting with has correct privileges; my Oracle person has > triple-checked. > > If I try to run a syncdb, I get the Oracle environment handle error, > even though I've specified that in manage.py. I also have my Oracle > home spec'd in my .bashrc and .bash_profile. I have no idea what to > try next. ugh. > > b > > On Feb 20, 2:33 pm, Matt Boersma wrote: > > > Sorry, ignore my previous reply since you figured it out. > > > It sounds like you have the tnsnames.ora and environment set up > > correctly. (Basically, in settings.py, you should either specify just > > DATABASE_NAME, so Oracle will use the tnsnames.ora or other lookup > > mechainism based on that, or else specify all DATABASE_foo parameters > > including DATABASE_HOST and DATABASE_PORT, which effectively bypasses > > tnsnames.ora.) > > > Did you run "manage.py syncdb" or create the necessary tables > > otherwise? Now Django is connecting to Oracle successfully, but > > simply running a query that references a table it can't find. > > > You might try "manage.py dbshell" to drop you into Oracle's sqlplus > > command line with the same connection parameters Django's dev server > > would use. Then try "SELECT * FROM mytable" or "DESC mytable" to see > > what's visible to those credentials. If the tables live in a > > different schema, you may need to create private synonyms to them in > > the Django user's schema--we nearly always end up with that structure > > in our Django/Oracle apps. > > > Hope this helps, > > > Matt > > > On Fri, Feb 20, 2009 at 12:50 PM, Brandon Taylor > > > wrote: > > > > OK, I am pretty sure I found out where to put the tns_names.ora file: > > > $ORACLE_HOME/network/admin > > > > But, I'm confused as to how to specify the database name. From the > > > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ > > > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME > > > setting. > > > > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I > > > get: > > > > DatabaseError: ORA-00942: table or view does not exist > > > > ? ? ? > > > > b > > > > On Feb 20, 1:21 pm, Brandon Taylor wrote: > > >> Hi Matt, > > > >> Ok, I modified manage.py to add two environ variables: > > > >> import os > > >> oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' > > >> os.environ['ORACLE_HOME'] = oracle_home > > >> os.environ['DYLD_LIBRARY_PATH'] = oracle_home > > > >> Now I'm getting an error: > > >> DatabaseError: ORA-12505: TNS:listener does not currently know of SID > > >> given in connect descriptor > > > >> Everything I've found online seems to point to a "tnsnames.ora" file > > >> that describes the connection information. A co-worker sent me their > > >> "tnsnames.ora" file, but I'm unsure where to put this in OS X. > > > >> My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2" > > > >> Thoughts? > > >> Brandon > > > >> On Feb 20, 11:04 am, Matt Boersma wrote: > > > >> > Brandon, > > > >> > Usually that error arises from cx_Oracle when the ORACLE_HOME > > >> > environment variable isn't set. Try doing "manage.py shell" and > > >> > looking at what's in os.environ--if you don't see ORACLE_HOME set to > > >> > the correct location there, try fixing that first. > > > >> > Matt > > > >> > On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor > > >> > wrote: > > > >> > > Hi everyone, > > > >> > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X > > >> > > 10.5.6 (Intel), Python 2.6.1 and Django trunk. > > > >> > > My built-in server will start up correct, but, when I attempt to get > > >> > > objects for a model, I receive the following error: > > > >> > > InterfaceError: Unable to acquire Oracle environment handle > > > >> > > Can anyone help me resolve this problem? > > > >> > > TIA, > > >> > > Brandon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to
Beginner URL question.
I've tried to find this on Google but I don't know the terminology so I don't know what to search for. It's more of an html question than a Django one but since I'm trying to learn Django, I thought I'd give this group a try. I'm developing a fiscal calendar application. The URL will be http://host/calendar_id/fiscal_year/fiscal_month/day The URL starts with just the year and appends the period and day as you drill into the calendar. Here's and example to illustrate; http://localhost:8000/calview/1/2009 - Show the 2009 fiscal year for calendar 1 http://localhost:8000/calview/1/2009/02 - Show the second period for FY 2009, calendar 1 http://localhost:8000/calview/1/2009/02/20 - Show the 20th day of the second period for the above I'm having trouble figuring out how to do the href. On the first page above that shows the entire year, When I try to add on the period with and href "02", the url becomes "http://localhost:8000/ calview/1/02" instead of "http://localhost:8000/calview/1/2009/02;. If I end the top URL with a slash, it works correctly but without that slash on the end, it replaces the year portion with the period instead of appending the period to the end. I realize that I could put in the full URL but that seems like it would be less flexible. I could also try and force the URL to always end in a slash but I'm not sure how to go about that. Is there any way to build a relative URL that appends onto the end of the URL in the address bar without needing to have a backslash as the last character? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
Hi Matt, Thanks for the reply. Well, I can get connected via sqlplus and I can: desc activities... not sure what's up from the Django side. The user I'm connecting with has correct privileges; my Oracle person has triple-checked. If I try to run a syncdb, I get the Oracle environment handle error, even though I've specified that in manage.py. I also have my Oracle home spec'd in my .bashrc and .bash_profile. I have no idea what to try next. ugh. b On Feb 20, 2:33 pm, Matt Boersmawrote: > Sorry, ignore my previous reply since you figured it out. > > It sounds like you have the tnsnames.ora and environment set up > correctly. (Basically, in settings.py, you should either specify just > DATABASE_NAME, so Oracle will use the tnsnames.ora or other lookup > mechainism based on that, or else specify all DATABASE_foo parameters > including DATABASE_HOST and DATABASE_PORT, which effectively bypasses > tnsnames.ora.) > > Did you run "manage.py syncdb" or create the necessary tables > otherwise? Now Django is connecting to Oracle successfully, but > simply running a query that references a table it can't find. > > You might try "manage.py dbshell" to drop you into Oracle's sqlplus > command line with the same connection parameters Django's dev server > would use. Then try "SELECT * FROM mytable" or "DESC mytable" to see > what's visible to those credentials. If the tables live in a > different schema, you may need to create private synonyms to them in > the Django user's schema--we nearly always end up with that structure > in our Django/Oracle apps. > > Hope this helps, > > Matt > > On Fri, Feb 20, 2009 at 12:50 PM, Brandon Taylor > > wrote: > > > OK, I am pretty sure I found out where to put the tns_names.ora file: > > $ORACLE_HOME/network/admin > > > But, I'm confused as to how to specify the database name. From the > > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ > > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME > > setting. > > > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I > > get: > > > DatabaseError: ORA-00942: table or view does not exist > > > ? ? ? > > > b > > > On Feb 20, 1:21 pm, Brandon Taylor wrote: > >> Hi Matt, > > >> Ok, I modified manage.py to add two environ variables: > > >> import os > >> oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' > >> os.environ['ORACLE_HOME'] = oracle_home > >> os.environ['DYLD_LIBRARY_PATH'] = oracle_home > > >> Now I'm getting an error: > >> DatabaseError: ORA-12505: TNS:listener does not currently know of SID > >> given in connect descriptor > > >> Everything I've found online seems to point to a "tnsnames.ora" file > >> that describes the connection information. A co-worker sent me their > >> "tnsnames.ora" file, but I'm unsure where to put this in OS X. > > >> My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2" > > >> Thoughts? > >> Brandon > > >> On Feb 20, 11:04 am, Matt Boersma wrote: > > >> > Brandon, > > >> > Usually that error arises from cx_Oracle when the ORACLE_HOME > >> > environment variable isn't set. Try doing "manage.py shell" and > >> > looking at what's in os.environ--if you don't see ORACLE_HOME set to > >> > the correct location there, try fixing that first. > > >> > Matt > > >> > On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor > >> > wrote: > > >> > > Hi everyone, > > >> > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X > >> > > 10.5.6 (Intel), Python 2.6.1 and Django trunk. > > >> > > My built-in server will start up correct, but, when I attempt to get > >> > > objects for a model, I receive the following error: > > >> > > InterfaceError: Unable to acquire Oracle environment handle > > >> > > Can anyone help me resolve this problem? > > >> > > TIA, > >> > > 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-users@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: "SuspiciousOperation" Error While Deleting an Uploaded File
Turns out the problem was the FileField value. It can't start with a forward slash, it has to be relative. On Feb 20, 2:28 pm, Tywrote: > That's the thing... (and I probably should have mentioned this) I'm > developing on Windows XP using the "manage.py runserver" command to > serve the files. > > On Feb 20, 2:26 pm, garagefan wrote: > > > Apache permissions must be set on the directory. I was having the same > > issue before I set the directory group to be Apache and gave it RWX > > privileges > > > On Feb 20, 2:21 pm, Ty wrote: > > > > When I login to the administration and try to delete a file I get a > > > "SuspiciousOperation" error. Here's the > > > traceback:http://dpaste.com/123112/ > > > > Here's my full model:http://dpaste.com/hold/123110/ > > > > Any help would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Trouble with admin select related
This was actually the admin overriding the select related in my manager with an empty one, which does not follow FK=null. Adding this to my Admin class I was able to force the select_related to behave. def queryset(self, request): return super(PageAdmin, self).queryset(request).select_related ('context__data_type', 'location') I think this approach is a little unintuitive and will start a convo on the dev list. On Feb 20, 12:15 pm, Karen Traceywrote: > On Thu, Feb 19, 2009 at 7:10 PM, Trey wrote: > > > I'm not sure if other people have stumbled onto this but I am having a > > LOT of trouble getting the admin to use select related. > > You know select_related is a performance optimization, right? It doesn't > affect results in any way, just the number of database queries that may be > required to produce a page. It isn't clear from what you have written here > how you are determining that select_related is not working. Are you > checking the number of queries issued somehow and seeing more than you would > expect? If so, explicitly listing the queries you are seeing vs. what you > are expecting (which also might require more complete model and admin defs > so people can understand the queries) would help people either explain why > the queries that are being issued are correct, or point out how to adjust > the admin defs to get the results you are expecting. > > If the problem is you are not seeing the results you are expecting on the > admin pages, then it likely has nothing to do with select_related, and you > need to more completely explain what you are expecting to see versus what > you are seeing. > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
On Feb 20, 12:50 pm, Brandon Taylorwrote: > OK, I am pretty sure I found out where to put the tns_names.ora file: > $ORACLE_HOME/network/admin > > But, I'm confused as to how to specify the database name. From the > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME > setting. Those docs could use some clarification. If you specify the database host and port, then DATABASE_NAME is indeed the SID. If you don't specify host and port, then DATABASE_NAME is the TNS name that will be used to look up the connection info. > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I > get: > > DatabaseError: ORA-00942: table or view does not exist Regardless of the above, this error suggests that you are in fact successfully connecting now, but that the tables Django is looking for don't exist. This could be because you haven't run Django's syncdb command [http://docs.djangoproject.com/en/dev/ref/django-admin/ #syncdb] to create the tables; or if you're connecting to a legacy database, because Django is looking for its automatically generated table names and not finding them. In the latter case, you should specify the 'db_table' Meta option [http://docs.djangoproject.com/en/ dev/ref/models/options/#db-table] on each of your models to the actual name of the table. Hope this helps, Ian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Writing custom model fields with Multi-table inheritance
> This sounds like a problem that has been fixed. Are you running with a > recent enough trunk or 1.0.X branch checkout so that you have this fix: > > http://code.djangoproject.com/changeset/9664 Karen I'm running build 9846. I'm going to put together a very minimal example to illustrate the problem and will post a link to it in this thread. Thanks! --gordy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple different user profile objects - Django code design help
On Feb 20, 6:07 am, Beres Botondwrote: > To be honest I don't really see why you would need multiple user > profile models, > instead of having one user profile model, and each entry would define > a different > user profile. What do you mean by "one user profile model, and each entry would define a different user profile"? Do you mean to have my single user profile model have many foreign keys hanging off of it pointing to other models? Or do you mean have a single user profile model with lots of instance data? Imagine an app where you have users who are teachers, students, or parents. You track different information about teachers (which courses they teach) vs. parents (relationship to student mom/dad, etc). I wouldn't want to cram all of that stuff into a single user profile model and then have to figure out which sets of fields apply at runtime. If it's just instance data and isn't a foreign key to another model, then it won't persist over time. Right? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
Sorry, ignore my previous reply since you figured it out. It sounds like you have the tnsnames.ora and environment set up correctly. (Basically, in settings.py, you should either specify just DATABASE_NAME, so Oracle will use the tnsnames.ora or other lookup mechainism based on that, or else specify all DATABASE_foo parameters including DATABASE_HOST and DATABASE_PORT, which effectively bypasses tnsnames.ora.) Did you run "manage.py syncdb" or create the necessary tables otherwise? Now Django is connecting to Oracle successfully, but simply running a query that references a table it can't find. You might try "manage.py dbshell" to drop you into Oracle's sqlplus command line with the same connection parameters Django's dev server would use. Then try "SELECT * FROM mytable" or "DESC mytable" to see what's visible to those credentials. If the tables live in a different schema, you may need to create private synonyms to them in the Django user's schema--we nearly always end up with that structure in our Django/Oracle apps. Hope this helps, Matt On Fri, Feb 20, 2009 at 12:50 PM, Brandon Taylorwrote: > > OK, I am pretty sure I found out where to put the tns_names.ora file: > $ORACLE_HOME/network/admin > > But, I'm confused as to how to specify the database name. From the > Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ > databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME > setting. > > If I set my DATABASE_NAME to my SID, and try to retrieve objects, I > get: > > DatabaseError: ORA-00942: table or view does not exist > > ? ? ? > > b > > On Feb 20, 1:21 pm, Brandon Taylor wrote: >> Hi Matt, >> >> Ok, I modified manage.py to add two environ variables: >> >> import os >> oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' >> os.environ['ORACLE_HOME'] = oracle_home >> os.environ['DYLD_LIBRARY_PATH'] = oracle_home >> >> Now I'm getting an error: >> DatabaseError: ORA-12505: TNS:listener does not currently know of SID >> given in connect descriptor >> >> Everything I've found online seems to point to a "tnsnames.ora" file >> that describes the connection information. A co-worker sent me their >> "tnsnames.ora" file, but I'm unsure where to put this in OS X. >> >> My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2" >> >> Thoughts? >> Brandon >> >> On Feb 20, 11:04 am, Matt Boersma wrote: >> >> > Brandon, >> >> > Usually that error arises from cx_Oracle when the ORACLE_HOME >> > environment variable isn't set. Try doing "manage.py shell" and >> > looking at what's in os.environ--if you don't see ORACLE_HOME set to >> > the correct location there, try fixing that first. >> >> > Matt >> >> > On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor >> > wrote: >> >> > > Hi everyone, >> >> > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X >> > > 10.5.6 (Intel), Python 2.6.1 and Django trunk. >> >> > > My built-in server will start up correct, but, when I attempt to get >> > > objects for a model, I receive the following error: >> >> > > InterfaceError: Unable to acquire Oracle environment handle >> >> > > Can anyone help me resolve this problem? >> >> > > TIA, >> > > 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-users@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: Oracle connection issue
Good, that's progress actually! So now cx_Oracle is finding the oracle libs correctly and giving up when it can't figure out how to connect to the database you've specified. So it needs to use one of Oracle's naming mechanisms to resolve the database location, such as LDAP or Oracle's own TNSNAMES.ORA flat file. Typically the client looks for $ORACLE_HOME/network/admin/tnsnames.ora. If you don't have that file or that directory structure under /Users/bft228/Library/Oracle/instantclient_10_2, you should go ahead and create them. Then try connecting again, and either it will work fine, or you'll have to do some editing of TNSNAMES.ORA to ensure hostnames and ports are all correct. There are ways to customize the location of TNSNAMES.ORA through environment variables, or to specify which set of naming methods to try, but probably this is sufficient for your use. Matt On Fri, Feb 20, 2009 at 12:21 PM, Brandon Taylorwrote: > > Hi Matt, > > Ok, I modified manage.py to add two environ variables: > > import os > oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' > os.environ['ORACLE_HOME'] = oracle_home > os.environ['DYLD_LIBRARY_PATH'] = oracle_home > > Now I'm getting an error: > DatabaseError: ORA-12505: TNS:listener does not currently know of SID > given in connect descriptor > > Everything I've found online seems to point to a "tnsnames.ora" file > that describes the connection information. A co-worker sent me their > "tnsnames.ora" file, but I'm unsure where to put this in OS X. > > My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2" > > Thoughts? > Brandon > > > On Feb 20, 11:04 am, Matt Boersma wrote: >> Brandon, >> >> Usually that error arises from cx_Oracle when the ORACLE_HOME >> environment variable isn't set. Try doing "manage.py shell" and >> looking at what's in os.environ--if you don't see ORACLE_HOME set to >> the correct location there, try fixing that first. >> >> Matt >> >> On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor >> wrote: >> >> > Hi everyone, >> >> > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X >> > 10.5.6 (Intel), Python 2.6.1 and Django trunk. >> >> > My built-in server will start up correct, but, when I attempt to get >> > objects for a model, I receive the following error: >> >> > InterfaceError: Unable to acquire Oracle environment handle >> >> > Can anyone help me resolve this problem? >> >> > TIA, >> > 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-users@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: Using a community Django Development system
On Fri, Feb 20, 2009 at 12:09 PM, DoJoewrote: > Can anyone share their experiences and setup details for using a > Django development server? I just ran across http://lethain.com/entry/2009/feb/13/the-django-and-ubuntu-intrepid-almanac/ the other day; maybe it'll help you out a bit. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
OK, I am pretty sure I found out where to put the tns_names.ora file: $ORACLE_HOME/network/admin But, I'm confused as to how to specify the database name. From the Django Oracle docs (http://docs.djangoproject.com/en/dev/ref/ databases/?from=olddocs#id9) they have the SID as the DATABASE_NAME setting. If I set my DATABASE_NAME to my SID, and try to retrieve objects, I get: DatabaseError: ORA-00942: table or view does not exist ? ? ? b On Feb 20, 1:21 pm, Brandon Taylorwrote: > Hi Matt, > > Ok, I modified manage.py to add two environ variables: > > import os > oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' > os.environ['ORACLE_HOME'] = oracle_home > os.environ['DYLD_LIBRARY_PATH'] = oracle_home > > Now I'm getting an error: > DatabaseError: ORA-12505: TNS:listener does not currently know of SID > given in connect descriptor > > Everything I've found online seems to point to a "tnsnames.ora" file > that describes the connection information. A co-worker sent me their > "tnsnames.ora" file, but I'm unsure where to put this in OS X. > > My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2" > > Thoughts? > Brandon > > On Feb 20, 11:04 am, Matt Boersma wrote: > > > Brandon, > > > Usually that error arises from cx_Oracle when the ORACLE_HOME > > environment variable isn't set. Try doing "manage.py shell" and > > looking at what's in os.environ--if you don't see ORACLE_HOME set to > > the correct location there, try fixing that first. > > > Matt > > > On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor > > wrote: > > > > Hi everyone, > > > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X > > > 10.5.6 (Intel), Python 2.6.1 and Django trunk. > > > > My built-in server will start up correct, but, when I attempt to get > > > objects for a model, I receive the following error: > > > > InterfaceError: Unable to acquire Oracle environment handle > > > > Can anyone help me resolve this problem? > > > > TIA, > > > 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-users@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: django newbie question
Alex, Thanks Ron On Feb 20, 2:37 pm, Alex Gaynorwrote: > On Fri, Feb 20, 2009 at 2:34 PM, nixon66 wrote: > > > eleom, > > > Thanks for the catch with country county in my model. > > > On Feb 20, 2:22 pm, eleom wrote: > > > Well, as the error message says, you must pass a County instance in > > > the argument 'county'. Now you are passing the name of the county, not > > > the county itself. So, your last line should be > > > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > > > city = 'Walla Walla', county=c, dollar_amount =54000) > > > > instead of > > > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > > > city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > > > where c is the County object defined before. > > > > P.S. By the way, you mix 'County' and 'Country' in your example. > > > > On Feb 20, 8:06 pm, nixon66 wrote: > > > > > If this is the wrong list to post a newbie question please let me > > > > know. I'm getting an error message while trying to populate the tables > > > > created by the models and not sure why. Here are the models > > > > > from django.db import models > > > > > class County(models.Model): > > > > name = models.CharField(max_length=80) > > > > slug = models.CharField(max_length=80) > > > > > def __unicode__(self): > > > > return self.name > > > > > def get_absolute_url(self): > > > > return "/countries/%s/" % self.slug > > > > > class Company(models.Model): > > > > name = models.CharField(max_length=50) > > > > address = models.CharField(max_length=80) > > > > client = models.CharField(max_length=50) > > > > city = models.CharField(max_length=50) > > > > county = models.ForeignKey(Country) > > > > dollar_amount = models.DecimalField('Cost (in dollars)', > > > > max_digits=10, decimal_places=2) > > > > > def __unicode__(self): > > > > return self.name > > > > > So I go into the shell and type this: > > > > > >>c=County(name='blah blah, slug="blah-blah") > > > > > then > > > > > >> l = Company(name='xyz corp', address='56 b. street', client='G > > corp', city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > > > > The error message I get is Valueerror: Cannot assign "blah blah" : > > > > "Company.county" must be a "County" instance. > > > > > doesn't this create the instance? > > > > >> c=County('blah blah', slug='blah-blah') > > > > > Any suggestion or point out my error would be appreciated. > > If you create a country in the admin the county field will display as a drop > down where you can select the correct county, and have a link where you can > create another one if it doesn't exist yet. > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django newbie question
On Fri, Feb 20, 2009 at 2:34 PM, nixon66wrote: > > eleom, > > Thanks for the catch with country county in my model. > > On Feb 20, 2:22 pm, eleom wrote: > > Well, as the error message says, you must pass a County instance in > > the argument 'county'. Now you are passing the name of the county, not > > the county itself. So, your last line should be > > > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > > city = 'Walla Walla', county=c, dollar_amount =54000) > > > > instead of > > > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > > city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > > > where c is the County object defined before. > > > > P.S. By the way, you mix 'County' and 'Country' in your example. > > > > On Feb 20, 8:06 pm, nixon66 wrote: > > > > > If this is the wrong list to post a newbie question please let me > > > know. I'm getting an error message while trying to populate the tables > > > created by the models and not sure why. Here are the models > > > > > from django.db import models > > > > > class County(models.Model): > > > name = models.CharField(max_length=80) > > > slug = models.CharField(max_length=80) > > > > > def __unicode__(self): > > > return self.name > > > > > def get_absolute_url(self): > > > return "/countries/%s/" % self.slug > > > > > class Company(models.Model): > > > name = models.CharField(max_length=50) > > > address = models.CharField(max_length=80) > > > client = models.CharField(max_length=50) > > > city = models.CharField(max_length=50) > > > county = models.ForeignKey(Country) > > > dollar_amount = models.DecimalField('Cost (in dollars)', > > > max_digits=10, decimal_places=2) > > > > > def __unicode__(self): > > > return self.name > > > > > So I go into the shell and type this: > > > > > >>c=County(name='blah blah, slug="blah-blah") > > > > > then > > > > > >> l = Company(name='xyz corp', address='56 b. street', client='G > corp', city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > > > > The error message I get is Valueerror: Cannot assign "blah blah" : > > > "Company.county" must be a "County" instance. > > > > > doesn't this create the instance? > > > >> c=County('blah blah', slug='blah-blah') > > > > > Any suggestion or point out my error would be appreciated. > > > If you create a country in the admin the county field will display as a drop down where you can select the correct county, and have a link where you can create another one if it doesn't exist yet. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django/Apache/wsgi problems -- help!
I'm glad to hear that everything is solved. > One more question: in what sense did you mean that MEDIA_ROOT > "is for file uploads"? I have not begun working on file uploads > yet, but I will need that, and I see there is documentation on it > which talks about several configurable options. Did you mean that > MEDIA_ROOT is the default location for uploaded files? Yes. Django uses MEDIA_ROOT as the root path for the upload_to parameter for FileField and ImageField. It defines the root of the directory tree where the files should be stored. It is typically the place where you will want to make publicly available through your web server. MEDIA_URL is used when constructing url values for such fields. > Thanks again for your help -- you saved my bacon! :) > Steve You are welcome. Regards, Polat Tuzla > > Polat Tuzla wrote: > > Also the /admin/ url gives > >> an internal error, which in apache's errlog shows a traceback > >> that ends in "OperationalError: no such table: django_session". > > > This is most probably due to the fact that you did not set your > > DB_NAME variable with the full path of your .db file. And sqlite3 is > > creating a new .db file as it cannot access the real one. > > That is: > > Instead of > > DATABASE_NAME = 'dev.db' > > you should set it as > > DATABASE_NAME = '/path/to/db/file/mydbfile.db' > > > And for the vhost configuation let me write down what works for me: > > > ServerNamewww.mysite.com > > ServerAlias *mysite.com > > Alias /media/admin /usr/lib/python2.5/site-packages/django/contrib/ > > admin/media > > > > Order allow,deny > > Allow from all > > > > Alias /media /path/to/project/site_media > > > > Order allow,deny > > Allow from all > > > > > WSGIScriptAlias / /path/to/project/apache/my.wsgi > > > WSGIDaemonProcess mysite.com user=myuser group=www-data threads=25 > > WSGIProcessGroup mysite.com > > > And set the configuration variables accordingly as: > > MEDIA_ROOT = '/path/to/project/site_media/' #this is for file > > uploads > > MEDIA_URL = "http://mysite.com/media/; > > ADMIN_MEDIA_PREFIX = '/media/admin/' > > >> (I also have MEDIA_ROOT set -- is it necessary to have both??) > > Yes it is. At least in this configuration I am demonstrating. > > > Hope this helps. > > Regards, > > > Polat Tuzla --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django newbie question
eleom, Thanks for the catch with country county in my model. On Feb 20, 2:22 pm, eleomwrote: > Well, as the error message says, you must pass a County instance in > the argument 'county'. Now you are passing the name of the county, not > the county itself. So, your last line should be > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > city = 'Walla Walla', county=c, dollar_amount =54000) > > instead of > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > where c is the County object defined before. > > P.S. By the way, you mix 'County' and 'Country' in your example. > > On Feb 20, 8:06 pm, nixon66 wrote: > > > If this is the wrong list to post a newbie question please let me > > know. I'm getting an error message while trying to populate the tables > > created by the models and not sure why. Here are the models > > > from django.db import models > > > class County(models.Model): > > name = models.CharField(max_length=80) > > slug = models.CharField(max_length=80) > > > def __unicode__(self): > > return self.name > > > def get_absolute_url(self): > > return "/countries/%s/" % self.slug > > > class Company(models.Model): > > name = models.CharField(max_length=50) > > address = models.CharField(max_length=80) > > client = models.CharField(max_length=50) > > city = models.CharField(max_length=50) > > county = models.ForeignKey(Country) > > dollar_amount = models.DecimalField('Cost (in dollars)', > > max_digits=10, decimal_places=2) > > > def __unicode__(self): > > return self.name > > > So I go into the shell and type this: > > > >>c=County(name='blah blah, slug="blah-blah") > > > then > > > >> l = Company(name='xyz corp', address='56 b. street', client='G corp', > > >> city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > > The error message I get is Valueerror: Cannot assign "blah blah" : > > "Company.county" must be a "County" instance. > > > doesn't this create the instance? > > >> c=County('blah blah', slug='blah-blah') > > > Any suggestion or point out my error would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django newbie question
Ahh!!! The light goes on. Thanks for the quick response. One additional question. How would you handle this if you are typing data into the admin and wanted to put in the county? On Feb 20, 2:22 pm, eleomwrote: > Well, as the error message says, you must pass a County instance in > the argument 'county'. Now you are passing the name of the county, not > the county itself. So, your last line should be > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > city = 'Walla Walla', county=c, dollar_amount =54000) > > instead of > > l = Company(name='xyz corp', address='56 b. street', client='G corp', > city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > where c is the County object defined before. > > P.S. By the way, you mix 'County' and 'Country' in your example. > > On Feb 20, 8:06 pm, nixon66 wrote: > > > If this is the wrong list to post a newbie question please let me > > know. I'm getting an error message while trying to populate the tables > > created by the models and not sure why. Here are the models > > > from django.db import models > > > class County(models.Model): > > name = models.CharField(max_length=80) > > slug = models.CharField(max_length=80) > > > def __unicode__(self): > > return self.name > > > def get_absolute_url(self): > > return "/countries/%s/" % self.slug > > > class Company(models.Model): > > name = models.CharField(max_length=50) > > address = models.CharField(max_length=80) > > client = models.CharField(max_length=50) > > city = models.CharField(max_length=50) > > county = models.ForeignKey(Country) > > dollar_amount = models.DecimalField('Cost (in dollars)', > > max_digits=10, decimal_places=2) > > > def __unicode__(self): > > return self.name > > > So I go into the shell and type this: > > > >>c=County(name='blah blah, slug="blah-blah") > > > then > > > >> l = Company(name='xyz corp', address='56 b. street', client='G corp', > > >> city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > > The error message I get is Valueerror: Cannot assign "blah blah" : > > "Company.county" must be a "County" instance. > > > doesn't this create the instance? > > >> c=County('blah blah', slug='blah-blah') > > > Any suggestion or point out my error would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
open sourced Django apps from Washington Times
Saw this link. Seems interesting http://opensource.washingtontimes.com/blog/post/coordt/2009/02/washington-times-releases-open-source-projects/ -- Ramdas S +91 9342 583 065 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "SuspiciousOperation" Error While Deleting an Uploaded File
That's the thing... (and I probably should have mentioned this) I'm developing on Windows XP using the "manage.py runserver" command to serve the files. On Feb 20, 2:26 pm, garagefanwrote: > Apache permissions must be set on the directory. I was having the same > issue before I set the directory group to be Apache and gave it RWX > privileges > > On Feb 20, 2:21 pm, Ty wrote: > > > When I login to the administration and try to delete a file I get a > > "SuspiciousOperation" error. Here's the traceback:http://dpaste.com/123112/ > > > Here's my full model:http://dpaste.com/hold/123110/ > > > Any help would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: "SuspiciousOperation" Error While Deleting an Uploaded File
Apache permissions must be set on the directory. I was having the same issue before I set the directory group to be Apache and gave it RWX privileges On Feb 20, 2:21 pm, Tywrote: > When I login to the administration and try to delete a file I get a > "SuspiciousOperation" error. Here's the traceback:http://dpaste.com/123112/ > > Here's my full model:http://dpaste.com/hold/123110/ > > Any help would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django newbie question
Well, as the error message says, you must pass a County instance in the argument 'county'. Now you are passing the name of the county, not the county itself. So, your last line should be l = Company(name='xyz corp', address='56 b. street', client='G corp', city = 'Walla Walla', county=c, dollar_amount =54000) instead of l = Company(name='xyz corp', address='56 b. street', client='G corp', city = 'Walla Walla', county='blah blah', dollar_amount =54000) where c is the County object defined before. P.S. By the way, you mix 'County' and 'Country' in your example. On Feb 20, 8:06 pm, nixon66wrote: > If this is the wrong list to post a newbie question please let me > know. I'm getting an error message while trying to populate the tables > created by the models and not sure why. Here are the models > > from django.db import models > > class County(models.Model): > name = models.CharField(max_length=80) > slug = models.CharField(max_length=80) > > def __unicode__(self): > return self.name > > def get_absolute_url(self): > return "/countries/%s/" % self.slug > > class Company(models.Model): > name = models.CharField(max_length=50) > address = models.CharField(max_length=80) > client = models.CharField(max_length=50) > city = models.CharField(max_length=50) > county = models.ForeignKey(Country) > dollar_amount = models.DecimalField('Cost (in dollars)', > max_digits=10, decimal_places=2) > > def __unicode__(self): > return self.name > > So I go into the shell and type this: > > >>c=County(name='blah blah, slug="blah-blah") > > then > > >> l = Company(name='xyz corp', address='56 b. street', client='G corp', city > >> = 'Walla Walla', county='blah blah', dollar_amount =54000) > > The error message I get is Valueerror: Cannot assign "blah blah" : > "Company.county" must be a "County" instance. > > doesn't this create the instance? > >> c=County('blah blah', slug='blah-blah') > > Any suggestion or point out my error would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
"SuspiciousOperation" Error While Deleting an Uploaded File
When I login to the administration and try to delete a file I get a "SuspiciousOperation" error. Here's the traceback: http://dpaste.com/123112/ Here's my full model: http://dpaste.com/hold/123110/ Any help would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Oracle connection issue
Hi Matt, Ok, I modified manage.py to add two environ variables: import os oracle_home = '/Users/bft228/Library/Oracle/instantclient_10_2' os.environ['ORACLE_HOME'] = oracle_home os.environ['DYLD_LIBRARY_PATH'] = oracle_home Now I'm getting an error: DatabaseError: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor Everything I've found online seems to point to a "tnsnames.ora" file that describes the connection information. A co-worker sent me their "tnsnames.ora" file, but I'm unsure where to put this in OS X. My ORACLE_HOME is "/Users/bft228/Library/Oracle/instantclient_10_2" Thoughts? Brandon On Feb 20, 11:04 am, Matt Boersmawrote: > Brandon, > > Usually that error arises from cx_Oracle when the ORACLE_HOME > environment variable isn't set. Try doing "manage.py shell" and > looking at what's in os.environ--if you don't see ORACLE_HOME set to > the correct location there, try fixing that first. > > Matt > > On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylor > wrote: > > > Hi everyone, > > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X > > 10.5.6 (Intel), Python 2.6.1 and Django trunk. > > > My built-in server will start up correct, but, when I attempt to get > > objects for a model, I receive the following error: > > > InterfaceError: Unable to acquire Oracle environment handle > > > Can anyone help me resolve this problem? > > > TIA, > > 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-users@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: django newbie question
On Fri, Feb 20, 2009 at 2:06 PM, nixon66wrote: > > If this is the wrong list to post a newbie question please let me > know. I'm getting an error message while trying to populate the tables > created by the models and not sure why. Here are the models > > from django.db import models > > class County(models.Model): >name = models.CharField(max_length=80) >slug = models.CharField(max_length=80) > >def __unicode__(self): >return self.name > >def get_absolute_url(self): >return "/countries/%s/" % self.slug > > class Company(models.Model): >name = models.CharField(max_length=50) >address = models.CharField(max_length=80) >client = models.CharField(max_length=50) >city = models.CharField(max_length=50) >county = models.ForeignKey(Country) >dollar_amount = models.DecimalField('Cost (in dollars)', > max_digits=10, decimal_places=2) > > >def __unicode__(self): >return self.name > > > So I go into the shell and type this: > > >>c=County(name='blah blah, slug="blah-blah") > > then > >> l = Company(name='xyz corp', address='56 b. street', client='G corp', > city = 'Walla Walla', county='blah blah', dollar_amount =54000) > > The error message I get is Valueerror: Cannot assign "blah blah" : > "Company.county" must be a "County" instance. > > doesn't this create the instance? > >> c=County('blah blah', slug='blah-blah') > > > Any suggestion or point out my error would be appreciated. > > > > > > > Yes, you create a County instance with County() however you aren't assigning that to county on the Company, you are assigning some string, you need to do Company(county=c). Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
admin permissions i18n
Hello, does somebody know if there's a way to localize admin permission names, so that, for example, in the user change form, instead of 'Can add ' a localized version of it is showed? I've searched documentation and the open tickets, but I have not found anything talking about this. (Ticket #65 talks about it but it's eventually closed as fixed without providing solution). I've also been reading the source and have found some places where changes could be done to easily support this. Just a couple of them: - redefine django.forms.models.ModelChoiceField.label_from_instance - redefine django.contrib.auth.models.Permission.__unicode__ But I would prefer not to modify django source code, to avoid maintenance problems, so I ask if I am missing something and this can be done without tweaking django. Thanks in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django newbie question
If this is the wrong list to post a newbie question please let me know. I'm getting an error message while trying to populate the tables created by the models and not sure why. Here are the models from django.db import models class County(models.Model): name = models.CharField(max_length=80) slug = models.CharField(max_length=80) def __unicode__(self): return self.name def get_absolute_url(self): return "/countries/%s/" % self.slug class Company(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) client = models.CharField(max_length=50) city = models.CharField(max_length=50) county = models.ForeignKey(Country) dollar_amount = models.DecimalField('Cost (in dollars)', max_digits=10, decimal_places=2) def __unicode__(self): return self.name So I go into the shell and type this: >>c=County(name='blah blah, slug="blah-blah") then >> l = Company(name='xyz corp', address='56 b. street', client='G corp', city = >> 'Walla Walla', county='blah blah', dollar_amount =54000) The error message I get is Valueerror: Cannot assign "blah blah" : "Company.county" must be a "County" instance. doesn't this create the instance? >> c=County('blah blah', slug='blah-blah') Any suggestion or point out my error would be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple form validation
On Fri, Feb 20, 2009 at 1:21 PM, flaggwrote: > > Ok this is driving me nuts. I have two form objects that manipulate > two models. I am trying to run the is_valid() method on both and then > save the form data to the DB. > > def all_valid(form1, form2): >return form1.is_valid() and form2.is_valid() > > def addorder(request): >today = date.today() >if request.method == 'POST': >orderform = OrderForm(request.POST, instance=Order(), > prefix="order") >equipform = EquipmentForm(request.POST, instance=Equipment(), > prefix="equipment") >if all_valid(equipform, orderform) == True: >orderform.save() >equipform.save() >return HttpResponseRedirect('/inventory/') >else: >orderform = OrderForm(initial={'orderdate': today.strftime('%Y- > %m-%d')}, instance=Order(), prefix="order") >equipform = EquipmentForm(instance=Equipment(), > prefix="equipment") > >return render_to_response('order_form.html', { 'orderform': > orderform, 'equipform': equipform }) > > If I only run is_valid on one form it adds the record correctly. But > when I add the second form validation check it fails. > It fails where, exactly? And how, exactly? 'Fails' meaning the the records aren't added and you aren't redirected to /inventory/ but rather get the form submission page redisplayed? If so, does the redisplay include any errors on any of the form fields? 'Fails' meaning an exception is thrown? 'Fails' meaning...? It would really help people help you if you were more specific about what 'fails' means. It also isn't entirely clear what you mean when you say if you run is_valid on one form (which one? does it matter which one? or no, either one works individually but just not both together?) 'the record' is added correctly -- the code you post appears to add 2 records, so presumably the code that works is a bit more different than just truncating the return line from all_valid to not call is_valid on the 2nd form? Exact details of the difference between the code that works and the code that fails might help people spot the significant difference. As it seems you have only posted the non-working version, people have to imagine what the working version looks like, which again makes it harder to try to help. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django/Apache/wsgi problems -- help!
Polat, Thank you, thank you!! That solved all the problems I had. I was really at a loss to know where to look -- perhaps I hadn't found the right docs, but this was the first time I had seen the things you suggested. One more question: in what sense did you mean that MEDIA_ROOT "is for file uploads"? I have not begun working on file uploads yet, but I will need that, and I see there is documentation on it which talks about several configurable options. Did you mean that MEDIA_ROOT is the default location for uploaded files? Thanks again for your help -- you saved my bacon! :) Steve Polat Tuzla wrote: > Also the /admin/ url gives >> an internal error, which in apache's errlog shows a traceback >> that ends in "OperationalError: no such table: django_session". > > This is most probably due to the fact that you did not set your > DB_NAME variable with the full path of your .db file. And sqlite3 is > creating a new .db file as it cannot access the real one. > That is: > Instead of > DATABASE_NAME = 'dev.db' > you should set it as > DATABASE_NAME = '/path/to/db/file/mydbfile.db' > > And for the vhost configuation let me write down what works for me: > > ServerName www.mysite.com > ServerAlias *mysite.com > Alias /media/admin /usr/lib/python2.5/site-packages/django/contrib/ > admin/media > > Order allow,deny > Allow from all > > Alias /media /path/to/project/site_media > > Order allow,deny > Allow from all > > > WSGIScriptAlias / /path/to/project/apache/my.wsgi > > WSGIDaemonProcess mysite.com user=myuser group=www-data threads=25 > WSGIProcessGroup mysite.com > > And set the configuration variables accordingly as: > MEDIA_ROOT = '/path/to/project/site_media/' #this is for file > uploads > MEDIA_URL = "http://mysite.com/media/; > ADMIN_MEDIA_PREFIX = '/media/admin/' > >> (I also have MEDIA_ROOT set -- is it necessary to have both??) > Yes it is. At least in this configuration I am demonstrating. > > Hope this helps. > Regards, > > Polat Tuzla > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multiple form validation
Ok this is driving me nuts. I have two form objects that manipulate two models. I am trying to run the is_valid() method on both and then save the form data to the DB. def all_valid(form1, form2): return form1.is_valid() and form2.is_valid() def addorder(request): today = date.today() if request.method == 'POST': orderform = OrderForm(request.POST, instance=Order(), prefix="order") equipform = EquipmentForm(request.POST, instance=Equipment(), prefix="equipment") if all_valid(equipform, orderform) == True: orderform.save() equipform.save() return HttpResponseRedirect('/inventory/') else: orderform = OrderForm(initial={'orderdate': today.strftime('%Y- %m-%d')}, instance=Order(), prefix="order") equipform = EquipmentForm(instance=Equipment(), prefix="equipment") return render_to_response('order_form.html', { 'orderform': orderform, 'equipform': equipform }) If I only run is_valid on one form it adds the record correctly. But when I add the second form validation check it fails. Am I missing something? The data I am inputting into the form is the correct format (i.e. IntegerField = a number, CharField = characters) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
URL field for only public addresses
I have a need for a subclass of the URL form field, in a slightly woolly way. I need it to only allow addresses which are *public*; that is, addresses which will have the same behaviour no matter where I am on the internet. (Yes, I know strictly you can never guarantee this for any number of reasons, but there are obvious cases where it won't be true) To a first approximation at least, this involves excluding localhost, and any IP addresses in the private ranges. It would also be nice if it also excluded any addresses which don't have valid global TLD's (eg intranet addresses like hostname.private should be excluded) I've also got the constraint that I'm definitely not interested in verify_exists - I want to be able to accept addresses which might 404 at the time of form validation. I know Django doesn't provide this by default, and I know how I would start doing it myself - I was just wondering if anyone else had faced similar issues and done some of the work for me ;-) Thanks, Toby --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: PostgreSQL case sensitive icontains
On Fri, Feb 20, 2009 at 12:00 PM, Alessandro Ronchi < alessandro.ron...@soasi.com> wrote: > > with postgreSQL I get case sensitive filters also with icontains. I do not see this behavior: Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.conf import settings >>> settings.DATABASE_ENGINE 'postgresql_psycopg2' >>> from ttt.models import DT >>> DT.objects.create(name='xyz') >>> DT.objects.create(name='XYZ') >>> DT.objects.filter(name__contains='y') [] >>> DT.objects.filter(name__icontains='y') [, ] >>> > Is there nothing I can do to solve this problem? > Perhaps if you gave a few more details on your models, your queries, and their results, someone could help. In the quick test I did icontains on PostgreSQL returns case-insensitive results, as expected. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using a community Django Development system
Can anyone share their experiences and setup details for using a Django development server? I'd like to setup a system using Ubuntu, MySQL and Perforce (version ctrl) so that a small group of developers can develop from one single system. If anyone can either point me to some existing information about this type of setup or share it, it would be greatly appreciated. Thx, Don --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django apache authentication strange behavior with apache indexing.
I posted this a couple of days ago and didn't get a response. Thought that I might try again. I am creating a private genealogy web page of pictures/obituaries/data files/census records etc... all just a set of files within a directory structure. I just want Apache to index the directory's contents and the files within them and serve them over the web. That works fine. Then I wanted to restrict access, which also worked fine using standard .htaccess authentication. But then I want to integrate that into my django web page, and restrict access using the django user database instead of the external user database. When I set the contents of my .htaccess files as follows: AuthType Basic AuthName "jlcarroll.net" Require valid-user SetEnv DJANGO_SETTINGS_MODULE django_smug.settings PythonAuthenHandler django.contrib.auth.handlers.modpython pythonOption DJANGO_SETTINGS_MODULE django_smug.settings Options +Indexes SetHandler None Authentication works fine, and I can index the files, but the index doesn't show directories for some strange reason The SetHandler None directive is there because I want Apache to index the files, and I haven't written a view to index them. I could write a view, but that is slower, and I am curious what is wrong, they are static files, so I would rather let Apache handle it. When I change the .htaccess file to the following: Options +Indexes SetHandler None It indexes files and directories, but of course has no authentication. I don't know why it would work without the django authentication but fail with that, since the Options +Inexes are the same. Perhaps django is setting some exclude directories flag while it is authenticating, not sure why it would do that, but it is all I could think of. when I set it to: AuthName "HohumRealm" AuthType Basic AuthUserFile /home/jlc/Family.passwd require valid-user Options +Indexes SetHandler None Authentication works, and directories index, but (obviously) the user database is not synced to django's user database. If I have to use regular .htaccess authentication this isn't a deal killer, but it does mean that I can't use the same user/password list for both, which is a bother to my users (they have to create a user twice, and some of them are computer illiterate, and would get confused). Any ideas how to fix this? If it could be fixed, it would be a MUCH better solution than doing things the old-school way. Apache version is 2.2.9, What other information would be useful? Thanks in advance for your help, James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem outputting date in template as timestamp
> I asked a similar question a while ago... turns out the server i'm > using from godaddy was set for Arizona and was an additional 20 some > minutes off... I checked my server and the timezone is set to US/CENTRAL and my settings file is set to America/Chicago. So that should be the same. Plus the time is off by ~14 days. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Connecting to Oracle
On Fri, Feb 20, 2009 at 10:52 AM, Brandon Taylorwrote: > > Hi everyone, > > I'm having a hell of a time getting connected to Oracle... > > We're running Intel MacBooks, OS X 10.5.6, Python 2.6.1, Django Trunk, > Oracle InstantClient 10_2. > > We have tried using cx_Oracle-5.0 and 4.4.1. cx_Oracle seems to > compile and install successfully, but, when we attempt to run a > project using the built-in server, we're getting an error with both > versions: > > Unhandled exception in thread started by 0x782030> > [snip] > Referenced from: /Users/bft228/.python-eggs/cx_Oracle-4.4.1-py2.6- > macosx-10.3-i386.egg-tmp/cx_Oracle.so > Reason: image not found > > > Can anyone out there help me get this working? I have very limited > experience with Oracle, so please bear with me. > Have you read this page or the ones it references: http://codingnaked.wordpress.com/2008/05/07/build-and-install-cx_oracle-on-macos-x-leopard-intel/ ? Someone in the comments there had the same error message and seemed to figure out how to fix it. Also, do not use cx_oracle 5.0. It has a bug that will cause problems, see: http://code.djangoproject.com/ticket/9935#comment:4 5.0.1 will apparently be OK, but 5.0 is definitely not good. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Writing custom model fields with Multi-table inheritance
On Fri, Feb 20, 2009 at 10:21 AM, gordytwrote: > > Howdy Viktor, > > On Feb 1, 1:36 pm, Viktor wrote: > > Hi, > > > > did you got any response or did you managed to solve your problem? > > I've just started to search for a UUIDField, and it would be great to > > have proper uuid columns for postgres. > > > > If so do you plan to commit it to django_extensions? > > Sorry for the delayed reply. I just noticed your message. I do have > my custom uuid field working, using native uuid datatype with > postgresql and char field for other databases. > > There is one situation where I'm seeing a problem in the Django admin > interface and as soon as I can resolve it I will post the complete > solution. > > The problem is seen when using a model that has a uuid primary key > that is edited inline (tabular or stacked) on the same page as a > parent model. I see this problem not just with my version of > UUIDField but also with the one that is currently in django- > extensions. > > I'm trying to figure out what Django does differently when using it's > own automatically generated primary key as opposed to using a declared > primary key. > This sounds like a problem that has been fixed. Are you running with a recent enough trunk or 1.0.X branch checkout so that you have this fix: http://code.djangoproject.com/changeset/9664 ? Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem outputting date in template as timestamp
server date incorrect? I asked a similar question a while ago... turns out the server i'm using from godaddy was set for Arizona and was an additional 20 some minutes off... On Feb 20, 11:49 am, Sean Brantwrote: > I am trying to render a timestamp in my template with date:"U" but the > timestamps are days off. I wrote up a simple test case that fails. Do > you think this is a bug or a user error? I am running rev: 9846. > > from django.test import TestCase > > class SimpleTest(TestCase): > def test_template_timestamp(self): > from datetime import datetime > from django.template import Context, Template > now = datetime.now() > t = Template('{{ now|date:"U" }}') > c = Context({'now': now}) > self.failUnlessEqual(int(now.strftime('%s')), int(t.render > (c))) > > Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Trouble with admin select related
On Thu, Feb 19, 2009 at 7:10 PM, Treywrote: > > I'm not sure if other people have stumbled onto this but I am having a > LOT of trouble getting the admin to use select related. > You know select_related is a performance optimization, right? It doesn't affect results in any way, just the number of database queries that may be required to produce a page. It isn't clear from what you have written here how you are determining that select_related is not working. Are you checking the number of queries issued somehow and seeing more than you would expect? If so, explicitly listing the queries you are seeing vs. what you are expecting (which also might require more complete model and admin defs so people can understand the queries) would help people either explain why the queries that are being issued are correct, or point out how to adjust the admin defs to get the results you are expecting. If the problem is you are not seeing the results you are expecting on the admin pages, then it likely has nothing to do with select_related, and you need to more completely explain what you are expecting to see versus what you are seeing. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django admin manytomany
I have a manytomany relationship between publication and pathology. Each publication can have many pathologies. When a publication appears in the admin template, I need to be able to see the many pathologies associated with that publication. Here is the model statement: class Pathology(models.Model): pathology = models.CharField(max_length=100) def __unicode__(self): return self.pathology class Meta: ordering = ["pathology"] class Publication(models.Model): pubtitle = models.TextField() pathology = models.ManyToManyField(Pathology) def __unicode__(self): return self.pubtitle class Meta: ordering = ["pubtitle"] Here is the admin.py. I have tried variations of the following, but always get an error saying either publication or pathology doesn't have a foreign key associated. I've even tried removing the inlines=[PathologyInline]. from myprograms.cpssite.models import Pathology class PathologyAdmin(admin.ModelAdmin): # ... list_display = ('pathology', 'id') admin.site.register(Pathology, PathologyAdmin) class PathologyInline(admin.TabularInline): #... model = Pathology extra = 3 class PublicationAdmin(admin.ModelAdmin): # ... ordering = ('pubtitle', 'year') inlines = [PathologyInline] admin.site.register(Publication,PublicationAdmin) Thanks for any help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: testing validation of form in unit testing
Here's the code that process all steps in unittest with checking validation form: http://dpaste.com/123059/ What I have tryed is to collect data myself as fixture to test the form validation. Thanks On Feb 20, 7:00 pm, Brielwrote: > You don't give a lot information about what is happening, so I'm > stabbing a bit in the dark here... > > I would guess your problem is that you have created a form which has a > filefield that is required. Even though you probably upload a file and > maybe even pass it to the form, you are not doing it in a way that > django can understand. Probably because you choose to construct your > own date instead of using the data from request.POST and > request.FILES. It would be a much better approach to use the data from > request, and then if it needs to be altered, to do it in the form > validation. This could be done if you fx have a models primary key and > instead want to return the object. > > Anyways, if this doesn't help you, you would help yourself a lot if > you do explain what exactly the problem is, what you are doing, maybe > a little snippet of code. > > On Feb 20, 5:01 pm, Vitaly wrote: > > > Hi all > > > I have a test that validate processed data to form with FileField. My > > steps in it direct me right to one problem. here is it. > > > 'file' is 'Required field' > > > What I do is process simple data right to form, not request.POST and > > request.FILES. > > I have tried process in data SimpleUploadedFile but no result. > > > Why is it? and how this problem can be solved? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Access extra parameters in forms.py
Fantastic! that fixed it. Thank you soo much, been driving me crazy for days now, Pete On Feb 20, 4:40 pm, Daniel Rosemanwrote: > On Feb 20, 2:40 pm, pete wrote: > > > > > Hi Daniel, > > > This has got me closer but i'm now just getting an empty select box > > appearing on in the form, with no data in. > > > class NewBugForm(forms.Form): > > assigned_to = forms.CharField(max_length=50,widget=forms.Select > > (choices=[]), initial='Anyone',required=False) > > > def __init__(self, *args, **kwargs): > > all_users = kwargs.pop("all_users") > > super(NewBugForm, self).__init__(*args,**kwargs) > > print all_users > > self.fields['assigned_to'].choices = all_users > > > If I print out all_users I can see it is there after the super(), but > > for some reason its not appending to the form. The following is a > > print out of all_users: > > > (('Anyone', 'Anyone'), ('Pete Randall', 'Pete Randall'), ('Chris > > Smith', 'Chris Smith')) > > > Could it have something to do with that list not being in the right > > format? > > > Cheers, > > > Pete. > > My mistake, the last line should be: > self.fields['assigned_to'].widget.choices = all_users > > That should work. > -- > 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-users@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: Oracle connection issue
Brandon, Usually that error arises from cx_Oracle when the ORACLE_HOME environment variable isn't set. Try doing "manage.py shell" and looking at what's in os.environ--if you don't see ORACLE_HOME set to the correct location there, try fixing that first. Matt On Fri, Feb 20, 2009 at 9:41 AM, Brandon Taylorwrote: > > Hi everyone, > > I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X > 10.5.6 (Intel), Python 2.6.1 and Django trunk. > > My built-in server will start up correct, but, when I attempt to get > objects for a model, I receive the following error: > > InterfaceError: Unable to acquire Oracle environment handle > > Can anyone help me resolve this problem? > > TIA, > 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-users@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: send_mail / mail_admins to qmail server
On Fri, Feb 20, 2009 at 3:55 AM, Reza Muhammadwrote: > > On Feb 20, 2009, at 2:19 PM, Karen Tracey wrote: > > ... > > >> > > Or does it fail not because of the password? because I can connect to >> the mail server from my regular email client with pretty much the same >> setting. >> > > Pretty much the same? What's different? Do you specify anything about > secure sockets or STARTTLS with the client? If you do, you probably need to > turn on EMAIL_USE_TLS in the Django config. Other than that I'm not sure > where to look for what's going wrong. > > > Sorry, I meant they are the same. The username, password, mail server > address are the same. I'm just confused why I can connect from my mail > client, but not through send_mail/mail_admins. > And you don't specify anything like secure sockets or STARTTLS required for the mail client? Lacking source to the mail client (which I'm assuming you don't have?) to compare what it does with what Django does, I'd probably take a network trace of the two cases and compare where they differ. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
PostgreSQL case sensitive icontains
with postgreSQL I get case sensitive filters also with icontains. Is there nothing I can do to solve this problem? -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.com Sviluppo Software e Sistemi Open Source Sede: Via Poggiali 2/bis, 47100 Forlì (FC) Tel.: +39 0543 798985 - Fax: +39 0543 579928 Rispetta l'ambiente: se non ti è necessario, non stampare questa mail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Grouping a list of entries by month name
In my case I wanted to get something like this: January 2008 Post name Post name December 2007 Post name Post name I can't figure out how to do it the way your are saying. I thought about doing: {% for entry in monts %} {% ifchanged %}{{ entry.pub_date|date:"F Y" }}{% endifchanged %} {{ entry.title }} on {{ entry.pub_date|date:"l jS \o\f F Y" }} {% endfor %} but that added for every post. -Martin 2009/2/19 Malcolm Tredinnick> > On Wed, 2009-02-18 at 23:35 -0800, Marlun wrote: > > I believe this will work perfectly in my case. > > > > To easy my curiosity, how would you do it differently if you wanted > > the sequence object to be grouped by date but have the month name > > instead of number? I mean right now I get a list of entry objects. How > > would you change your view code to retrieve a sequense sorted by month > > name and year in the template? > > The month or year are more presentation details than data retrieval > operations. You still sort the result set by date, which brings all the > entries for month X in a particular year together. Then, in your > template, you can format the display however you like (including using > the "ifchanged" template tag if you want to display some value only when > it changes). > > Use the "date" template filter to format the results: if "obj" is a date > object, the {{ obj|date:"M" }} will display the month name in a > template. > > Regards, > Malcolm > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: testing validation of form in unit testing
You don't give a lot information about what is happening, so I'm stabbing a bit in the dark here... I would guess your problem is that you have created a form which has a filefield that is required. Even though you probably upload a file and maybe even pass it to the form, you are not doing it in a way that django can understand. Probably because you choose to construct your own date instead of using the data from request.POST and request.FILES. It would be a much better approach to use the data from request, and then if it needs to be altered, to do it in the form validation. This could be done if you fx have a models primary key and instead want to return the object. Anyways, if this doesn't help you, you would help yourself a lot if you do explain what exactly the problem is, what you are doing, maybe a little snippet of code. On Feb 20, 5:01 pm, Vitalywrote: > Hi all > > I have a test that validate processed data to form with FileField. My > steps in it direct me right to one problem. here is it. > > 'file' is 'Required field' > > What I do is process simple data right to form, not request.POST and > request.FILES. > I have tried process in data SimpleUploadedFile but no result. > > Why is it? and how this problem can be solved? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django/Apache/wsgi problems -- help!
Also the /admin/ url gives > an internal error, which in apache's errlog shows a traceback > that ends in "OperationalError: no such table: django_session". This is most probably due to the fact that you did not set your DB_NAME variable with the full path of your .db file. And sqlite3 is creating a new .db file as it cannot access the real one. That is: Instead of DATABASE_NAME = 'dev.db' you should set it as DATABASE_NAME = '/path/to/db/file/mydbfile.db' And for the vhost configuation let me write down what works for me: ServerName www.mysite.com ServerAlias *mysite.com Alias /media/admin /usr/lib/python2.5/site-packages/django/contrib/ admin/media Order allow,deny Allow from all Alias /media /path/to/project/site_media Order allow,deny Allow from all WSGIScriptAlias / /path/to/project/apache/my.wsgi WSGIDaemonProcess mysite.com user=myuser group=www-data threads=25 WSGIProcessGroup mysite.com And set the configuration variables accordingly as: MEDIA_ROOT = '/path/to/project/site_media/' #this is for file uploads MEDIA_URL = "http://mysite.com/media/; ADMIN_MEDIA_PREFIX = '/media/admin/' > (I also have MEDIA_ROOT set -- is it necessary to have both??) Yes it is. At least in this configuration I am demonstrating. Hope this helps. Regards, Polat Tuzla --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem outputting date in template as timestamp
I am trying to render a timestamp in my template with date:"U" but the timestamps are days off. I wrote up a simple test case that fails. Do you think this is a bug or a user error? I am running rev: 9846. from django.test import TestCase class SimpleTest(TestCase): def test_template_timestamp(self): from datetime import datetime from django.template import Context, Template now = datetime.now() t = Template('{{ now|date:"U" }}') c = Context({'now': now}) self.failUnlessEqual(int(now.strftime('%s')), int(t.render (c))) Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Oracle connection issue
Hi everyone, I'm using Oracle instantclient_10_2 (Intel), cx_Oracle-5.0.1, OS X 10.5.6 (Intel), Python 2.6.1 and Django trunk. My built-in server will start up correct, but, when I attempt to get objects for a model, I receive the following error: InterfaceError: Unable to acquire Oracle environment handle Can anyone help me resolve this problem? TIA, 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-users@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: Access extra parameters in forms.py
On Feb 20, 2:40 pm, petewrote: > Hi Daniel, > > This has got me closer but i'm now just getting an empty select box > appearing on in the form, with no data in. > > class NewBugForm(forms.Form): > assigned_to = forms.CharField(max_length=50,widget=forms.Select > (choices=[]), initial='Anyone',required=False) > > def __init__(self, *args, **kwargs): > all_users = kwargs.pop("all_users") > super(NewBugForm, self).__init__(*args,**kwargs) > print all_users > self.fields['assigned_to'].choices = all_users > > If I print out all_users I can see it is there after the super(), but > for some reason its not appending to the form. The following is a > print out of all_users: > > (('Anyone', 'Anyone'), ('Pete Randall', 'Pete Randall'), ('Chris > Smith', 'Chris Smith')) > > Could it have something to do with that list not being in the right > format? > > Cheers, > > Pete. My mistake, the last line should be: self.fields['assigned_to'].widget.choices = all_users That should work. -- 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-users@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: Query over related models
On Fri, Feb 20, 2009 at 9:43 AM, Peter Müllerwrote: > I want to select all Posts where text contains "Some Text" or > Attachment.name (which is related to one post) contains "Some Text". > Is there a way to do this with Django's ORM? This is covered in the "Making queries" documentation (http://docs.djangoproject.com/en/dev/topics/db/queries/). Specifically, you'll want to look at the sections about related objects (http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects) and complex lookups (http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects). Read through that, and hopefully you'll understand the answer, which looks something like:: Post.objects.filter(Q(text__contains='some text') | Q(attachment__name__contains='some text')) Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---