Re: best way to organize models that store businesses/hours?

2009-03-17 Thread luxagraf

Alex-

Thanks for the suggestions... the 14 fields is definitely an option,
but like you said it feels awkward and would make it hard to adapt
should things change down the road.

Darryl -

> Darryl Ross  wrote:
> The first issue that comes to mind with that idea is what if the business has
> multiple opening periods in a day, such as open in the morning, closed over
> lunch and open in the afternoon again?

There are a few edge cases like that (also what to do for
establishments where the kitchen closes at one time, but the bar
remains open a bit later), which I haven't solved yet. But in both
cases loosely related models seem like the way to go.

cheers
Scott Gilbertson
luxag...@gmail
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



best way to organize models that store businesses/hours?

2009-03-16 Thread luxagraf

Hello all-

I'm working of a site that will store various business listings
(restaurants, bars, clubs etc) and then I'd like to also track the
hours each business is open... The ultimate goal being something like
lawrence.com's "open now" feature and other time-related queries of
that type. I'm trying to figure out the best way to store the hours
data and was wondering if anyone had any suggestions...

Because the open and close times vary by day of the week, storing them
directly in the business model (or the models inheriting from it in
this case) isn't possible.

My instinct is to use a separate model for the hours and then tie it
to the business model using generic relations to span various models.
I know that would work, but I can't shake the feeling that there's a
better way and I'm just not seeing it, so I thought I'd throw it out
there and see what others think.

I also should note that I'm not terribly concerned with the admin
interface aspect (I don't plan to enter most of this data through the
admin, it's already in a spreadsheet so I'll likely just load it all
at once using a script and make the occasional update via the admin).
My primary concern is optimizing for speed, i.e. the less joins, multi-
table and other expensive database queries the better.

If anyone has any suggestions or tips I'd love to hear them.

cheers
Scott Gilbertson
luxag...@gmail

--~--~-~--~~~---~--~~
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: Running django+apache on my macbook

2008-01-19 Thread luxagraf

Since I wrote that little guide Heather links to, I should point out
that while the mod_python bit works fine, the real problem on a
macbook with Leopard installed ends up being mysqldb (see
). I never have
been able to successful compile a version of mysqldb that would work
with Leopard's default Apache and MySQL.

In the end I wanted to mirror my remote production setup as closely a
possible so I went ahead and installed my own Apache2, python 2.4 and
the rest (OS X 10.5 comes with python 2.5, which can cause problems
when your production environment is python2.4).

But if you have any questions, feel free to e-mail me.

cheers
sng


On Jan 19, 2008 10:32 AM, Heather <[EMAIL PROTECTED]> wrote:
>
> You have to do some editing to make it work for 64 bit.  If you google
> mod_python leopard 64 bit you'll find some pages.  Here is one...
> http://blog.wired.com/monkeybites/2007/11/tips-and-tricks.html
> I have a macbook pro and am running django w/ mod_python and the built
> in apache2 and mysql.
>
>
> On Jan 18, 11:51 pm, John M <[EMAIL PROTECTED]> wrote:
> > Thakn you Graham, thats what I'm talking about.  I just finished
> > trying to compile mod_python, and it's not working, and I figured it
> > was something like that.
> >
> > So it's off to try mod_wsgi.
> >
> > Thanks
> >
> > J
> >
> > On Jan 18, 4:29 pm, Graham Dumpleton <[EMAIL PROTECTED]>
> > wrote:
> >
> > > On Jan 19, 8:49 am, John M <[EMAIL PROTECTED]> wrote:
> >
> > > > I guess I wasn't clear on the PURPOSE to do it, experience, not
> > > > practicality.
> >
> > > > I love the built-in django server, it's awesome, how much easier could
> > > > anyone make it, I think none.  But, I wanted to get ready for what it
> > > > might be like to deploy django at a hosting facility, or maybe even on
> > > > a home setup in Apache, thats all.  Since I have a macbook, with
> > > > Apache 2 installed, I figured I'd try it.  after checking the config
> > > > and various googles, it turns out that gettingmod_pythonon the mac
> > > > os X might not be as easy as say a debian apt-get kind of thing :).
> >
> > > > So, back to the question, how do I get a mac book with stock apache
> > > > installed, to run django?
> >
> > > Simple, don't use mod_python as it hasn't been patched to build
> > > cleanly on a 64bit Intel MacOSX Leopard machine. Use instead mod_wsgi
> > > 2.0 (RC) as it will build out of the box on MacOSX. See:
> >
> > >  http://www.modwsgi.org
> > >  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
> > >  http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX
> >
> > > Graham
> >
> > > > Thanks
> >
> > > > John
> >
> > > > On Jan 18, 12:08 pm, Christian Joergensen <[EMAIL PROTECTED]> wrote:
> >
> > > > > John M wrote:
> > > > > > OK,
> >
> > > > > > So I know Linux / Apache pretty well, never really done any 
> > > > > > hard-core
> > > > > > stuff with it.  Now I want to use apache on my macbook (intel) OSx
> > > > > > 10.5 (upgrade),but have no clue about how to do it.
> >
> > > > > > Googling for how to installmod_pythonresults in a lot of issues from
> > > > > > what I can find, 64bit vs 32bit, etc.
> >
> > > > > > So my question is, whats the easiest way to just get my macbook 
> > > > > > intel
> > > > > > 10.5 to run apache and Django.
> >
> > > > > You don't really need Apache andmod_pythonfor developing Django, just
> > > > > use the built-in webserver.
> >
> > > > > Take a look here:http://www.djangoproject.com/documentation/install/
> >
> > > > > Note the first paragraph of "Install Apache andmod_python". Developing
> > > > > your applications undermod_pythonis quite a hassle IMO.
> >
> > > > > Regards,
> >
> > > > > --
> > > > > Christian Joergensen | Linux, programming or web 
> > > > > consultancyhttp://www.razor.dk|   Visit us at:http://www.gmta.info
> >
>

--~--~-~--~~~---~--~~
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: Introducing DjangoSites.Org

2007-06-20 Thread luxagraf

Ross-

Very nice!

One thing, When I signed up, at first I forgot to put @gmail.com in
the sign-up form and it came back with a "please correct the errors
below" message, but didn't actually highlight the errors (using FF2 on
a Mac for what it's worth).

Otherwise, very nice.

cheers
sng

On 6/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> A week ago I posted about a project I was working on, Djangosites.org.
> It's intended to be a showcase of what's out there in Django Land.
>
> I've received some fantastic feedback, and a new website template
> courtesy of maddiin.
>
> The site is now live and ready to be used and abused. Please, login
> and submit your sites. I've added a quick blurb to the top of the
> DjangoPoweredSites page directing people to the new site as well as
> the existing list.
>
> Hopefully it proves useful to newcomers to the community. What I'd
> really love is if some of the Django heavyweights could post some
> sites up - it would kick ass if this can eventually replace the
> DjangoPoweredsites wiki page.
>
> Thanks to maddiin for the site design, and to the django-users mailing
> list for feedback and suggestions. If you have any feedback please
> don't hesitate to email it to me and I'll take it all on board.
>
> Most of all, thanks to the Django community for rocking. I know you
> guys will embrace this :)
>
> Regards,
>
> Ross Poulton
> www.rossp.org
> www.djangosites.org
>
>
> >
>

--~--~-~--~~~---~--~~
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: Re: problems turning debug off

2006-12-05 Thread luxagraf

Adrian

Thanks for your help. I check the logs and the error generated was
"TemplateNotFound" for 404.html. So I created a 404 template and now
it works fine (even though the page doesn't generate a 404 error),

Curiously it only did that on pages that are served by the flatpages
app, must be something in  django.flatpages that needs a 404 template
I guess.

And yes I am running django through mod_python

Anyway it works now. Thanks again.

cheers
sng


On 12/5/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 12/6/06, luxagraf <[EMAIL PROTECTED]> wrote:
> > I'm trying to launch a site and every time I turn off django's
> > debugging or python debugging I start getting 500 error pages, but
> > when the debugging is on none of those pages throw any errors?
> >
> > Anyone seen this before?
> >
> > Am I missing something.
>
> Hi luxagraf,
>
> I assume you're using mod_python and you're getting the standard
> Apache "500 Server Error" pages, in which case you should check your
> Apache error log. If your error page is being served by Django, make
> sure your ADMINS and EMAIL_HOST settings are correct -- then, Django
> will e-mail you the tracebacks for any error.
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com
>
> >
>

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problems turning debug off

2006-12-05 Thread luxagraf

I'm trying to launch a site and every time I turn off django's
debugging or python debugging I start getting 500 error pages, but
when the debugging is on none of those pages throw any errors?

Anyone seen this before?

Am I missing something.

sng


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---



Help with Contact Form

2006-11-30 Thread luxagraf

Hello all I have a quick question, I just whipped up a custom
manipulator for a contact form and, following the suggestion in the
django docs, I'm using a

HttpResponseRedirect("/contact/thankyou/")

to get rid of the post data, but what I'd like to display at that
redirect url is a copy of the message the user sent... but I can't
figure out how to do that...

is there a way to do something like this:

HttpResponseRedirect("/contact/thankyou/"
extra_context={'my_form_data': data_as_list})

note that I'm not storing the message, there is no model to query to,
I thought of using a cookie, but the seems unnecessary...

any suggestions?

--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---



Character length issue using core.mail.send_mail

2006-11-27 Thread luxagraf

Hello all

I've got an issue with django.core.mail that's driving me crazy... I'm
using a custom manipulator to handle the data submitted through a web
contact form... everything works great except that when I import and
try to use send_mail() from django.core.mail I get strange results

send_mail() works great as long as the email address in question is
under 21 characters... doesn't matter what 21 characters they are, but
if it goes over that limit the page throws a mod_python "list index
out of range" error...

Anybody have any insight into this?

The strange thing is another app in the same project uses the exact
same code and works perfectly, no matter what the address length is...
I've been pulling my hair out over this for two hours now and I can't
figure it out, any help is appreciated.

here's my manipulator if that helps:

class ContactManipulator(forms.Manipulator):
def __init__(self):
self.fields = (
forms.EmailField(field_name="email", is_required=True),
forms.TextField(field_name="name", length=30, 
maxlength=200,
is_required=True),
forms.TextField(field_name="subject", length=30, 
maxlength=200,
is_required=True),
forms.LargeTextField(field_name="comments", 
is_required=True),
)

def contact_form(request):
manipulator = ContactManipulator()
if not request.POST:
errors = new_data = {}
form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('contact_form.html', {'form': form})
else:
new_data = request.POST.copy()
errors = manipulator.get_validation_errors(new_data)
if not errors:
manipulator.do_html2python(new_data)
mail_subject = '[Sweetleaf]  %s ' % 
(new_data['subject'])
mail_body = 'Hello Admin, \n my name is %s \n I 
wrote:\n\n %s \n\n
you write me back at %s ' % (new_data['name'], new_data['comments'],
new_data['email'])
send_mail(mail_subject, mail_body, '[EMAIL PROTECTED]',
['[EMAIL PROTECTED]'], fail_silently=False)
return HttpResponseRedirect("/contact/thankyou/")
else:
form = forms.FormWrapper(manipulator, new_data, errors)
return render_to_response('contact_form.html', {'form': form})



I have a feeling I'm gonna feel pretty silly for this when I sort it
out, but in the mean time it's the only thing holding up the launch of
this site.

Also as a footnote, I have this manipulator in my view.py... is that
the recommended place for it or should I move that somewhere else?

cheers
sng


--~--~-~--~~~---~--~~
 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: Re: Re: Re: Custom view problems

2006-10-24 Thread luxagraf

Russ-

print_r does roughly what {% debug %} does, thanks for that tip.

I realized that I can't use the method you mentioned because my Tag
model has a slug field but the Essay model only stores the Tag.name
value, which is fine until I have multiword tags. So i'd either need
to strip out the dashes fromt the GET var or use two queries. Both of
which feel clumsy to me, but for now it'll have to do.

That doesn't explain why I'm getting an empty list object (because the
page I was testing was a single word tag), but I guess for now I'll
just use the double query method until I can come up with a cleaner
way of doing it.

Thanks again for taking the time to help.

cheers
sng
<http://luxagraf.net>


On 10/24/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> On 10/24/06, luxagraf <[EMAIL PROTECTED]> wrote:
> >
> > Which works and the template loads, but there doesn't seem to be
> > anything in the object essay_list...
>
> Your view and template appear to be ok, as long as the 'tag' argument
> is of a type compatible with the query.
>
> > is there a
> > python way to have essay_list get spit out something like
> > print_r(essay_list) would do in php...?
>
> I have never used PHP, so I have no idea what print_r does; however,
> here are a few useful debugging techinques:
>
> 1) Does it work in a shell? ./manage.py shell provides a shell
> environment that lets you try out queries before you use them in your
> view. This can be used to check that your query works, and that there
> are data to return.
>
> 2) Put some print statements in your view. The output of these
> statements will appear in the development server log. Use these
> printouts to validate that a) 'tag' is value of a type that can be
> used in a query, and b) essay_list has entries that match the tag.
>
> 3) Put the {% debug %} template tag in your template. This will output
> a whole lot of data about your template, context, etc.
>
> Hope this helps.
>
> Yours,
> Russ Magee %-)
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Re: Re: Custom view problems

2006-10-24 Thread luxagraf

Russ-

Okay, one more question I changed the view around to make the code a
bit cleaner and use your suggestion as well as the render_to_response
shortcut I read about in the docs..


def view_items_tagged(request, tag):
essay_list = Essay.objects.filter(tags=tag)
return render_to_response('blog/tag_detail.html', {'essay_list':
essay_list, 'tag': tag})

Which works and the template loads, but there doesn't seem to be
anything in the object essay_list... In my template I have this code:

{% for essay in essay_list %}
 display stuff .
{% endfor %}

And nothing is displaying, that is the page loads fine and all the
auxilary content is there and {{ tag }} works fine, but essay_list is
empty, I think this has something to do with the context in render to
response, but I can't figure out what... the one thing I miss from php
is the print_r() method for debugging situations like this, is there a
python way to have essay_list get spit out something like
print_r(essay_list) would do in php...?

Anyway if you could point me in the right direction I'd be grateful


cheers
sng
<http://luxagraf.net>







On 10/23/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> On 10/24/06, luxagraf <[EMAIL PROTECTED]> wrote:
> >
> > Russ-
> >
> > ah. okay that makes sense. I was assuming that entry_set was a
> > contruct itself, but it's actually modelname_set...
>
> Yup.
>
> > So to make it purely abstract, things are working like this:
> >
> > response_obj = get_object_or_404(Model, param=value)
> > response_obj.modelname_set.all().select_related()
> >
> > and I can just append as many models as have M2M relations with the
> > first? Or is there a better way to do this?
>
> You appear to be on the right track. Is there a better way? It depends
> a bit on your application; however,
>
> model_list = ModelName.objects.filter(response=response_obj)
>
> might be slightly cleaner - it returns an empty list if there are no
> models for a response, rather than the 404 exception that your
> approach will yield (plus, it does it in a single query, rather than
> two queries)
>
> > Anyway thanks so much for your help, I've got it working now.
>
> No problems. Glad I could help.
>
> Yours,
> Russ Magee %-)
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Re: Custom view problems

2006-10-23 Thread luxagraf

Russ-

ah. okay that makes sense. I was assuming that entry_set was a
contruct itself, but it's actually modelname_set...

So to make it purely abstract, things are working like this:

response_obj = get_object_or_404(Model, param=value)
response_obj.modelname_set.all().select_related()

and I can just append as many models as have M2M relations with the
first? Or is there a better way to do this?

Anyway thanks so much for your help, I've got it working now.

cheers
sng
<http://luxagraf.net>




On 10/23/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>
> On 10/24/06, luxagraf <[EMAIL PROTECTED]> wrote:
> >
> > "'Tag' object has no attribute 'entry_set'"
> >
> > Which I believe means that get_object_or_404 is not finding anything
> > to return... and yet the correct tag is being passed in and the error
> > reporting shows the value of tag being what it should...
>
> I read this as 'get_object_or_404' is returning an object, but that
> object doesn't have an entry_set attribute. If get_object_or_404 was
> not finding an object, it would raise a Http404 exception.
>
> I can't say I know the 23 excuses data model, but if Entry is supposed
> to have an m2m or m2m relation with Tag (which is implied by you
> requesting tag.entry_set), the error you are reporting would be
> consistent with not having added the Entry model to your application.
> Without the data model, its difficult to help more than this.
>
> Yours,
> Russ Magee %-)
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Custom view problems

2006-10-23 Thread luxagraf

Hello all,

I'm new to django but I'm figuring things out for the most part. I've
built a simple blog app with entries and tags as a kind of starter
app...

Anyway I'm having a problem with my first attempt at a custom view.
What i want to do is show a list of entries that have a given tag so
I've written my own view to handle this (I couldn't figure out a way
to do ManyToMany with generic views, if I've missed something there
feel free to enlighten me).

in my urls.py I have

urlpatterns = patterns('luxagraf.blog.views',
(r'tag/(?P[a-zA-Z0-9_.-]+)', 'view_items_tagged'),
...

And then in my view.py I have:

from django.shortcuts import get_object_or_404
from django.template import RequestContext, loader
from django.http import HttpResponse

from luxagraf.blog.models import Tag

def view_items_tagged(request, tag):
e = []
a = get_object_or_404(Tag, slug=tag)
e = a.entry_set.all().select_related()
t = loader.get_template('blog/tag_index.html')
c = RequestContext(request, {'object_list': e, 'tags': tag})
return HttpResponse(t.render(c))

Which is more or less copied from the source of 23excuses blog and
adapted to fit my naming scheme. So far so good except that I keep
getting the error

"'Tag' object has no attribute 'entry_set'"

Which I believe means that get_object_or_404 is not finding anything
to return... and yet the correct tag is being passed in and the error
reporting shows the value of tag being what it should...

Can anyone explain the error of my ways?

much appreciated

cheers
sng


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---