Inline formsets

2010-07-19 Thread Ryan Osborn
Hi,

I am trying to create a form in which a user can fill out details and
it will create a parent object and multiple child objects, much like
the django admin does when you set up a model to be a tabuar inline in
the admin.py.

I think I have to use inline formsets for this, but when I do this,
only the forms for the child objects get rendered (i.e. the ones for
Game, not Match).  Here is the code I have so far:

models.py

class Ladder(models.Model):
name = models.CharField(max_length=50)

class Player(models.Model):
user = models.ForeignKey(User, unique=True)
phone = models.CharField(max_length=12)

class LadderMembership(models.Model):
ladder = models.ForeignKey(Ladder)
player = models.ForeignKey(Player)
position = models.IntegerField(editable=False)

class Match(models.Model):
ladder = models.ForeignKey(Ladder)
winner = models.ForeignKey(Player, related_name='wins')
loser = models.ForeignKey(Player, related_name='losses')
date = models.DateField()

class Game(models.Model):
match = models.ForeignKey(Match)
winner_score = models.IntegerField()
loser_score = models.IntegerField()

views.py

@login_required
def ladder_challenge(request, ladder_id):
ladder = Ladder.objects.get(id=ladder_id)
if request.POST.get('post'):
pass
BookFormSet = inlineformset_factory(Match, Game)
formset = BookFormSet()
context = RequestContext(request,
{'ladder':ladder,'formset':formset})
return render_to_response('ladder/challenge.html',context)

ladder/challenge.html

{% extends "base.html" %}

{% block title %}Ladder Challenge{% endblock %}

{% block content %}

{% csrf_token %}
{{formset}}


{% endblock %}


I would be very grateful if someone could point out where I am going
wrong.

Thanks,

Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Multiple URLs, Common View

2010-07-19 Thread Ryan Osborn
You could try using this as your pattern:

(?P[a-zA-Z0-9-]+)

Ryan

On Jul 19, 1:03 am, Phil Edwards  wrote:
> On 18/07/2010 23:55, Phil Edwards wrote:
>
>
>
> > -begin-
> > def servePage(request):
> > if request.path[1:] == '':
> > thisPage = Page.objects.get(name = unicode('home'))
> > else:
> > thisPage = Page.objects.get(name = unicode(request.path[1:]))
> > sidebar_list = Page.objects.filter(category = thisPage.category)
> > article_list = Article.objects.filter(page =
> > thisPage.id).order_by('-amendedon')
> > return render_to_response('base.html', locals())
> > --end--
>
> Meh. Don't know what happened to the indentation there, but it should
> look like this:
>
> -begin-
> def servePage(request):
>      if request.path[1:] == '':
>          thisPage = Page.objects.get(name = unicode('home'))
>      else:
>          thisPage = Page.objects.get(name = unicode(request.path[1:]))
>      sidebar_list = Page.objects.filter(category = thisPage.category)
>      article_list = Article.objects.filter(page =
> thisPage.id).order_by('-amendedon')
>      return render_to_response('base.html', locals())
> --end--
>
> --
>
> Regards
>
> Phil Edwards   |  PGP/GnuPG Key Id
> Brighton, UK   |  0xDEF32500

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



Re: django mailing list app

2010-07-19 Thread Ryan Osborn
How about this?
http://www.freehackers.org/thomas/2010/04/03/announcing-colibri-10-alpha1-a-mailing-list-manager-with-a-django-based-web-interface/

Ryan

On Jul 18, 10:34 am, James Hancock  wrote:
> I am looking for an app that can manage subscriptions to a mailing list for
> a web app I am making. For those who are curious I am creating a web app for
> managing free english classes in japan. The current site is goeigo.org.
>
> Features:
> allow users to subscribe and unsubscribe to the list.
>
> Allow admins to send emails to certain groups.
>
> Example:
> Send an email to all of the classes in Japan.
> Send and email to all of the classes in a prefecture/state.
> Send and email to all of the users signed up for a class.
>
> Is there an application that would easily do this? I can't seem to find one
> yet.
>
> Thanks,
> Hancock

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Inline formsets

2010-07-23 Thread Ryan Osborn
Can anyone help with this?

Thanks,

Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Select widget options

2010-08-04 Thread Ryan Osborn
Hi,

Is there a way to change the text shown in the select widget for each
option?  I have the following form where player2 is a foreign key to
user.

class MatchForm(forms.ModelForm):
class Meta:
model = Match
fields = ['player2','result','date']
widgets = {'result': forms.RadioSelect(), 'date':
AdminDateWidget()}

The select widget shows the returned value from the User models
__unicode__ method, which is their username.  I want to change this to
display get_full_name.  Is there an easy way to do this?

Thanks,

Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Best-practice for building URLs in templates with JavaScript

2011-04-23 Thread Ryan Osborn
You could always make the payment_id group optional using a ?:

update_payment/(?P\w+)?

that way this will match either:

update_payment/

or

update_payment/123

Hope that helps,

Ryan

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



Re: Django Bigener

2011-05-07 Thread Ryan Osborn
The django tutorial that the others have mentioned is the best place to 
learn the basics.  There is also a book on E-Commerce in django: 
http://www.amazon.co.uk/Beginning-Django--Commerce-Experts-Development/dp/1430225351/ref=sr_1_9?s=books&ie=UTF8&qid=1304834462&sr=1-9

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



Django on FreeHostingCloud.com

2011-05-08 Thread Ryan Osborn
I recently came across FreeHostingCloud.com and wanted to see if it is 
possible to deploy django on it since it provides unlimited bandwidth, disk 
space and databases and also allows the use of python through fastcgi.

I have been following the guide in the documentation here:
http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache

I have uploaded the following .htaccess file to the public_html folder:

AddHandler fastcgi-script .fcgiRewriteEngine OnRewriteCond %{REQUEST_FILENAME} 
!-fRewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]

and then created the following mysite.fcgi file, also in the public_html folder 
and gave it 755 permissions in order to make it executable:

import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home//python/")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

I then uploaded django, flup and my project "mysite" to the python folder 
mentioned in the mysite.fcgi so that they should be on the python path.  
However, whenever I try to access the page, it always just shows the contents 
of the mysite.fcgi file instead of the django page.

I was wondering if anyone had any experience in using django on 
FreeHostingCloud or if anyone could spot anything I may have overlooked.

Thanks,

Ryan 

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



Re: Django on FreeHostingCloud.com

2011-05-10 Thread Ryan Osborn
Is no one able to offer any help?

Thanks,

Ryan

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



Repetition in urls.py

2011-03-24 Thread Ryan Osborn
Hi,

I am using django 1.3 and have the following in my urls.py for a
blogging application:

urlpatterns = patterns('',
url(r'$',
ArchiveIndexView.as_view(model=Entry,date_field='created',paginate_by=10),
name='blog_archive_index'),
url(r'today/$',
TodayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),
name='blog_archive_today'),
url(r'(?P\d{4})/$',
YearArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_year'),
url(r'(?P\d{4})/(?P[a-z]{3})/$',
MonthArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_month'),
url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/$',
DayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_day'),
url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/(?
P[\w\-]+)/$',
DateDetailView.as_view(model=Entry,date_field='created'),name='blog_entry_detail'),
)

I was just wondering if there was a simple way to condense this as
with django 1.2 I could add all this in to a dictionary like:

info_dict = {'model': Entry, 'date_field': 'created', 'paginate_by':
10}

Ryan

-- 
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: Repetition in urls.py

2011-03-24 Thread Ryan Osborn
Thanks guys, works great

On Mar 24, 7:54 pm, akaariai  wrote:
> On Mar 24, 9:40 pm, Ryan Osborn  wrote:
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > I am using django 1.3 and have the following in my urls.py for a
> > blogging application:
>
> > urlpatterns = patterns('',
> >     url(r'$',
> > ArchiveIndexView.as_view(model=Entry,date_field='created',paginate_by=10),
> > name='blog_archive_index'),
> >     url(r'today/$',
> > TodayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),
> > name='blog_archive_today'),
> >     url(r'(?P\d{4})/$',
> > YearArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_year'),
> >     url(r'(?P\d{4})/(?P[a-z]{3})/$',
> > MonthArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_month'),
> >     url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/$',
> > DayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_day'),
> >     url(r'(?P\d{4})/(?P[a-z]{3})/(?P\d{2})/(?
> > P[\w\-]+)/$',
> > DateDetailView.as_view(model=Entry,date_field='created'),name='blog_entry_detail'),
> > )
>
> > I was just wondering if there was a simple way to condense this as
> > with django 1.2 I could add all this in to a dictionary like:
>
> > info_dict = {'model': Entry, 'date_field': 'created', 'paginate_by':
> > 10}
>
> > Ryan
>
> You can define the info_dict as above, and then use:
> url(r'$', ArchiveIndexView.as_view(**info_dict),
> name='blog_archive_index'), ...
>
>  - Anssi

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



unique_for_date not working?

2011-03-25 Thread Ryan Osborn
Hi,

I am using django 1.3 and have the following in my models.py:

class Entry(models.Model):
title = models.CharField(max_length=255)
slug = models.SlugField(unique_for_date='created')
created = models.DateField(auto_now_add=True, editable=False)

However, I can add an entry in the admin interface with a slug and
then immediately afterwards add another entry with the same slug
without an error being rasied.  Am I missing something?

Thanks,

Ryan

-- 
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: unique_for_date not working?

2011-03-25 Thread Ryan Osborn
Thanks for your reply Jacob.  The only problem with the method you
suggested is that the field now shows up in the admin form which
allows people to edit it.  I would rather that this didn't happen.  Is
there any way around this?

Thanks,

Ryan

On Mar 25, 1:54 pm, Jacob Kaplan-Moss  wrote:
> Hi Ryan --
>
> On Fri, Mar 25, 2011 at 3:55 AM, Ryan Osborn  wrote:
> > I am using django 1.3 and have the following in my models.py:
>
> > class Entry(models.Model):
> >    title = models.CharField(max_length=255)
> >    slug = models.SlugField(unique_for_date='created')
> >    created = models.DateField(auto_now_add=True, editable=False)
>
> > However, I can add an entry in the admin interface with a slug and
> > then immediately afterwards add another entry with the same slug
> > without an error being rasied.  Am I missing something?
>
> Basically what's happening is that `auto_now_add` and `editable`
> outdated kludges. Both work by actually excluding the field in
> question from the admin form, which means it's not available for
> validation so none is ran.
>
> A better approach, I think, would be to use something like::
>
>     import datetime
>     from django.db import models
>
>     class Entry(models.Model):
>        title = models.CharField(max_length=255)
>        slug = models.SlugField(unique_for_date='created')
>        created = models.DateField(default=datetime.date.today)
>
> This will work as expected in the admin and in model forms.
>
> Jacob

-- 
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: unique_for_date not working?

2011-03-25 Thread Ryan Osborn
The problem with this is that the unique_for_date no longer works
again

On Mar 25, 3:15 pm, Daniel Roseman  wrote:
> On Friday, March 25, 2011 3:01:47 PM UTC, Ryan Osborn wrote:
>
> > Thanks for your reply Jacob.  The only problem with the method you
> > suggested is that the field now shows up in the admin form which
> > allows people to edit it.  I would rather that this didn't happen.  Is
> > there any way around this?
>
> > Thanks,
>
> > Ryan
>
> Add it to the `exclude` list in your admin class.
> --
> DR.

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



Re: How to send emails?

2011-03-30 Thread Ryan Osborn
Hi,

django-registration can take care of this for you: 
https://bitbucket.org/ubernostrum/django-registration/

Ryan

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



Re: How to store multiple instances of a single object in the database

2011-03-30 Thread Ryan Osborn
Have you considered using the 'through' argument for the many to many 
field?  This lets you specify your own intermediate table to which you can 
add extra data.  So you could add in a quantity field so you would know how 
many of each molecule you need.

Here is the documentation: 
http://docs.djangoproject.com/en/1.3/topics/db/models/#intermediary-manytomany

Hope this helps,

Ryan

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



Re: How to store multiple instances of a single object in the database

2011-03-31 Thread Ryan Osborn
No problem, glad to have helped :)

-- 
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: Static/media url in template

2011-04-05 Thread Ryan Osborn
You need to have *django.core.context_processors.media* in your 
TEMPLATE_CONTEXT_PROCESSORS 
setting in order to use this template tag.

The same with STATIC_URL, you need to have *
django.core.context_processors.static* in order to use it.

Hope this helps,

Ryan

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



How to find list of blocking issues for django releases?

2014-05-23 Thread Ryan Osborn
How can I go about finding a list of the issues that are blocking a djago 
release?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/01eb499e-407d-494f-80f6-061cb7035931%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.