feeds and repetition
Hi, Dumb question - In a feed situation, I am using something like: return Page.objects.order_by('-date')[:30] That will always return (say) 30 results. They don't change, it's always the same 30, with perhaps a few new ones. Do I have to worry about this sameness -- or does the syndication system remove duplicates? Is this a Django thing or an RSS thing? i.e. where does it look at the data and say 'drop this, it's the same as last time'? \d -- Where I web: http://otherwise.relics.co.za/ Comics, tutorials, software and sundry --~--~-~--~~~---~--~~ 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: Multithreaded development server
On Tue, 2009-01-27 at 06:21 -0800, Almad wrote: > On Jan 26, 1:19 am, Russell Keith-Magee > wrote: > > On Sun, Jan 25, 2009 at 10:45 PM,Almad wrote: > > > I still feel kinda weird that I must hack around Django so much to > > > make basic testing things working :-]]] > > > > Let's be clear here - the "basic testing" thing that is failing here > > is a very specific, and somewhat esoteric edge case - the case of a > > view that invokes, via HTTP, another view on the same server. > > No, case we're talking about is a test that calls one view multiple > times in a row - and that is enough to have a problem with dev server. Perhaps you could show some simplified example code? I have at least a few dozen tests that do this and they don't have any problem. Serial requests work fine with the development server. I know of plenty of other people doing similar things. [...] > OK, if it's not meant for serious development and testing work, I > guess it's OK then. Depends on your definition of "serious". Given the thousands of Django applications that have, at least, started out using the development server, your claim seems a little vacuous. > (I'd just say that opitional multithreading contained in 10-line long > patch is not so complicated) > > > A multithreaded server would also act as a tacit encouragement to use > > Django's development server for real deployments, which we _really_ > > don't want to encourage. If people start using Django's development > > server in production, we would have to start treating it as a > > production-ready server - doing security and performance audits and > > the like - and again, this distracts us from what we consider to be > > the "main game". > > OK, if community is expected to ignore 'do not use this option for > production or you'll be banned from all our communication channels on > first complaint', I guess nothing can be done. And if somebody had said that, you *might* even be have a semi-valid complaint. What colour is the sky in your world? The "community" is not expected to ignore the 'do not use in production'. They're expected to read it and take it to heart. Nothing has ever been said about banning. Russell pointed out something that has been mentioned multiple times in the past: the development server has a well-defined role to play and the step-up from there to using other servers when circumstances require is incredibly minimal. Graham's blog post, given earlier in the thread, about how to use mod_wsgi is just one example of that. Once we expand the scope of the development server, it *will* be used in further unintended ways and we *will* be obliged to maintain it, including issuing security fixes and the like. You might well have some reduced outlook on the time commitment involved there, which is fine, since you aren't one of the people on the hook for things like that in Django. The group of core maintainers have decided to devote time elsewhere. > > i guess PHP users are our target group. > > > The _only_ type of view that is affected by this decision is the view > > that uses urllib (or equivalent) to invoke another view on the same > > server. > > Yes, that's the only type of view affected. And some tests... > > > We (the Django core team) have decided that this is a > > compromise we can live with. The set of cases where this behavior is > > required is very small, doesn't form a part of the requirements for > > most (almost all) web development projects. For that small subset of > > users that _do_ have a legitimate use for this, there are some > > lightweight multithreaded options (like CherryPy) out there, and to > > the best of my knowledge, none of these options _require_ the patching > > of core in order to use them. > > Well, after I fall into small group of users that do some automatized > acceptance testing (and thus require, like, Selenium) and discovered > that things looks like working after I lobotomized Django and replaced > it with CherryPy, I'm now satisfied. When you could have just used mod_wsgi, or CherryPy's WSGI server or any number of other things. Nice over-reaction there. Note, also, that there's a ticket open in Trac to add some extra bits and pieces for allowing Selenium integration with Django's test framework. That would also give you some idea of the direction things could go. This was a very disappointing mail to read. Whilst I realise you might well be frustrated, the tone is simply insulting to the amount of work that has gone into developing and supporting Django and tries to inflate whatever problem it is that you're having (which hasn't been explained in detail) way out of proportion. 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...@googlegro
Re: File as data backend for model
On Tue, 2009-01-27 at 17:13 -0500, Matthias Julius wrote: > I am trying to write a model for which the data can be represented as > a simple array of a fixed number of one byte integers. To use a > SQL database for that would be very much overkill. I would simply use > a file where I can seek to the index position and read or write that > byte. > > While this in itself is not that hard to do I am wondering about how > to implement a model that integrates well into django (provides all > methods and attributes that are expected by other parts of django) but > does not use the database as backend but some other data source > instead. > > Somehow I did not find a complete interface documentation for > models.Model and about the internal workings of django. I didn't go > to the last resort (Read the Source!), yet. The source is the interface documentation. Python is sufficiently close to English that duplicating it is usually a great way not to add much value. What there isn't at the moment, however, is any overview document on what pieces do what. However, I can short-circuit things a little bit: this is going to be a little fiddly to make it work transparently. You are either going to have to go down the route that Google App Engine does and provide replacements for the existing model fields you want to use, or write your own QuerySet replacement that knows how to talk to something like the Query class and doesn't talk to the database. The talk I gave at DjangoCon last year (the one about the ORM) has a quick guide to some of that that might provide some clues. The videos are on YouTube. In the future (Django 1.2, maybe?) I want to make it possible to replace the SQL storage portion with "something else". But that's a fairly intrusive change and not trivial to do. 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: Bound Inline Formset doesn't render FileField's current value, needs to be reentered.
On Tue, 2009-01-27 at 14:48 -0800, Rodrigo C. wrote: > > This isn't a Django issue. It's a standard property of browsers: you > > can't set an initial value for file input fields. This is a security > > measure, to stop malicious pages uploading files from your hard drive > > without your explicit instruction. > > I see. If there's no way to set the initial value for the field, would > there be some way to make Django not return an error when the user > tries to save the field without re-uploading the file? And maybe > display the current value so the user knows it's already uploaded (as > the admin site does)? This depends on how you're using the formset. In order not to raise an error, the form field involved has to know that there is a previous value and what it is. The standard FileField form field already does that (if no data is submitted and the "initial" value on the field is set, it passes validation). Displaying the initial value for file fields is something that has to be done manually in form display, from memory. So, perhaps you could give a small, reduced to the minimum, example of how you're setting all this up. Maybe it's a problem in inline formsets, or maybe it's an oversight in your code. At the moment, hard to tell. 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: how to: munge words and numbers into a URL, then reverse it ?
On Tue, 2009-01-27 at 16:48 +0100, felix wrote: > > there is some hashing function or combination of URL encoding that can > do this : > > > given some parameters : > > 'music' 'artist' 32L 2L 100 100 > ( artist id 32, 2nd picture, dimensions 100 x 100 ) > > I wish to generate a fake filename eg: > > tartan_ba6e5e06e794f1368ed3ec20b4594eec.png > > and then be able to reverse that filename back into the original > parameters when needed. > > so its either hashing, or compressing the string (to use the most of > the allowable chars a-zA-Z0-9_ ) or something Hashing is a one-way operation. You can go one way, but not the other. Why not just do something simple, like putting all the pieces into a string separated by something like commas? ','.join(parameters), for example? In fact, to work around problems with the separator appearing in the parameters themselves, I'd use something like django.utils.http.urlquote() to convert each parameter and then join them together with '&' (which urlquote will have encoding from the input parameters). The reverse process is then splitting on '&' and then calling urllib.unquote() on the parameters. 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: DateField comparison with date.today()
On Tue, 2009-01-27 at 22:03 +, Tim Sawyer wrote: > Hi, > > I have a model that includes: > > from datetime import date as pydate, datetime > > date = models.DateField() > > I've overridden delete to do: > > def delete(self): > ... > if self.date < pydate.today(): > Notification.process(None, self, 'Event deleted') > > and that works fine > > If I override save to do something similar: > > def save(self): > ... > if self.date < pydate.today(): > Notification.process(lOldEvent, self, 'Event changed') > > I get an error running my tests: > > File "/home/mysite/src/MySite/events/models.py", line 79, in save > > if self.date < pydate.today(): > > TypeError: can't compare datetime.datetime to datetime.date > > I'm confused why it works in delete(), but not in save(). Am I going about > this the wrong way, or should my approach work? The answer is almost certainly because delete() operates on something that is loaded from the database, so the attribute contains a datetime.date instance. However, save() operates on something provided from userspace, which could be a string, or, in this case, a datetime.datetime object. You haven't mentioned how you're creating these objects. Through the admin? Through forms of your own? Through Python code assigning to the attributes? In any case, it's not inconceivable that the types could be different (unfortunately). 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: Setup_environ before or after forking?
On Tue, 2009-01-27 at 12:56 -0800, Andrew Fong wrote: [...] > Question: Does it make more sense to call setup_environ before or > after forking? I'd do it after forking. > > In particular, I don't know how Django sets up its database > connection. A connection is created the first time you access a database and then closed when the response is sent back (or, in standalone cases, when you either explicitly close it or when the process ends). > Do forked processes share one connection or does each > process have their own connection? The most precise answer is "it depends", but the simplest answer is that they would be shared and it wouldn't behave as you expect. Don't do that. Forked processes share file descriptors, for example (well, they're duplicated, not shared), so if the connection uses a file descriptor, which it will, that is duplicated. > Are there pros and cons to each? Creating the connection after forking will work. Creating the connection before forking will likely lead to lots of difficult to diagnose race conditions and the like. 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: Extending User model
On Tue, 2009-01-27 at 21:44 +0100, Alex Rades wrote: [...] > my situation is: It's a site for students and companies, where > students can post their data and search for internships, and companies > post their data, internship opportunities, and search for students. > > So, students have to fill their profile with student-related stuff and > companies have their own kind of profile with company related stuff. > > Therefore, in this situation, I don't think it is wise to go with your > idea #2 (use only 1 user model and implement a permissions-style > system) since these two kind of users are so different. Think about > this: I want the degree field to be mandatory for students, while of > course it doesn't apply for companies. Thought #2 was orthogonal to thought #1. You can still have the profile class contain a generic relation to the per-user-customised type of profile class. > About your idea #1, I think this could be wiser in my case. I could > just place a near the login form, with two options: Student > and Company, then I could wrap the generic login view to create the > right kind of user, and from that moment, user.get_profile() should > give me back the right kind of profile. Well, it will give you back the common profile class, from which you can descend, with another database query to the specific class. Generic Relations aren't automatically retrieved (even using select_related()). However, that won't affect how you write the code: you just access attributes normally, like you do with normal relations. A third option is to consider just not using the User profile support, but writing a helper method that accepts a user instance and returns the right sort of profile class based on, say, the type of user or something like that. 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: Common fields in an abstract class, with customized db_column values for concrete models
On Tue, 2009-01-27 at 11:19 -0800, psj wrote: > Hi community -- > > All my models have some common fields, say "created_date" and > "last_modified_date". However, for various reasons not important here, > we have some naming conventions on column names: we like them to have > a prefix that pertains to the entity itself, so that the Account model > has db_column="ac_created_date" and the Category model has > db_column="ct_created_date". > > It seems that the "common fields" scenario is a prime candidate for > the Abstract Base Class model inheritance scenario, but I'm having > some difficulty making the ABC mechanism work with these custom > db_column values. > > Creating a class method that returns the Model's preferred prefix > doesn't seem to work, as the inherited models seem to get the prefix > of the abstract class. > > Am I missing a straightforward way of doing this? No, you're not missing a straightforward way. That behaviour isn't supported. It would be a little fiddly to add, but not impossible. Not sure it's really worth it for Django's core, however, since it's an edge-case and ABC's are only a convenience, not a requirement. 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: Changing comments preview form
On Tue, 2009-01-27 at 20:11 +0100, Florian Lindner wrote: > Hello, > > I'm playing around with the contrib.comments framework. I want to > change the preview form. For that I've copied preview.html to xgm/Blog/ > templates/comments (xgm is my project, Blog is app). My template > loaders are: > > TEMPLATE_LOADERS = ( > 'django.template.loaders.app_directories.load_template_source', > 'django.template.loaders.filesystem.load_template_source', > ) > > But modification I make to the preview.html in my app dir does not > seem to be noticed. The problem is that there's no ordering guarantee here. There is a comments/preview.html template provided by the django.contrib.comments app and a comments/preview.html template provided by your application. It happens that the app_directories loader runs through the applications in the order they're listed in INSTALLED_APPS at the moment, although I'm not sure that is guaranteed. For now, though, you could probably make this work by ensuring your application is listed in INSTALLED_APPS before the django.contrib.comments application. In general, another approach is to this is to use the TEMPLATE_LOADERS in the default order provided by Django (filesystem loader before app_directories loader) and put any override templates in a directory that is specified in the TEMPLATE_DIRS setting. Then the filesystem loader will be run first and is guaranteed to find your override before the app_directories loader starts its run. For comments, if you're only wanting to change the preview form for a particular model or particular application, note that the template loaded for preview is not comments/preview.html, always. That is the name that is loaded is all else fails. However, the application first looks for comments/__preview.html comments/_preview.html where is the name of the application and is the name of the model to which the comment is attached. If either of those templates are found, they are used for preference. So for an app-specific customisation for an app called "foo", say, you could create comments/foo_preview.html in the foo/templates/ directory and it will be loaded for the preview. So, there you go. Three different solutions for the same problem. Regards, Malcolm 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: error when using Create, Update generic views
On Tue, 2009-01-27 at 19:36 -0800, vierda wrote: > Dear all, > > Today I'm learning to use generic views for create and update objects. > It required form_class or model for the argument. My model is User > from django.contrib.auth.models.User and my form as per below : > > from django.contrib.auth.models import User > from django.forms import ModelForm > > class RegistrationForm(ModelForm): >class Meta: > model = User > fields = ('username', 'email', 'password') > > > class UserProfileForm(ModelForm): >class Meta : > model = User > fields = ('email',) > > I call the generic views in urls.py as per below : > > from django.conf.urls.defaults import * > > urlpatterns = patterns('django.views.generic.create_update', > (r'^register/ > $','create_object'{'form_class':'fintoo.apps.authorization.forms.RegistrationForm'}), > (r'^update/ > $','update_object'{'form_class':'fintoo.apps.authorization.forms.UserProfileForm'}), > ) > If that's a cut-and-paste, you have a couple of typos. There should be a comma between the view name and the extra dictionary. > but it always raise error 'str' object has no attribute '_meta' Django also gives you a full traceback that tells you (and us) where the error occurs. That's important information. If you're viewing the error through the debug page in a web browser, switch to the cut-and-paste view before pasting the traceback. It will be much more readable. 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: Adjusting these models for other functionality
On Tue, 2009-01-27 at 09:57 -0800, Almost George wrote: > -- MODELS -- ( Other, unimportant fields/models have been removed ) > > class Band(models.Model): > name= models.CharField(max_length = 50, unique = True) > > class Venue(models.Model): > name= models.CharField(max_length = 50) > > class Event(models.Model): > name= models.CharField(max_length = 50, unique = True) > info= models.TextField(max_length = 200, blank = True) > date= models.DateTimeField() > bands = models.ManyToManyField(Band) > venue = models.ForeignKey(Venue) > > If an Event is part of a Tour/Festival that has multiple dates (not > necessarily consecutive) I don't want to re-enter the bands and extra > info for each Event - where, essentially, I'll only have a different > Venue and Date assigned. > > Currently, the Automatic Admin gives me the ability to quickly add/ > change Bands and Venues for an Event, in one place. I'd like to keep > it that way if possible. > > I've been thinking this into the ground on the best way to abstract > the Bands/Dates/Venues from the Event without causing rediculous > amounts of Joins to happen just to list the Events by date, and show > which Bands will be at each. You won't be able to create "ridiculous" amounts of joins. Databases are optimised to handle joins (certainly dozens at a time and often more), so stop trying to prematurely optimise. There's simply no other way to view what you're doing. Even with really huge and complicated schemas "normalise until it hurts; denormalise until it works" is the right order. You aren't approaching that order of complexity, so you can focus on step one for now. It sounds like an event should have a many-to-many relation to a date-range class that specifies the various dates. That will allow searches for events on a particular dates, dates for a particular event and so on. You should be able to organise things so that Festivals are simply Events. In fact, it seems to be that the whole structure here sort of rotates around Events. Without events, you have nothing, whether the event is a garage band gig or Woodstock. So I'd drive outwards from there. Events have multiple dates associated with them (as above -- I'd use a dateinterval style of class, but that's optional). They also have a many-to-many relation to bands, which is the band or bands that are part of the event. You might want to do that via a manual intermediate model (ManyToManyField(through=...) ) if the bands for an event also carry extra information (headliners, first support act, etc). And a Festival (name adjusted to choice) that is OneToOne with Event -- from Festival -> Event, since every Festival is an Event, but not vice-versa -- which provides extra information about the festival. There are possibly other structures, but that's one that comes to my mind after a little thought. 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: Problem with encoding and using ifequal in Django templates
On Tue, 2009-01-27 at 09:25 -0800, Ben Gerdemann wrote: > Hello, > > I'm having problems using {% ifequal s1 "some text" %} to compare > strings with extended characters in Django templates. When string s1 > contains ascii characters >127, I get exceptions in the template > rendering. I know you've solved this yourself, but for future reference: there are no such animals as "ASCII characters > 127". ASCII is a 7-bit encoding. You could be talking about UTF-8 bytes or Unicode characters (codepoints) in that range (or ISO-8859-1 or other encoding of choice), but not ASCII. Using the right terms for future problems will avoid any "wtf?!" moments on the part of the readers. 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: passing self?
On Tue, 2009-01-27 at 08:32 -0800, ajlozier wrote: > I have made a little progress on the problem I posted about earlier > (http://groups.google.com/group/django-users/browse_thread/ > thread/100679d9c298dc52/ffa1564be0c4b276?hl=en&lnk=gst&q=tree > +admin#ffa1564be0c4b276">creating tree inputs in the admin) but am > getting stuck on what i am sure is a very minor point. > > warning, i am sure this is a very n00b question. i've only been using > django/python for about one week now. > > http://pastebin.com/d6bab03fe > > right now i am getting an error on line 19 - "two arguments are > required." but, if i try to pass self as the first argument, it says > self is not defined. > > my background is php - i am getting the feeling that self is not > necessarily the same thing as $this in php (or 'this' in javascript) > can someone illuminate what this means, why (if i do) have to have > self as the first argument in my def MyStyleAdminForm, and how i need > to pass it from within the class? Well, "self" is kind of like $this or "this", but not precisely equivalent. You can't quite Use The Force like that when programming and it would be worthwhile doing a Python tutorial (e.g. the one at python.org) if this is a stumbling block. That being said.. The getClassificationTree() method is a method on the MyStyleAdminForm model. It is, in fact, an *instance* method, which means you can only call it on an instance of the model. The highly normal way to do this in Python is (if "foo" is an instance of MyStyleAdminForm): foo.getClassificationTree(parents) Also possible is MyStyleAdminForm.getClassificationTree(foo, parents) but that's less common and, for that reason, less advisable (as it will make anybody reading the code later wonder why you're doing things in an odd way). In your particular case, however, you have a more fundamental problem: you're trying to call an instance method on the class before you have an instance. Line 19 in that paste is executed at parse time -- when the module is first imported. Python is just constructing the class object at that point. Instances are only created much later on (when the admin wants to use that class). So something about your approach needs to be rethought there. 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: Splitting a NullBooleanField in a template
On Tue, 2009-01-27 at 06:53 -0800, chewynougat wrote: > After having a closer look in django, it seems that the > RadioFieldRenderer that renders the radio buttons, renders the entire > set as a single string, therefore it is not possible to split these > fields in the template (using django) - if anyone else is interested! That's correct, for the default widget used in that case. Nothing to prevent you writing your own widget that works as you would like, however. That's part of the reason why widget classes are separate from form fields and why the form fields take a widget parameter: to allow such customisations. 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 -~--~~~~--~~--~--~---
error when using Create, Update generic views
Dear all, Today I'm learning to use generic views for create and update objects. It required form_class or model for the argument. My model is User from django.contrib.auth.models.User and my form as per below : from django.contrib.auth.models import User from django.forms import ModelForm class RegistrationForm(ModelForm): class Meta: model = User fields = ('username', 'email', 'password') class UserProfileForm(ModelForm): class Meta : model = User fields = ('email',) I call the generic views in urls.py as per below : from django.conf.urls.defaults import * urlpatterns = patterns('django.views.generic.create_update', (r'^register/ $','create_object'{'form_class':'fintoo.apps.authorization.forms.RegistrationForm'}), (r'^update/ $','update_object'{'form_class':'fintoo.apps.authorization.forms.UserProfileForm'}), ) but it always raise error 'str' object has no attribute '_meta' really appreciate for your kind help thank you regards, -vierda- --~--~-~--~~~---~--~~ 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: reverse foreignkey "add" method using multiple INSERTs
On Tue, 2009-01-27 at 02:17 -0800, Andrew Ingram wrote: > Hi All, > > I'm using something along the following lines to bulk add a bunch of > objects to a model's reverse foreignkey relationship: > > foo.bar_set.add(*bars) > > where bars is a list of Bar objects. > > I've noticed that Django is generating a new INSERT query for each > object in the list rather than just using a single INSERT with all the > objects. I'm no expert on whether this is optimal or not, I just want > to be sure that this behaviour is deliberate rather than an oversight. At present, at least, Django never generates multi-value insert statements. 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: template: writing "\u20ac 20.000" fails
On Tue, 2009-01-27 at 00:37 -0800, SanPy wrote: > Thanks a lot, Malcolm, > > You got me on the right track, I just needed to escape the string, > like this: > > var prices=[{% for price in prices %}[{{ price.0 }}, '{{ price.1| > escape }}']{% if not forloop.last %},{% endif %}{% endfor %}]; > > I tried the `escapejs` filter. That didn't work. What does "didn't work" mean? It raised an error? Your computer caught on fire? The "escapejs" filter isn't broken and works quite well. The "escape" filter does HTML-aware escaping, not Javascript-aware escaping. They are different, so using the "escape" (of "force_escape") filter for data intended for Javascript will lead to incorrect results. 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 -~--~~~~--~~--~--~---
Settings,py - and Update the MySQL connection
Hi all, I recently had a person make me databases for a website and put them on there for me... I use django - anyway, I got a completely new site - same host/domain name/etc - just a new outlook for the site - however the guy who created my databases told me, that in order get the databases transfered and setup from one site to the other I needed to 1. Backup the MySQL database on the old host (PHPMyAdmin can make a backup, iirc). - DONE 2. Import the MySQL database on the new host. - DONE (since there is not a new host - its still go daddy) 3. Copy the files (from your webroot: /templates, /python and /.htaccess). - DONE 4. Update settings.py: Change any file system paths, and update the MySQL connection information. Step 4 is where I am confused... How do I update in settings.py? And how do I update the MySQL connection information... I am a noob, and wish this guy would get back to me, b/cs I was going to pay him $50 to just put everything on the new site if anyone can help shed some light on this that would be greatly appreciated. Thanks Kyle --~--~-~--~~~---~--~~ 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: urlresolvers.reverse() breaks when given exactly one arg of more than one character
On Jan 27, 9:14 pm, Malcolm Tredinnick wrote: > This isn't anything to do with reverse(). It's a Python thing. The > "args" argument has to be a sequence. A list or a tuple, for example. Ah, I hadn't thought of that. Somewhere deep within the Django source, something probably says "for arg in args". The REASON I didn't think of that is because of what it says when it displays the exception: "with arguments '('1', '2')' ". In order to print that, I thought Django ran the function tuple() on args, and I couldn't figure out why. I tried putting in args=['1', '2'], and the exception said "with arguments '('1', '2')' " again. Why did it turn the square brackets into parens? I took this as further evidence that Django ran the function tuple() on args, turning any list into a tuple. I couldn't figure out why they would do that. Now I see that the parens in the exception are probably meaningless - it doesn't matter what kind of sequence it is, and it's not actually being converted into a tuple, it is just being written between parens for the purpose of the exception. --~--~-~--~~~---~--~~ 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: urlresolvers.reverse() breaks when given exactly one arg of more than one character
On Tue, 2009-01-27 at 18:07 -0800, Fluoborate wrote: > Hello All, > > I have a question. When I use the function > django.core.urlresolvers.reverse(), it works fine with args=(), and it > works fine with args=(string1, string2 [, ...more strings]), and it > even works fine with args=(anyOneCharacterLongString). However, if I > give it args=(multiCharacterString), it does not work. This isn't anything to do with reverse(). It's a Python thing. The "args" argument has to be a sequence. A list or a tuple, for example. In Python, this is a tuple: ('a',) So is this: ('a', 'b') This, however, is not a tuple (a tuple must contain at least one comma, whether separating two or more items, or following a single item): ('a') (it's a one-character string). Now, a string is also a sequence, so if you pass in: ('fred') anything expecting a sequence will be able to iterate over that, getting respective elements of 'f', 'r', 'e' and 'd'. However, that's almost certainly not what you meant and it's different from ('fred',) -- which has a trailing comma and is thus a one-tuple. 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: urlresolvers.reverse() breaks when given exactly one arg of more than one character
Thats because of an anouing thing with tuples where args=('12') is identical to args='12', you would need to do args=('12',) to make it work right Dj Gilcrease OpenRPG Developer ~~http://www.openrpg.com On Tue, Jan 27, 2009 at 7:07 PM, Fluoborate wrote: > > Hello All, > > I have a question. When I use the function > django.core.urlresolvers.reverse(), it works fine with args=(), and it > works fine with args=(string1, string2 [, ...more strings]), and it > even works fine with args=(anyOneCharacterLongString). However, if I > give it args=(multiCharacterString), it does not work. > > For instance, from the command line: reverse('mysite.myapp.views.onedataset', args=('6')) > '/myapp/6/' reverse('mysite.myapp.views.onedataset', args=('12')) > Traceback (most recent call last): > File "", line 1, in > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/core/urlresolvers.py", line 254, in > reverse >*args, **kwargs))) > File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/django/core/urlresolvers.py", line 243, in > reverse >"arguments '%s' not found." % (lookup_view, args, kwargs)) > NoReverseMatch: Reverse for '' with > arguments '('1', '2')' and keyword arguments '{}' not found. > > Look at that! It broke the perfectly valid arg '12' into what seems to > be a tuple, ('1', '2'). Why did it do that? Let's try this: reverse('mysite.myapp.views.onedataset', args=(['12'])) > '/myapp/12/' reverse('mysite.myapp.views.onedataset', args=(('16',))) > '/myapp/16/' > > Weird, it worked. It seems that whatever Django gets as *args, it > applies the function tuple() to it. If *args is one string, tuple() > turns it into a tuple containing a bunch of one character strings, > thus breaking the lookup. If *args is empty, a one character string, > or more than one string, then it works out alright because tuple() > cannot mangle it. > > The solution? If you have just one string to pass as *args, make it a > list or tuple. It took me a bunch of frustration before I figured this > out. Well, looking at the clock I guess it only wasted about forty > minutes of my time. And a bunch of that was spent writing this post. > Still, I was annoyed. This problem went completely under the radar > during testing because I never created more than 9 entries, so the bug > never surfaced. > > I thought I might be able to save somebody else some trouble. Also, > Django could conceivably fix this pretty easily. > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
urlresolvers.reverse() breaks when given exactly one arg of more than one character
Hello All, I have a question. When I use the function django.core.urlresolvers.reverse(), it works fine with args=(), and it works fine with args=(string1, string2 [, ...more strings]), and it even works fine with args=(anyOneCharacterLongString). However, if I give it args=(multiCharacterString), it does not work. For instance, from the command line: >>> reverse('mysite.myapp.views.onedataset', args=('6')) '/myapp/6/' >>> reverse('mysite.myapp.views.onedataset', args=('12')) Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/core/urlresolvers.py", line 254, in reverse *args, **kwargs))) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/django/core/urlresolvers.py", line 243, in reverse "arguments '%s' not found." % (lookup_view, args, kwargs)) NoReverseMatch: Reverse for '' with arguments '('1', '2')' and keyword arguments '{}' not found. Look at that! It broke the perfectly valid arg '12' into what seems to be a tuple, ('1', '2'). Why did it do that? Let's try this: >>> reverse('mysite.myapp.views.onedataset', args=(['12'])) '/myapp/12/' >>> reverse('mysite.myapp.views.onedataset', args=(('16',))) '/myapp/16/' Weird, it worked. It seems that whatever Django gets as *args, it applies the function tuple() to it. If *args is one string, tuple() turns it into a tuple containing a bunch of one character strings, thus breaking the lookup. If *args is empty, a one character string, or more than one string, then it works out alright because tuple() cannot mangle it. The solution? If you have just one string to pass as *args, make it a list or tuple. It took me a bunch of frustration before I figured this out. Well, looking at the clock I guess it only wasted about forty minutes of my time. And a bunch of that was spent writing this post. Still, I was annoyed. This problem went completely under the radar during testing because I never created more than 9 entries, so the bug never surfaced. I thought I might be able to save somebody else some trouble. Also, Django could conceivably fix this pretty easily. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Automatically printing display of model object's data
Here I have a silly function for pretty printing any model object's data. def pprint(res): for instr in dict(res.__dict__): if instr[-3:] == "_id": instr = instr[:-3] displaymeth = "get_%s_display" % instr try: atr =getattr(res,displaymeth) except: atr =getattr(res,instr) print "%s: %s" % (instr,atr) It sort of prints out an easy to read representation of any model object. Is there a better way to do this? I am sure there was something already in Django to do this, but I am having a hard way of finding. I am still on .96 Thanks, Brian Ray --~--~-~--~~~---~--~~ 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: ObjectPaginator
Patricio Palma wrote: > Hi guys. > I'm trying to use Rosetta ( http://code.google.com/p/django-rosetta/ ) > > in a view (home, a rosetta views) is using a ObjectPaginator and > InvalidPage but i've a execption > cant find module ObjectPaginator. > > Googling I fix it using > > from django.core.paginator import Paginator as ObjectPaginator, > InvalidPage > > but in some code line call to > > get_page() method > > 'Paginator' object has no attribute 'get_page' > > > where is my problem > > > Thanks > > > > > get_page is from version < 1.0 in > 1.0use page(num) take a look at : http://www.djangoproject.com/documentation/models/pagination/ Leonel --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ObjectPaginator
Hi guys. I'm trying to use Rosetta ( http://code.google.com/p/django-rosetta/ ) in a view (home, a rosetta views) is using a ObjectPaginator and InvalidPage but i've a execption cant find module ObjectPaginator. Googling I fix it using from django.core.paginator import Paginator as ObjectPaginator, InvalidPage but in some code line call to get_page() method 'Paginator' object has no attribute 'get_page' where is my problem 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: Form validated before submitted
JonUK wrote: > Solved - problem was caused by these lines > > def __init__(self, *args, **kwargs ): >super( ContactForm, self ).__init__( args, kwargs ) > > changing to explicit parameter names fixed it. > The correct generic form would have been def __init__(self, *args, **kwargs ): super( ContactForm, self ).__init__( *args, **kwargs ) regards Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
"ImportError: cannot import name SimpleCookie" on access to Django
I have Django 1.0.2 installed, using mod_python compiled against Python 2.6.1 and Apache 2.2.11. Upon accessing my Django project's configured URL, I get the following errors: [Tue Jan 27 19:33:05 2009] [error] [client 127.0.0.1] Traceback (most recent call last): [Tue Jan 27 19:33:05 2009] [error] [client 127.0.0.1] File "C:\\Python26\\Lib\\site-packages\\mod_python\\importer.py", line 1537, in HandlerDispatch\ndefault=default_handler, arg=req, silent=hlist.silent) [Tue Jan 27 19:33:05 2009] [error] [client 127.0.0.1] File "C:\\Python26\\Lib\\site-packages\\mod_python\\importer.py", line 1202, in _process_target\nmodule = import_module(module_name, path=path) [Tue Jan 27 19:33:05 2009] [error] [client 127.0.0.1] File "C:\\Python26\\Lib\\site-packages\\mod_python\\importer.py", line 304, in import_module\nreturn __import__(module_name, {}, {}, ['*']) [Tue Jan 27 19:33:05 2009] [error] [client 127.0.0.1] File "c:\\python26\\lib\\site-packages\\django-1.0.2_final-py2.6.egg\\django\\core\\handlers\\modpython.py", line 4, in \nfrom django import http [Tue Jan 27 19:33:05 2009] [error] [client 127.0.0.1] File "c:\\python26\\lib\\site-packages\\django-1.0.2_final-py2.6.egg\\django\\http\\__init__.py", line 3, in \nfrom Cookie import SimpleCookie, CookieError [Tue Jan 27 19:33:05 2009] [error] [client 127.0.0.1] ImportError: cannot import name SimpleCookie The Cookie module is present in C:\Python26\Lib, and that path is in the PythonPath registry key. Any thoughts on where this error is coming from? Jon P --~--~-~--~~~---~--~~ 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: Creating test databases. Nose framework
On Wed, Jan 28, 2009 at 5:51 AM, Oleg Oltar wrote: > Hi! > I am trying to create few nose test for my application. > I need to test registration/login, so want to create a test sqlite3 > database, and pre-populate it with some data. > No sure how to do it. > I created a setup method: > def setup(): > setup_test_environment() > create_test_db() > But getting an exception on from django.db.backends.creation import > create_test_db create_test_db() is a method on creation object, not a method to be imported from the creation module. Invocation is: from django.db import connection connection.creation.create_test_db() See django.test.simple.run_tests() for a full working example. 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: Form validated before submitted
Solved - problem was caused by these lines def __init__(self, *args, **kwargs ): super( ContactForm, self ).__init__( args, kwargs ) changing to explicit parameter names fixed it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to change python version in ubuntu???
DragonSlayre wrote: > > On Jan 27, 4:11 pm, Steve Holden wrote: > >> DragonSlayre wrote: >> >> >>> On Jan 27, 3:15 pm, Steve Holden wrote: >>> DragonSlayre wrote: >>> How do you do this? >>> >> http://www.swc.scipy.org/lec/shell02.html >> >> regards >> Steve >> > > WOW, that explains it all... Looks about as good as every other thing > that I've read on the net. > Ok, so I do a set | less - hey there's no Environment variable > with PYTHON in it. - who cares though right - now I know how to use > grep... yay!! > > This is what F**ks me off with most of the developers out there - so > vague in documentation (if it exists). > > I know you are probably just trying to help Steve, but if you know how > to do this, is it so hard just to say how? It's very frustrating to > spend hours and hours trying to find out how to do something so > simple, and still have no answer. Personally - I wish there was a > radio button that I could select to switch between python versions, > but unfortunately, a radio button just isn't as superior as a > terminal. > > The link provided looks like a great reference, but unfortunately it's > like giving someone a toolkit and expecting them to build a house from > it. > I'm sorry if you found that reference confusing. This indicates that you may need to climb the computing curve a little further before you can expect to get the most from Django. It is after all primarily a programmer's framework. [sigh] In essence, the PATH shell environment variable in most Linux/UNIX shells today is a colon-separated list of directories. When you issue a command the shell performs various substitutions (filename, shell variable, history, alias, and so on) and ends up with a list of tokens. Usually the tokens are separated by spaces, though you can change this behavior by setting specific environment variables. If the first token contains any slashes it's interpreted as the path to the program to be executed (relative to the current direct directory, unless it starts with a slash in which case it's an absolute path). Otherwise the shell looks for a file of that name in each of the directories on the PATH until it either finds it or exhausts the PATH. So let's say you have python 2.5 installed as /usr/bin/python and 2.6 installed as /usr/local/bin/python. When you type "python ..." at the command line, which of those is executed depends on the order of the directories in the PATH. There's more, but that's the scoop. Hope this helps. regards Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multithreaded development server
On Tue, Jan 27, 2009 at 11:21 PM, Almad wrote: > > P.S.: Sorry for the sarcastic tone of my e-mail. I appreciate Your > work as well as Django framework (or at least some parts of it), but I > just don't get it: for each and every project I've written in Django, > I banged my head against the wall because of some issues that > prevented me from normal testing - and were rejected by devs because > of 'esoteric edge case'...and then reading 'Testing Django apps' on > first presentation slide, 'because it's most important'. Sorry, but my stress-induced fibritis can only take so much. As a hint, if you ever find yourself in a position where you need to apologize at the end of an email for the tone you've taken, it's probably a good indicator that you need to go back and edit for tone. As a further hint, using pejoratives in project naming - like, say, "Sane Testing in Django" - isn't a good way to encourage others to assist you. I've explained the reasoning behind Django's decisions. I can only assure you that I know many people that aren't affected by those decisions, and are able to use Django's testing framework, as is, without difficulty. Some of them are even able to use Selenium. If you sit down and work through the problem, you will establish that the consequences of those decisions aren't as widespread as you seem to think. There is _exactly_ one limitation to Django's development server - _concurrent_ web requests. To be sure, this does impose limitations, but as long as you don't need concurrent server requests, you won't have any problems with a single-threaded server. Most web pages can be adequately served by a number of _sequential_ web requests. I will also remind you that just because _you_ hit a given problem every single day, doesn't mean that _everyone_ hits that problem every single day. Such is the nature of esoteric problems. You will note that so far in this thread, you haven't actually described your problem - just that a multithreaded server is apparently the only way to solve it. If you ever feel like describing your problem (sans rhetoric) and working constructively towards a solution, let me know. 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 -~--~~~~--~~--~--~---
Form validated before submitted
I have a ModelForm and a view, but the form's validation messages are always rendered on first viewing - any idea why? # ModelForm class ContactForm( ModelForm ): first_name = CharField( 'Firstname' ) last_name = CharField( 'Lastname' ) company = CharField( 'Company' ) tel = CharField( 'Telephone' ) email = EmailField( 'Email' ) message = CharField( 'Message', widget=Textarea ) class Meta: model = Contact fields = ( 'first_name', 'last_name', 'company', 'tel', 'email', 'message', ) def __init__(self, *args, **kwargs ): super( ContactForm, self ).__init__( args, kwargs ) self.fields.keyOrder = self.Meta.fields # View def contact( request ): if request.method == 'POST': contact = ContactForm( request.POST, auto_id='contact_%s' ) if contact.is_valid(): contact.user = request.user contact.save() contact = None else: contact = ContactForm( auto_id='contact_%s' ) return render_to_response( 'contact.html', { 'contact' : contact, }, context_instance = RequestContext( request ) ) --~--~-~--~~~---~--~~ 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: Creating test databases. Nose framework
thanks for the doc. So if I have to store a User object in db (with fields (name, email, pass) How should I define the fixture? Should I define it in setup? Also, is there a way I can actually create the test db. Still can't import create_test_db :( On Wed, Jan 28, 2009 at 12:49 AM, Jeff Hammerbacher wrote: > Hey Oleg, > > To load some sample data for your tests, see Django's documentation on > fixtures: > http://docs.djangoproject.com/en/dev/topics/testing/#fixture-loading. > > Later, > Jeff > > > On Tue, Jan 27, 2009 at 1:05 PM, Karen Tracey wrote: > >> On Tue, Jan 27, 2009 at 3:51 PM, Oleg Oltar wrote: >> >>> Hi! >>> I am trying to create few nose test for my application. >>> I need to test registration/login, so want to create a test sqlite3 >>> database, and pre-populate it with some data. >>> No sure how to do it. >>> >>> I created a setup method: >>> def setup(): >>> setup_test_environment() >>> create_test_db() >>> >>> But getting an exception on from django.db.backends.creation import >>> create_test_db >>> >>> Please help me to find it out how to use the create_test_db function to >>> create the db >>> >>> Also. How to add some data there without running tests first? >>> >>> >> I know nothing of nose, but: >> >> http://www.assembla.com/wiki/show/nosedjango >> >> says it is a plugin for nosetests that supports fixture loading & test >> database setup and teardown, which seems to be what you are looking for? >> >> 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: File as data backend for model
Hey Matthias, To use Django's model object for this task, you will need to implement a custom manager for your file's structure; you can see some basic documentation at http://docs.djangoproject.com/en/dev/topics/db/managers/#topics-db-managers. It should be noted that Django's ORM is not well suited to non-relational data sources right now, from my brief experience, so you'll probably be better off implementing your own class to perform these manipulations. Regards, Jeff On Tue, Jan 27, 2009 at 2:13 PM, Matthias Julius wrote: > > I am trying to write a model for which the data can be represented as > a simple array of a fixed number of one byte integers. To use a > SQL database for that would be very much overkill. I would simply use > a file where I can seek to the index position and read or write that > byte. > > While this in itself is not that hard to do I am wondering about how > to implement a model that integrates well into django (provides all > methods and attributes that are expected by other parts of django) but > does not use the database as backend but some other data source > instead. > > Somehow I did not find a complete interface documentation for > models.Model and about the internal workings of django. I didn't go > to the last resort (Read the Source!), yet. > > What is the best way to approach something like that? > > Matthias > > > > --~--~-~--~~~---~--~~ 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: Creating test databases. Nose framework
Hey Oleg, To load some sample data for your tests, see Django's documentation on fixtures: http://docs.djangoproject.com/en/dev/topics/testing/#fixture-loading. Later, Jeff On Tue, Jan 27, 2009 at 1:05 PM, Karen Tracey wrote: > On Tue, Jan 27, 2009 at 3:51 PM, Oleg Oltar wrote: > >> Hi! >> I am trying to create few nose test for my application. >> I need to test registration/login, so want to create a test sqlite3 >> database, and pre-populate it with some data. >> No sure how to do it. >> >> I created a setup method: >> def setup(): >> setup_test_environment() >> create_test_db() >> >> But getting an exception on from django.db.backends.creation import >> create_test_db >> >> Please help me to find it out how to use the create_test_db function to >> create the db >> >> Also. How to add some data there without running tests first? >> >> > I know nothing of nose, but: > > http://www.assembla.com/wiki/show/nosedjango > > says it is a plugin for nosetests that supports fixture loading & test > database setup and teardown, which seems to be what you are looking for? > > 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: Bound Inline Formset doesn't render FileField's current value, needs to be reentered.
> This isn't a Django issue. It's a standard property of browsers: you > can't set an initial value for file input fields. This is a security > measure, to stop malicious pages uploading files from your hard drive > without your explicit instruction. I see. If there's no way to set the initial value for the field, would there be some way to make Django not return an error when the user tries to save the field without re-uploading the file? And maybe display the current value so the user knows it's already uploaded (as the admin site does)? --~--~-~--~~~---~--~~ 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: in what namespace do widgets reside?
great - 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: Bound Inline Formset doesn't render FileField's current value, needs to be reentered.
On Jan 27, 9:11 pm, "Rodrigo C." wrote: > I have model that represents a file, and has a FileField, that I am > rendering via an Inline Formset. When a user fills in the form it gets > saved with no problems. > However, I want the users to be able to continue editing the file, but > when I re-display the newly created object, the data for the FileField > doesn't show, so if the user edits some data but doesn't re-upload the > file, she gets an error. > How can I make the formset render the FileField's current value within > the form field? > This isn't a Django issue. It's a standard property of browsers: you can't set an initial value for file input fields. This is a security measure, to stop malicious pages uploading files from your hard drive without your explicit instruction. There isn't really any way round it, except to do something extremely complicated like GMail does and upload the file in the background while the user fills in the form, then replace the file field with a reference to the uploaded version of the file. -- 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: How to change python version in ubuntu???
On Tue Jan 27 12:12 , DragonSlayre sent: > >Thanks Waylan - http://achinghead.com/archive/83/installing-multiple-versions-python/ >is just what I needed. > >Thanks Shaleh, > >I appreciate the detailed explanation :) >Yes - the shell is something that I have to get more familiar with - >I've only really recently started using ubuntu for development so am >on a bit of a learning journey. > We learn something new everyday. When we stop learning we stop growing. Stop growing and you are as good as dead (-: The book I linked to should really help you on this journey. GUIs are very useful but sometimes getting your hands dirty on the command line is a good thing. (-: >So it seems pretty easy to invoke the version of python I want to use, >and using symbolic links make sense (especially after seeing Waylan's >link). > >Just a couple of questions: > >I didn't quite get what you were referring to with the Django command >line tool, and Django scripts - are you talking about django- >admin.py ? yes, that is what I meant. >When you install a python package from the package manager or using >apt-get, is there some way to tell it to install into a specific >version of python, or does it use the python symlink /usr/bin/python, >or something else? - Waylan installed easy_install for each python >version in his example (so he could install packages for different >python versions). > Typically, if a python library package is tied to a specific python version the version will be in the package name. For instance idle-python2.4 and idle-python2.5. Otherwise, the package will install into a generic python accessible location and be available to all version of python installed. Look at /usr/lib and /usr/share. You should see multiple directories with the word 'python' in their name. Digging through their contents should make things more clear. I have never played with easy_install, so I can not comment on how that would interact with prebuilt Ubuntu packages. I usually use Debian's unstable version aka Sid. unstable in this case is the scientific definition meaning often changing and not the more common usage of might break at any moment (-: One more helpful tip. Go to the python.org website. There is a mailing list there called 'python tutor'. It is meant for all kinds of Python newbie questions -- ask about code, ask about packages, whatever. The people on the list have been there for quite a few years and will be very careful to explain things (-: Just the archives from that list may be helpful to you, depending on how you learn new things. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Article lists
Hi! I'm planing to add an article list to my application. The idea is to show every article stored in the database but in a truncated way. So I used the following template tags to produce the list {% autoescape off %} {% for article in list_of_articles %} {{article.title}} {{article.body|truncatewords:120}} {% endfor %} {% endautoescape %} But have few questions about how to extend the result. 1. truncatewords filter produces "...", is there a way I can change it to MORE? --~--~-~--~~~---~--~~ 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: Several browser windows, one session object - should I be locking django session objects?
On Jan 27, 4:52 pm, Matthias Julius wrote: > mvtango writes: > > my users keep several browser windows open in my application, I need > > to keep session information for all these windows separate. But I have > > only one session object - modifying it while the user works in window > > A and window B in parallel might get me in trouble if Request A and > > Request B are under way in parallel. > > > So I thought about locking the session, modifiying it, saving it > > during the request. I thought about locking the session at the > > database level. > > > Questions: Anybody run into this? Would locking be the right way to do > > it? Or are there any other ways of solving this? Session data is stored in the database and the ORM. These transactions are are threadsafe, so you won't run into conditions where browser A overwrites the newly submitted data from browser B. If you need to know know however whether browser A finished before browser B and browser B had access to the complete transaction in browser A, you are going to need to set up some logic that checks for browser A's transaction being done before you allow browser B (i recommend doing this in validation and not looping or waiting for some condition). Yet another way you can just be super sure is to set up only one thread and process on your server. This will force the tranactions to excute in order, but the trade off is speed and flexiblity. Your best bet is just to program without needing context from browser A's session to be completed before browser B's. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
File as data backend for model
I am trying to write a model for which the data can be represented as a simple array of a fixed number of one byte integers. To use a SQL database for that would be very much overkill. I would simply use a file where I can seek to the index position and read or write that byte. While this in itself is not that hard to do I am wondering about how to implement a model that integrates well into django (provides all methods and attributes that are expected by other parts of django) but does not use the database as backend but some other data source instead. Somehow I did not find a complete interface documentation for models.Model and about the internal workings of django. I didn't go to the last resort (Read the Source!), yet. What is the best way to approach something like that? Matthias --~--~-~--~~~---~--~~ 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 yesno to generate images
Margie wrote: > Thanks very much, autoescape did the trick, here is the result for > anyone interested: > > {% autoescape off %} > {{ task.done|yesno:" \" alt=\"False\" />, \"False\" />" }} > {% endautoescape %} > Neat, but I think you need to correct your first alt string :) regards Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to: munge words and numbers into a URL, then reverse it ?
P.S ,,, Never use index in name generation, or you will run out of range one day ;) think of that nightmare in advance... i can only wish further schlaf süß, grüß Puneet On Tue, Jan 27, 2009 at 10:25 PM, felix wrote: > > ah, danke dir ! > > that's exactly what I was looking for > > full encodings here: > http://docs.python.org/library/codecs.html#standard-encodings > > actually I guess in this case I would have a series of numbers; > > [ content_type_id, object_id, index, width, height ] > > rather than a string. I can figure that out, or it would be simple enough > to join them and do the pack. > it won't be so long as the example I posted. > > > FYI > this would be for thumbnails : if the thumbnail exists the static server > will serve it, else django will be triggered to build it. > > but I wouldn't want to open up the URL so that anybody could request say > > for i in range(0,1): > get image urls until my server gives up ... > > > but I will design the paths so that it exposes the object ID like so: > > %(content_type_id)s_%(object_id)s_%(encoded)s.jpg > > so that I can easily delete all thumbs when the object is deleted > > currently I create thumbs on demand via template tags. > this also leaves dead thumbs laying around. > > > > > > On Tue, Jan 27, 2009 at 5:43 PM, Puneet Madaan wrote: > >> I am assuming that you already have an idea of how your datastring will >> look like, and what data it is containing... I am considering *"music >> artist 32L 2L 100 100"* as input data >> so here is a example... >> >> L1 = "music artist 32L 2L 100 100".encode("hex") >>> L2 = zlib.compress(L1) >>> L3 = L2.encode("hex") >>> print L3 >>> >> >> L3 can now be taken as URI referencing string.. which in this special case >> is >> >> >> '789c35c5c10d00200c02c095102aa4f3e8fe336862fcdc7967466e8bf00853ee28454862adfb7308c2ff00401d0b64' >> >> and reverse algo for this is also as easy >> >> >>> D1=789c35c5c10d00200c02c095102aa4f3e8fe336862fcdc7967466e8bf00853ee28454862adfb7308c2ff00401d0b64'.decode("hex") >>> D2 = zlib.decompress(D1) >>> D3 = D2.decode("hex") >>> >> >> you will get your "music artist 32L 2L 100 100" back >> >> And your URL will not send further a psuedo encoded number which is ugly >> enough for non-developers :D >> you are free to choose encoding, and can nest them in multiple algos to >> make the thing more complex >> >> greetings, >> Puneet >> >> >> On Tue, Jan 27, 2009 at 4:48 PM, felix wrote: >> >>> >>> there is some hashing function or combination of URL encoding that can do >>> this : >>> >>> >>> given some parameters : >>> >>> 'music' 'artist' 32L 2L 100 100 >>> ( artist id 32, 2nd picture, dimensions 100 x 100 ) >>> >>> I wish to generate a fake filename eg: >>> >>> tartan_ba6e5e06e794f1368ed3ec20b4594eec.png >>> >>> and then be able to reverse that filename back into the original >>> parameters when needed. >>> >>> so its either hashing, or compressing the string (to use the most of the >>> allowable chars a-zA-Z0-9_ ) or something >>> >>> hints or pointers anyone ? >>> thanks >>> >>> >>> >>> http://crucial-systems.com >>> >>> >>> >>> >> >> >> -- >> If you spin an oriental man, does he become disoriented? >> (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu >> >> is der net süß » ε(●̮̮̃•̃)з >> -PM >> >> >> > > > > -- If you spin an oriental man, does he become disoriented? (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu is der net süß » ε(●̮̮̃•̃)з -PM --~--~-~--~~~---~--~~ 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: Several browser windows, one session object - should I be locking django session objects?
mvtango writes: > my users keep several browser windows open in my application, I need > to keep session information for all these windows separate. But I have > only one session object - modifying it while the user works in window > A and window B in parallel might get me in trouble if Request A and > Request B are under way in parallel. > > So I thought about locking the session, modifiying it, saving it > during the request. I thought about locking the session at the > database level. > > Questions: Anybody run into this? Would locking be the right way to do > it? Or are there any other ways of solving this? I doubt it is possible to tell from which browser window a request comes if you use session cookies. I guess you need to either send the session ID along as POST data or make it part of the URL. Matthias --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
sites framework with multiple machines
I have a client that maintains several hundred small web sites running on dozens of different machines all over the world. These sites have common data (footers, privacy policy pages, etc.) he would like to manage through a single CMS. Currently, he uploads all the changes manually using FTP. Yikes! The sites all run PHP, but my client has expressed interest in moving to Django eventually. Would this be possible using Django's sites framework? I have not used the sites framework before, but on first read of the documentation, it seems that sites is restricted to a single Django installation with all the sites running on the same physical machine. Is that 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 -~--~~~~--~~--~--~---
DateField comparison with date.today()
Hi, I have a model that includes: from datetime import date as pydate, datetime date = models.DateField() I've overridden delete to do: def delete(self): ... if self.date < pydate.today(): Notification.process(None, self, 'Event deleted') and that works fine If I override save to do something similar: def save(self): ... if self.date < pydate.today(): Notification.process(lOldEvent, self, 'Event changed') I get an error running my tests: File "/home/mysite/src/MySite/events/models.py", line 79, in save if self.date < pydate.today(): TypeError: can't compare datetime.datetime to datetime.date I'm confused why it works in delete(), but not in save(). Am I going about this the wrong way, or should my approach work? Thanks, Tim. --~--~-~--~~~---~--~~ 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 imagefield at development server
felix wrote: > > on my dev server (laptop) I serve the MEDIA_ROOT through the normal > apache localhost. > I do not get django to serve them. > ok, thank's for your attention, the problem is solved, i don't know how it solved, but with deleting table from database, than create it again with python manage.py syncdb after i run server again this is running well. TIA somat. -- Stay Hungry Stay Foolish http://somat.wordpress.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: admin list display icons for callable?
Thanks guys, it was staring me in the face but I didn't get it until the 4th or 5th re-read! Creating links in the list display with allow_tags is a great feature. Paddy On Jan 27, 5:42 pm, Malcolm Tredinnick wrote: > On Mon, 2009-01-26 at 21:51 -0800, Paddy Joy wrote: > > The admin interface shows nice green/red icons for BooleanFields. If I > > have a callable that returns only true or false, is there a way I can > > make these show in the admin with icons rather than the text > > 'True'/'False' > > > For example I would like the callable 'photo_ad' to show on the list > > display with icons rather than text. > > Alex has already given the answer to this question, but I'd add that > it's well worth reading (and then re-reading and re-reading) the section > about list_display and list_display_links in the admin docs ([1]). There > are lots of interesting possibilities there. > > [1]http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display > > 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: Django imagefield at development server
on my dev server (laptop) I serve the MEDIA_ROOT through the normal apache localhost. I do not get django to serve them. ie I do not do this at all: urlpatterns += patterns('', (r'^site-media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), ) pdb is very important to know. just type import pdb; pdb.set_trace() anywhere in your code and you will be thrown into the debugger. the browser will hang while you are in the debugger (in terminal/shell), which is why I suggested maybe that was why you were hanging. or do you mean : how do you do that when the code is the admin ? only if you have edited anything in django code base itself . On Tue, Jan 27, 2009 at 9:35 PM, Akhmat Safrudin wrote: > > felix wrote: > > no problem uploading using the dev server > > > > no idea. you didn't leave a pdb in your code, did you ? > > > > what is the output if any in the shell ? > i point the url in the browser to http://localhost:8000/admin/ > how to debug with pdb in admin area ? > > somat. > > -- > Stay Hungry Stay Foolish > > > > > --~--~-~--~~~---~--~~ 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: munge words and numbers into a URL, then reverse it ?
ah, danke dir ! that's exactly what I was looking for full encodings here: http://docs.python.org/library/codecs.html#standard-encodings actually I guess in this case I would have a series of numbers; [ content_type_id, object_id, index, width, height ] rather than a string. I can figure that out, or it would be simple enough to join them and do the pack. it won't be so long as the example I posted. FYI this would be for thumbnails : if the thumbnail exists the static server will serve it, else django will be triggered to build it. but I wouldn't want to open up the URL so that anybody could request say for i in range(0,1): get image urls until my server gives up ... but I will design the paths so that it exposes the object ID like so: %(content_type_id)s_%(object_id)s_%(encoded)s.jpg so that I can easily delete all thumbs when the object is deleted currently I create thumbs on demand via template tags. this also leaves dead thumbs laying around. On Tue, Jan 27, 2009 at 5:43 PM, Puneet Madaan wrote: > I am assuming that you already have an idea of how your datastring will > look like, and what data it is containing... I am considering *"music > artist 32L 2L 100 100"* as input data > so here is a example... > > L1 = "music artist 32L 2L 100 100".encode("hex") >> L2 = zlib.compress(L1) >> L3 = L2.encode("hex") >> print L3 >> > > L3 can now be taken as URI referencing string.. which in this special case > is > > > '789c35c5c10d00200c02c095102aa4f3e8fe336862fcdc7967466e8bf00853ee28454862adfb7308c2ff00401d0b64' > > and reverse algo for this is also as easy > > >> D1=789c35c5c10d00200c02c095102aa4f3e8fe336862fcdc7967466e8bf00853ee28454862adfb7308c2ff00401d0b64'.decode("hex") >> D2 = zlib.decompress(D1) >> D3 = D2.decode("hex") >> > > you will get your "music artist 32L 2L 100 100" back > > And your URL will not send further a psuedo encoded number which is ugly > enough for non-developers :D > you are free to choose encoding, and can nest them in multiple algos to > make the thing more complex > > greetings, > Puneet > > > On Tue, Jan 27, 2009 at 4:48 PM, felix wrote: > >> >> there is some hashing function or combination of URL encoding that can do >> this : >> >> >> given some parameters : >> >> 'music' 'artist' 32L 2L 100 100 >> ( artist id 32, 2nd picture, dimensions 100 x 100 ) >> >> I wish to generate a fake filename eg: >> >> tartan_ba6e5e06e794f1368ed3ec20b4594eec.png >> >> and then be able to reverse that filename back into the original >> parameters when needed. >> >> so its either hashing, or compressing the string (to use the most of the >> allowable chars a-zA-Z0-9_ ) or something >> >> hints or pointers anyone ? >> thanks >> >> >> >> http://crucial-systems.com >> >> >> >> > > > -- > If you spin an oriental man, does he become disoriented? > (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu > > is der net süß » ε(●̮̮̃•̃)з > -PM > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Bound Inline Formset doesn't render FileField's current value, needs to be reentered.
I have model that represents a file, and has a FileField, that I am rendering via an Inline Formset. When a user fills in the form it gets saved with no problems. However, I want the users to be able to continue editing the file, but when I re-display the newly created object, the data for the FileField doesn't show, so if the user edits some data but doesn't re-upload the file, she gets an error. How can I make the formset render the FileField's current value within the form field? Here's the view, the Parent model is "Articulo", the inline model is "Archivo": ArchivoInlineFormSet = inlineformset_factory(Articulo, Archivo, extra=3) @login_required def create_article(request, id=False): text = "Enviar" button = "Enviar" user = request.user if request.method == 'POST': #save data for new article form = ArticuloForm(request.POST, request.FILES) if form.is_valid(): #save info articulo = form.save() articulo.autores.add(user.get_profile()) articulo.save() formset = ArchivoInlineFormSet(request.POST, request.FILES, instance=articulo) if formset.is_valid(): formset.save() else: #start editing new article form = ArticuloForm() formset = ArchivoInlineFormSet() objContext = RequestContext(request, locals()) return render_to_response("editar/articulo.html", objContext) and the class, the troublesome field is "archivo": class Archivo(models.Model): articulo = models.ForeignKey(Articulo) tipo = models.IntegerField() numero = models.IntegerField() archivo = models.FileField(upload_to="archivos") etapa = models.IntegerField() --~--~-~--~~~---~--~~ 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: Creating test databases. Nose framework
On Tue, Jan 27, 2009 at 3:51 PM, Oleg Oltar wrote: > Hi! > I am trying to create few nose test for my application. > I need to test registration/login, so want to create a test sqlite3 > database, and pre-populate it with some data. > No sure how to do it. > > I created a setup method: > def setup(): > setup_test_environment() > create_test_db() > > But getting an exception on from django.db.backends.creation import > create_test_db > > Please help me to find it out how to use the create_test_db function to > create the db > > Also. How to add some data there without running tests first? > > I know nothing of nose, but: http://www.assembla.com/wiki/show/nosedjango says it is a plugin for nosetests that supports fixture loading & test database setup and teardown, which seems to be what you are looking for? 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: Debugging infinite loops
Check out http://docs.python.org/library/logging.html for logging. There's also some Django logging middleware floating around that might be useful -- just Google for it. On Jan 27, 11:45 am, defone wrote: > Hi, > > I'm seeing occasionally bug that is causing an infinite loop. What is > the best way to debug these in production environment? I was thinking > that why there is no built-in simple profiler in Django, just for > example to log how much time it takes to e.g. render each view? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Setup_environ before or after forking?
I am running a python process separate from my actual Django web server to do background processing. Since I need database access and I like using Django's models, I call django.core.management.setup_environ at the start of my background process. I am now trying to fork the process using the processing module (http://pypi.python.org/pypi/processing) so I can run code on multiple cores concurrently. Specifically, I use the Pool class to create a bunch of worker processes that I can asynchronously assign work to. Each of my worker processes also need DB access via Django's models. Question: Does it make more sense to call setup_environ before or after forking? In particular, I don't know how Django sets up its database connection. Do forked processes share one connection or does each process have their own connection? Are there pros and cons to each? Also, if it matters, I'm currently running MySQL 5.0.5 as the DB. Thanks! -- Andrew --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Creating test databases. Nose framework
Hi! I am trying to create few nose test for my application. I need to test registration/login, so want to create a test sqlite3 database, and pre-populate it with some data. No sure how to do it. I created a setup method: def setup(): setup_test_environment() create_test_db() But getting an exception on from django.db.backends.creation import create_test_db Please help me to find it out how to use the create_test_db function to create the db Also. How to add some data there without running tests first? 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: Question about login_required redirect_field_name
On Tue, Jan 27, 2009 at 3:25 PM, Jonathan Nelson wrote: > > I just figured it out. > > Instead of using a decorator, I just used this: > def myview(request, comment_id): > ...if not request.user.is_authenticated(): > ..return HttpResponseRedirect('/login/?next=%s') % request.path > This is what the decorator is for, so that your do not have to put this code in your view. The redirect_field_name is used if you want to use a value other than 'next' for the name of the query string parameter that holds the value to be redirected to. So, if I decorate a view with: @login_required(redirect_field_name='martha') def index(request, model_name): and try to access that view (happens to be at /puzzles/) when not logged in, I get redirected to (on my local testserver): http://localhost:8000/accounts/login/?martha=/puzzles/ I doubt you really want to change redirect_field_name, it is not the name but the value of the variable that you want to vary by view, and that is what is automatically done by the @login_required decorator. Just use it with no parameters. Karen > > On Jan 27, 11:57 am, Jonathan Nelson wrote: > > I'm trying to decorate a view function with login_required. I want > > the user to be redirected to the current view after they log in. > > > > I'm trying: > > > > @login_required(redirect_field_name=request.path) > > def myview(request, comment_id): > > return render_to > > > > but, I'm getting a "NameError: name 'request' is not defined". I'm > > assuming that's because the decorator doesn't have access to the > > request object. Is there a way to have access to that in the > > decorator? I can't create my url like this, either: > > > > @login_required(redirect_field_name='/myview/%s' %comment_id ) > > def myview(request, comment_id): > > return render_to > > > > because the decorator doesn't seem to have access to the post > > variables. > > > > Any thoughts? > > > --~--~-~--~~~---~--~~ 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: Extending User model
On Tue, Jan 27, 2009 at 5:12 AM, Malcolm Tredinnick wrote: > > On Tue, 2009-01-27 at 00:11 +0100, Alex Rades wrote: >> Hi, >> I need to have two sets of users in my application: One is the Person >> and the other is the Company. So, I have to decide between going with >> the userprofile way or inheriting from User. >> >> The problem with userprofile is that i can only register One class >> with AUTH_PROFILE_MODULE >> The problem with User inheritance is that I have to rewrite parts of >> UserAdmin and its Forms to have these two sets of users in the admin. > > Two thoughts about this: > > (1) Although you can only register on AUTH_PROFILE_MODULE, you can make > that a small class that has a GenericRelation to an appropriate set of > alternatives, one for "people" and one for "companies". Or it can be a > base class that other classes inherit from in the two cases. I'd > probably use the generic relation, but I'm not sure. > > (2) You might want to think hard about whether you're really modelling > this the right way. Companies are simply not users. There could be users > who have permissions or can take actions on behalf of a company. But > there are a lot of cases that you'll bump into where treating a company > and a user as identical types of things ("things that can be authorised > entities") will cause headaches. I've played that game, made the > mistakes, and regretted it. It's usually easier to implement a > permissions-style system so that certain users can do things on a > company-wide level and others cannot. That way you only have to worry > about users and their permissions. HI Malcom, Thanks a lot for your hints, let give you a little bit more information: my situation is: It's a site for students and companies, where students can post their data and search for internships, and companies post their data, internship opportunities, and search for students. So, students have to fill their profile with student-related stuff and companies have their own kind of profile with company related stuff. Therefore, in this situation, I don't think it is wise to go with your idea #2 (use only 1 user model and implement a permissions-style system) since these two kind of users are so different. Think about this: I want the degree field to be mandatory for students, while of course it doesn't apply for companies. About your idea #1, I think this could be wiser in my case. I could just place a near the login form, with two options: Student and Company, then I could wrap the generic login view to create the right kind of user, and from that moment, user.get_profile() should give me back the right kind of profile. Do you have suggestions? I think I'm going to do this with your solution #1, but I'm not completely sure :) Thanks a lot for your 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: Django imagefield at development server
felix wrote: > no problem uploading using the dev server > > no idea. you didn't leave a pdb in your code, did you ? > > what is the output if any in the shell ? i point the url in the browser to http://localhost:8000/admin/ how to debug with pdb in admin area ? somat. -- Stay Hungry Stay Foolish --~--~-~--~~~---~--~~ 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 imagefield at development server
phoebebright wrote: > You might also check, > You have DEBUG = True in settings.py > And have permissions set on the photo directory > And have something in urls.py file to point to the photo directory 0. DEBUG was true, 1. to ensure directory is writable, its set to 777, 3. is it some think like this ? : urlpatterns += patterns('', (r'^site-media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), ) if so i have add that to urls.py somat. -- Stay Hungry Stay Foolish --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Several browser windows, one session object - should I be locking django session objects?
Hi there, my users keep several browser windows open in my application, I need to keep session information for all these windows separate. But I have only one session object - modifying it while the user works in window A and window B in parallel might get me in trouble if Request A and Request B are under way in parallel. So I thought about locking the session, modifiying it, saving it during the request. I thought about locking the session at the database level. Questions: Anybody run into this? Would locking be the right way to do it? Or are there any other ways of solving this? Thanks! Martin --~--~-~--~~~---~--~~ 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: Question about login_required redirect_field_name
On Tue, Jan 27, 2009 at 2:57 PM, Jonathan Nelson wrote: > > I'm trying to decorate a view function with login_required. I want > the user to be redirected to the current view after they log in. > > I'm trying: > > @login_required(redirect_field_name=request.path) > def myview(request, comment_id): > return render_to > > but, I'm getting a "NameError: name 'request' is not defined". I'm > assuming that's because the decorator doesn't have access to the > request object. Is there a way to have access to that in the > decorator? I can't create my url like this, either: > > @login_required(redirect_field_name='/myview/%s' %comment_id ) > def myview(request, comment_id): > return render_to > > because the decorator doesn't seem to have access to the post > variables. > > Any thoughts? > I don't believe redirect_field_name does what you think it does. Try just @login_required with no parameters and I think it will do what you are looking for. 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: Question about login_required redirect_field_name
I just figured it out. Instead of using a decorator, I just used this: def myview(request, comment_id): ...if not request.user.is_authenticated(): ..return HttpResponseRedirect('/login/?next=%s') % request.path On Jan 27, 11:57 am, Jonathan Nelson wrote: > I'm trying to decorate a view function with login_required. I want > the user to be redirected to the current view after they log in. > > I'm trying: > > @login_required(redirect_field_name=request.path) > def myview(request, comment_id): > return render_to > > but, I'm getting a "NameError: name 'request' is not defined". I'm > assuming that's because the decorator doesn't have access to the > request object. Is there a way to have access to that in the > decorator? I can't create my url like this, either: > > @login_required(redirect_field_name='/myview/%s' %comment_id ) > def myview(request, comment_id): > return render_to > > because the decorator doesn't seem to have access to the post > variables. > > Any thoughts? --~--~-~--~~~---~--~~ 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 change python version in ubuntu???
Thanks Waylan - http://achinghead.com/archive/83/installing-multiple-versions-python/ is just what I needed. Thanks Shaleh, I appreciate the detailed explanation :) Yes - the shell is something that I have to get more familiar with - I've only really recently started using ubuntu for development so am on a bit of a learning journey. So it seems pretty easy to invoke the version of python I want to use, and using symbolic links make sense (especially after seeing Waylan's link). Just a couple of questions: I didn't quite get what you were referring to with the Django command line tool, and Django scripts - are you talking about django- admin.py ? When you install a python package from the package manager or using apt-get, is there some way to tell it to install into a specific version of python, or does it use the python symlink /usr/bin/python, or something else? - Waylan installed easy_install for each python version in his example (so he could install packages for different python versions). Thanks a lot, Things are becoming much clearer now. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Debugging infinite loops
Hi, I'm seeing occasionally bug that is causing an infinite loop. What is the best way to debug these in production environment? I was thinking that why there is no built-in simple profiler in Django, just for example to log how much time it takes to e.g. render each view? --~--~-~--~~~---~--~~ 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-like filters in custom views
On Tue, Jan 27, 2009 at 2:00 PM, bobhaugen wrote: > > Anybody done anything like: > a) using the django admin change_list filters directly in custom views > and templates outside of admin? > or > b) created something *like* the admin change_list filters for use in > custom views and templates outside of admin? > or > c) got any tips on the simplest way one could do such a thing? Yes, been there done that about 2.5 years ago when I started with Django and wanted similar functionality for my own non-admin pages. As I was also brand-new to Python it was a good exercise in figuring out where the code was that did it, how it worked, and what I needed to do to to create similar function for my own use. If I were to encounter the problem today I might try to approach it in a way to make that code more generally re-usable. However, that was more than I could tackle at the time and I haven't had to revisit that code in at least 2 years so all I can say is as I recall it wasn't too hard to figure out what admin was doing and borrow/adapt the code for use in my own project. 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: in what namespace do widgets reside?
On Tue, Jan 27, 2009 at 3:42 PM, JonUK wrote: > > Apologies for the daft question, but after 10 mins of trawling through > the official docs and various random google articles, I cannot find > thyis info. I found it by clicking ion "the Module Index" link in the main documentation page, which took me to this page: http://docs.djangoproject.com/en/dev/modindex/ and then searching for 'widget'. HTH, -- Ramiro Morales --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Question about login_required redirect_field_name
I'm trying to decorate a view function with login_required. I want the user to be redirected to the current view after they log in. I'm trying: @login_required(redirect_field_name=request.path) def myview(request, comment_id): return render_to but, I'm getting a "NameError: name 'request' is not defined". I'm assuming that's because the decorator doesn't have access to the request object. Is there a way to have access to that in the decorator? I can't create my url like this, either: @login_required(redirect_field_name='/myview/%s' %comment_id ) def myview(request, comment_id): return render_to because the decorator doesn't seem to have access to the post variables. Any thoughts? --~--~-~--~~~---~--~~ 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: Seperate Email Server - Django
Madhav, You need to configure this in your mail server. On Wed, Jan 28, 2009 at 1:17 AM, madhav wrote: > > I am not very sure, whether this posting will be attributed to > sendmail or any other mailing software when compared to Django. I am > using Django 1.0.2. And I have requirement like, each user of the site > will be mailing any other guy and I have rules for that communication > (let them aside for now). So user1 will be picking an email id like: > mypickeduser1n...@sitedomain.com and will be sending an email to > user2, whose email id will be like: > mypickeduser2n...@sitedomain.com. Like that any number of users will > be sending emails to any numbers of users. And any outsider should be > able to send an email to mypickeduser2n...@sitedomain.com. My question > is,So in this context, do I need to build my own smtp(setup mailing) > servers. I am totally a newbie in the smtp arena. Can I achieve the > email communication between the users without "mailing server" > configurations? > Can this be achievable? > > > -- 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 -~--~~~~--~~--~--~---
Seperate Email Server - Django
I am not very sure, whether this posting will be attributed to sendmail or any other mailing software when compared to Django. I am using Django 1.0.2. And I have requirement like, each user of the site will be mailing any other guy and I have rules for that communication (let them aside for now). So user1 will be picking an email id like: mypickeduser1n...@sitedomain.com and will be sending an email to user2, whose email id will be like: mypickeduser2n...@sitedomain.com. Like that any number of users will be sending emails to any numbers of users. And any outsider should be able to send an email to mypickeduser2n...@sitedomain.com. My question is,So in this context, do I need to build my own smtp(setup mailing) servers. I am totally a newbie in the smtp arena. Can I achieve the email communication between the users without "mailing server" configurations? Can this be achievable? --~--~-~--~~~---~--~~ 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: in what namespace do widgets reside?
On Tue, Jan 27, 2009 at 6:42 PM, JonUK wrote: > > Apologies for the daft question, but after 10 mins of trawling through > the official docs and various random google articles, I cannot find > thyis info. django.forms.widgets --~--~-~--~~~---~--~~ 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: Performance using session, passing data from one request to another, use js or not? Best practice?
Thanks for the answer, I was already getting worried about my 'session' way. No caching for know although it doesn't seem difficult to implement. And yes the way you do it would have that advantage, but mine has beautiful urls!! ^^ thanks again, Tim DG --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Common fields in an abstract class, with customized db_column values for concrete models
Hi community -- All my models have some common fields, say "created_date" and "last_modified_date". However, for various reasons not important here, we have some naming conventions on column names: we like them to have a prefix that pertains to the entity itself, so that the Account model has db_column="ac_created_date" and the Category model has db_column="ct_created_date". It seems that the "common fields" scenario is a prime candidate for the Abstract Base Class model inheritance scenario, but I'm having some difficulty making the ABC mechanism work with these custom db_column values. Creating a class method that returns the Model's preferred prefix doesn't seem to work, as the inherited models seem to get the prefix of the abstract class. Am I missing a straightforward way of doing this? Any help appreciated, psj --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Changing comments preview form
Hello, I'm playing around with the contrib.comments framework. I want to change the preview form. For that I've copied preview.html to xgm/Blog/ templates/comments (xgm is my project, Blog is app). My template loaders are: TEMPLATE_LOADERS = ( 'django.template.loaders.app_directories.load_template_source', 'django.template.loaders.filesystem.load_template_source', ) But modification I make to the preview.html in my app dir does not seem to be noticed. What's wrong? Thanks, Florian --~--~-~--~~~---~--~~ 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-like filters in custom views
Anybody done anything like: a) using the django admin change_list filters directly in custom views and templates outside of admin? or b) created something *like* the admin change_list filters for use in custom views and templates outside of admin? or c) got any tips on the simplest way one could do such a thing? --~--~-~--~~~---~--~~ 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 change python version in ubuntu???
> >On Mon Jan 26 17:51 , DragonSlayre sent: > >> >> >> >>On Jan 27, 1:41 pm, sha...@speakeasy.net> wrote: >> >>> Does this help? Found via google and ubuntu >forums.https://launchpad.net/~doko/+archive >>> >>> Sorry, I run Debian (which ubuntu is based on), I just apt-get install all >>> of the >>> available python versions and then run /usr/bin/python to test things. >> >>The problem isn't installing python, which can be done through the >>package manager or with apt-get, but the problem is for example >>changing back to 2.5 once 2.6 is installed. > >It should install a binary as python2.6. It should not touch your python2.5 >binary. Then you simply call the version you are interested in. Or change the >/usr/bin/python symlink. > I just say your mail to Steve asking for people to be very clear in their explanations. Sorry, many of us make the (incorrect) assumption that if you are using Linux, experimenting with the package managers, etc. that there is a certain level of shell competency. This is in no way intended as a jab at you or others. When many of us started doing this, we were thrown into the deep water and struggled to swim. These days with all of the GUI support, easy OS installs, etc. it is easy for us to forget that today's newbie did not have to fight as hard as those in the past. Again, this is not a "you have not bled enough, leave us alone" comment. Just explaining where many of us are coming from. May I recommend a great book called Unix Shells by Example. http://www.amazon.com/UNIX-R-Shells-Example-4th/dp/013147572X/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1233081731&sr=8-1 (note there is no referral ID in that link). The lady who wrote it does a great job. It explains all of the common shell tools. Read it, pass it around to your friends. I leave a copy at work to hand over to new hires. Now back to the topic at hand. In Debian and ubuntu, great care is taken to support upgrading and testing. Each Python version will be installed in a version specific directory. So python 2.4 will be /usr/bin/python2.4 and have its files stored in /usr/lib/python2.4/..., etc. This means you can install as many python packages as you like and then just invoke the correct binary for the task at hand. What this means for you is python 2.6 packages should be safe to install and can be invoked as python2.6. You can edit the Django command line tool to call python2.6 instead of just python. Then the right version will be called. When the distribution considers a version of python the standard for a release all they do is set the /usr/bin/python symbolic link to the correct binary. It is a bad idea to change this link unless you are sure all of the software you need can run safely with that python version. $PYTHONHOME is not necessarily the variable you need to set. Sometimes it is, it all depends on how you installed Python. If you only use packages, then simply invoking the correct binary is 100% the easiest way and requires no other changes. If you compile from sources, then be sure to place the output in /usr/local or /opt/. When you then call /usr/local/bin/python or /opt/python2.6/bin/python the right files should be used. But all of this assumes you update the Django scripts to call the right python and not just depend on /usr/bin/python or '/usr/bin/env python' to find the right one. It is OK to edit this scripts, honest. (-: --~--~-~--~~~---~--~~ 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 Slider in Django Form
I had been looking through that documentation already, but it's certainly possible I missed something. I'll give it another look. Thanks for the help guys :) On Jan 23, 5:10 pm, Brian Neal wrote: > On Jan 23, 2:43 pm,oboedude wrote: > [...] > > > How do I create a custom widget and what do I have to do to use my > > custom widget in a form? > > Read the documentation on forms, then checkout the section on form > media: > > http://docs.djangoproject.com/en/dev/topics/forms/media/#topics-forms... > > I've integrated several jQuery plugins using both Widget and Form > media hooks that Django provides. > > Best, > BN --~--~-~--~~~---~--~~ 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: Custom Template Tag - Passing variable for use in tag processing
On Jan 28, 2009, at 1:52 AM, phoebebright wrote: > > I have duplicated as best I can the processing for handling variables > in custom template tags mentioned in an earlier post but it's not > working for me as I need the value of the variable before I parse it. > Is there another way of making the variable available? > > The tag is being called from the tempalte with: > > {% page_links "category" %} > > Where category is being passed into the template from a view. (also > tried "{{category}}" and {{category}} and category) > > I want to use the value of category to determine which list of pages > to return. > > I KNOW THIS DOESN"T WORK: > > @register.tag(name="page_links") > def get_page_links(parser,token): >tag_name, cat = token.contents.split() >return PageLink(cat[1:-1]) > > class PageLink(template.Node): > >def __init__(self, cat): > >cat= template.Variable(cat) >print cat <- outputs category >if cat=='business': >pages=BusinessPage.objects.filter > (is_live=True).select_related().order_by('order') >elif cat=='community': >pages=CommunityPage.objects.filter > (is_live=True).select_related().order_by('order') >elif cat=='tourism': >pages=TourismPage.objects.filter > (is_live=True).select_related().order_by('order') > >else: >pages = False > >self.pages = pages > >def render(self, context): >context['pages'] = self.pages > >return '' > I might be missing something you're trying to do here, but the usual method for resolving a variable in a custom template tag is to first put it into the tag (without quotes) like so: {% page_links category %} Then attach that to your PageLink node in its __init__ method as a Variable: self.cat = template.Variable(cat) Then inside the render method first resolve it: category = self.cat.resolve(context) and then check the value of category against your various models. That all has to be done in render, not __init__, because context is only available in render. This is all straight out of the docs: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#passing-template-variables-to-the-tag Apologies in advance if I've misunderstood what you're trying to do... Eric > > This code works fine as long as I call it like this: > > {% page_links "business" %} > > @register.tag(name="page_links") > def get_page_links(parser,token): > >tag_name, cat = token.contents.split() >cat = cat[1:-1] > >if cat=='business': >pages=BusinessPage.objects.filter > (is_live=True).select_related().order_by('order') >elif cat=='community': >pages=CommunityPage.objects.filter > (is_live=True).select_related().order_by('order') >elif cat=='tourism': >pages=TourismPage.objects.filter > (is_live=True).select_related().order_by('order') >else: >pages = False > >return PageLink(pages) > > class PageLink(template.Node): > >def __init__(self, pages): >self.pages = pages > >def render(self, context): >context['pages'] = self.pages > >return '' > > --~--~-~--~~~---~--~~ 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: Extending User with a profile
Os my bug. It was a mistype in a model. Exception gone now On Tue, Jan 27, 2009 at 8:43 PM, Oleg Oltar wrote: > Hi! > I want to add a profile to every user, that I can register in my > application. In future it should contain such fields as avatar, email, > about_me fields > > I found a snippet how to extend django User model: > http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ > > But when added the proposed code to my view: > (so now it looks like this) > from django.contrib.auth.models import User > > > class UserProfile(models.Model): > url = models.URLField > about = models.TextField() > user = models.ForeignKey(User, unique=True) > > > I caught an exception on syncdb > >class UserProfile(models.Model): > File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", > line 80, in __new__ > new_class.add_to_class(obj_name, obj) > File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", > line 164, in add_to_class > value.contribute_to_class(cls, name) > TypeError: Error when calling the metaclass bases > unbound method contribute_to_class() must be called with URLField > instance as first argument (got ModelBase instance instead) > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Extending User with a profile
Hi! I want to add a profile to every user, that I can register in my application. In future it should contain such fields as avatar, email, about_me fields I found a snippet how to extend django User model: http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ But when added the proposed code to my view: (so now it looks like this) from django.contrib.auth.models import User class UserProfile(models.Model): url = models.URLField about = models.TextField() user = models.ForeignKey(User, unique=True) I caught an exception on syncdb class UserProfile(models.Model): File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", line 80, in __new__ new_class.add_to_class(obj_name, obj) File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", line 164, in add_to_class value.contribute_to_class(cls, name) TypeError: Error when calling the metaclass bases unbound method contribute_to_class() must be called with URLField instance as first argument (got ModelBase instance instead) --~--~-~--~~~---~--~~ 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 change python version in ubuntu???
On Mon Jan 26 17:51 , DragonSlayre sent: > > > >On Jan 27, 1:41 pm, sha...@speakeasy.net> wrote: > >> Does this help? Found via google and ubuntu forums.https://launchpad.net/~doko/+archive >> >> Sorry, I run Debian (which ubuntu is based on), I just apt-get install all >> of the >> available python versions and then run /usr/bin/python to test things. > >The problem isn't installing python, which can be done through the >package manager or with apt-get, but the problem is for example >changing back to 2.5 once 2.6 is installed. It should install a binary as python2.6. It should not touch your python2.5 binary. Then you simply call the version you are interested in. Or change the /usr/bin/python symlink. --~--~-~--~~~---~--~~ 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: http links without using URLs.py
Thanks! Ana On Jan 27, 9:51 am, Adam Stein wrote: > Eggs seems to be something related to python packages, not sure exactly > what they are used for. I needed the PYTHON_EGG_CACHE because my web > server could not write to the default egg cache directory and so I had > it use a temp place. > > Perhaps somebody else can better explain eggs. > > > > On Tue, 2009-01-27 at 09:42 -0800, May wrote: > > Hello Adam, > > > Thanks! I have already set up several sections for the > > django site, so I must not have the syntax quite right for apache to > > ignore the static links. I will work on it. One last question? What > > are eggs? > > SetEnv PYTHON_EGG_CACHE /tmp/.python-eggs > > > Thanks, > > Ana > > > On Jan 27, 9:23 am, Adam Stein wrote: > > > I ONLY use it for development with the Django server. I only set up to > > > serve static pages when DEBUG = True (as they show toward the bottom of > > > the page). > > > > No need to change links on the production server (apache + mod_python) > > > because the URLs are a different location than what I have set up for > > > mod_python. > > > > You set up mod_python using if you are using > > > Apache. This tells apache that ONLY what matches the specified location > > > will use mod_python. > > > > An example: > > > > > > > SetHandler python-program > > > PythonHandler django.core.handlers.modpython > > > PythonInterpreter my_arbitrary_unique_name_here > > > PythonPath "['/my/django/code'] + sys.path" > > > SetEnv DJANGO_SETTINGS_MODULE WebSite.settings > > > SetEnv PYTHON_EGG_CACHE /tmp/.python-eggs > > > PythonDebug On > > > > > > > With this setup, only those URLs that have /my_django_site/ will go to > > > Django (via mod_python). Any other URLs will get serviced by Apache as > > > normal. > > > > It is quite discouraged to have Django serve static pages on a > > > production server since it's not meant for that, so it's slow and > > > inefficient. > > > > On Tue, 2009-01-27 at 09:06 -0800, May wrote: > > > > Hello, > > > > > The tutorial suggests not serving the static pages with this method on > > > > a permanent basis. Are you using this method for your production > > > > server? I'm using windows/apache/modpython and I've tried using the > > > > IP address and still run into django url requests. Do you know of a > > > > way to get apache to override django? > > > > > Thanks, > > > > > Ana > > > > > On Jan 27, 8:55 am, Adam Stein wrote: > > > > > Check out: > > > > > >http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs > > > > > > I have Django serve static files during development so that all my > > > > > links > > > > > that don't need to go thru Django work. > > > > > > On Tue, 2009-01-27 at 08:42 -0800, May wrote: > > > > > > Hello, > > > > > > > I'm converting PHP pages to Django. I'm using base.html for my > > > > > > formatting. I've included the left-side bar in the base.html, which > > > > > > includes links that do not require using a database, such as the > > > > > > "contact us" page. Since I'm using localhost for testing my link > > > > > > looks something like this: > > > > > > > http://127.0.0.1/contactus.html/"; >Contact Us > > > > > > > Since the left-side bar is in base.html when the link is selected > > > > > > django requires that I place the link in the URL.py and include it > > > > > > in > > > > > > View.py. I have many links like this and would prefer that the > > > > > > links > > > > > > go directly to the page ignoring the django requests. > > > > > > > Is there a simple work around for this, that will allow me to > > > > > > continue > > > > > > to use the convenience of the base.html inheritance? > > > > > > > Thanks, > > > > > > > Ana > > > > > > -- > > > > > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > > > > > Disclaimer: Any/All views expressed > > > > > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] > > > > -- > > > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > > > Disclaimer: Any/All views expressed > > > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] > > -- > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > Disclaimer: Any/All views expressed > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] --~--~-~--~~~---~--~~ 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: Unicode issue with Oracle
On Tue, Jan 27, 2009 at 12:53 PM, Karen Tracey wrote: > Don't use cx_Oracle 5.0, use a 4.X version. The docs were recently changed > to specify that, after investigation into > http://code.djangoproject.com/ticket/9935 revealed the problem is due to a > bug in cx_Oracle 5.0. > Thanks, Karen. It worked! -- João Olavo Baião de Vasconcelos Bacharel em Ciência da Computação Analista de Sistemas - Infraestrutura joaoolavo.wordpress.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 -~--~~~~--~~--~--~---
Adjusting these models for other functionality
-- MODELS -- ( Other, unimportant fields/models have been removed ) class Band(models.Model): name= models.CharField(max_length = 50, unique = True) class Venue(models.Model): name= models.CharField(max_length = 50) class Event(models.Model): name= models.CharField(max_length = 50, unique = True) info= models.TextField(max_length = 200, blank = True) date= models.DateTimeField() bands = models.ManyToManyField(Band) venue = models.ForeignKey(Venue) If an Event is part of a Tour/Festival that has multiple dates (not necessarily consecutive) I don't want to re-enter the bands and extra info for each Event - where, essentially, I'll only have a different Venue and Date assigned. Currently, the Automatic Admin gives me the ability to quickly add/ change Bands and Venues for an Event, in one place. I'd like to keep it that way if possible. I've been thinking this into the ground on the best way to abstract the Bands/Dates/Venues from the Event without causing rediculous amounts of Joins to happen just to list the Events by date, and show which Bands will be at each. Also, with Dates/Venues abstracted, it (seems like it) makes it harder to just get a list of Events by date, and use Pagination, etc. Any suggestions/ideas on how to alter the models to get a bit closer to the functionality I desire? --~--~-~--~~~---~--~~ 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 imagefield at development server
You might also check, You have DEBUG = True in settings.py And have permissions set on the photo directory And have something in urls.py file to point to the photo directory On Jan 27, 1:58 pm, Akhmat Safrudin wrote: > dear list, > i am a noob, > i just starting a project, then create app and add some models, > in the model there is an ImageField, > at the admin area i can't insert record, the browser status is "waiting for > localhost" > is django development server can upload file/image ? > i have completely read model documentation and django managing file but > didn't get it solved. > > my models and settings look like this : > > class person(models.Model): > name = models.CharField(max_length=30) > address = models.CharField(max_length=50) > photo = models.ImageField(upload_to='photo') > > settings.py : > MEDIA_ROOT = '/home/somat/project/media/' > > MEDIA_URL = '/media/' > > thank's > > somat. > > -- > Stay Hungry Stay Foolishhttp://somat.wordpress.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 -~--~~~~--~~--~--~---
Custom Template Tag - Passing variable for use in tag processing
I have duplicated as best I can the processing for handling variables in custom template tags mentioned in an earlier post but it's not working for me as I need the value of the variable before I parse it. Is there another way of making the variable available? The tag is being called from the tempalte with: {% page_links "category" %} Where category is being passed into the template from a view. (also tried "{{category}}" and {{category}} and category) I want to use the value of category to determine which list of pages to return. I KNOW THIS DOESN"T WORK: @register.tag(name="page_links") def get_page_links(parser,token): tag_name, cat = token.contents.split() return PageLink(cat[1:-1]) class PageLink(template.Node): def __init__(self, cat): cat= template.Variable(cat) print cat <- outputs category if cat=='business': pages=BusinessPage.objects.filter (is_live=True).select_related().order_by('order') elif cat=='community': pages=CommunityPage.objects.filter (is_live=True).select_related().order_by('order') elif cat=='tourism': pages=TourismPage.objects.filter (is_live=True).select_related().order_by('order') else: pages = False self.pages = pages def render(self, context): context['pages'] = self.pages return '' This code works fine as long as I call it like this: {% page_links "business" %} @register.tag(name="page_links") def get_page_links(parser,token): tag_name, cat = token.contents.split() cat = cat[1:-1] if cat=='business': pages=BusinessPage.objects.filter (is_live=True).select_related().order_by('order') elif cat=='community': pages=CommunityPage.objects.filter (is_live=True).select_related().order_by('order') elif cat=='tourism': pages=TourismPage.objects.filter (is_live=True).select_related().order_by('order') else: pages = False return PageLink(pages) class PageLink(template.Node): def __init__(self, pages): self.pages = pages def render(self, context): context['pages'] = self.pages return '' --~--~-~--~~~---~--~~ 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: http links without using URLs.py
Eggs seems to be something related to python packages, not sure exactly what they are used for. I needed the PYTHON_EGG_CACHE because my web server could not write to the default egg cache directory and so I had it use a temp place. Perhaps somebody else can better explain eggs. On Tue, 2009-01-27 at 09:42 -0800, May wrote: > Hello Adam, > > Thanks! I have already set up several sections for the > django site, so I must not have the syntax quite right for apache to > ignore the static links. I will work on it. One last question? What > are eggs? > SetEnv PYTHON_EGG_CACHE /tmp/.python-eggs > > Thanks, > Ana > > On Jan 27, 9:23 am, Adam Stein wrote: > > I ONLY use it for development with the Django server. I only set up to > > serve static pages when DEBUG = True (as they show toward the bottom of > > the page). > > > > No need to change links on the production server (apache + mod_python) > > because the URLs are a different location than what I have set up for > > mod_python. > > > > You set up mod_python using if you are using > > Apache. This tells apache that ONLY what matches the specified location > > will use mod_python. > > > > An example: > > > > > > SetHandler python-program > > PythonHandler django.core.handlers.modpython > > PythonInterpreter my_arbitrary_unique_name_here > > PythonPath "['/my/django/code'] + sys.path" > > SetEnv DJANGO_SETTINGS_MODULE WebSite.settings > > SetEnv PYTHON_EGG_CACHE /tmp/.python-eggs > > PythonDebug On > > > > > > With this setup, only those URLs that have /my_django_site/ will go to > > Django (via mod_python). Any other URLs will get serviced by Apache as > > normal. > > > > It is quite discouraged to have Django serve static pages on a > > production server since it's not meant for that, so it's slow and > > inefficient. > > > > > > > > On Tue, 2009-01-27 at 09:06 -0800, May wrote: > > > Hello, > > > > > The tutorial suggests not serving the static pages with this method on > > > a permanent basis. Are you using this method for your production > > > server? I'm using windows/apache/modpython and I've tried using the > > > IP address and still run into django url requests. Do you know of a > > > way to get apache to override django? > > > > > Thanks, > > > > > Ana > > > > > On Jan 27, 8:55 am, Adam Stein wrote: > > > > Check out: > > > > > >http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs > > > > > > I have Django serve static files during development so that all my links > > > > that don't need to go thru Django work. > > > > > > On Tue, 2009-01-27 at 08:42 -0800, May wrote: > > > > > Hello, > > > > > > > I'm converting PHP pages to Django. I'm using base.html for my > > > > > formatting. I've included the left-side bar in the base.html, which > > > > > includes links that do not require using a database, such as the > > > > > "contact us" page. Since I'm using localhost for testing my link > > > > > looks something like this: > > > > > > > http://127.0.0.1/contactus.html/"; >Contact Us > > > > > > > Since the left-side bar is in base.html when the link is selected > > > > > django requires that I place the link in the URL.py and include it in > > > > > View.py. I have many links like this and would prefer that the links > > > > > go directly to the page ignoring the django requests. > > > > > > > Is there a simple work around for this, that will allow me to continue > > > > > to use the convenience of the base.html inheritance? > > > > > > > Thanks, > > > > > > > Ana > > > > > -- > > > > > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > > > > > Disclaimer: Any/All views expressed > > > > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] > > > -- > > > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > > > Disclaimer: Any/All views expressed > > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] > -- Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com Disclaimer: Any/All views expressed here have been proven to be my own. [http://www.csh.rit.edu/~adam/] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
in what namespace do widgets reside?
Apologies for the daft question, but after 10 mins of trawling through the official docs and various random google articles, I cannot find thyis info. 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: http links without using URLs.py
Hello Adam, Thanks! I have already set up several sections for the django site, so I must not have the syntax quite right for apache to ignore the static links. I will work on it. One last question? What are eggs? SetEnv PYTHON_EGG_CACHE /tmp/.python-eggs Thanks, Ana On Jan 27, 9:23 am, Adam Stein wrote: > I ONLY use it for development with the Django server. I only set up to > serve static pages when DEBUG = True (as they show toward the bottom of > the page). > > No need to change links on the production server (apache + mod_python) > because the URLs are a different location than what I have set up for > mod_python. > > You set up mod_python using if you are using > Apache. This tells apache that ONLY what matches the specified location > will use mod_python. > > An example: > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > PythonInterpreter my_arbitrary_unique_name_here > PythonPath "['/my/django/code'] + sys.path" > SetEnv DJANGO_SETTINGS_MODULE WebSite.settings > SetEnv PYTHON_EGG_CACHE /tmp/.python-eggs > PythonDebug On > > > With this setup, only those URLs that have /my_django_site/ will go to > Django (via mod_python). Any other URLs will get serviced by Apache as > normal. > > It is quite discouraged to have Django serve static pages on a > production server since it's not meant for that, so it's slow and > inefficient. > > > > On Tue, 2009-01-27 at 09:06 -0800, May wrote: > > Hello, > > > The tutorial suggests not serving the static pages with this method on > > a permanent basis. Are you using this method for your production > > server? I'm using windows/apache/modpython and I've tried using the > > IP address and still run into django url requests. Do you know of a > > way to get apache to override django? > > > Thanks, > > > Ana > > > On Jan 27, 8:55 am, Adam Stein wrote: > > > Check out: > > > >http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs > > > > I have Django serve static files during development so that all my links > > > that don't need to go thru Django work. > > > > On Tue, 2009-01-27 at 08:42 -0800, May wrote: > > > > Hello, > > > > > I'm converting PHP pages to Django. I'm using base.html for my > > > > formatting. I've included the left-side bar in the base.html, which > > > > includes links that do not require using a database, such as the > > > > "contact us" page. Since I'm using localhost for testing my link > > > > looks something like this: > > > > > http://127.0.0.1/contactus.html/"; >Contact Us > > > > > Since the left-side bar is in base.html when the link is selected > > > > django requires that I place the link in the URL.py and include it in > > > > View.py. I have many links like this and would prefer that the links > > > > go directly to the page ignoring the django requests. > > > > > Is there a simple work around for this, that will allow me to continue > > > > to use the convenience of the base.html inheritance? > > > > > Thanks, > > > > > Ana > > > > -- > > > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > > > Disclaimer: Any/All views expressed > > > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] > > -- > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > Disclaimer: Any/All views expressed > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] --~--~-~--~~~---~--~~ 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: http links without using URLs.py
On Jan 27, 11:06 am, May wrote: > Hello, > > The tutorial suggests not serving the static pages with this method on > a permanent basis. Are you using this method for your production > server? I'm using windows/apache/modpython and I've tried using the > IP address and still run into django url requests. Do you know of a > way to get apache to override django? > > Thanks, > > Ana You might want to look into using the contributed app Flatpages for these static pages. http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/ Alternatively, in an Apache environment, you could use the location directive to tell Apache not to send requests for certain files in a certain directory through mod_python. This would be similar to telling Apache not to send media files through mod_python, as discussed here: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1 Maybe something like: SetHandler None Then put all your static html files in that directory. BN --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Comma as a decimal separator
Hi everybody there! :-) I have a decimal field and I wish I could use a comma as a separator between the integer and the decimal part (according to my country habit). How do you think I can manage that? I found this snippet [0], which seems promising. The thing is, I need to use that field in my admin backend and I don't know how to integrate that snippet in my admin. Here comes a stripped-down version of my models.py: ### class Product(models.Model): name = models.CharField(max_length=30) value = models.DecimalField(max_digits=10, decimal_places=2, default="0.00") class ProductAdmin(admin.ModelAdmin): list_display = ('name','value') admin.site.register(Product, ProductAdmin) ### Thanks for your help, cheers, Fabio. [0] http://www.djangosnippets.org/snippets/643/ -- Fabio Natali --~--~-~--~~~---~--~~ 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 with encoding and using ifequal in Django templates
Sometimes there's nothing like describing a problem to someone else to help you solve it. :) I should have marked the Python strings as Unicode like this and everything works now: def test(request): return render_to_response("test.html", { "s1": u"dados", "s2": u"aprovação", } ) --~--~-~--~~~---~--~~ 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: http links without using URLs.py
On Tue, 2009-01-27 at 08:42 -0800, May wrote: > I'm converting PHP pages to Django. I'm using base.html for my > formatting. I've included the left-side bar in the base.html, which > includes links that do not require using a database, such as the > "contact us" page. Since I'm using localhost for testing my link > looks something like this: > > http://127.0.0.1/contactus.html/"; >Contact Us > > Since the left-side bar is in base.html when the link is selected > django requires that I place the link in the URL.py and include it in > View.py. I have many links like this and would prefer that the links > go directly to the page ignoring the django requests. If you want to bypass the view you can try direct_to_template: http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-simple-direct-to-template -- Marco Buttu --~--~-~--~~~---~--~~ 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 with encoding and using ifequal in Django templates
Hello, I'm having problems using {% ifequal s1 "some text" %} to compare strings with extended characters in Django templates. When string s1 contains ascii characters >127, I get exceptions in the template rendering. What am I doing wrong? I'm using UTF-8 coding throughout the rest of application in both the data, templates and Python code without any problems. Any ideas? Cheers, Ben views.py def test(request): return render_to_response("test.html", { "s1": "dados", "s2": "aprovação", } ) test.html s1={{s1}} s2={{s2}} {% ifequal s1 "dados" %} s1="dados" is true {% endifequal %} {% ifequal s1 "aprovação" %} s1="aprovação" is true {% endifequal %} {% comment %} The following two comparions cause the following exception: Caught an exception while rendering: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128) {% ifequal s2 "dados" %} s2="dados" is true {% endifequal %} {% ifequal s2 "aprovação" %} s2="aprovação" is true {% endifequal %} {% endcomment %} {% ifequal s2 u"dados" %} s2="dados" is true {% endifequal %} {% comment %} The following comparison causes the following exception: Caught an exception while rendering: 'ascii' codec can't encode characters in position 8-9: ordinal not in range(128) {% ifequal s2 u"aprovação" %} s2="aprovação" is true {% endifequal %} {% endcomment %} Output s1=dados s2=aprovação s1="dados" is true --~--~-~--~~~---~--~~ 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: http links without using URLs.py
I ONLY use it for development with the Django server. I only set up to serve static pages when DEBUG = True (as they show toward the bottom of the page). No need to change links on the production server (apache + mod_python) because the URLs are a different location than what I have set up for mod_python. You set up mod_python using if you are using Apache. This tells apache that ONLY what matches the specified location will use mod_python. An example: SetHandler python-program PythonHandler django.core.handlers.modpython PythonInterpreter my_arbitrary_unique_name_here PythonPath "['/my/django/code'] + sys.path" SetEnv DJANGO_SETTINGS_MODULE WebSite.settings SetEnv PYTHON_EGG_CACHE /tmp/.python-eggs PythonDebug On With this setup, only those URLs that have /my_django_site/ will go to Django (via mod_python). Any other URLs will get serviced by Apache as normal. It is quite discouraged to have Django serve static pages on a production server since it's not meant for that, so it's slow and inefficient. On Tue, 2009-01-27 at 09:06 -0800, May wrote: > Hello, > > The tutorial suggests not serving the static pages with this method on > a permanent basis. Are you using this method for your production > server? I'm using windows/apache/modpython and I've tried using the > IP address and still run into django url requests. Do you know of a > way to get apache to override django? > > Thanks, > > Ana > > On Jan 27, 8:55 am, Adam Stein wrote: > > Check out: > > > > http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs > > > > I have Django serve static files during development so that all my links > > that don't need to go thru Django work. > > > > > > > > On Tue, 2009-01-27 at 08:42 -0800, May wrote: > > > Hello, > > > > > I'm converting PHP pages to Django. I'm using base.html for my > > > formatting. I've included the left-side bar in the base.html, which > > > includes links that do not require using a database, such as the > > > "contact us" page. Since I'm using localhost for testing my link > > > looks something like this: > > > > > http://127.0.0.1/contactus.html/"; >Contact Us > > > > > Since the left-side bar is in base.html when the link is selected > > > django requires that I place the link in the URL.py and include it in > > > View.py. I have many links like this and would prefer that the links > > > go directly to the page ignoring the django requests. > > > > > Is there a simple work around for this, that will allow me to continue > > > to use the convenience of the base.html inheritance? > > > > > Thanks, > > > > > Ana > > > -- > > > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > > > Disclaimer: Any/All views expressed > > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] > -- Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com Disclaimer: Any/All views expressed here have been proven to be my own. [http://www.csh.rit.edu/~adam/] --~--~-~--~~~---~--~~ 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: http links without using URLs.py
Hello, The tutorial suggests not serving the static pages with this method on a permanent basis. Are you using this method for your production server? I'm using windows/apache/modpython and I've tried using the IP address and still run into django url requests. Do you know of a way to get apache to override django? Thanks, Ana On Jan 27, 8:55 am, Adam Stein wrote: > Check out: > > http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs > > I have Django serve static files during development so that all my links > that don't need to go thru Django work. > > > > On Tue, 2009-01-27 at 08:42 -0800, May wrote: > > Hello, > > > I'm converting PHP pages to Django. I'm using base.html for my > > formatting. I've included the left-side bar in the base.html, which > > includes links that do not require using a database, such as the > > "contact us" page. Since I'm using localhost for testing my link > > looks something like this: > > > http://127.0.0.1/contactus.html/"; >Contact Us > > > Since the left-side bar is in base.html when the link is selected > > django requires that I place the link in the URL.py and include it in > > View.py. I have many links like this and would prefer that the links > > go directly to the page ignoring the django requests. > > > Is there a simple work around for this, that will allow me to continue > > to use the convenience of the base.html inheritance? > > > Thanks, > > > Ana > > -- > > Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com > > Disclaimer: Any/All views expressed > here have been proven to be my own. [http://www.csh.rit.edu/~adam/] --~--~-~--~~~---~--~~ 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: http links without using URLs.py
Check out: http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs I have Django serve static files during development so that all my links that don't need to go thru Django work. On Tue, 2009-01-27 at 08:42 -0800, May wrote: > Hello, > > I'm converting PHP pages to Django. I'm using base.html for my > formatting. I've included the left-side bar in the base.html, which > includes links that do not require using a database, such as the > "contact us" page. Since I'm using localhost for testing my link > looks something like this: > > http://127.0.0.1/contactus.html/"; >Contact Us > > Since the left-side bar is in base.html when the link is selected > django requires that I place the link in the URL.py and include it in > View.py. I have many links like this and would prefer that the links > go directly to the page ignoring the django requests. > > Is there a simple work around for this, that will allow me to continue > to use the convenience of the base.html inheritance? > > Thanks, > > Ana > -- Adam Stein @ Xerox Corporation Email: a...@eng.mc.xerox.com Disclaimer: Any/All views expressed here have been proven to be my own. [http://www.csh.rit.edu/~adam/] --~--~-~--~~~---~--~~ 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: munge words and numbers into a URL, then reverse it ?
I am assuming that you already have an idea of how your datastring will look like, and what data it is containing... I am considering *"music artist 32L 2L 100 100"* as input data so here is a example... L1 = "music artist 32L 2L 100 100".encode("hex") > L2 = zlib.compress(L1) > L3 = L2.encode("hex") > print L3 > L3 can now be taken as URI referencing string.. which in this special case is '789c35c5c10d00200c02c095102aa4f3e8fe336862fcdc7967466e8bf00853ee28454862adfb7308c2ff00401d0b64' and reverse algo for this is also as easy D1=789c35c5c10d00200c02c095102aa4f3e8fe336862fcdc7967466e8bf00853ee28454862adfb7308c2ff00401d0b64'.decode("hex") > D2 = zlib.decompress(D1) > D3 = D2.decode("hex") > you will get your "music artist 32L 2L 100 100" back And your URL will not send further a psuedo encoded number which is ugly enough for non-developers :D you are free to choose encoding, and can nest them in multiple algos to make the thing more complex greetings, Puneet On Tue, Jan 27, 2009 at 4:48 PM, felix wrote: > > there is some hashing function or combination of URL encoding that can do > this : > > > given some parameters : > > 'music' 'artist' 32L 2L 100 100 > ( artist id 32, 2nd picture, dimensions 100 x 100 ) > > I wish to generate a fake filename eg: > > tartan_ba6e5e06e794f1368ed3ec20b4594eec.png > > and then be able to reverse that filename back into the original parameters > when needed. > > so its either hashing, or compressing the string (to use the most of the > allowable chars a-zA-Z0-9_ ) or something > > hints or pointers anyone ? > thanks > > > > http://crucial-systems.com > > > > > -- If you spin an oriental man, does he become disoriented? (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu is der net süß » ε(●̮̮̃•̃)з -PM --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
http links without using URLs.py
Hello, I'm converting PHP pages to Django. I'm using base.html for my formatting. I've included the left-side bar in the base.html, which includes links that do not require using a database, such as the "contact us" page. Since I'm using localhost for testing my link looks something like this: http://127.0.0.1/contactus.html/"; >Contact Us Since the left-side bar is in base.html when the link is selected django requires that I place the link in the URL.py and include it in View.py. I have many links like this and would prefer that the links go directly to the page ignoring the django requests. Is there a simple work around for this, that will allow me to continue to use the convenience of the base.html inheritance? Thanks, Ana --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---