get_absolute_url always returning empty string
Completely lost on this... I'm trying to set up permalinks to my articles, which are using generic views. I've gotten it to work by hard coding the url path into the get_absolute_url function, but I'd like it to be based off the url defined in the view (http:// docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#the- permalink-decorator). [from urls.py] news_dict = { 'queryset' : Article.objects.all(), 'date_field' : 'pub_date', } urlpatterns = patterns('django.views.generic.date_based', url(r'^(?P\d{4})/(?P[a-z]{3})/(?P\w{1,2})/(? P.*)/$', 'object_detail', dict(news_dict, slug_field='slug'), name='article_view'), ) [from models.py] @models.permalink def get_absolute_url(self): return ('article_view', (), { 'year': self.pub_date.strftime('%Y'), 'month': self.pub_date.strftime('%b').lower(), 'day': self.pub_date.strftime('%d') }) get_absolute_url = permalink(get_absolute_url) Whenever I call get_absolute_url, all it returns is an empty string - with no indication of what went wrong. Any ideas on this? I don't see how my code's any different from the docs... --~--~-~--~~~---~--~~ 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: date-based ordering confusion
On Sun, Feb 15, 2009 at 12:25 AM, Justin Myerswrote: > > On Feb 14, 12:55 am, Gour wrote: > > Finally, I managed to add 'class Meta' as subclass of BlogPost class (as > > above), but I wonder if adding 'ordering = ('-timestamp',)' to > > BlogPostAdmin class is supposed to work or what is explanation if it > > should not work (as we experienced)? > > ordering is an option in model Meta classes, but it's not an option in > ModelAdmin classes. Here are the lists of what you can use in each: > ModelAdmin: > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-options > model Meta: > http://docs.djangoproject.com/en/dev/ref/models/options/#ordering > > While order is something that's handy to have in the admin, it's not > specific to it. It's a property of the model itself, since it ends up > in any QuerySet involving that model. > > Hope that helps, > Justin > > > Justin, I'd take a look at that link again: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ordering 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: date-based ordering confusion
On Feb 14, 12:55 am, Gourwrote: > Finally, I managed to add 'class Meta' as subclass of BlogPost class (as > above), but I wonder if adding 'ordering = ('-timestamp',)' to > BlogPostAdmin class is supposed to work or what is explanation if it > should not work (as we experienced)? ordering is an option in model Meta classes, but it's not an option in ModelAdmin classes. Here are the lists of what you can use in each: ModelAdmin: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-options model Meta: http://docs.djangoproject.com/en/dev/ref/models/options/#ordering While order is something that's handy to have in the admin, it's not specific to it. It's a property of the model itself, since it ends up in any QuerySet involving that model. Hope that helps, Justin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Customizing geodjango admin mapping interface
Hi, Currently i am working with Sri Lanka data set, which I used local ordinates not lon lat. I want to customize admin interface where users can add Georapgical data through admin interface, But problem i am having in Geomodel admin class coordinates values are given in Lon Lat is it possible to change this to local coordinate. Or there is another way to do this. Plz can some one help me on this problem . Thanks in advance. Waruna --~--~-~--~~~---~--~~ 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: Changing the name of a project
On Sat, 2009-02-14 at 20:51 +, Lee Braiden wrote: > Hi Malcom, > > 2009/2/14 Malcolm Tredinnick: [...] > > I know that I don't find myself "violating the DRY principle over and > > over again" and I've written more than a few lines of code using Django > > as one of the supporting library sets. > > Really? So you don't have to write your app names in your urls.py as > well as in your settings.py, for instance? Yes, I do, but that's not a DRY-violation. I'm using the names for different purposes. I also specify things other than my app names in urls.py -- because things in there are just names for places containing views, not necessarily Django applications. You're confusing correlation and effect there. > > It neither encourages nor discourages. Django, not being a person, is > > very agnostic on the whole issue. > > No, as a framework and project template tool, it provides suggestions > on how to start and continue a project. Those suggestions include > apps that, again, have to be named on the command line, in a settings > file, in a urls file (or two!), in templates, in calls to templates, > etc. Um .. names are how we refer to things in both the real world and code. If I'm referring to the same thing in multiple places, I'm going to use it's name more than once. That isn't a DRY-violation. It's a requirement since the code cannot read my mind. We use app names in a lot of places because they provide a namespace. Removing the app name layer would mean things inside apps would have to be unique across all apps. Namespacing is a good thing. > Don't get me wrong --- I love django, and use it joyfully over > alternatives. But it's absolutely _not_ DRY, Highly debatable on the evidence you've presented here, unless you stretch the word beyond useful meaning. Having to use the name of an object when you use it is not DRY-violation. Using namespaces (and having to specify the active namespace) is not a DRY-violation. Telling manage.py which application you wish to perform an action on is a specific instruction, not a DRY-violation. [...] > > We also, again, have that perspective thing going, so, in places such as > > the beginner's tutorial, we might use the project name in some places, > > but it's simply not that important: the idea there is to teach people > > about Django > > That's a noble goal, and the tutorials are generally good, but again, > this particular issue only distracts people from the real tasks of > starting their first django project. Why do people need to learn > about adding apps to the settings file right away? Because you have to add apps to the setting file so that Django knows which apps you are using. > The boilerplate > like app-loading can be autodetected, so they simply start a project, > start an app, and add their models/views/templates. Auto-detecting of applications is not something Django does, with good reason, so using it in the tutorial would be incorrect (we don't use features that don't exist and we aren't going to add a Mickey Mouse feature that has no benefit once you move beyond the tutorial). It's simply not something that can be done correctly: you would end up always installing every application on your Python path every time you ran syncdb, for example -- far from optimal -- so Django doesn't even attempt it. > > not teach them about Python > > But they're having to learn python NOW. Hopefully not, no. It turns out that some people do work that way, but it's not ideal and I don't have a lot of sympathy for them (if they can do it, fine, if not, go back to step 1 and learn the language). Learn to crawl before walking. Learn the language before using things that use the language. [...] > > Standardise what, exactly? If something's designed to be reusable, it > > will be built to be installed somewhere on the Python path. That already > > works. It's been standardised by following Python. > > Agreed, but django doesn't use the path. Huh?! You are misunderstanding something big there, if you don't think the Python path is involved. You specify module names in the INSTALLED_APPS list and in import statements in your code. They are imported using the Python path. A very normal way to create things in Django is have a directory (or six) of applications on the Python path and specify a few them you are going to use in a settings file somewhere else. > It expects each module to be > manually specified, each template path to be manually added, etc. Indeed, you are required to say which applications you wish to use in a particular collection. Because using all of the ones you have available is hardly appropriate most of the time. You aren't, however, required to add every template path if things fit certain layouts -- the app_loader exists to help out there in a controlled way, for example. In cases when you want to use the filesystem loader, again, neither Python nor Django can read your mind, so it doesn't
Re: Problems with multithreading in fastcgi environment
hi what is it ? 2009/2/15 Malcolm Tredinnick> > On Sat, 2009-02-14 at 11:31 -0800, Gregor Müllegger wrote: > > Hi djangonauts, > > > > at the moment i try to setup a youtube-like site. Users can upload > > videos which will be converted with ffmpeg to the flv format. The > > convertion process is fired up in a view. Though i use the "threaded" > > module to not interrupt the view for sending back the response. > > This comes up quite often and the standard answer is that this isn't the > right approach to solving the problem. You are tying the background > processing to the lifecycle of the fastcgi process. Web processes can > stop and start for various reasons (including periodically being killed > after a number of requests to rest the memory base). > > Better to use a queue-like setup where you make a record of any > conversions that need to be done and have another process (or processes) > that go through the queue and convert things. The lifecycle of the > latter processes aren't then tied to the web-stack lifecycles. > > 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: Problems with multithreading in fastcgi environment
On Sat, 2009-02-14 at 11:31 -0800, Gregor Müllegger wrote: > Hi djangonauts, > > at the moment i try to setup a youtube-like site. Users can upload > videos which will be converted with ffmpeg to the flv format. The > convertion process is fired up in a view. Though i use the "threaded" > module to not interrupt the view for sending back the response. This comes up quite often and the standard answer is that this isn't the right approach to solving the problem. You are tying the background processing to the lifecycle of the fastcgi process. Web processes can stop and start for various reasons (including periodically being killed after a number of requests to rest the memory base). Better to use a queue-like setup where you make a record of any conversions that need to be done and have another process (or processes) that go through the queue and convert things. The lifecycle of the latter processes aren't then tied to the web-stack lifecycles. 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: Advice on many to many with too many records in admin
On Sat, 2009-02-14 at 11:28 -0800, Rob Hudson wrote: > Hi Django Users, > > I'm setting up a new Django model for a Newsletter app. The > newsletter model has a many to many to a Book model that has about > 20,000 records. This results in a multiple select box that is > unusable for searching/selecting books. > > I have some ideas on what I can do to make this usable but I also > wanted to see if anyone else has had this problem and what they did to > work around it. > > Some ideas with what I imagine are their pros/cons... > > 1) Instead of using a many to many, use a text field that the user > enters a comma separated list of items as lookup strings for the Book > model. Pros: Pretty simple to do. Cons: Opens up potentially lots of > user error by having to type exact strings for the model lookup. > > 2) Override the admin views and templates for adding and editing > Newsletters and use a different widget for selecting books. The > widget could be an AJAX auto complete multiple widget of some sort, as > seen on a lot of sites. Pros: Easier for the user to enter multiple > books using a common web pattern. Cons: I'd say quite a bit more time > consuming to set up. I'd go with he AJAX widget if you're after maximum usability (and can afford the Javascript dependency). It's not going to be that painful to set up. It's the equivalent of live-search functionality and there are a lot of examples of doing that with AJAX around on the Internet. 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: assertRaises doesnt catch custom error
On Sat, 2009-02-14 at 11:28 -0800, pault wrote: > I have defined a custom error but if I test if custom error gets > raised it fails if I test for Exception the test passes > > class CustomError(Exception): > """ > This exception is my custom error > """ > > class Company(models.Model): > name = models.CharField(max_length=200) > > def test_error(self): > raise CustomError('hello') > > > and in my tests.py: > > import unittest > from api.models import > Company,Customer,Employee,Location,Product,ProductCategory,AllreadyPayedError,CustomError > > #class AllreadyPayedException(Exception): pass You mean AlreadyPaidException. Trust me on this. :-) > > class CompanyTestCase(unittest.TestCase): > def setUp(self): > self.company = Company.objects.create(name="lizto") > > def test2(self): > self.assertRaises(CustomError, self.company.test_error) > > > == > ERROR: test2 (lizto.api.tests.CompanyTestCase) > -- > Traceback (most recent call last): > File "/Users/.../tests.py", line 27, in test2 > self.assertRaises(CustomError, self.company.test_error) > File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/unittest.py", line 320, in failUnlessRaises > callableObj(*args, **kwargs) > File "/Users/../models.py", line 17, in test_error > raise CustomError('hello') > CustomError: hello Using the code you provide (after removing the imports that don't exist in the code you provide), this works perfectly for me. So there's something special about your setup. If I were you, I'd start from the simple example you show. Create an app that only contains that models.py and that tests.py and fix the import line to remove everything except Company and CustomError. That's what passes for me. 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: database lookup in url conf to efine the application url conf to be included
On Sat, 2009-02-14 at 10:39 -0800, yuccaplant wrote: > Hi all, > > I want to develop a cms and I want my urls partially to be user- > defined, for example: > > /home/info > /home/blog/-/post/ > /frank/blog/-/articles/2003 > /frank/bio > > The first part (the part before '/-/' if any) would map to an > application in the database and is user defined (it could be > anything). That first part could also define additional information to > be passed to the application, in the case of a blog-application this > could be the blog-id. So: I think you're designing the implementation a bit in what follows, rather than the functionality. All this talk of database lookups in URLConf isn't appropriate, unless you want to write your own URL resolver. > /home/info > A lookup in the database would return the application name: 'Page' and > the page-id: '23'. The url conf of application Page should be included > and the page-id passed to it. How do we know what Page and page-id correspond to here? You haven't explained what this is going to do. If /home/ is the generic base URL, you could create a pattern that goes before all the user-specific ones (below) that captures it and any following information and passes the processing to a view function which works out that it needs to return Page and 23 and then calls a subsequent function. > > /home/blog/-/post > A lookup in the database would return the application name: 'Blog' and > the blog-id: '54'. The url conf of application Blog should be included > and the blog-id passed to it. The included url conf takes care to map > the second part of the url (post) to a view. > > /frank/blog/-/articles/2003 > A lookup in the database would return the application name: 'Blog' and > the blog-id: '22'. The url conf of application Blog should be included > and the blog-id passed to it. The included url conf takes care to map > the second part of the url (articles/2003) to the apropriate view. > > /frank/bio > A lookup in the database would return the application name: 'Page' and > the page-id: '455'. The url conf of application Page should be > included and the page-id passed to it. Again, using an initial view to further refine things will work here. The URL pattern will look like url('^(?P.*?)/(?P.*)$', user_app_mapping), and the user_app_mapping view could do something like this: def user_app_mapping(request, user, application): app_name, object_id = get_data_from_inputs(user, application) return real_view(app_name, object_id) > So I would to have something like: > > urlpatterns = patterns('', > (r'^(.*)$', include(, )), Except that include() doesn't work like that. You would need to write your own function to do that. > ) > (where and are found by a database > lookup of the first part of the url.) > > I can't firgure out how the database lookup would fit in and how I > could pass something like a blog-id to the included application url > conf. > > Any ideas how I could accomplish this? Either use intermediate views or look into writing your own URL resolver subclass. The former is easier. The latter might allow you to write everything in your URL Conf file, although whether that will be clearer or not remains to be seen. It will also be a lot more work (and will require reading the existing code and working out how to do it). 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: raise ValidationError has no effect
On Sat, Feb 14, 2009 at 11:07 AM, Alistair Marshall < runninga...@googlemail.com> wrote: > > I have been trying to create a custom field that allows the user to > enter a flowrate and clean the data back to kg/s or mol/s. > > I though I had everything sorted, when I type '10 tones/year', it > correctly did the conversion however when I type something that does > not validate such as 'twenty' or '5 mph' the code runs till the raise > validation error, however nothing else happens and the overall forms > clean function gets called (which doesn't have all the fields in its > clean_data attribute. > Nothing else happens as opposed to what? What are you expecting to happen? One field raising a validation error doe not prevent the overall form clear() from being called, this is covered here: http://docs.djangoproject.com/en/dev/ref/forms/validation/ where it states: As mentioned, any of these methods can raise a ValidationError. For any field, if the Field.clean() method raises a ValidationError, any field-specific cleaning method is not called. However, the cleaning methods for all remaining fields are still executed. The clean() method for the Form class or subclass is always run. If that method raises a ValidationError, cleaned_data will be an empty dictionary. The previous paragraph means that if you are overriding Form.clean(), you should iterate through self.cleaned_data.items(), possibly considering the _errors dictionary attribute on the form as well. In this way, you will already know which fields have passed their individual validation requirements. The idea is to get all the problems identified, as far as possible, and not let the first error encountered stop the process. That way (hopefully) all the problems can be noted with error messages in one go-round with the user, rather than having submit, here's an error, fix one error, resubmit, here's a 2nd error, fix, resubmit, here's a 3rd error, etc. 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: need help validating imagefield in modelform..
Hi, I haven't much forms with image/files, but I believe you should do something like this: photo = self.cleaned_data.get('photo') This is for your second version. When doing stuff like this I find it sometimes can be helpful to insert an error like just typing raise. Django will in the debug screen let you look at your variables. So you could see what you fx are getting when you do your photo = ... and see why it raised that error. Hope it helps Briel On 14 Feb., 10:52, PeteDKwrote: > Hi :) > > I'm trying to validate an uploaded image's size and filetype. > However i have problems even gettings to the validation as django > keeps telling me that there's no object. > When i don't use the validation part I can upload an image just fine. > So the upload thing works. > > I just can't figure out how to pass on the file to the validation > part. > I have tried with several approaches I have found on the internet. > Therefore i will list my view, model and the two form methods i have > tried. > > first, my view: > > def upload_file(request): > myprofile = request.user.get_profile() > current = request.user > print "upload 1" > if request.method == 'POST': > form = AvatarForm(request.POST, > request.FILES,instance=myprofile) > print "upload 2" > if form.is_valid(): > [...] > > model: > class Avatar(models.Model): > user = models.ForeignKey(User,unique=True,editable=False) > photo = models.ImageField(upload_to=get_profile_path, blank=True, > null=True) > thumbnail = models.ImageField(upload_to='profile_thumb', blank=True, > null=True) > > form: > > class AvatarForm(ModelForm): > > class Meta: > model = Avatar > > #1 > > def clean(self,data,initial=None): > content = super(ImageField, self).clean(self,data,initial) > content_type = content.content_type.split('/')[0] > if content_type in settings.CONTENT_TYPES: > if content._size > settings.MAX_UPLOAD_SIZE: > raise forms.ValidationError(_('Please keep > filesize under %s. > Current filesize %s') % (filesizeformat(settings.MAX_UPLOAD_SIZE), > filesizeformat(content._size))) > else: > raise forms.ValidationError(_('File type is not > supported')) > return content > #2 > def clean(self): > if 'photo' in self.cleaned_data: > photo = self.cleaned_data['photo'] > print photo > if photo.get('content-type') != 'image/jpeg': > msg = 'Only .ZIP archive files are allowed.' > raise forms.ValidationError(msg) > return photo > > The error i get is pretty much the same with both methods. Nonetype > has nu method/attribute: content_type/get... So i don't know if the > rest of the validation code works since I can't pass my file through > to the validation :-( > > Any help is appreciated :-) > > And a good weekend to all of you --~--~-~--~~~---~--~~ 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: raise ValidationError has no effect
I dont really get your problem, but it seems that your problem is going on in your views. When you raise a validation error the clean method should stop right there like you say it does. It's up to you to act on validation errors with stuff like is_valid() and do what you want when the form doesn't validate. On 14 Feb., 17:07, Alistair Marshallwrote: > I have been trying to create a custom field that allows the user to > enter a flowrate and clean the data back to kg/s or mol/s. > > I though I had everything sorted, when I type '10 tones/year', it > correctly did the conversion however when I type something that does > not validate such as 'twenty' or '5 mph' the code runs till the raise > validation error, however nothing else happens and the overall forms > clean function gets called (which doesn't have all the fields in its > clean_data attribute. > > I have posted the code on dpaste, any hints or suggestions and would > be greatly appreciated (this is hurting my head now) > > http://dpaste.com/120538/ > > Thanks > > Alistair > > http://www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Accessing new_object when processing formsets in Admin
Greetings, I'm hoping for some advice here. I'm using the admin that captures some information about a human, including their address (represented as an FK to an Address model thing). Additionally it has a formset (StackedInline) that displays N other forms that capture information about other humans. All of these humans live at the same address. Hopefully that make sense. Assuming the "main" form is valid I want to get the value of the FK to the Address from the "main" form and use it when processing the forms in the formset. I can see several ways of doing this but I'm not sure what's the best. It appears that the easiest is to override save_form() and do stuff with the return value there. Is that reasonable or is there a better way? Apologies in advance if this isn't clear. ---Rick --~--~-~--~~~---~--~~ 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 database connections
On Sat, Feb 14, 2009 at 4:15 PM, Jack Orensteinwrote: > > I'm trying to understand how Django 1.0 handles connections. This is > from the django docs, on the subject of raw SQL: > > from django.db import connection > cursor = connection.cursor() > cursor.execute("select ...") > row = cursor.fetchone() > > If I have a Django app running lots of requests, then how are > connections handled? Is connection the same in each request, even > requests running concurrently? That can't possibly be the case, > (could it)? So does each request get its own? When are connections > closed? When closed are they really closed, or just returned to a > pool? Can the pool be configured, (e.g. to set the postgres > search_path)? > > Sorry to ask such basic questions, but I've been unable to find this > information documented. > > Jack Orenstein > > > > > A quick disclaimer, all of this is AFAIK and to the best of my memory: The connection object in django.db is a thread local object, meaning that each thread get's it's own one, and whenever you access that object you get the one for the current thread(it may actually mean that all the attributes on the object are local to that thread, I don't completely remember, the effect is the same anyway). This basically means each request has it's own connection to the DB since you can't have multiple simultaneous requests in the same thread. There is a signal handler that closes this connection to the DB at the end of each request. There is no connection pool, when a new connection is opened it is really created to the db, and when it's closed it really is closed. 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 -~--~~~~--~~--~--~---
Django database connections
I'm trying to understand how Django 1.0 handles connections. This is from the django docs, on the subject of raw SQL: from django.db import connection cursor = connection.cursor() cursor.execute("select ...") row = cursor.fetchone() If I have a Django app running lots of requests, then how are connections handled? Is connection the same in each request, even requests running concurrently? That can't possibly be the case, (could it)? So does each request get its own? When are connections closed? When closed are they really closed, or just returned to a pool? Can the pool be configured, (e.g. to set the postgres search_path)? Sorry to ask such basic questions, but I've been unable to find this information documented. Jack Orenstein --~--~-~--~~~---~--~~ 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: Changing the name of a project
Hi Malcom, 2009/2/14 Malcolm Tredinnick: > So I realise this you are writing your opinion, but also consider that > the flip side isn't completely invalid. There's an outside chance > (alternatively expressed as "100% guaranteed") that when I write > something here about pragmatics, it's going to be based on my > experiences and collected knowledge (both professional and otherwise -- > you know, around 25 years of programming computers) and also never > intended to deceive or mislead. You're being a bit categorical in > implying that what I suggested leads to all those bad things. OK, fair enough. Maybe I was a little too strong in my wording; most people will figure out how to fix a problem if and when it becomes an issue for them --- in that much, I agree. However, I think it's unnecessary to distract people from learning best practice by teaching them something else with the excuse of "getting started". Small projects to get started? Sure. Simple projects to get started? Sure. Projects with corners cut, though? I think that will only lead to a delayed and even steeper learning curve, when they have to unlearn things to learn something else that they could have been guided gently through from the beginning. > I know that I don't find myself "violating the DRY principle over and > over again" and I've written more than a few lines of code using Django > as one of the supporting library sets. Really? So you don't have to write your app names in your urls.py as well as in your settings.py, for instance? > It neither encourages nor discourages. Django, not being a person, is > very agnostic on the whole issue. No, as a framework and project template tool, it provides suggestions on how to start and continue a project. Those suggestions include apps that, again, have to be named on the command line, in a settings file, in a urls file (or two!), in templates, in calls to templates, etc. Don't get me wrong --- I love django, and use it joyfully over alternatives. But it's absolutely _not_ DRY, and as a result, I have to start my projects by cloning a branch of already modified templates, rather than simply using the django-admin tool's pre-supplied templates. If I wasn't doing that, then django WOULD be encouraging me to repeat myself, every time I start a project, or even an app. > We also, again, have that perspective thing going, so, in places such as > the beginner's tutorial, we might use the project name in some places, > but it's simply not that important: the idea there is to teach people > about Django That's a noble goal, and the tutorials are generally good, but again, this particular issue only distracts people from the real tasks of starting their first django project. Why do people need to learn about adding apps to the settings file right away? The boilerplate like app-loading can be autodetected, so they simply start a project, start an app, and add their models/views/templates. > not teach them about Python But they're having to learn python NOW. Obscure python, too, about how to specify module paths to load. What I'm suggesting is that it's not necessary to know (or repeat) all that just to get apps loaded. > As noted, it's not, per se, > evil to use a project-based import path, particularly for the tutorial > code, so we elect not to make a huge deal out of it. Not evil, no, but it's not best practice either. As an IT tutor, I think we fail users by teaching them to follow sketchy practices. Practices very quickly become bad habits, and its the educators job to help prevent those. Especially if they can lead to refactoring a lot of work, or re-learning things later on. > We may even change > it in the future, who knows. > Standardise what, exactly? If something's designed to be reusable, it > will be built to be installed somewhere on the Python path. That already > works. It's been standardised by following Python. Agreed, but django doesn't use the path. It expects each module to be manually specified, each template path to be manually added, etc. > This is about picking the > right battles along the learning curve. My Very First Django App or even > my fifth Django app is very unlikely to be generically useful. So > creating it as if it was is losing focus on other bits that could well > be more important at the time. This makes sense, but it's very possible to have adding django apps be fully functional and pluggable, with simple copy-and-paste to a new project. If django made it THAT easy to reuse code, then there's no reason lesson 3 or so couldn't start with, essentially, "let's start a new project, lesson3. It will combine the two earlier projects. Copy the apps from lesson1 and lesson2 to lesson3. Now run the server..." > Your lack of specifics isn't helping your communication here. What work > does Django need to build in? Granted. The problem is that I have little time to explain this all out point by point or
Re: Exceptions and SET client_encoding to 'UNICODE'
Everything is happening in a Postgres transaction; at the first error the transaction aborts and you must issue a ROLLBACK to the DB before continuing. Consult Django's transaction dogs for information on how to do this. On 2/14/09, 83...@gmx.de <83...@gmx.de> wrote: > > Hi Folks, > > I'd like to update/initiate a database with an unique=True Field. > > It shall be a "batch-process" (List of entries to take over into the > database. > > for item in leasing: > l = Leasing(leasing = item) > try: > l.save() > except IntegrityError,e : > errors.append(e) > except: > pass > leasing.append(errors) > > same with except (ProgramminError, IntegrityError), e > > First IntegrityError-Exception will be catched but next not - I get an > ProgrammingError > > SET client_encoding to 'UNICODE'.. > > and all other entries in the list will be skiped with the same error- > message... no storing into the database even though there's no > IntegrityErros (unique elements). > > consequently - I can't process the whole list. > > Is this behaviour known - and is there a solution/work around. > > If not - how can I "batch" the whole list and catch IntegrityErrors > > It is Potgresql database > > Thx > Timothy > > > > -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: Advice on many to many with too many records in admin
On Sat, Feb 14, 2009 at 2:44 PM, Rob Hudsonwrote: > > On Sat, Feb 14, 2009 at 11:29 AM, Alex Gaynor > wrote: > > Have you tried using raw_id_fields with it? > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#raw-id-fields > > Just now tested that out. That works pretty well but the downside is > that, for the user, the ID means nothing. It has the lookup button to > pick a book, but once selected, it's difficult to review that > everything looks correct before saving. > > It does solve the too many records to search through problem, but > usability is lacking, IMO. > > Thanks for the suggestion... I think I'll use it for now and see if > anyone else responds. > > -Rob > > > > You might try messaging Jannis Leidel on freenode then, I know he's been working on a ManyToMany ajax lookup field to complement his foreign key one: http://jannisleidel.com/2008/11/autocomplete-form-widget-foreignkey-model-fields/ 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: Advice on many to many with too many records in admin
On Sat, Feb 14, 2009 at 11:29 AM, Alex Gaynorwrote: > Have you tried using raw_id_fields with it? > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#raw-id-fields Just now tested that out. That works pretty well but the downside is that, for the user, the ID means nothing. It has the lookup button to pick a book, but once selected, it's difficult to review that everything looks correct before saving. It does solve the too many records to search through problem, but usability is lacking, IMO. Thanks for the suggestion... I think I'll use it for now and see if anyone else responds. -Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problems with multithreading in fastcgi environment
Hi djangonauts, at the moment i try to setup a youtube-like site. Users can upload videos which will be converted with ffmpeg to the flv format. The convertion process is fired up in a view. Though i use the "threaded" module to not interrupt the view for sending back the response. In my development installation and on the production server in the "python manage.py shell" seems to work all perfectly. But when i try to use this method on the production server with a browser (i use nginx with django in an fcgi server, method is prefork), the video will not be converted as long as i try to do it in a new thread. If i block the view with processing the video in the same thread as the request, everything works ok. Does anyone know if there are known problems with multithreading in an fcgi environment? I hope someone can help me ... this bugs me quite a while. Thank you all. Gregor --~--~-~--~~~---~--~~ 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: Advice on many to many with too many records in admin
On Sat, Feb 14, 2009 at 2:28 PM, Rob Hudsonwrote: > > Hi Django Users, > > I'm setting up a new Django model for a Newsletter app. The > newsletter model has a many to many to a Book model that has about > 20,000 records. This results in a multiple select box that is > unusable for searching/selecting books. > > I have some ideas on what I can do to make this usable but I also > wanted to see if anyone else has had this problem and what they did to > work around it. > > Some ideas with what I imagine are their pros/cons... > > 1) Instead of using a many to many, use a text field that the user > enters a comma separated list of items as lookup strings for the Book > model. Pros: Pretty simple to do. Cons: Opens up potentially lots of > user error by having to type exact strings for the model lookup. > > 2) Override the admin views and templates for adding and editing > Newsletters and use a different widget for selecting books. The > widget could be an AJAX auto complete multiple widget of some sort, as > seen on a lot of sites. Pros: Easier for the user to enter multiple > books using a common web pattern. Cons: I'd say quite a bit more time > consuming to set up. > > Any other ways to do this? Or some examples of #2 to help someone > along? > > Thanks, > Rob > > > Have you tried using raw_id_fields with it? http://docs.djangoproject.com/en/dev/ref/contrib/admin/#raw-id-fields 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 -~--~~~~--~~--~--~---
Advice on many to many with too many records in admin
Hi Django Users, I'm setting up a new Django model for a Newsletter app. The newsletter model has a many to many to a Book model that has about 20,000 records. This results in a multiple select box that is unusable for searching/selecting books. I have some ideas on what I can do to make this usable but I also wanted to see if anyone else has had this problem and what they did to work around it. Some ideas with what I imagine are their pros/cons... 1) Instead of using a many to many, use a text field that the user enters a comma separated list of items as lookup strings for the Book model. Pros: Pretty simple to do. Cons: Opens up potentially lots of user error by having to type exact strings for the model lookup. 2) Override the admin views and templates for adding and editing Newsletters and use a different widget for selecting books. The widget could be an AJAX auto complete multiple widget of some sort, as seen on a lot of sites. Pros: Easier for the user to enter multiple books using a common web pattern. Cons: I'd say quite a bit more time consuming to set up. Any other ways to do this? Or some examples of #2 to help someone along? Thanks, Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
assertRaises doesnt catch custom error
I have defined a custom error but if I test if custom error gets raised it fails if I test for Exception the test passes class CustomError(Exception): """ This exception is my custom error """ class Company(models.Model): name = models.CharField(max_length=200) def test_error(self): raise CustomError('hello') and in my tests.py: import unittest from api.models import Company,Customer,Employee,Location,Product,ProductCategory,AllreadyPayedError,CustomError #class AllreadyPayedException(Exception): pass class CompanyTestCase(unittest.TestCase): def setUp(self): self.company = Company.objects.create(name="lizto") def test2(self): self.assertRaises(CustomError, self.company.test_error) == ERROR: test2 (lizto.api.tests.CompanyTestCase) -- Traceback (most recent call last): File "/Users/.../tests.py", line 27, in test2 self.assertRaises(CustomError, self.company.test_error) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/unittest.py", line 320, in failUnlessRaises callableObj(*args, **kwargs) File "/Users/../models.py", line 17, in test_error raise CustomError('hello') CustomError: hello -- Ran 18 tests in 1.122s Anybody an idea what I should do to test if CustomError gets raised --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
HELP! python in free(): error: free_pages: pointer to wrong page
All, Since upgrading to 1.0.2, and now to pre-alpha SVN-9832, my manage.py runserver crashes with: jer...@host396:/home/jerome/ccoa$ manage.py runserver 8077 Validating models... 0 errors found Django version 1.1 pre-alpha SVN-9832, using settings 'ccoa.settings' Development server is running at http://127.0.0.1:8077/ Quit the server with CONTROL-C. [14/Feb/2009 12:04:30] "GET /admin/coa/person/28/ HTTP/1.1" 200 9262 [14/Feb/2009 12:04:31] "GET /admin/jsi18n/ HTTP/1.1" 200 803 [14/Feb/2009 12:25:54] "GET /admin/coa/person/28/ HTTP/1.1" 200 9262 [14/Feb/2009 12:25:55] "GET /admin/jsi18n/ HTTP/1.1" 200 803 python in free(): error: free_pages: pointer to wrong page jer...@host396:/home/jerome/ccoa$ This error occurs when using Admin to attempt to save a model. Any suggestions how to procede from here? (I'm running python 2.4.3 on OpenBSD with postgresql 8.1.5 via py- psycopg-1.1.21p1) 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 -~--~~~~--~~--~--~---
database lookup in url conf to efine the application url conf to be included
Hi all, I want to develop a cms and I want my urls partially to be user- defined, for example: /home/info /home/blog/-/post/ /frank/blog/-/articles/2003 /frank/bio The first part (the part before '/-/' if any) would map to an application in the database and is user defined (it could be anything). That first part could also define additional information to be passed to the application, in the case of a blog-application this could be the blog-id. So: /home/info A lookup in the database would return the application name: 'Page' and the page-id: '23'. The url conf of application Page should be included and the page-id passed to it. /home/blog/-/post A lookup in the database would return the application name: 'Blog' and the blog-id: '54'. The url conf of application Blog should be included and the blog-id passed to it. The included url conf takes care to map the second part of the url (post) to a view. /frank/blog/-/articles/2003 A lookup in the database would return the application name: 'Blog' and the blog-id: '22'. The url conf of application Blog should be included and the blog-id passed to it. The included url conf takes care to map the second part of the url (articles/2003) to the apropriate view. /frank/bio A lookup in the database would return the application name: 'Page' and the page-id: '455'. The url conf of application Page should be included and the page-id passed to it. So I would to have something like: urlpatterns = patterns('', (r'^(.*)$', include(, )), ) (where and are found by a database lookup of the first part of the url.) I can't firgure out how the database lookup would fit in and how I could pass something like a blog-id to the included application url conf. Any ideas how I could accomplish this? thanks in advance, Pieter --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Exceptions and SET client_encoding to 'UNICODE'
Hi Folks, I'd like to update/initiate a database with an unique=True Field. It shall be a "batch-process" (List of entries to take over into the database. for item in leasing: l = Leasing(leasing = item) try: l.save() except IntegrityError,e : errors.append(e) except: pass leasing.append(errors) same with except (ProgramminError, IntegrityError), e First IntegrityError-Exception will be catched but next not - I get an ProgrammingError SET client_encoding to 'UNICODE'.. and all other entries in the list will be skiped with the same error- message... no storing into the database even though there's no IntegrityErros (unique elements). consequently - I can't process the whole list. Is this behaviour known - and is there a solution/work around. If not - how can I "batch" the whole list and catch IntegrityErrors It is Potgresql database Thx Timothy --~--~-~--~~~---~--~~ 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: Javascript problem
Ok I found it! I used href="..." instead of "src=...". I am very sorry Thx all anyway, it taught me some other things;) On 14 fév, 17:58, arbiwrote: > I still can't find the pb. > My js file looks like that : > > function hello() > { > alert('hello'); > > } > > do I need to add a : {% block reference %} {%endblock %} in this js > file, and the same in my html file? What I can't understand, is that > my paths are right and my css works... > > On 14 fév, 01:18, felix wrote: > > > actually if you've got firebug on it won't cache at all. > > it will check if for "not modified" headers and reuse if the server says its > > not modified. > > > the worst thing is that firefox is very slow with all the gadgets turned on. > > I use safari + firefox at the same time. just safari for speed. > > > so arbi - > > > its a 404, you're path is wrong on the script tag. > > > you can always copy the js URL out of the html source and try to load the js > > directly and try different paths till you find it. > > > On Fri, Feb 13, 2009 at 11:10 PM, Briel wrote: > > > > Firefox is known to cashe things a lot, this might be the reason why > > > it doesn't load all the stuff. Also you should look at the page source > > > to see if the missing js file is listet. > > > > On 13 Feb., 21:14, arbi wrote: > > > > Ok I tryed it, and they say : "test.js is not loaded" in firebug. > > > > I don't see what to do next. What is strange also is that my > > > > background-body images are loaded on safari (no pb) and not on > > > > firefox... > > > > Any solution? > > > > thx > > > > > On 13 fév, 18:19, felix wrote: > > > > > > use Firefox with Firebug installed if you aren't already. > > > > > > you can then see if you get any 404s and if any of the included files > > > failed > > > > > with syntax errors > > > > > or if something happened during javascript runtime to kill it > > > > > > also, I like django-compress quite a bit for css and js > > > > > > felix : crucial-systems.com > > > > > > On Fri, Feb 13, 2009 at 6:11 PM, arbi wrote: > > > > > > > Thx, but I did this already. In fact i have no problem for a css > > > > > > doc, > > > > > > but problems for a js doc. I don't know why! > > > > > > My css is in "/media/css/css_file.css" and my js is in "/media/js/ > > > > > > test.js". A simple "alert" in my test.js file doesn't work. I don't > > > > > > understand. > > > > > > Any help? > > > > > > Thx! > > > > > > Arbi > > > > > > > On 12 fév, 23:29, Alex Gaynor wrote: > > > > > > > On Thu, Feb 12, 2009 at 5:28 PM, arbi wrote: > > > > > > > > > Hi all, > > > > > > > > > I am trying to execute a javascript doc to display a google map. > > > The > > > > > > > > javascript doc to refer to is "google-map.js". How do I write it > > > in > > > > > > > > here ? : > > > > > > > > TEMPLATE : > > > > > > > > > > type="text/javascript"> > > > > > > > > . > > > > > > > > > I tryed many things and it did not work! I read many things, but > > > I > > > > > > > > can't figure out how to solve this pb. > > > > > > > > Is there an easy solution? > > > > > > > > > Thx a lot for your help > > > > > > > > Arbi (newb) > > > > > > > > Take a look here: > > > > > >http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs > > > > > > > > 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: Javascript problem
I still can't find the pb. My js file looks like that : function hello() { alert('hello'); } do I need to add a : {% block reference %} {%endblock %} in this js file, and the same in my html file? What I can't understand, is that my paths are right and my css works... On 14 fév, 01:18, felixwrote: > actually if you've got firebug on it won't cache at all. > it will check if for "not modified" headers and reuse if the server says its > not modified. > > the worst thing is that firefox is very slow with all the gadgets turned on. > I use safari + firefox at the same time. just safari for speed. > > so arbi - > > its a 404, you're path is wrong on the script tag. > > you can always copy the js URL out of the html source and try to load the js > directly and try different paths till you find it. > > On Fri, Feb 13, 2009 at 11:10 PM, Briel wrote: > > > Firefox is known to cashe things a lot, this might be the reason why > > it doesn't load all the stuff. Also you should look at the page source > > to see if the missing js file is listet. > > > On 13 Feb., 21:14, arbi wrote: > > > Ok I tryed it, and they say : "test.js is not loaded" in firebug. > > > I don't see what to do next. What is strange also is that my > > > background-body images are loaded on safari (no pb) and not on > > > firefox... > > > Any solution? > > > thx > > > > On 13 fév, 18:19, felix wrote: > > > > > use Firefox with Firebug installed if you aren't already. > > > > > you can then see if you get any 404s and if any of the included files > > failed > > > > with syntax errors > > > > or if something happened during javascript runtime to kill it > > > > > also, I like django-compress quite a bit for css and js > > > > > felix : crucial-systems.com > > > > > On Fri, Feb 13, 2009 at 6:11 PM, arbi wrote: > > > > > > Thx, but I did this already. In fact i have no problem for a css doc, > > > > > but problems for a js doc. I don't know why! > > > > > My css is in "/media/css/css_file.css" and my js is in "/media/js/ > > > > > test.js". A simple "alert" in my test.js file doesn't work. I don't > > > > > understand. > > > > > Any help? > > > > > Thx! > > > > > Arbi > > > > > > On 12 fév, 23:29, Alex Gaynor wrote: > > > > > > On Thu, Feb 12, 2009 at 5:28 PM, arbi wrote: > > > > > > > > Hi all, > > > > > > > > I am trying to execute a javascript doc to display a google map. > > The > > > > > > > javascript doc to refer to is "google-map.js". How do I write it > > in > > > > > > > here ? : > > > > > > > TEMPLATE : > > > > > > > > type="text/javascript"> > > > > > > > . > > > > > > > > I tryed many things and it did not work! I read many things, but > > I > > > > > > > can't figure out how to solve this pb. > > > > > > > Is there an easy solution? > > > > > > > > Thx a lot for your help > > > > > > > Arbi (newb) > > > > > > > Take a look here: > > > > >http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs > > > > > > > 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 -~--~~~~--~~--~--~---
raise ValidationError has no effect
I have been trying to create a custom field that allows the user to enter a flowrate and clean the data back to kg/s or mol/s. I though I had everything sorted, when I type '10 tones/year', it correctly did the conversion however when I type something that does not validate such as 'twenty' or '5 mph' the code runs till the raise validation error, however nothing else happens and the overall forms clean function gets called (which doesn't have all the fields in its clean_data attribute. I have posted the code on dpaste, any hints or suggestions and would be greatly appreciated (this is hurting my head now) http://dpaste.com/120538/ Thanks Alistair http://www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ 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 için yeterli Türkçe kaynak bulunamadığı için bazı kaynak örnekleri alıntı yaparak bir sunum yapmayı düşündüm.
http://groups.google.com.tr/group/django-turkiye --~--~-~--~~~---~--~~ 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 için yeterli Türkçe kaynak bulunamadığı için bazı kaynak örnekleri alıntı yaparak bir sunum yapmayı düşündüm.
Django nedir? Django için yeterli Türkçe kaynak bulunamadığı için bazı kaynak örnekleri alıntı yaparak bir sunum yapmayı düşündüm. Django nedir? Neler yapabiliriz? Bize sağladığı yararlar nelerdir? Nasıl ayar yapmamız gerekiyor? Bu sorulara cevap bulabilmek için 1 aydır çalışmaktayım ve deneyimlerimi anlaşılır bir dilde anlatacağım. Muslu YÜKSEKTEPE 14/02/2009 tarihinde Ubuntu İşletim Sistemi üzerinde Open Office.org Write ile hazırlanmıştır. --~--~-~--~~~---~--~~ 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: how to use post_save signals
On Feb 14, 6:28 am, gupthawrote: > hi , > In models.py i have > class Customer(...) > bill_no=models.CharFeild(...) > > All i need to access the field 'bill_no' and assign a value, In > views.py i wrote > > from django.db.models.signals import post_save > from mypro.myapp import Customer > > def after_save(sender,instance,created,**kaw): > sender.bill_no='INV'+ str(sender.id) > > post_save.connect(after_save,sender=Customer) > > i'm getting an exception as attribute bill_no and id is not found ,so > i checked the db tables ,they are present, I suppose i misunderstood > the concept .Please help me to find the fault The object being saved is 'instance', not 'sender'. Also, don't forget to save the changes to the object after modifying it. -- 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 -~--~~~~--~~--~--~---
how to use post_save signals
hi , In models.py i have class Customer(...) bill_no=models.CharFeild(...) All i need to access the field 'bill_no' and assign a value, In views.py i wrote from django.db.models.signals import post_save from mypro.myapp import Customer def after_save(sender,instance,created,**kaw): sender.bill_no='INV'+ str(sender.id) post_save.connect(after_save,sender=Customer) i'm getting an exception as attribute bill_no and id is not found ,so i checked the db tables ,they are present, I suppose i misunderstood the concept .Please help me to find the fault --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
need help validating imagefield in modelform..
Hi :) I'm trying to validate an uploaded image's size and filetype. However i have problems even gettings to the validation as django keeps telling me that there's no object. When i don't use the validation part I can upload an image just fine. So the upload thing works. I just can't figure out how to pass on the file to the validation part. I have tried with several approaches I have found on the internet. Therefore i will list my view, model and the two form methods i have tried. first, my view: def upload_file(request): myprofile = request.user.get_profile() current = request.user print "upload 1" if request.method == 'POST': form = AvatarForm(request.POST, request.FILES,instance=myprofile) print "upload 2" if form.is_valid(): [...] model: class Avatar(models.Model): user = models.ForeignKey(User,unique=True,editable=False) photo = models.ImageField(upload_to=get_profile_path, blank=True, null=True) thumbnail = models.ImageField(upload_to='profile_thumb', blank=True, null=True) form: class AvatarForm(ModelForm): class Meta: model = Avatar #1 def clean(self,data,initial=None): content = super(ImageField, self).clean(self,data,initial) content_type = content.content_type.split('/')[0] if content_type in settings.CONTENT_TYPES: if content._size > settings.MAX_UPLOAD_SIZE: raise forms.ValidationError(_('Please keep filesize under %s. Current filesize %s') % (filesizeformat(settings.MAX_UPLOAD_SIZE), filesizeformat(content._size))) else: raise forms.ValidationError(_('File type is not supported')) return content #2 def clean(self): if 'photo' in self.cleaned_data: photo = self.cleaned_data['photo'] print photo if photo.get('content-type') != 'image/jpeg': msg = 'Only .ZIP archive files are allowed.' raise forms.ValidationError(msg) return photo The error i get is pretty much the same with both methods. Nonetype has nu method/attribute: content_type/get... So i don't know if the rest of the validation code works since I can't pass my file through to the validation :-( Any help is appreciated :-) And a good weekend to all of you --~--~-~--~~~---~--~~ 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: forms - dynamically change initial values
On Feb 14, 8:13 am, Evgenywrote: > I meant django form. > Sure, I know about initial values in the constructors of fields, so I > can set these values in "design-time" and get forms with some > defaults. > But what happens in my situation: > -user clicks on the submit button of a form and sends some data to > server > -server redirects to the same page using HttpResponseRedirect object. > The constructor of HttpResponseRedirect class has a single argument - > the url to the new (the same in this case) page. > - so the page gets rendered with the design-time (static) initial > values > I'm trying to modify somehow these initial values in runtime, so the > user would see the form with the values he entered on his last submit. > But in the same time I don't want to leave the form bound. Pass an 'initial' dictionary to the form instantiation: http://docs.djangoproject.com/en/dev/ref/forms/fields/#dynamic-initial-values -- 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: a error occurs while use comment framework
thanks On Dec 30 2008, 1:26 pm, "James Bennett"wrote: > On Mon, Dec 29, 2008 at 3:38 AM, Shuge Lee wrote: > > return render_to_response( 'a.html', {'obj': obj, 'category': > > Category} ) > > > a.html > > ... > > {% load comments %} > > {% render_comment_form for category %} > > The problem may be that you are passing Category -- the model which > represents all categories in your database -- instead of a specific > individual category. You may want to read up on the distinction > between a class and an instance of a class for further information. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---