Re: Is ODBC supported so to use DB's like Access, Teradata?
KG wrote: > What needs to be done to make use of any other DB engine thru ODBC? > An ODBC database backend would need to be written for the Django ORM. signature.asc Description: OpenPGP digital signature
Re: Login to another system with django
ganno wrote: > Hi all, > > I am new to django.And i need to develope a login system which > manage my session on another php site.Main login is from django site > but when i redirects my page then my session is not maintained and and > i will be redirected as anonymous user not as current user.I want to > make that centralized and want to login as same use so end user will > be not able to identify that application has changed.I am maintaining > my session through database.so please suggest me way or wrapper or > module which handels this. > What you have described calls for an SSO module. Basically you modify Django and/or the other web app to use the same database table for sessions Django makes this fairly easy, and many PHP applications don't. There is probably a lot of resources "out there" by googling "Django SSO" Take care! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: seg fault with LDAP authentication
molhacker wrote: I've been running into a very frustrating situation with a seg fault in Apache when authenticating Django using LDAP. The problem is intermittent, probably one out of every 5 logins causes the seg fault. The code I'm using for LDAP (borrowed from the web, thanks Mick) Have you tried the ldap backend contained in Ticket #2507? We've used this in production as long as the code has been around (the original author was my co-worker) We've had very few problems with it. http://code.djangoproject.com/ticket/2507 Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: version control convention?
Serdar T. wrote: > Is it better to create repositories at a site-, project- or app-level? > Technically, you can do all three. Definitely put all of your re-usable apps into their own repository. I always put my projects into their own repository, but I don't necessarily include apps that I'm using in them that come from somewhere else. I do have a couple of repos that are just projects and have no apps in them. The apps are expected to be on the python path at runtime. There are a couple of times when you really don't need your app to be re-usable. It's fine to create a project and an app that will always and forever live in the same version controlled repo. Another common practice is to take advantage of version control systems features of being able to reference external repositories. svn has an "external" option, and git has something called submodules. I'm not super familiar with other version control systems, but I'm sure there are equivalents in most popular ones. Generally speaking, when you are writing an app, the repo should have a layout that looks something like this: /docs/ /appname/ /readme.txt /authors.txt /setup.py ...etc... This is a fairly common in practice. The idea is that a lot of those things don't belong in with your python code, so they live one level up. Django itself follows this convention, as do most python projects. When you want to track a whole site, you can add projects and/or apps as submodules/externals. Generally speaking, a single site could/should be a single Django project, and making this distinction doesn't come up terribly often in the configurations I've seen. Hopefully this was helpful and happy coding! Jeff Anderson signature.asc Description: OpenPGP digital signature
Django-gitosis
Hello fellow Django users! I've been wanting to set up gitosis on a server for a while now. I think a new Django app might make this easier for the end users. The people that'd access the git repos I want to host could simply put their public SSH key in their Django-powered user profile, the new app lets gitosis know, and away they go. The only issue is that gitosis expects me to build configuration files manually, adding users by hand. It'd be fairly straightforward to get a django-gitosis app to streamline this for me. I'm mostly interested in getting feedback for my ideas. If someone is interested, and would like to contribute to my little app, that'd be great too. I haven't dove into the gitosis code much, but it is written in Python. At some point gitosis parses the config options and makes them available via a Python interface. The first way to get a django-gitosis to handle the configuration on the fly would be to replace the code that parses the text file, and make it code that parses a Django model, but returns the same type of information to the file. I bet this method is more trouble than it's worth. The next method is to modify the config files directly. I like this solution better because it's the simplest one. Simple usually means "less likely to break in the future", which is good. I do believe that gitosis uses a Python module to read from and write to its config files, and I can use the same thing. What method would you use, and why? Thanks for the input! Jeff Anderson gitosis: |git://eagain.net/gitosis.git| --~--~-~--~~~---~--~~ 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: free django hosting
Hernan Olivera wrote: details in http://www.alwaysdata.com/offers/shared/ Very cool! I don't speak French, but I know enough about words to get the idea. signature.asc Description: OpenPGP digital signature
Re: free django hosting
xankya wrote: hi, anybody know free django hosting ? I highly doubt that there would be free persistent process hosting out there. You might be able to use parts of Django in regular CGI scripts at a free host. Beyond that, you might look into getting a free dynamic dns account and using your home machine. If you find otherwise, I'd be interested to know. Thanks! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Cron Job Question
Chris wrote: > I have a python / django script that I have written which will be > used as a cron. Basically this script goes out to my database and gets > rows from a given table and performs a specific task then deletes the > row once finished. What I would like to do is have multiple instances > of this script running to check for new additions to this table every > 15 minutes or so. I am not sure how I can divide up the work to be > processed among all running scripts with out having issues. > I'm curious: why do you need multiple instances? The only reason I can think of is that you need multiple machines to get the tasks done in a timely manner. Is this the case? The model that we use for a similar setup is the script will check the database, process ALL unprocessed rows (no wait in between jobs), and then when it's done, it waits a few seconds and checks again. This works very well in production. Most of the time only one or two jobs will be inserted at a time, but occasionally several hundreds or thousands of jobs will be inserted. One instance of the worker script handles this very well. We moved away from the cron job, and implemented a simple daemon process. If you really really really need the multiple instances, you could have a worker script that launches the jobs one at a time, and will only spawn as many as you need at once. I'd also suggest looking into database locking or transactions if you want to have multiple scripts with their fingers in the same table. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Any libraries to create an online help system in Django or Python?
alibongo wrote: > I admit I know little to nothing about Django and Python, but I've > been charged with creating an online help system to an application > we're writing in Django. I need to have online help features like > Search, Index, Next|Previous page, etc. So something that is displayed > in a new window, and displays context-sensitive help. Rather than > write this in-house, I was wondering if anyone knew of a Python or > Django library that already delivers this type of functionality? I'd suggest using sphinx. It's designed for documenting Python projects, and it's the documentation build system that Python and Django both use. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: How to receive Emails in my django app
zweb wrote: > i can send emails easily using django. > > I want to set up an email address, where users can send email to the > app (designated email address) and my django application receives it, > parses it and stores it in database. > > What would be the easiest way to do it. ie " To receive email from > users in Django application" There was a thread about this a few months ago. Here are some options you have: On your mailserver, if you run your own, you can set up an alias that will actually send the messages to a command via a pipe. superwebapp: "|/path/to/my/pythonscript.py" The script will receive the message verbatim. You can use Python's 'email' module to parse out the sender, body, attachments, etc. This is the solution that I've worked with, and it works well if you run your own postfix server. This type of script will likely be useful if you use the postfix pipe method or one of the other two methods. The code will be the same once passed into a Python string. Another option is to run a python daemon using the 'smtpd' module. It essentially is its own mailserver, and can process incoming mail in native Python. I've never used it, but it seems like a good option for some setups. You just need to set it up so that mail at that address will get to that server. I haven't set this up, but I'd be willing to bet that this is easiest if you have a dedicated webserver that hosts your app that is separate from your domain's mailserver. The third option is to use an imap or pop library and download the messages that way. Python has the 'imaplib' module for imap, and 'poplib' for pop3. I haven't implemented this either. I'd be willing to guess that this is easiest if you have a shared host, or don't run your own mailserver. Take Care! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: can Django's views call on several programs to run at the same time?
Victor wrote: > Hi, > > I was planning to use Django to create a webapp that runs several > Python applications in parallel with user input data. The applications > take a while to run (>2 minutes) when they work in parallel, so I want > to make a page that says "Processing..." and show the output of each > of the applications as they finish. Is there a way to do this without > using threading? Does Django even support this functionality? > There are a few ways to implement this. After working in an environment with similar requirements and restrictions, this is how I would do it: Your site will accept jobs via the web interface. It only stores the *request* for whatever is needed in a database. It won't try to execute the request on its own, or in a thread. An external script periodically checks the database for jobs. If it sees a new job, it sets the status, and begins processing. If your worker script is smart enough, it could even update the percentage complete, or store what is being done specifically in the database. I've always thought that threading could be a viable way to do this type of task, but the more I've read about it, and the more I've seen its pitfalls I've decided that it's evil. If the webserver crashes, it's more difficult to resume the task. The external script doesn't care if the webserver is even running, and having the jobs in a database is a built-in error recovery mechanism. I've even added jobs to the queue manually at times. The user's "processing" page should likely be ajax-driven. It'd poll the site for the status every few seconds until the job is done, or there is an error. The external script will either need to be a daemon or a cronjob that is periodically run. I prefer making the external script its own daemon. We have a system that usually only gets one job every few minutes, and the job won't take more than a minute to complete. Most jobs will take less than a second to complete. Occasionally, we need to run hundreds of jobs all at once. Since it uses a "polling" model, a delay between checking the database is usually a good idea, but even a two second delay between each job of 500 will put a huge performance hit for when we need the large jobs. The solution is to check the database for new jobs, and then run *all* new jobs that are currently in the database. After processing all jobs, it waits two seconds and polls again. The 500 jobs (most of which take a fraction of a second) get done very quickly, and the database won't get over-hammered by our polling. If daemonizing your own script isn't an option, a similar objective can be achieved with a cron job. I'd suggest using a lock file to prevent the system(s) from being bogged down with too many requests. The external script can still use your models and the Django ORM, even though it isn't a web application. I'm working on a set of examples of things I've implemented using Django, but I haven't gotten my example for this one running quite yet. Hopefully this is enough to give you an idea as to how to design things. I don't really have any code that is sharable, but the concept is fairly straightforward (I hope.) I'm happy to clarify anything if needed. Happy Coding! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Shouldn't blank=True imply null=True?
tofer...@gmail.com wrote: > On 07.01-08:51, Jeff Anderson wrote: > >>> I agree with this. I use null=False, blank=True for some ImageFields >>> and integers. >>> >> I'm interested in how a blank integer looks in a MySQL database. Can you >> provide an example? >> > > please troll somewhere else. > I wasn't trolling, thank you. I was genuinely interested in how this would look. signature.asc Description: OpenPGP digital signature
Re: Shouldn't blank=True imply null=True?
Karen Tracey wrote: > On Wed, Jan 7, 2009 at 10:51 AM, Jeff Anderson > <jeffe...@programmerq.net>wrote: > > >> varikin wrote: >> >>> I agree with this. I use null=False, blank=True for some ImageFields >>> and integers. >>> >> I'm interested in how a blank integer looks in a MySQL database. Can you >> provide an example > I believe the further description a bit later in the email covered this: > > In the case of an integer, I use it for order of the images. So if a number > >> is given for an image, it is used, otherwise auto assign the order number. >> > > > That is, blank is not actually stored in the DB but rather the lack of a > user-provided value triggers creation of an auto-assigned value. > But that is code that could/should belong in the form/validation code. The models define how things are to be setup and stored in the database backend. A blank value in a webpage does not translate to a blank value in the database, so blank=True is incorrect in this case, as an auto-assigned value isn't actually blank, because a non-blank value will be stored in the database. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: lighttpd + django on windows
Eric Simorre wrote: > it does not work , and I don't find what to do > Well, there's your problem. You should just make it work. :) signature.asc Description: OpenPGP digital signature
Re: Shouldn't blank=True imply null=True?
varikin wrote: > I agree with this. I use null=False, blank=True for some ImageFields > and integers. I'm interested in how a blank integer looks in a MySQL database. Can you provide an example? signature.asc Description: OpenPGP digital signature
Re: Newbie: Help to understand string handling
phoebebright wrote: > Thanks for your response. Do you think a working knowledge of python > is essential for django then? And do I import modules the same in > django and python? Are there any python things you can't do in > django? > Django *is* Python. In fact, Django is only a Python library. It is not its own language. signature.asc Description: OpenPGP digital signature
Re: Shouldn't blank=True imply null=True?
Malcolm Tredinnick wrote: > On Mon, 2009-01-05 at 23:39 -0700, Jeff Anderson wrote: > >> Malcolm Tredinnick wrote: >> >>> The way to think about this problem is whether there's a situation where >>> blank=True, null=False makes sense or is even possible for non-text >>> fields and Mike quite possibly has a valid point there: you cannot store >>> a blank value in a non-NULL integer field, for example. >>> >>> >> I was trying to think of a way that a non-NULL "blank" integer would be >> useful. I can't even think of how it would exist– it just doesn't make >> sense. This thread may do well on the dev list. I believe that there is >> a valid point here, and that at least Integer fields (and quite possibly >> other non-text fields) should behave the way that Mike is describing. >> > > I don't think we'd want to get too subtle here. Either it makes sense > for all non-text fields, or it doesn't. Agreed– I simply haven't spent any time thinking about this particular problem in respect to any field other than an IntegerField. I can't think of any non-text field that it may not make sense with. I have a hunch that a DateField could cause some confusion. Say I'm going to write a model, and I put in a date field. Is it a number? Is it a string? If it's a string, I have to explicitly include null=True. The way that one thinks of a datefield may vary from person to person, depending on their database experience and expectations. Without consulting any documentation, I'd be willing to bet that dates are more like numbers in this respect. I just set blank=True and hope that the null=True is set. What is a blank date anyway? "-00-00" might count as a 'blank date', as the month and day are invalid. To be sure, I'd have to look it up in a table in the documentation. I probably don't write models often enough to learn this answer and store it in my long-term memory. I might end up putting both blank=True and null=True just to be safe, and I've just defeated the purpose of the magic that we're proposing to put in anyway. What happens/should happen if I set blank=True and null=False? The "right answer" will probably vary based on who you ask, and it's one of those things that you just have to make room for on the Django cheat sheet and pencil in. Subtle magic is bad. A counter-argument against changing this behavior is "why are you setting blank=True on a field that simply can't be blank in the first place?" On an IntegerField (and friends) it just doesn't make sense, so it's likely that what I really mean is null=True, so that's what I should put in. Setting blank=True on an IntegerField doesn't cause any problems as far as I can tell, so the current behavior isn't at all destructive. The option is basically ignored. Django generally tries to stay away from "magic" as a rule of thumb, so leaving the behavior alone makes sense, and keeps things sweet and simple. It does catch a couple people off guard occasionally, which prompted this thread. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Shouldn't blank=True imply null=True?
Malcolm Tredinnick wrote: > The way to think about this problem is whether there's a situation where > blank=True, null=False makes sense or is even possible for non-text > fields and Mike quite possibly has a valid point there: you cannot store > a blank value in a non-NULL integer field, for example. > I was trying to think of a way that a non-NULL "blank" integer would be useful. I can't even think of how it would exist– it just doesn't make sense. This thread may do well on the dev list. I believe that there is a valid point here, and that at least Integer fields (and quite possibly other non-text fields) should behave the way that Mike is describing. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Permissions: is something wrong with them?
Artem Skvira wrote: > Is it worth asking this question is dev group? > No. Your usage question does not belong on the dev group. It belongs here, on the user group. signature.asc Description: OpenPGP digital signature
Re: Slow application performance...
vernon wrote: > Hi everyone, > > When I was first experimenting with Django on my local machine with > the bundled webserver, one of the things I was really impressed by was > the speed — everything was instantaneous. Listing things in the DB, > modifying and saving changes etc... > > I finally decided to deploy the beginnings on my app on my remote > server using the Apache/mod_python setup described in the docs. > The mod_python setup is a memory hog. It loads a copy of your code into memory for each persistent apache process. I'm guessing you are using all your available memory on your slice, and swapping. I had this same problem. I posted about it to this group a couple weeks ago. Basically, switch to mod_wsgi in daemon mode. It'll reduce your memory usage, and increase the speed of the site. Search the archive for more details. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: caching...mechanism
Vignesh.isquare wrote: > I find that caching the pages records lesser number of page views than > what actually happensthis causes fall in the revenue for the site. > > What caching mechanism should be followed so that the no page view is > lost from the analytics perspective... > I'd follow the model that Google uses. As far as I can tell, there is a javascript that is run in each page that sends information back to google. You can write a similar javascript that sends a small request back to your own webserver. You can force Django to never cache the views that the Javascript points to. That's what I'd do. I'm not sure how many visitors you get that don't have Javascript, but almost all traffic that you get will be Javascript enabled user-agents. It also depends on your target market. Most grandmas won't be running noscript, but people going to a programming blog might be more inclined to disable javascript. As a fallback, you could simply use an iframe to point to your analytic view. That'll probably cover most everything. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Variables in templates
Vicky wrote: > Is there any way to create a variable within the templates...? > You'll need to be more specific. What exactly are you trying to do? You can define anything you need in your view, and then pass it to the template. Logic belongs in the view. Templates are only there to put that data into the final file format for the end user (html in most cases). Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: django static-generator and fastcgi
CreativeConvergence wrote: > Hello, > > I'm using nginx and I'd like to use the static-generator middleware > but the example is for a proxy to apache and I'm using nginx with > fastcgi. > > Do you have an example setup of static-generator & nginx/fastcgi ? > I've never used this middleware, but its homepage seems to have an nginx example: http://superjared.com/projects/static-generator/#sample_nginx_configuration I don't think that using fastcgi should affect anything if you're using nginx. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Serializing QuerySets and Python objects best practices
vernon wrote: > Hi, > > I'm trying to do something fairly simple (and doable), but I was > wondering if there was a "best practices" approach. I'm developing a > client-heavy app, and I'd like to return something like this to my > JavaScript: > > {"posts": Post.objects.all(), "comments": Comment.objects.all()} > > Right now, I'm just running serializer.serialize on each of the query > sets and constructing the JSON string myself, but I have more > complicated use case where that becomes messy. > I believe there is a python json module. I know that Django makes use of it for importing/exporting database fixtures. It is bundled with django at: django.utils.simplejson. I'd start there, and poke around in the Django code for more examples. I'm no expert here, this is just where I'd start looking. Happy coding! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: "Building you first Django app, Part 1" example not working
Chris wrote: > it says it can't find django-admin.py I didn't see that for my most recent reply. Your problem is that django-admin.py isn't on your PATH. Either put it in your PATH or run it with a full path: /path/to/django-admin.py If you're unfamiliar with this terminology, you need to read up on some unix basics. There are many tutorials about the unix shell out there. I can't recommend one because I would just google for an introduction to the unix/linux/macos terminal. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: "Building you first Django app, Part 1" example not working
Chris wrote: > No directory created in my cd, but I see you're working remotely, no? > I'm trying to get it running on my Mac first before running it on a > server or remote machine. Am I wrong? What I'd really appreciate is > someone telling me EXACTLY what I need to do – every single aspect of > installation, explained in dummy terms, if possible. I know I'm > overlooking something stupid – it says it can't find django- > admin.py... so I'm lost – thanks for the reply, though! > No, that was locally on my mac. That's exactly what you need to do. The django-admin.py script exits on success with no output. That's what it's supposed to do. Does the mysite directory not exist after you run that command? Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: "Building you first Django app, Part 1" example not working
Chris wrote: > When I'm in the command line, and run the command django-admin.py > startproject mysite, I don't get an error, but nothing happens... as > far as I can tell! Did you check to see if the 'mysite' directory was created? Here's what it looks like on my osx terminal: jeffe...@pax:~$ django-admin.py startproject mysite jeffe...@pax:~$ cd mysite/ jeffe...@pax:~/mysite$ Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Admin formatting
MS wrote: > I am learning Django under Windows Vista. > > I am using Python 2.5 and Wamp5. The document root for Apache is set > to c:/wamp/www/ > > I have a project under c:/wamp/www/DjangoProjects/mysite > Don't do that. You don't need your python code in the document root, and it's a bad idea to make it available to the world. > If I run it using the Django built-in server it works fine. If I run > it using Apache and wsgi-python the application works fine but the > admin does not look the same, I suspect it does not make use of the > admin css files. Correct. You have to tell apache that the location of the admin media should be handled with the default handler, and then make an alias for that location to point to the correct location on disk. This is in the docs: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1 Cheers, and happy coding! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: FTP'ing without locking
Russell Keith-Magee wrote: > On Thu, Dec 18, 2008 at 6:15 AM, Greg Taylor <squishywaf...@gmail.com> wrote: > >> This is somewhat of a core Python question with a Django twist. I'm >> running mod_wsgi and am trying to figure out how to FTP a file from my >> Django app to a remote host without locking the thread up. I've tried >> something like: >> >> from subprocess import Popen >> print Popen(["python", command_str, "53363", "1"]).pid >> >> I'm sure there's a much better way to do what I'm trying to. I thought >> about threading it off, but wouldn't the wsgi process have to stick >> around for the thread to return? >> > > You can't really do any long lived processing in a view. Threading > won't really solve the problem, for the exact reason you have > identified. > > The solution here is to use a separate worker process. I was playing around with doing something similar, but instead of an independent worker process, I did use the python thread library. I just spouted off a thread to do its thing from the view, and then returned the httpresponse object. I never put this into production, and I was mostly just playing around with it. I only tested it in the django development server. It worked quite well. I had a separate view that answered ajax requests about the status of the process. Since the django dev server didn't hang, I don't imaging having a persistant python thread hanging around processing for a minute or two would make the webserver hang in a mod_python or mod_wsgi environment, but I didn't try it. Why would this be the case? From the "I've done it without a hitch" department, Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: generating an image?
garagefan wrote: > Is it possible to generate an image, to save it on my server, of a web > page by passing through the url only? > > say perhaps I want to link to a few sites from mine, and i'd like to > include a thumbnail of the site... and instead of taking a screen > capture, and uploading it, i pass through the url of the page, and the > image of the homepage is generated from that. > I found a few utilities by googling for: web screenshot automated The first result talks about a couple utilities that'll do what you want. http://iecapt.sourceforge.net/ - Windows only, uses IE for rendering http://cutycapt.sourceforge.net/ - cross platform, uses the same rendering engine as konquerer/google chrome/safari. Jeff Anderson signature.asc Description: OpenPGP digital signature
Memory Footprint
Hello, First, I'm gonna say that I have DEBUG turned off, and it's not Django's fault. My Django sites seem to eat lots of memory. This is fine, and it isn't a huge deal except that I am using all of my VPS's memory plus swap. The real solution is to upgrade memory on the VPS, but I'm a poor college student so I want to reduce the memory footprint any way I can. I'm using mod_python and apache. I've seen discussion about mod_python specifically where it was suggested to set large variables to None when you're done with them. Django does most of the grunt work, and my views don't seem to load any very large variables. It seems like any variables instantiated by my views would go out of scope after the view function has returned, and the Python garbage collection will show up. I'm curious to know if anyone has ever tried to optimize their code to reduce the overall memory footprint. I haven't found any blog posts about it yet. I'm willing to resort to making my Django code as non-persistent as possible. My sites are all low traffic, so non-persistent processes plus memcached shouldn't be too terrible, even if I get slashdotted. I just need to squeeze out as much as I can out of the ram I have. Swapping makes the Django requests painfully slow. I am running memcached, which does seem to help my sites go faster, but it isn't helping the memory footprint go down (obviously.) I'm also considering switching to lighttpd. I've read it has a smaller footprint than apache. I've also read that mod_wsgi performs better than mod_python. Please let me know if you have any other ideas! I'm also curious to know if anyone thinks that one of the things I mention trying would help or hurt. Thanks! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Please help me with static files serving
Oleg Oltar wrote: > Hi! > > I am trying to setup django to use static files for development purposes. > I used http://docs.djangoproject.com/en/dev/howto/static-files/ > > But actually failed to serve anything :( > > My urls.py > > urlpatterns = patterns('django.views.generic.simple', > > (r'','direct_to_template',{'template':'index.html'}), >) > if settings.DEBUG: > urlpatterns += patterns('', > (r'^media/(?P.*)$','django.views.static.serve', {'\ > document_root': '/Users/oleg/media/spilka/'}), > ) > > But needed media is not loaded, e.g. > > `-- spilka > |-- css > | `-- styles.css > > And http://127.0.0.1:8000/media/css/styles.css > gives Page not found: > /usr/local/lib/python2.5/site-packages/django/contrib/admin/media/css/styles.css You've run into a "gotcha" with your MEDIA_URL and ADMIN_MEDIA_PREFIX. Basically the development server will add the static file view automatically based on the ADMIN_MEDIA_PREFIX url. This is set to '/media' so your own media URL is passed, and it is trying to serve the files from the admin media. One way to fix this is to change your url from /media to something else, and leave all the admin media at /media. Usually what I do is change the ADMIN_MEDIA to something else. '/admin/media' makes sense to me, so that's usually what I set it to. Some people set their MEDIA_URL url to something like '/static'. Another logical way to set the URLs is to have MEDIA_URL be '/media' and ADMIN_MEDIA_PREFIX set to '/media/admin' Hopefully this is helpful and makes sense! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Can javascript call a python script?
Eric wrote: > Hello, this might be a silly question, but I'm wondering if javascript > can call a python script, and if so, how? > I believe Javascript can execute external commands, but I'm sure that it'd be turned off entirely for security reasons. I wouldn't trust client side code to modify my database any day. It sounds like you're asking if Javascript can run a python script on the server. Technically, any time a request is made to a webserver code (including python scripts) can be run on the server, and Javascript can make server requests. That's what Ajax is for. The javascript will send a request to the server without reloading the page in the browser, and can (optionally) change something in the loaded page based on data received by the response, while the server can do whatever it wants– including updating a database. Hopefully this is helpful! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: "safari can't open the page"
omat wrote: > Hi, > > I am getting "safari can't open the page" error when trying to login > to my application which runs in a VPN. > Is this application running in the dev server, or on a production server? What is the topology of the network/VPN? Have you tried using konqueror or google chrome? Both of those browsers use the same engine that safari does. > - I login via admin with safari, but safari cannot still the same > error when trying to open a page behind login > I'm not sure what you mean here. I'd suggest watching what is going on with wireshark. It very well could be an issue with a header or something– especially if you're doing something crazy weird in the view. Have you checked the log to see if Safari is actually hitting the webserver? Hopefully this will give you some idea as to how to start diagnosing the problem. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: locmem or memcache
Peter Bengtsson wrote: > What's faster, locmem or memcache? > > I know that the docs rave on about how fast memcache is but what about > locmem? That sounds pretty fast to me since it doesn't need another > TCP service and just uses the RAM. > My particular site (for mobile phones without any media) is so tiny > that I wouldn't worry about some RAM bloat. > http://groups.google.com/group/django-users/browse_thread/thread/8bdf1809d0c2cda8 signature.asc Description: OpenPGP digital signature
Re: Compare Lists for Unique Items
Alex Jillard wrote: > I've been working with Python and Django for the past week or so and thus > far it's been great. My question is more of a general Python question than > it is a Django question, but hopefully I can get some help or a link to an > appropriate doc/website. So far I've not been able to dig up much useful > information up on Google. > > The application that I'm working on checks a CVS repository for all active > projects and returns a list of the corresponding project names. I'd then > like to put these names into a database. We start a few new projects every > week, so our CVS repo grows fairly quickly and I'd like to be able to have > the database stay current, either with a cron job or by a user starting the > processes. > > So far all that works, but since CVS will always return a full list of > projects, and I only want one entry in the database per project, I need to > filter out the new projects. Right now I'm just comparing what the CVS > return list contains with what is in the database. > > Here is the code that I use. Output_list is from CVS and current_projects > is from the database. Is there a faster way to do this, or a built in > method in Python? This code works fine now, but I can see it getting slow. > I'm not sure of a pre-built way of doing this, but if your data is guaranteed to be sorted, you can take advantage of that, and improve the performance of the algorithm. Use a binary search rather than iterating through the whole current_projects list. You can also use the Python keyword 'in' instead of comparing each term: for b in output_list: if b not in current_projects: new_projects.append(b) Even this will give you a bit of a performance boost, because 'in' doesn't (shouldn't?) iterate through the whole list in every case. I don't believe that 'in' will take advantage of a sorted List, so if it really matters to you, you could implement your own function that does. Another thing that may speed things up: right now you are building the output_list up, and then building the current_projects list up, and then comparing them one by one. You could build the current_projects list, and then instead of putting the items in 'output_list' into a list, do the comparison there: if item not in current_projects: new_projects.append(item) Of course, this won't work if you are getting a list as input, and not the individual items. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Dynamic image creation
Aneurin Price wrote: > Hello, > > I'd like to be able to generate images dynamically for a Django-based > website, and I'm wondering how best to go about it. > > The idea is to do certain things to existing images, such as > superimpose them on a background. The set of base images will be > more-or-less static; it's just the operation performed on it which > might change, so I don't really want to create an image model and have > to instantiate it for each image. Rather I'd like to be able to simply > put them in a directory, so I can make a request for > 'imagename-operation.png', and have my application check to see if it > exists in a cache, and if not, look for 'imagename.png' in the base > images directory and apply the given operation to it. I'm fine with > the image operations, but I can't decide where I should be doing this > work. > > I'm tempted to do it all in a view, so 'imagename' and 'operation' are > parsed from the request name and passed to the appropriate function, > which returns the image. Doing it in the view however doesn't really > feel right, and I wondered if perhaps I would be better with some > custom middleware, or something else entirely. > A view is the right place to do this. A view takes a request, parses it, and returns the response. This process holds true for html, an image, pdf, or office document. You'll likely want to use PIL for the actual manipulation/operation, but as long as you can get the binary content of the image into Python, you're fine. Simply set the mime type and content of the response, and you're good to go. There are examples in the Django documentation on how to do this with a PDF, but the response object instance creation will be basically the same for an image as well. Take care! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Develop in windows, serve in linux
TheIvIaxx wrote: > This isnt really a django specific question, but i figured some folks > have a similar setup and might be able to offer advice. I'm > developing my django site on vista and i have a server running linux/ > apache. Im not sure how to get all my files from the windows box onto > the server. The linux box doesnt have X installed so no remoting :( > > Is there a common set of tools for this type of thing? > Absolutely-- ssh, scp, sftp. Use putty for ssh shell access. There is also winscp, and several gui ftp clients can handle sftp. All the tools mentioned use an ssh connection to provide their various services. There's plenty of info "out there" about using the terminal. Take care! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: shared application?
Haku wrote: > Sorry, my english didn't help me in explaining myself! > > I have just one site with 2 applications > App A is something like "1st floor office documents" > App B is something like "2nd floor office documents" > It sounds like you want one application, and two groups with independent data in the database. This is a fairly common request, but I've never implemented it. I believe that the correct way to achieve this is to use a custom form and/or manager with your app. It is possible, but I personally don't know how to do this. I skimmed the admin doc for info about a using a custom manager. I didn't see it, but that doesn't mean it isn't there. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: shared application?
Haku wrote: > Hi all, and please excuse me if i ask something obvious for you. I > can't get out of this problem! > > I've got a site with 2 separate applications (call it A & B). Each one > has it's own administrators and there must be absolutely no > information passed from application A to application B and vice-versa. > > Beside, i have a very simple gallery application. Administrators form > both applications (A and B) should upload images to the gallery, but A > should see only A's files and B only B's. > > How can this be done with the administration site? > It sounds like you have two different websites, but since you're asking the question I'm guessing that you want both applications on the same site. The way to do it is to use the permission system that comes with the Django auth/admin system. I've never implemented it myself, but it's all documented. You can also have multiple admin sites installed on different URL paths. Make one admin site for one app, and another admin site for the other. I've never done that either though, but it too is documented. :) Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Problem upgrading to Django 1.0.2
lazyant wrote: > Hello, > > I've been running django 0.96.3 installed from the tar file for over > half a year without problems, I'm using python 2.3.4 on CentOS 4. > > I'm trying to upgrade to 1.0.2 from tar file and after running 'sudo > python setup.py install' I get about 20 byte-compiling errors, they > are all syntax errors regarding '@' or 'for'; here are the first and > last of those errors: > The '@' errors happen in the gis package because it uses the newer style decorators. While Django supports Python 2.3, django.contrib.gis does not. This is very likely a problem with the tarball distribution, as it should be able to cope for what Django and its contrib apps support and don't support. I'm guessing that the 'for' errors is a similar problem. I don't usually use setup.py when I install Django, but I'm sure there's a way to skip the byte compiling stage, at least for the gis stuff. As long as you don't plan on using gis, ignoring those errors won't hurt you. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Using a HTML to fire off a data processing script on the server (REST or SOAP)
shi shaozhong wrote: > Dear Jeff Anderson, > > Thank you for your email. > > It sounds very interesting to me. I must confess that I am not a > programmer, and have no experience with Django. But I have a project > in hand to do such a work. > > Have you ever tried to use feedback.py to fire off another Python > script (external script)? The external script may run for 2 - 3 > minutes. > > Perhaps you can show me how to use feedback.py to fire off a zip.py. > All you really need is to use a Python thread. They are fairly easy to use, but I don't use them enough to know without looking up how to do it. If I needed to do it, I'd simply do a google search for "python threads". If you feel like this type of thing would be too difficult or time consuming, contact me off list and I am willing to do paid freelance work. I could get it working fairly quickly. I'm a poor college student, so I'm happy to get extra money any way I can. :) Thanks! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Using a HTML to fire off a data processing script on the server (REST or SOAP)
Shao wrote: > Dear ALL, > > I am very much interested in using a HTML to fire off a data > processing script to run over the internet. > > I will be very grateful if you can advise me on passing parameters > from an HTML form to a script and fire the script off to carry out > full execution, monitor its progress and return an innerHTML with link > (a name string of) the file generated back to allow user to download > the result. > > The script run over a period of 2 to 3 minutes. > I designed a system to do something similar, but never implemented it fully. Basically, a Django view would fire off a Python thread that would run the script, and report its progress. I chose to use a Django model that the Python thread would store its progress in. The progress was monitored by the end user via AJAX. It queried the progress of the job once a second or so until it was completed. I only implemented a proof of concept, where the script would only count to 100. Unfortunately, I didn't save the code. The project I was doing it for was scrapped. The proof of concept code was fairly easy to implement. I think it'd fit your bill. If you aren't familiar with AJAX, I suggest reading a tutorial about how AJAX works, and then consider using an AJAX library. Hopefully this gives you a good starting point. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: php templates support
DULMANDAKH Sukhbaatar wrote: >> when i use my hosting provider (mediatemple) which i believe is >> running django via a fast cgi container setup. overall, the setup >> seems to work, no errors, definately calling php.py, and detects the >> php:file.php tags, but no php is converted into the template output. >> blank text, not even the original php..so, it seems to run the php, >> but never updates the templates with the output. >> > > As I understand, you want to run php script or template inside Django. > Am I right? It's impossible, because Django is, as you may know, > written in python. Python and PHP are completely separate languages > with completely different syntax and so on. > You didn't follow the link that was provided. Ticket #2440 includes a patch that does just that. A php script may not be Python, but it definitely isn't hard to run a PHP script, and that's exactly what this does. Craic is having difficulty with this particular patch. As for using this patch, it was in fact marked as 'wontfix'. Any time I need to use the same template in two places, I just make a copy and maintain it in two different spots. Things like CSS can be common, but storing the HTML in two different spots really shouldn't be too cumbersome. If set up properly, you'll only need to change two files; one for your PHP template, and one for your Django template. Anything else that needs to be changed would be CSS, which can be shared (unless your template engine generates CSS on the fly), or you'd be changing some piece of functionality that should be only in your PHP app, or only in your Django app. It'd also speed things up a bit, because you won't be using os.open or subprocess to run PHP each time your cache runs dry and need to re-generate the template. One of the reasons to move to Django from PHP is to get away from PHP's faults, but you're suggesting to re-introduce them by putting them underneath your Django app. I'm sure this isn't what you wanted to hear, but I disagree with the concept of running PHP to get an html template into Django, though I think it's kind of cool that someone has done it. :p Take care! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Noon Help
Johnny Utah wrote: > Thanks for the input. > > When you say Django.admin would be useful, do you mean users would > access the admin interface? > Please respond to the list when asking further questions. That being said: no-- users shouldn't access the admin interface. Admins should. It's there to make your life much easier, and it does that very well. You'll still need to build views for your app, but if you need to go in and change something manually, the admin interface is way better than dropping to SQL. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Noon Help
Johnny Utah wrote: > Hi Guys, > > If I'm posting this on the wrong site, my apologies. > > I'm a beginner to both Python and Django and I would like to develop a > public site. I'm not looking for help with code as much as with what > modules I will need (e.g. django.contrib.auth). Any help is greatly > appreciated! > It sounds like Django is the right tool to do the job. The things that are in django.contrib that'll probably be most useful is auth and admin. These are documented at docs.djangoproject.com pretty well. If you have any specific questions that come up, this is the place to ask. It sounds like you're already headed in the right direction. Use Django's auth system, the admin site, and build your own app for reptile tracking. I'd use it, except I'm not a reptile owner– we only have a bird. Happy Coding! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Receiving emails via app
James Bennett wrote: > On Sat, Oct 25, 2008 at 2:09 PM, Jeff Anderson <[EMAIL PROTECTED]> wrote: > >> We have an alias set up in postfix that sends the e-mail to our script >> via a pipe. >> >> The python script imports our Django models, and parses the e-mail >> message with the email module, and does what it needs to. >> > > You can also use Python's built-in SMTP server module to set up a > lightweight server process, and have your regular MTA forward messages > to it. This lets the entire mail-processing routine happen in Python, > which is often a bit easier to set up. > > See Doug Hellmann's recent PyMOTW article on this for some basic > details: http://blog.doughellmann.com/2008/10/pymotw-smtpd.html > This sounds like the best of both worlds option. One python process for all e-mails without the overhead of having to check the e-mail passively. A second server still needs to be run, but if you aren't already running a mail server that "disadvantage" goes away. I may consider switching to this. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Receiving emails via app
AndyB wrote: > This sounds like exactly what I need to do. However my Unix-fu isn't > up to coping with the sentence 'We have an alias set up in postfix > that sends the e-mail to our script via a pipe.'... :( > > My naive assumption is that one could use something like poplib in the > standard library to connect to a POP3 server and process incoming > emails that way. Does that sound a sensible route to take? > It does sound sensible, but a heck of a lot more complicated than setting up an alias. If you use postfix, all you need to do is add one line to your /etc/aliases file and run newaliases. Here are the few lines in our postfix aliases file: tick: "|/git/tick/tickets/email_process.py /git comment" closed-ticket: "|/git/tick/tickets/email_process.py /git closed" open-ticket:"|/git/tick/tickets/email_process.py /git open" Ours is a ticket system called tick. we have an 'email_process.py' that takes two arguments- /git is a directory to prepend to the PYTHONPATH.the last argument is the type of e-mail message we are processing. We also have a ticket open handler, and a ticket close handler, but we don't use them. It seems like running a Python process constantly to check pop3 is more overhead, and an additional service to run. If you are already running postfix, an alias is a really simple and efficient way to get e-mail messages processed on the fly as they are received. The disadvantage is that each time a message is received, a python interpretor is loaded into memory. If you will be handling more than 1 or two messages a minute, I'd definitely go for the pop3 route, and have the python process stay loaded in memory. It'd put a decent amount of load on the mailserver to constantly check and download hundreds of messages all the time, but my guess is that it might be less load than loading several hundred instances of a python interpretor. It'd be interesting to test. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Receiving emails via app
umit wrote: > Hi, i am trying to build a quick blog system. But i want users can > send emails to submit messages with pictures. > How can i receive emails and process them? What should i use? > We use Python's email module. We have an alias set up in postfix that sends the e-mail to our script via a pipe. The python script imports our Django models, and parses the e-mail message with the email module, and does what it needs to. This should give you a decent starting point. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Import error exception "No module named urls" when running from eclipse
DragonSlayre wrote: > Hi, I'm new to django/python, and I'm testing out eclipse for > development. > > I'm using pydev, and managed to run my app, but then when I go to the > web page, I get: > > ImportError at /time/ > No module named urls > You'll need to include the code for the view that is being called, and possibly your urls.py Do you have a urls.py in your project? Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Get External IP Address
Ty wrote: > I'd like to grab the users external IP address. I'm using it for a > spam catching class that I'm porting over to Django/Python. Is this > possible? > > This person outlines how to 'hack' it, but I'd rather not depend on an > external site. > http://dmiessler.com/blog/how-to-use-python-to-get-your-external-ip > There might be a Python networking library out there, or you could parse the output of "ifconfig" on linux, or "ipconfig" on windows. You could look at the SERVER_NAME environmental variable, which is usually the server's fqdn, which is as good as the IP address. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: newforms question
Jeff Gentry wrote: > Hi there ... > > To date, I've not been using Django's form system (nor 'newforms'), but am > trying to integrate another app into a suite that I'm developing. The > code on this is a bit older and is using newforms - when I fire up the > server (running off of the 1.0 branch) I get "No module named > newforms". I've been a bit lax in trying to follow how this all shook > out, but am I correct in my thinking that 'newforms' is now simply > 'forms'? > This is correct. oldforms was removed, and newforms was renamed to forms. This happened before the 1.0 release. You just need to change your code to reflect this, and it should likely work. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Django development environment (newbie)
Trastabuga wrote: > Can I combine it with Apache so I can serve my static and index.html > with Apache and the rest with django-admin.py server? > You could make your MEDIA_URL point to a URL that is hosted somewhere else, like Apache. I find it easiest to just use the static file view when running the Django development environment, and turning that off in a production environment. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: How to translate into Django
Pythoni wrote: > In PHP can be used > include "http://url_address;; > ?> > > > How must I translate that to be able to use it in Django? > Use a Python library to fetch the content, and set a context variable passed to a template to hold the included content. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: ldapauth and TLS
Daniele Procida wrote: > I'm trying to get django.contrib.auth.ldapauth.LDAPBackend - from: > > <http://code.djangoproject.com/attachment/ticket/2507/ldapauth.py> > > working with our LDAP server. > > IWe need TLS before the server will permit us to exchange a password with it. > > According to the documentation, we should be able to set LDAP_OPTIONS > along with the other settings: > > ``LDAP_OPTIONS`` -- hash, python-ldap global options and their values > {ldap.OPT_X_TLS_CACERTDIR: '/etc/ldap/ca/'} > > However, if we set any value in LDAP_OPTIONS (other than 'None' - and > even the one in the example above) we get an error: > > Exception Value: > 'dict' object has no attribute 'LDAP_OPTIONS' > Exception Location: > /usr/lib/python2.5/site-packages/django/contrib/auth/ldapauth.py in > authenticate, line 113 > > The full error is at: <http://dpaste.com/84838/> > > How can we set LDAP_OPTIONS to turn on TLS? > Hello, LDAP_OPTIONS should be defined in your settings.py. Paste what you have in your settings.py for the ldap configuration, and I can help diagnose. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: manage.py tab completion
[EMAIL PROTECTED] wrote: > Depending on your site's setup, there is a variety of extra manage.py > commands that could be available. Is it possible to set up tab > completion on these commands? for example: > > ./manage.py syn > => /manage.py syncdb > > If it is not currently supported, how hard would it be to include? > Would it use the readline library? > This is already implemented with a bash completion script. I'm not 100% sure where in svn it lives, but its there, and it works. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: HTTPS Service for Django
Harish wrote: > Hi Friends, > > I configured a django site using apache, which is running on Fedora 9. > Now I want to enable the > HTTPS (secured ) service on that site > > Any ideas on how to achieve this? > Configure apache to do SSL-- no special setup needed for Django. signature.asc Description: OpenPGP digital signature
Re: Which IDE do you choose with django?
zjffdu wrote: > I am a newbie of django, and want to know which IDE is suit for > django? > I'd say that it'd be good to continue using whatever IDE you use for your other Python development. Django is, after all, simply Python code that you call from your code. Jeff Anderson signature.asc Description: OpenPGP digital signature
Picky Generic Views
Hello, So I'm working on a third party Django app, and we use a couple generic views, specifically login and logout. For the urls.py in a project that uses our app, we do this: (r'^path', include(smug.urls), {'repo': 'docs'}) Our own views need the repo kwarg. This is something necessary for our views to work. My question is how to get generic views to ignore this kwarg. We include a couple url patterns in smug.urls that use generic views, and they die because they get this extra kwarg. Is there a way to explicitly turn this off, or do we need to put our generic views in a separate python module (smug.genericurls for example)? We'd really rather use the generic views, but they seem a bit picky for some of the crazy stuff we're doing. If there's a way to turn that behavior off, great. If not, we can split it out. Thanks! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: django cms outside of django
chiggsy wrote: >> By "outside of Django" I'm guessing you mean "outside of a web environment" >> > > Yes, that is what i meant. > > >> Yes, you can use Django components separately. At work we use Django's >> ORM for management scripts such as print accounting. >> >> I've set up a standalone Django template-- no views, models, or urls. It >> was more like a traditionaly CGI script. >> > > > That sounds promising. I really wanted to use the ./manage.py > inspectdb tool in particular to turn this foreign db into python for > me. Is it at all possible to share your template? > Actually, I wrote up a little howto when I did the standalone Django template. http://www.programmerq.net/django_standalone_templates.html As for using the ORM in a standalone mode, there are plenty of examples and the like out there. Its pretty straightforward to do-- you just need to set your DJANGO_SETTINGS_MODULE to point to your settings, and write models/use inspectdb. The same type of thing is achieved when someone wants a cronjob to do something with their Django models. There are plenty of howtos for that as well. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: django cms outside of django
chiggsy wrote: > What steps are needed to use the django cms outside of django. I have > a database , that i want to manipulate. it's just a db. I dont want > to learn SQLAlchemy for this , today. I just want to goof around with > it, run some queries, etc. is this possible? > By "outside of Django" I'm guessing you mean "outside of a web environment" Yes, you can use Django components separately. At work we use Django's ORM for management scripts such as print accounting. I've set up a standalone Django template-- no views, models, or urls. It was more like a traditionaly CGI script. You just need to import the appropriate Django libs in your Python script, and you are good to go. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: How to invoke a request to an URL inside a web app without making a real request?
maverick wrote: > Hi, I have a django web application, I want to invoke a request of one > URL inside this application, e.g. "/getdata/", and capture the output > of such URL and do some further processing. > > Of course I can do that by make a real request, however I feel this > may not be the best solution, is there any internal way to invoke a > request ? > If the url is part of your Django project, just call the view function. You can either instantiate a dummy request object to pass to it, or pass it the one that you have available already. You'll get an response object back, and you can take the content of the response object, and do whatever you want with it. I ran into something similar and worked out how to implement it. I haven't actually done it yet, so I can't share any gotchas that might come up. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: HTTPS Question...
[EMAIL PROTECTED] wrote: > We have an online application for school, where we request the > individuals SSN and PharmCAS information. The application will be at > say www.oursite.com/application/. Since we're gathering sensitive > data, I want to obviously make this secure using https:// I don't want > the rest of the site to be on secure, just the online app part of the > site. What would be the best way to do this? Create a subdomain, > https://application.oursite.com/ or can I just secure > https://www.oursite.com/application/ ? > The way to do it is to implement redirects where necessary. I have an app that is public-facing on regular http. There are no comments or logins, it is simply a presentation layer for what we add in the admin. I have an apache redirect for /admin/* that redirects to the admin on an instance of the site served over SSL. There is also a middleware that exists so Django can handle the redirects. There are a few different incarnations of it here: http://www.djangosnippets.org/tags/ssl/ Hopefully this is what you need! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Integrating into PHP-based site...
megrez80 wrote: > Ok, so I can probably live with duplicating some HTML. > > Then my next question is how to access .css and image files (which > reside under the server's document root) > from within my template? Do I need to duplicate those under my app > path somewhere? > No, you just need to make sure that the html code spit out by Django points to the proper location. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: how to get a magnifier in an image
Kenneth Gonsalves wrote: > hi, > when I open a jpg file directly in firefox, I get a magnifying glass cursor, > which on clicking gives me a bigger more detailed image. The same file when > served through the get_photo_url in a django template does not give this - > how can I achieve this? > This is a browser feature. Some browsers have a plug-in that adds this functionality. It has nothing to do with Django itself. I'm not sure what 'get_photo_url' is, nor why you are trying to use Django templates to present a straight jpg image. In short, you'll need to investigate a client-side solution to get this behavior, and Django is only server-side. signature.asc Description: OpenPGP digital signature
Re: Integrating into PHP-based site...
megrez80 wrote: > Hello, > I'm currently prototyping a web application using Django which > must be integrated into an existing PHP-based site. Can anyone comment > on, or provider a pointer to documentation for, the issues involved. > In particularly, how to go about inheriting the existing look-and- > feel. > The look and feel will be the easiest part-- you just need to take the HTML generated by your PHP app, and repurpose it as a Django template. This shouldn't take long. Things like changing a menu bar that need to be common between the PHP and the Django side would probably need to be maintained and updated in tandem. You'll probably run into issues other than the look and feel, but there is no reason that you can't have both Django and PHP running on one server. If you need to have both Django and PHP access the same database, you can do that. Look in the Django documentation for "legacy db" stuff to get Django working with your existing tables. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: How to stop internal django server
Hingarajiya,Ravi wrote: > Hi Alessandro, > >Thanks for your reply.I know kill command. > > But we are developing IDE for Django. So We want to know that how > to stop internal server using any command (example : /etc/init.d/httpd > stop in apache web server ). /etc/init.d/httpd stop is just a wrapper script that uses the kill command. You need to do the same thing to kill any process. ctrl+c sends signal 2 to the running process. kill is exactly what you need to use. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: faking a cron job
Julian wrote: > hi there, > > i have written a middleware-class wich is doing what a cronjob should > do. it is doing some backup-stuff, and repeats that every 12 hours. it > is a thread and is placed in the list of middleware-classes, but not > processing any request or overwriting any typical method for a > middleware class. > > my problem is: with the devlopment-server it's created once. with > mod_python and _three_ apache instances, there are three instances of > my backup-thread, but i want to have only one. > > how can i start a thread (without having an extra cronjob) in my > django-app only once on the whole server??? the hackish solution would > be to store the actual PID on a special place. > Doing a cronjob's job in a middleware-spawned thread is hackish to begin with-- storing a PID is the best way to do what you want done given your constraints. Another implementation you might consider, is to create a view that executes the backup job when called. Do a check when it is called to see if it's been at least twelve hours. Set up a cronjob on your local machine that uses curl or wget to make a request that executes the backup job. The check to see if its been at least twelve hours would prevent the job from being abused if someone finds it. If you want to hide it, make a view that starts the backup job, and then raises a 404-- the code will still get through, but anyone that visits the URL would have no way of knowing that it was doing something. If a cronjob is really what fits the bill, consider switching your hosting provider or plan to something that includes cronjobs-- its worth it to not be hackish. :) Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: User Login with Django 1.0
jeffhg58 wrote: > I just recently upgraded to Django 1.0, but when I log in with users > that I have created I get up a popup window > stating syntax error and after I login the clock and calendar objects > are lost. > You'll need to be much more specific. Where are you logging in. What do you mean by "popup" and what clock and calendar objects are you speaking of? signature.asc Description: OpenPGP digital signature
Re: actual django stack
Frédéric Sidler wrote: > What it the best Django stack today. > > In django doc, it says that apache with mod_python is the best > solution in production. But in the same time I see that everyblock use > nginx (probably in mode fastcgi). > > Did you some of you test different solution and can share some output here. > > Here are the ones I see actually > > Apache mod_python > Apache in fastcgi mode > Lighttpd in fastcgi mode > Nginx in fastcgi mode > I've only used Django with apache/mod_python in production. At work we are considering moving to lighttpd with fastcgi. I've played with fastcgi, and it seems like just as solid of a solution as mod_python. For apache, mod_wsgi has/will supercede mod_python. signature.asc Description: OpenPGP digital signature
Re: where is my pythonpath
KillaBee wrote: > I need to edit my pythonpath, but where it? > Your PYTHONPATH isn't a file. It is a list of directories that python searches through to find python code. When you type 'import django' it looks in the first directory for code that provides the Django module, then the next, and the next until it finds it. if you set an environmental variable before running python, you can tack on a list of directories to the front of the PYTHONPATH that python uses. if you are using bash, type `export PYTHONPATH=/path/to/dir1:/path/to/dir2` To see what your pythonpath is from inside python, do this: import sys print sys.path sys.path is just a python list that contains strings that are the directories python will look into. You can modify this list from inside python to control what your python path will be. Hopefully this is helpful. ps-- all this information is in nearly every python book available, and freely available on the internet. Try googling for "python path" and I'm sure this information would have come up in your search. This isn't even Django specific-- this is a python question. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Help: Running 1.0 and 0.96 side by side?
Matt Conrad wrote: > Thanks for the reply. I don't quite understand yet. Let's see how close I am. > > I have a Python application directory (on my machine, > C:\apps\Python25\). Inside that directory I have > \Lib\site-packages\django, which is currently v0.96. > > Right now, the PYTHONPATH environment variable is not set at all on my > machine. When I work through Django examples, I can run "manage.py" > from my Django application folder (C:\work\djcode\mytut\) and > automatically talk to django modules, which are presumably in > \Lib\site-packages\django. This happens, I assume, because > C:\apps\Python25\ is on my system path, and either a) Python > automatically checks the \site-packages\ subdirectory for imports, or > b) a hook was added when I installed Django, so that Python knows to > look there for "django" imports. > > I have not installed Django v1.0 yet. I will have to do something > when I install it so as not to overwrite the version already in > \site-packages\. The obvious solution is to rename the existing > directory to (say) django096 before installing, but I don't know what > I might break when I do that. > > I'm not sure we're on the same page, but maybe you are telling me that > if I rename the old directory and then install v1.0 so that I have > both \django (1.0) and \django096 (0.96) both under \site-packages\, > that I can set the PYTHONPATH variable to tell python to > preferentially choose one of these directories over the other? Or are > you perhaps talking about having different installs of Python itself, > or something else entirely? > It sounds like you're new to python programming. Your PYTHONPATH is where python looks for modules. To see what yours is, do this in a python interpretor: >>> import sys >>> sys.path You'll see the list of directories that python searches, in order, for a Python module. You can influence what this list is, by setting the PYTHONPATH environmental variable. All you need to do is set your PYTHONPATH appropriately, and point it to the appropriate place, depending on which Django installation you need to use. Anything in the PYTHONPATH environmental variable is put at the beginning of sys.path in the python interpretor. You can't just rename the django directory and expect it to work-- it won't. signature.asc Description: OpenPGP digital signature
Re: Help: Running 1.0 and 0.96 side by side?
Matt wrote: > Does anyone have ideas on running 0.96 and 1.0 side by side safely? > All I've done in the past is set my PYTHONPATH based on which checkout/release of Django I want used in a particular instance. It works quite well, even in production. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: First App: devel server - can't establish a connection to 127.0.0.1
Rob wrote: Not for me! :( I get a "Unable able to connect. Firefox cannot establish a connection to the server at 127.0.0.1:8000" message. I've searched the group messages and there are only a handful of (unrelated) messages about this. First question: are you really running the development server on your local box? If you're sshing to another machine, then it won't work. 127.0.0.1 is always the machine it is referenced from. You can change where the development server is being run by locating your ip address (use the ifconfig command and look for the address associated with eth0), and running the dev server like this: python manage.py runserver :8000 In a common case, it might be: python manage.py runserver 192.168.1.3:8000 You can then connect to it via that ip address instead, so if you are SSHing to another machine, you can access the dev server even though it's over the network. Just keep in mind that it'll be accessible to anyone who can see that machine. Your /etc/hosts don't define ip addresses, they define hostnames-- it seems like you understood it backwards. If it's any help, I'd actually rather be running Apache + mod_python... you know, make your development and production environments as similar as possible... This really isn't necessary when working with an initial Django project. It's possible to use an apache instance with mod_python for development, but it is nowhere near as convenient as the Django dev server. At least for initial developing of Django projects, I'd recommend you stick with the dev server-- it is there to help you be more productive and keep things from getting in your way. Hopefully this helps! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Composite Forms? Are widgets the right thing to use?
Jon Loyens wrote: Hi all, I have a sight where I need to generate forms that are made up of two or three other forms. For example I have New User sign up form that accepts user information (user name, name, password), a shipping and a billing address (with the same usual field) and credit card info. Sometimes, I need a composite form with all of the above while sometimes I need a form with just a subset of the information. As an example, I'd like to define a series of forms like this: Is there a way to do this sort of thing with the Forms API? I had hope for FormSets but that's a more dynamic thing that I need which is really a Composite form pattern. There is no reason that you couldn't include multiple forms in an HTML post operation. You just have to make sure that there won't end up being duplicate fields across forms. You'd have your view figure out just which 3 you need, and then call the appropriate template. You'd end up having something like: {{ CreditCardForm.as_ul }} {{ AddressForm.as_ul }} {{ NewUserForm.as_ul }} Your view would then create an instance of all three forms with the request.POST data. When forms get passed a value they don't need, they discard it. Simple as pie. Hopefully this is helpful! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: mas sobre unicodedecode erros RESUELTO!
anonymous wrote: Sin DATABASE_OPTIONS se resuelve el problema en mysql!! Muchas Gracias! De nada. Como dijo Karen, casi no necesita DATABASE_OPTIONS en settings.py. Cuando se usa DATABASE_OPTIONS, solo hay que specificar el tipo del database engine y no mas. Es posible que hay otros casos que requieren otron opciones, pero nunca he visto un projecto que lo usa. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: mas sobre unicodedecode erros
anonymous wrote: Hola, UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128) ¿Cómo podría resolverlo? La versión de django es svn trunk y la de Mysql es la 5. Tendría que ver tus modelos antes de ayudar con eso. ¿Has probado eso con algo más de Mysql? No sé si soporte unicode sqlite. ¿Sierve eso sin los opciones DATABASE_OPTIONS, o teine la misma problema? Disculpa mí español. No lo uso en la computadora mucho. ¡Graciás! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: status of unicode support in 0.96?
Andrew D. Ball wrote: Greetings. I haven't found any good documentation yet on how Django supports Unicode in version 0.96. The following webpage has links for version 0.96 and 0.95, but those links don't work. :-/ : The header at the top is a generic header that gets added blindly to all documentation, hence the broken links. Does anyone have some more information on using Unicode with Django 0.96? Unfortunately, unicode support was added post-0.96. If you need it, you'll need the development version. Fortunately, the svn version is very stable, has more features, and less bugs than 0.96. It is also very near to 1.0 status. It would be silly to start with 0.96 and then have to rework all your code for 1.0 in the near future. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Modulo of 4 not working right
Joshua Jonah wrote: I'm not sure how to put the "better fix", would it be in the while statement? should it be child of the statement? I tried the "simple fix" and it isn't working either. It returned a list of 33 items in one of the sections, that would work out to 8.25. Obviously it is divisible, but i dont want it to be a float for obvious reasons, can you clarify for me? The 'simple fix', to remove 'not' from the statement works because of how modulo works, which works like this: >>> 10 % 4 2 The modulo returns the /remainder/. It will not be a float. Let's see how this evaluates:: >>> if 10 % 4: ...print "true" ... true If the modulo returns anything other than 0, it will evaluate to True. In python any integer other than 0 evaluates to True. You are treating modulo like it is an operation to find out if the second number goes into the first number an even amount of times. That's why removing the 'not' is the 'simple fix'. So if there isn't enough fields for 4 columns, say 11, 11 % 4 will evaluate to true. Add one more, and 12 % 4 will evaluate to false. The 'good fix' is set up to do the logic all at once. Because modulo returns an integer, you can just set the number of blank fields to the number that modulo returns. Hopefully that helps! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: .pyc files not being created
Dana wrote: @Evert Thanks for the information, Ill be looking into all that today. @Graham, So there is no speed increase in using compiled python than using just strait python? So why is python ever compiled in the first place? There is a speed increase-- it's just not that big in this situation. It still compiles it, it just doesn't write out the compiled bytecode in your case. It will compile it the first time it is accessed, and then stay in active memory. If the .pyc files were being created on the fly, it would save that initial request a very small amount of time. You would see a huge slowdown if you were using python to run cgi, and python had to load itself into memory, compile the code, and run it for each and every request. Fortunately with mod_python, this isn't the case. Hopefully this makes a little more sense now. Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Inquiry
Kadusale, Myles wrote: Good Day to All! I am new to Django and I was wondering if there is a sample application that deals with sessions that is not using cookies. Django's session framework uses cookies. I don't know why you wouldn't want to do sessions without cookies, and I don't know of any projects that aim to do that. It wouldn't be difficult, however, to implement your own sessions that don't use cookies. Also is there a directory structure in an web app when using Django? Like in J2EE?? If you are referring to Java namespaces, then yes: Python has them. If you are asking about urls in Django, I suggest you read through the tutorial in the official Django documentation. Good luck! Jeff Anderson PS - instead of replying to an existing thread and changing the subject, it is better to start your own thread. Your message is in the middle of another thread. Thanks! signature.asc Description: OpenPGP digital signature
Re: Updating Database Schema
Chris wrote: What's the best way to update database schema? If I add a column to a table in my models.py and then run "manage.py syncdb", it doesn't add the new column in the database. syncdb will never issue an alter statement-- this could be devastating on a production server with lots of data. You have a few options: * issue the alter table command yourself * drop the table altogether and run syncdb again * check out the django-evolution project on google code. I haven't used it, but it is designed to handle just this. Good Luck! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: XML and django
Ahmad Akkaoui wrote: Hello everyone, I would like to know how to I would go about parsing an xml string in Django. Is there a built in XML library or am I going to have to rely on external parsers. There are plenty of options to parse XML. Just pick your favorite Python XML parsing library and run with it. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Server config
[EMAIL PROTECTED] wrote: Hey, At work we're getting a new server and going to use it as our web- server and use Django to run our website and our special student/ faculty stuff. What does everyone recommend? FreeBSD, RedHat, or Ubuntu? We have been using rhel since about rhel3, but we're dumping it for arch linux. rhel5 seems to introduce more bugs than it addresses. We've had smooth sailing with arch linux so far. Anything that you are comfortable with that runs python and apache should probably work fine for running your django apps. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: newsletter in django
sebey wrote: I am planning on making a newsletters so should I use django build-in options or mailman or something else you would recomenmt I recommend mailman. It is scalable and proven mailing list software. but I am new to web dev and python so therefore django as well but I have one request that it is easy to mantain and costumize (costum signup in like an ajax window as an example) Writing django views is very nice. You are free to use whatever JavaScript toolkit that suits your needs-- django doesn't force you to choose one. Hopefully this is helpful! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Include django views in other web sites
Alessandro wrote: I need to include some django output in other web pages. The problem is that Sometimes I cannot use server side includes on the other side, and I don't know how to do. I thought maybe some javascript or ajax to include with a
Re: Command Line Admin
Eduardo O. Padoan wrote: python manage.py shell Yes, this works, but I'm thinking more of a curses-based app that can use the admin app's definitions and validations. I'm really looking at a niche where the admin website is 'too much' and the 'manage.py shell' is not enough. signature.asc Description: OpenPGP digital signature
Command Line Admin
I thought of something that might prove useful. Anyone that has installed trac has used trac's command line admin interface. Something similar for django might be desirable in some situations. What I'm thinking is more or less a drop-in replacement for the django.contrib.admin app. One would get access to admin functionality from the command line: python manage.py admin-cli One would be able to add, delete, or modify instances. It is possible that this might be more useful as a curses-driven app rather than as a straight CLI similar to trac's. The benefits to such a system would include higher security for the web portal. I might have a blog that I really don't want to get spammed. I disable comments, and I uninstall the admin interface. I would be able to make all changes to my site independent of any web requests. Granted, this is security for the paranoid. Another benefit would be that it is nice to be able to edit content in more than one way. Sometimes a full-blown web browser is just out of the question. My server doesn't have X on it at all, so if I want to edit something through the admin interface, I either have to get up, and bring my laptop to where my server terminal is, or I have to get up and go use my desktop. Neither of these are a big deal, but the point is that it'd be nice to have the option to simply use a CLI for a django admin. There's no reason to write something like this to make it necessary to take out the existing django admin from your INSTALLED_APPS-- it would be an opt-in app, just like the web admin interface. I haven't found anything like this that already exists. I'd be willing to do some coding for something like this if there's some interest. Please respond with your opinions, comments, constructive criticism, etc. If its already been done, I'd be excited to hear about that as well. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: how to? : non-required admin fields
eddie wrote: Hi. I'm looking to find out how you make form fields in the admin section non-required. I've done a few hours of searching, but haven't found the answer yet. If anyone can let me know where I can find it, it would be much appreciated. Put blank=True and null=True in your models.py for the field in question. signature.asc Description: OpenPGP digital signature
Re: Problems setting up LDAP backend
satish wrote: Hi Jeff, Thanks for helping me out here. I did enable logging on the LDAP server. Looks like the requests are not going to the LDAP server. I removed backends.pyc. When I run the server the next time, it should have generated the backends.pyc right? I also removed django.contrib.auth.backends.ModelBackend.pyc- which is not getting re-generated as well. Any thoughts? Well, I still don't know exactly what is going wrong... When you attempt to authenticate, what exactly happens? Do you get a "bad username/password" when you try to log in? Is 'settings_local.py' even being used? Usually the settings module is 'settings.py'. Do you have one of those as well? I've never had any problem with the patch from #2507 for ldap auth. Is that what you are using? I put the authentication_backends and ldap-specific settings into my settings.py Try this: $ python manage.py shell >>> from django.conf import settings >>> settings.AUTHENTICATION_BACKENDS ('reviewboard.accounts.backends.LDAPBackend',) (to make sure it is in fact set correctly) Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Permissiond
[EMAIL PROTECTED] wrote: I don't understand why I keep getting "permission denied" when I try to install Django. Here is what I get when trying to install as the Admin: You don't have write permission in whatever directory you are executing that command in. Either change to a directory in which you do have write permission, or change the user you are using to one that has write permission to the directory that you are in. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Problems setting up LDAP backend
satish wrote: Hi All, I was able to setup review board with the default auth backend. However I am having problem setting it with LDAP. It looks like you are using the patch from ticket #2507 When you say "no errors or warnings" what undesired behavior are you experiencing? some things that might help to diagnose: * tail the log of the ldap server to see if a request is actually hitting it. * try authenticating a user from the python shell If you are still stuck, provide some more details, and I'll be happy to help from there. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: using only database part of Django
Peter wrote: Hello. I want to use Django database API without using other parts of Django (views, templates etc). What is the most correct way of doing that? You still need to create a settings.py, and tell your script where it is. import os os.environ['DJANGO_SETTINGS_MODULE']='mypythonmodule.settings' then you simply import the parts of django you need for the script. I use the same trick in a small script that only uses the django template system, and nothing else. My settings.py only contains the TEMPLATE_DIRS setting. Yours will only need the database settings. hopefully this helps! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Lighttpd Vs Apache
James Matthews wrote: Hi, I am now debating on if i should use Apache with mod_python or Lighttpd with fastcgi. I won't be serving many files (just one webpage for now...) But that page will preform be doing many calculation/database query's. Which one would you guys recommend. Pros and Cons I would recommend apache with mod_python. This is the setup that django recommends. If you have access to the server in question, this is a viable option. In my opinion, mod_python is less overhead than FastCGI. FastCGI is usually recommended for shared hosting environments. Lighttpd is usually useful for serving lots of files, or minimizing overhead when optimizing for a set of given hardware. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Date based URLconf condition not working
joshuajonah wrote: Is this not impossible? 404 error: Using the URLconf defined in jj.urls, Django tried these URL patterns, in this order: 1. ^admin/ 2. ^blog/$ 3. ^blog/(?Pd{4})/?$ Hello! Put a \ in front of the 'd'. Right now, you have a regex that only matches: ^blog// (not numbers) Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Modeling complex ER-diagrams with Django. How to get started?
giovanni wrote: Hello: I am new to Django. I am intrigued by the possibility of providing a web front-end to complex databases. Let's say I have a database with more than 10 or 20 related tables, with a complex ER-diagram, such as, for example, the picture here: http://blog.hundhausen.com/files/AdventureWorksLT.jpg. There are many tables with multiple one-to-many and many-to-one relationships. How easy it is to quickly develop a web front-end for database searches and updates (add,delete,edit records) using Django or some other web application framework? And how would I get started? I only have the ER-diagram and the actual database tables and relationships between the various keys to get started. Once you know the ropes a web front-end can be developed using django fairly quickly. It sounds like you are trying to hook django into an existing database? You can use the 'inspectdb' feature to start creating django models for your specific existing database-- I've heard of some bugs when detecting foreign key, many to many, etc... The first thing to do would be to learn the ins and outs of the django ORM using a blank database-- just get comfortable working with the API. Play with the foreignkey, manytomany, etc... Once you are comfortable with creating django models, the database introspection won't be as beastly to take on-- you'll already be in familiar territory. As for creating the various views for presenting information in the user's browser, it is fairly straightforward. Good luck! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Does django-driven Blog popular?
kylin wrote: > Thanks > I am looking forward to finding some samples to study.Could you give > me any advices? > At work we were using wordpress to post information about changes we made to the system. It didn't suit our needs, so I wrote a django blog from scratch that fit our specifications and needs to the letter. This was complete with RSS feeds, categories, and ReStructured Text for the posts themselves. It fits our bill better than wordpress did, and it only took me a little over six hours of total work to get it complete. I've spent another hour or so tweaking things, but it is largely unchanged. If you are interested in learning more about django, you could try building your own blog system for practice. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Template engine
Juanjo Conti wrote: Hi, I am using Django's template engine to produce rtf files and I have noticed something: if the first line of my template is a {%load ... %} tag then the result has a withe like at the to of it. This is not a problem in html, the common use of the tempalte engine, but is fatal in a rtf file. I write this because I think that this behaibour should bi fixed, am I right? Anyway I have putted the load tag in the second line of my tempalte :) Juanjo The way to fix this is to include the {% load ... %} tag on the same line as something else. I'm not familiar with the RTF format, but to eliminate the blank line at the top of an html file, you would do this: {% load ... %} instead of {% load ... %} Hopefully this helps! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: can't find media
Adam Fraser wrote: Hi, I'm testing Django locally and I've added the line: (r'^projectprofiler/media/(?P.*)$', 'django.views.static.serve', {'document_root': '/projectprofiler/media/'}), to urls.py as it is mentioned to do so here (http:// www.djangoproject.com/documentation/static_files/). Note: The path to the file on the site is the same as it is locally. The browser is now being directed to the correct place, but I'm still getting a 404 even though the path to the directory is exactly correct: Request URL:http://127.0.0.1:8000/projectprofiler/media/MochiKit.js "/projectprofiler/media/MochiKit.js" does not exist type "ls /projectprofiler/media/MochiKit.js" I'm suspecting that "projectprofiler" isn't a directory off / You need to supply the full path. Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: why my django site doesn't create .pyc file?
Scott Moonen wrote: >> I think this way, apache could be a little more faster. Am I right? >> >> > > I don't think it will be faster. Django normally runs as a long-standing > process (either inside Apache or as a standalone process, depending on the > deployment model you've chosen). So, unlike ordinary CGI scripts, your > Python bytecode will not need to be generated except for the very first time > that your code is loaded. Once it's up and running it will already be in > memory so it won't need to be reinterpreted. > When I first noticed that mod_python didn't seem to spit out .pyc files, I figured that this was a "feature" because of its one-time loading nature. I kind of liked the concept because .pyc files seem like clutter sometimes. Good to know that my assumption was wrong. I'm going to keep my permissions the way that they are. :) signature.asc Description: OpenPGP digital signature