If I understand your issue correctly, you want to mix new content created and managed by Django with legacy content that exists in the form of static html files.<br><br>This is actually easier than it sounds. There are many possible solutions, but here's one. Whether it is the right one will depend on how much of what type of stuff you have. <br>
<br>So let's say you have a model you're using for content. And let's say you want this model to represent a "page" whether that page is new (managed by Django) or legacy (exists in file). That way both types of "page" can be managed by the same views at similar URLs. If you want that content object to do double duty, here's what you might do:<br>
<br>1. Add a FilePathField to your model. Docs: <a href="http://docs.djangoproject.com/en/dev/ref/models/fields/#filepathfield">http://docs.djangoproject.com/en/dev/ref/models/fields/#filepathfield</a><br><br>2. Add a method to your model that returns the contents of the file at the path specified in that field<br>
<br>3. In your template(s), check for the presence of a value in the FilePathField. If it's there, just dump out the contents of the file. If not, proceed to render your page as you normally would.<br><br>If you end up with images that use relative paths that are no longer valid, you can probably fix those quickly with an entry in urls.py or an Apache RewriteRule. Shouldn't take much to map any legacy paths to the new static directory.<br>
<br>Anyway... hope that's helpful.<br><br>Dylan<br><br><br><div class="gmail_quote">On Wed, Apr 1, 2009 at 10:59 PM, kirby urner <span dir="ltr"><<a href="mailto:kirby.urner@gmail.com">kirby.urner@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks Dylan, plus to those replying off list.<br>
<br>
I'm trying to wrap an old static HTML website in Django such that I<br>
don't have to change relative paths to images in subdirectories that<br>
won't really be there anymore. I'm wanting all URLs from the outside<br>
world to stay the same as well i.e. all the old links will work as is.<br>
<br>
<a href="http://www.4dsolutions.net/ocn/cp4e.html" target="_blank">http://www.4dsolutions.net/ocn/cp4e.html</a> will now point to<br>
<a href="http://www.4dsolutions.net/controlroom/ocn/old/archive/cp4e.html" target="_blank">http://www.4dsolutions.net/controlroom/ocn/old/archive/cp4e.html</a> under<br>
the hood, with the later containing <img src="graphics/pix.png"> tags<br>
that need to be statically served from controlroom/media/ocn/graphics<br>
-- that kind of thing.<br>
<br>
Kind of a hack maybe, an exercise. The idea is new content would take<br>
advantage of the framework more, but this is a way of grandfathering<br>
in what's at the site already, basically with no changes.<br>
<br>
Kirby<br>
<div><div></div><div class="h5"><br>
<br>
On Wed, Apr 1, 2009 at 5:12 PM, Dylan Reinhardt<br>
<<a href="mailto:python@dylanreinhardt.com">python@dylanreinhardt.com</a>> wrote:<br>
> This might help:<br>
><br>
> <a href="http://docs.djangoproject.com/en/1.0/howto/static-files/" target="_blank">http://docs.djangoproject.com/en/1.0/howto/static-files/</a><br>
><br>
> HTH,<br>
><br>
> Dylan<br>
><br>
><br>
> On Wed, Apr 1, 2009 at 4:59 PM, kirby urner <<a href="mailto:kirby.urner@gmail.com">kirby.urner@gmail.com</a>> wrote:<br>
><br>
>> Django is driving me nuts I have to admit. It's the static media bit.<br>
>> It's all on my Ubuntu laptop so if someone wants to show me where I'm<br>
>> going wrong, the bagels are on me... (I had it working but then<br>
>> decided to move directories around...). Write me off list maybe. I<br>
>> live near the Bagdad.<br>
>><br>
>> Yeah, more Python talks would be good. I'm not altogether clear what<br>
>> the audience will be like but I think there's always room for "just<br>
>> the basics" i.e. a good old fashioned tutorial that doesn't go too<br>
>> fast. I know we're into test driven development but I think doctest<br>
>> is sufficient with noobs. Indeed, Python pedagogy is effective<br>
>> because interactive...<br>
>><br>
>> I could see PPUG offering a standard once month free class with<br>
>> rotating presenter, then spin-off more advanced topic classes that fly<br>
>> when they fill, sort of Saturday Academy still. Having something like<br>
>> a fixed schedule for the free ones, then scrambling amongst ourselves<br>
>> to always have an instructor, would be a fun way to make PPUG a<br>
>> stronger glue maybe. Just a thought.<br>
>><br>
>> Kirby<br>
>> _______________________________________________<br>
>> Portland mailing list<br>
>> <a href="mailto:Portland@python.org">Portland@python.org</a><br>
>> <a href="http://mail.python.org/mailman/listinfo/portland" target="_blank">http://mail.python.org/mailman/listinfo/portland</a><br>
>><br>
</div></div><div class="im">> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
</div>> URL: <<a href="http://mail.python.org/pipermail/portland/attachments/20090401/a977a3dd/attachment.htm" target="_blank">http://mail.python.org/pipermail/portland/attachments/20090401/a977a3dd/attachment.htm</a>><br>
<div><div></div><div class="h5">> _______________________________________________<br>
> Portland mailing list<br>
> <a href="mailto:Portland@python.org">Portland@python.org</a><br>
> <a href="http://mail.python.org/mailman/listinfo/portland" target="_blank">http://mail.python.org/mailman/listinfo/portland</a><br>
><br>
_______________________________________________<br>
Portland mailing list<br>
<a href="mailto:Portland@python.org">Portland@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/portland" target="_blank">http://mail.python.org/mailman/listinfo/portland</a><br>
</div></div></blockquote></div><br><br><blockquote style="margin: 1.5em 0pt;"></blockquote>