Re: Best Practices in Implementing Mini-Content Boxes Across the Site

2008-10-16 Thread Lisa Dusseault
+1 - thanks to Ronny, Bruno and Daniel's advice in this thread.  It helps
sometimes to have pointers to info/tools in the context of a problem, even
if I was vaguely aware of the info/tools before.

On Thu, Oct 16, 2008 at 4:30 AM, Israel Dacanay Canasa <[EMAIL PROTECTED]>wrote:

>
> Bruno,
>
> Thanks a lot!
>
> I didn't know that Django will include the templatetags of all apps
> mentioned in settings.py. I thought that templatetags are included
> only within the context of the current app accessed by the browser.
>
> Now everything looks clearer, and I feel that I just got out from
> being a newbie, because this information gave me an idea on how to do
> almost all the things that I want for my project.
>
> Thank you so much!
>
> Israel Dacanay Canasa
> -
> Email: [EMAIL PROTECTED]
> Cel #: +63917-404-8030
> Phone #: +632-567-2635
>
> On 10 16, 08, at 7:12 PM, bruno desthuilliers wrote:
>
> >
> > On 16 oct, 12:34, raeldc <[EMAIL PROTECTED]> wrote:
> >> Hello Again Guys!
> >>
> >> With your guidance, I was able to get a pretty good idea on how to
> >> put
> >> mini-content boxes on my website.
> >>
> >> However, one thing I realized (with my still limited understanding of
> >> Django), is that templatetags are actually coupled with apps. To
> >> create templatetags, I must make it as a templatetags module inside
> >> my
> >> apps. It doesn't look "loosely coupled" to me if I want to reuse the
> >> same templatetag on different apps.
> >
> > It's just like for any function/class/whatever you want to make
> > reusable in different contexts : put it in a separate package /
> > module / app.
> >
> > Since indeed Django requires templatetags to live in a "django
> > application" - that is, a python package with a more or less defined
> > layout -, then the solution is obvious:
> >
> > - start a new 'mycustomtags' app
> > - move your templatetags to this app
> > - put that app somewhere in your PYTHONPATH (apps don't have to live
> > in your project, cf django.contrib.XXX apps)
> > - and of course mention that app in your project
> > settings.INSTALLED_APPS
> >
> > Note that just any 'component' of a django app is optional. IOW, you
> > don't have to have models AND views AND urls AND whatnot - just put
> > what makes sense. In your case, your mycustomtemplatetags app layout
> > would only contain the mandatory[1] top-level __init__.py, the
> > templatetags directory - with it's own mandatory __init__.py -, and
> > your templatetags file(s). FWIW, that's just what the template_utils
> > app do:
> > http://code.google.com/p/django-template-utils/
> >
> > 1] mandatory to make Python consider this directory as a Python
> > package.
> >
> > HTH
> >
> >
> > >
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: invalid literal for int() with base 10 trying to access uploaded image

2008-09-18 Thread Lisa Dusseault
I've seen the same problem with FileFields, so it's not just ImageFields.  I
haven't figured it out yet.  I can make a link to the file work from the
main UI, but I don't know how the admin constructs its link in an unmodified
admin form.

Lisa

On Thu, Sep 18, 2008 at 5:17 AM, silk.odyssey <[EMAIL PROTECTED]> wrote:

>
> I am using an imagefield from the admin interface. I can upload images
> without problems but when I click the link to view the image, I get
> the following error.
>
> invalid literal for int() with base 10: '1/photos/desktop.png'
>
> Any idea what's wrong? I am using django 1.0.
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: change file upload destination "on the fly" for tests

2008-09-17 Thread Lisa Dusseault
I have a bunch of unit tests that do file upload too.  E.g.:

def testBasics(self):
testpage = self.test_report.page_set.create(slug="testpage", title =
"Test Page")
self.assertEquals(testpage.report, self.test_report)
testpage.page_spec.save("testgraphspec.json",
ContentFile(TESTSPECSTR))
graphspecs = testpage.graphspecs()
assert "age1" in graphspecs.keys()
self.assertEquals(graphspecs["age1"].slug, "age1")

I have no idea if this is the best way or not, but it seems that the django
unit test magic does the right thing here, and the file that is created upon
upload gets cleaned up afterward,  without any need to change the MEDIA
location or do other painful things.

Are you using django's "manage.py test" to run the tests?

Lisa


On Wed, Sep 17, 2008 at 11:42 AM, Faheem Mitha <[EMAIL PROTECTED]> wrote:

>
>
> Hi,
>
> I wrote some unit tests for file upload. since I didn't want the files in
> the unit tests to be uploaded to the "official locaion", I changed the
> upload location by reassiging MEDIA_ROOT to something else, '/tmp' in this
> case.
>
> With an upgrade to Django 1.0, this method no longer works. The file
> upload appears to ignore the value of MEDIA_ROOT.
>
> Can anyone suggest another method? Apparently file upload is now more
> flexible - vide http://code.djangoproject.com/wiki/FileStorageRefactor.
> I'm not sure if it is possible to use this kind of functionality to do
> this. Suggestions welcome.
>
> Thanks, Faheem.
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: change file upload destination "on the fly" for tests

2008-09-17 Thread Lisa Dusseault
I have a bunch of unit tests that do file upload too.  E.g.:



On Wed, Sep 17, 2008 at 11:42 AM, Faheem Mitha <[EMAIL PROTECTED]> wrote:

>
>
> Hi,
>
> I wrote some unit tests for file upload. since I didn't want the files in
> the unit tests to be uploaded to the "official locaion", I changed the
> upload location by reassiging MEDIA_ROOT to something else, '/tmp' in this
> case.
>
> With an upgrade to Django 1.0, this method no longer works. The file
> upload appears to ignore the value of MEDIA_ROOT.
>
> Can anyone suggest another method? Apparently file upload is now more
> flexible - vide http://code.djangoproject.com/wiki/FileStorageRefactor.
> I'm not sure if it is possible to use this kind of functionality to do
> this. Suggestions welcome.
>
> Thanks, Faheem.
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---