Re: Form Wizard won't proceed past the second step

2009-08-14 Thread Dustin

Looks like you're not implementing the done() method required in
FormWizard sub-classes.
http://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/#creating-a-formwizard-class

On Aug 14, 11:29 am, Adam Olsen  wrote:
> I've got a FormWizard with two forms in it.  It validates the first
> form correctly, and proceeds onto the second form, but when I click
> submit for the second form, it does no validation and just jumps back
> to the first step.  I get no errors in this process.
>
> My urls.py looks like this:
>
> urlpatterns = patterns('sendoutcards.retail.views',
>     (r'^register/$', forms.RegistrationWizard()),
> )
>
> My FormWizard, two Forms, and the templates involved are here:
>
> http://dpaste.com/hold/80601/
>
> What am I doing wrong?
>
> --
> Adam Olsen
> SendOutCards.comhttp://www.vimtips.orghttp://last.fm/user/synic
--~--~-~--~~~---~--~~
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 model layout for option variance

2011-01-10 Thread Dustin
I am building an interface that consists of several fields, mostly
drop down boxes (menus).  Depending on the menu item (option) selected
in each menu, however, there may be a unique set of "properties" that
the user should be presented with.  e.g. "Option A may have the
customizable properties Quantity and Size, Option B may have the
property Radius only, and still Option C may have no properties at
all." and properties may be text input, or perhaps another menu
altogether.

I am trying to determine the best method of setting this up in
Django.  Here are my two ideas:

IDEA #1: Use a class for each set of menu items, a class for each set
of options, and store the possible properties in a dict.

class MenuItem(models.Model):
  item = models.CharField(max_length=200, unique=True)

class Option(models.Model):
  key = models.CharField(max_length=200)
  value = models.CharField(max_length=200)

class Category(models.Model):
  selection = models.ForeignKey(MenuItem)
  options = models.ManyToManyField(Option, null=True)
  OPTION_DICT = {
'Option A': {
  'quantity': {
'type': 'text',
  },
  'size': {
'type': 'menu',
'options': ('1 inch', '2 inches', '3 inches'),
  }
},
'Option B': {
  'radius': {
'type': 'text',
  },
},
  }

class MyForm(models.Model):
  category = models.ForeignKey(Category)
  ...


This is obviously a generic layout.  In reality, there will be
Category, MenuItem, and Option base classes, and  copies (inherited)
of all 3 for each category with an specific option rules needed.
Initial data would obviously have to be put in the DB before this
would work at all.


IDEA #2:  Put the whole set of categories, options and rules in a
dictionary and scrap the Category, MenuItem, and Option models all
together.  I figure performance would be marginally better this way,
and also easier to code/modify (maybe).


Is there another solution I'm missing here?  I want to weigh all
options before fully committing.  It's a fairly large project and I'd
like to get it right the first time.

-- 
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: image servers?

2011-01-10 Thread Dustin
I haven't used Rackspace, but i would assume (hope) they support
remote mounting.

I would use sshfs to mount the Rackspace server on your local drive
(on the Django server) and reference that in MEDIA_ROOT

e.g.

sshfs usern...@my.rackspace.domain:/path/to/rackspace/home/dir /mnt/
rackspace

change MEDIA_ROOT to

MEDIA_ROOT = '/mnt/rackspace/'

and MEDIA_URL

MEDIA_URL = 'my.rackspace.domain'

On Jan 10, 6:55 pm, garagefan  wrote:
> so i bit the hype and got myself a rackspace cloud account. i also got
> a rackspace file account for image serving. i would like to write
> something that overrides where all images are saved, regardless of the
> model that requests the save.
>
> what would this be? would i make this a middleware? I assume i need to
> extend and "replace" the default "save file to MEDIA_ROOT directory"
>
> i havent had to extend or replace django's default behavior, so before
> i start digging in to this, i need to know the best place for this...
> which, i assume would be middleware. yes?
>
> thanks!

-- 
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: Any advice on why my template inheritance does not seem to be working??

2011-02-09 Thread Dustin
Wow, thank you. Yes that was exactly my problem. My view code was:

def problems(request):
problems_list = Problems.objects.all()
return render_to_response('problems_index.html', {'problems_list':
problems_list})

And as soon as I changed it to "problems_index_problist.html" it
worked!!

This makes much more sense now, in terms of how template inheritance
works...

Thanks,
Dustin

On Feb 9, 11:14 am, creecode  wrote:
> Hello Dustin,
>
> I suspect your are confused about how inheritance works.
>
> On Feb 9, 7:43 am, Dustin D  wrote:
>
> > No matter what I do, when I visit the parent, it just displays the
> > default value inside {% block problist %} as if the child doesn't
> > exist.
>
> I think you are referencing the parent template something like...
>
> return render_to_response ( 'problems_index.html',
>         context_instance = RequestContext ( request, context ) )
>
> Which only pulls in the parent template because there is no include
> tag to pull in the child template.
>
> I think what you need to do is reference the child template in your
> view.  Something like...
>
> return render_to_response ( 'problems_index_problist.html',
>         context_instance = RequestContext ( request, context ) )
>
> I think you'll also need to adjust your template code once you get an
> understanding of how the inheritance works.
>
> The relevant view code would help us determine if this is indeed the
> case.
>
> Toodle-lo.
> creecode

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



Unable to log in to admin using RemoteUserMiddleware

2011-04-30 Thread Dustin
Hello,

I'm having difficulty finding a fix for this problem. Someone posted
the exact same problem I am having about a year ago. Has there been
any solution to this?

Basically, RemoteUserMiddleware is working just fine after I followed
these directions:
http://docs.djangoproject.com/en/dev/howto/auth-remote-user/#configuration

My problem is that I can not seem to log into the admin site with any
users, even superusers created via manage.py

Here is a link to the old article:
http://groups.google.com/group/django-users/browse_thread/thread/0fe27b2ca4056c8a/7a12438967014133?show_docid=7a12438967014133

Any help will be extremely appreciated :)

Thank you,
Dustin

-- 
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: Unable to log in to admin using RemoteUserMiddleware

2011-05-01 Thread Dustin
So I figured out a hack to solve this problem and hopefully this will
save someone from this problem in the future.

After RemoteUserMiddleware is included in the settings.py file, when
you visit any area of the site where your server asks you to log in,
once you log in it will automatically create an entry for your
username in the database table auth_user. This row with your server's
username is created the first time you do this.

Now the problem is, when you go to the admin site, you are technically
already logged in to your server, but you see the dialog box asking
for username and password. You might think to yourself, "I should just
be able to enter a superuser's credentials and log in", but this will
not work. And if you think about it, it's kind of weird. Your already
logged in to your server via your username, which your django app is
now using, and then trying to enter someone else's credentials (i.e.
the superuser). So its like your trying to log in on top of your
servers username with the superuser. Kind of weird.

So what can you do?

If you look at the entry in the database that was generated when you
first logged in to your django app using your server's username, the
values 'is_staff' and 'is_superuser' are set to '0'. All you need to
do is manually set 'is_superuser' for that entry. Then when you go to
the admin site, it will automatically authenticate you, no need to
provide credentials again.

So for mysql you would need to run the following command (substitute
'usern...@your-server.com' with the username you use for your server):

UPDATE auth_user SET is_superuser='1' where username = 'username@your-
server.com';

I hope this helps anyone that has the same issue. Feel free to contact
me with any questions at dtdan...@indiana.edu

Cheers!
Dustin

On Apr 30, 9:40 pm, Dustin  wrote:
> Hello,
>
> I'm having difficulty finding a fix for this problem. Someone posted
> the exact same problem I am having about a year ago. Has there been
> any solution to this?
>
> Basically, RemoteUserMiddleware is working just fine after I followed
> these 
> directions:http://docs.djangoproject.com/en/dev/howto/auth-remote-user/#configur...
>
> My problem is that I can not seem to log into the admin site with any
> users, even superusers created via manage.py
>
> Here is a link to the old 
> article:http://groups.google.com/group/django-users/browse_thread/thread/0fe2...
>
> Any help will be extremely appreciated :)
>
> Thank you,
> Dustin

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



Any advice on why my template inheritance does not seem to be working??

2011-02-09 Thread Dustin D
For some reason, I cannot seem to get template inheritance working and
I have tried everything I can think of, so now I'm asking here. My
problem is this: When I use one template, everything works fine. But
as soon as I try to offload some of the code in a child, it just
doesn't show up. Here are my files:

In my settings file I have added the template directory:

TEMPLATE_DIRS = (
"/home/dtdannen/Projects/contestron/contestron1/templates",
)

My views.py points to the right place. Here is my 'base' or 'parent'
file (filename "problems_index.html"):

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

  
  Welcome to the problems page! Happy Coding :)



  {% block problist %}
  No problems currently exist, check back soon for new
problems
  {% endblock problist %}
  
  This is where the standard footer will go...



This file works just fine. In fact, if I just substitute the code from
the child and paste it into here (where the {% block problist %} is)
everything works. I know that its not a problem with my variables or
my database. Here is my 'child' file (filename
"problems_index_problist.html"):

{% extends "problems_index.html" %}

{% block problist %}
TEMPLATE INHERITANCE IS WORKING

  {% for prob in problems_list %}

  Description:
  {{ prob.description }}

  Solution:
  {{ prob.solution }}

  
  {% endfor %}
{% endblock problist %}

No matter what I do, when I visit the parent, it just displays the
default value inside {% block problist %} as if the child doesn't
exist. Both the child and parent files are in the same directory, the
directory I listed in my settings under template dirs.

I have spent like 2 hours trying to figure this out, reading stuff
online, and nothing so far. Any help will be very much appreciated.

Thank you,
Dustin

P.S. I know my files might seemed to be named funny, but that's
because I wasn't sure if the actual filename of the parent and/or
child matter to the template system. Any advice on this would be
great.

-- 
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: Unable to log in to admin using RemoteUserMiddleware

2011-05-01 Thread Dustin Dannenhauer
So I figured out a hack to solve this problem and hopefully this will save
someone from this problem in the future.

After RemoteUserMiddleware is included in the settings.py file, when you
visit any area of the site where your server asks you to log in, once you
log in it will automatically create an entry for your username in the
database table auth_user. This row with your server's username is created
the first time you do this.

Now the problem is, when you go to the admin site, you are technically
already logged in to your server, but you see the dialog box asking for
username and password. You might think to yourself, "I should just be able
to enter a superuser's credentials and log in", but this will not work. And
if you think about it, it's kind of weird. Your already logged in to your
server via your username, which your django app is now using, and then
trying to enter someone else's credentials (i.e. the superuser). So its like
your trying to log in on top of your servers username with the superuser.
Kind of weird.

So what can you do?

If you look at the entry in the database that was generated when you first
logged in to your django app using your server's username, the values
'is_staff' and 'is_superuser' are set to '0'. All you need to do is manually
set 'is_superuser' for that entry. Then when you go to the admin site, it
will automatically authenticate you, no need to provide credentials again.

So for mysql you would need to run the following command (substitute '
usern...@your-server.com' with the username you use for your server):

*UPDATE auth_user SET is_superuser='1' where username = '
usern...@your-server.com';*

I hope this helps anyone that has the same issue. Feel free to contact me
with any questions at dtdan...@indiana.edu

Cheers!
Dustin


On Sat, Apr 30, 2011 at 9:40 PM, Dustin  wrote:

> Hello,
>
> I'm having difficulty finding a fix for this problem. Someone posted
> the exact same problem I am having about a year ago. Has there been
> any solution to this?
>
> Basically, RemoteUserMiddleware is working just fine after I followed
> these directions:
> http://docs.djangoproject.com/en/dev/howto/auth-remote-user/#configuration
>
> My problem is that I can not seem to log into the admin site with any
> users, even superusers created via manage.py
>
> Here is a link to the old article:
>
> http://groups.google.com/group/django-users/browse_thread/thread/0fe27b2ca4056c8a/7a12438967014133?show_docid=7a12438967014133
>
> Any help will be extremely appreciated :)
>
> Thank you,
> Dustin

-- 
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: Filter_horizontal, applying filter on the right box - chosen items

2016-04-06 Thread Dustin Dobernig
I know this is question is old but I was looking for the solution myself 
and couldn't find an quick answer so I ended up just doing it myself. My 
solution is here https://djangosnippets.org/snippets/10560/

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/21f68d06-580e-431b-9921-d9ce3aa782e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


YAFU: Yet Another File Upload app...

2007-11-07 Thread Dustin Lang


Hi,

It didn't seem like any of the current Django file upload apps provided exactly 
the functionality I needed, so I hacked my own.  If the community is 
interested, I can try to polish it a bit and contribute it.

We deal with large uploads - up to hundreds of megabytes - so I wanted the 
following:

-the server should not keep the whole file in memory while the upload is 
progressing: it should stream to disk

-the server shouldn't have to copy the streamed data: it should only write the 
uploaded file once

-the user must get some feedback (a progress meter, or whatever) while the 
upload is progressing


I wrote some code that accomplishes this.  You can see an ugly demo at:
http://oven.cosmo.fas.nyu.edu:/upload-demo/

It works as follows:

-There is a python CGI program that accepts the upload.  It's not a Django view 
because it needs to stream the input as it comes in from the network; it runs 
as a normal mod_python handler.

-This CGI program parses the multipart/form-data input, looking for an 
"upload_id" field (which tells it which temp file to write the uploaded file 
to), and then looks for the file data itself and streams that to disk.  At the 
end of the upload, it produces a dictionary of the "normal" form fields and an 
object representing the uploaded file.

-We have a "main" form with several fields, and within that HTML page there are 
two IFRAMEs.  The first one contains an "upload" form: it requests a form which 
has a hidden "upload_id" field and a file input element (and a hidden submit 
button).  The second IFRAME contains an (initially hidden) upload progress 
meter.

-If the user submits the "upload" form (by hitting ENTER in the file input 
dialog), some Javascript gets triggered which displays the upload progress 
meter.  (The upload progress meter is a snazzy little AJAX dealie - quite nice 
but its CSS needs some attention).  If the file is empty or some other error 
occurs, the progress meter shows an error message.

-When the file upload starts, the CGI writes "Upload in progress..." and when 
if it finishes successfully, it writes a hidden  element.  Some Javascript 
notices that the upload form's IFRAME finished loading, and it looks for that 
 to ensure that the upload was successful.  If so, it grabs the 
"upload_id", saves it in a hidden field in the main form, and submits the main 
form.

-The main form goes to a normal Django view, and it can use the "upload_id" to 
pull a reference to the file out of a database.


I know it sounds overly complicated, but it seemed to be necessary to achieve 
the user experience and server-side requirements I had.

Before it's ready for prime-time, it will need some fixes:

-the form-multipart parsing is currently hacky; the RFC should get translated 
into regular expressions

-the upload form handler currently doesn't really do anything with the other 
form fields - it should store them in a database.

-there's not a lot of checking of upload_id values - one could easily add some 
rules that only upload_ids that have been generated by the server can be 
uploaded; and that it's invalid to try to re-upload a file; or that only 
authenticated users are allowed to upload files.

-I'm new to python and Django, so I'm sure there is a lot of polishing that 
could be done.

-I tried to work out a solution that didn't require two IFRAMES (one for the 
file form, one for the progress meter), but couldn't get it to work.


Anyway, let me know if you're interested in this code and I'll bundle it up if 
anyone is.

Cheers,
dstn.


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



Django on Debian Sarge?

2006-07-02 Thread Dustin Laurence
Hi, I was looking at trying Django for a project and noticed that in the
comments to the installation directions it was claimed that Debian
Sarge's mod_python isn't recent enough to run Django.  That would be a
big complication.  Is anyone running Django on Sarge, and can anyone
confirm that it does/does not need something besides the bog-standard
apache2/mod_python/postgres/etc already in the stable package pool?

Though it's much less important, I wouldn't mind knowing the same answer
for Gentoo (with just x86 keywords) since it might be handy to do some
development on a Gentoo laptop.

Dustin



pgpZNjkLIvwIb.pgp
Description: PGP signature


Re: Django on Debian Sarge?

2006-07-02 Thread Dustin Laurence
On Sun, Jul 02, 2006 at 09:09:59PM -0700, Iain Duncan wrote:
> 
> I haven't installed on Sarge, but on Gentoo it's no problem because
> installing the newest stable packages is the default ( sarge's are
> tested much longer with much longer release cycle ).

I normally would assume so, but here is what bothered me.  From the
install page comments:

> pol April 21, 2006 at 4:23 p.m.
>
> Though is says states that only "mod_python 3.x" is required, this is
> wrong. You must ahve version 3.2.7 at least. Debian (sarge) stable only
> includes 3.1.3, so you will have to get and install the newest version
> of mod_python manually.

but

lindy laurence # emerge mod_python -p

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] dev-python/mod_python-3.1.4-r1
lindy laurence #

which would indicate that Gentoo's stable mod_python still isn't new
enough, odd as that sounds.  It's only one patchlevel higher than
Sarge's version.

> ...My home dev box is
> gentoo, all I had to do was emerge mod_python and the mysqldb e-build (
> can't remember name ), checkout django from svn, and follow the
> instructions on the tutorial.

OK, well, that's reassuring, and maybe indicates that that comment is
wrong and Sarge is likely to work too.

Dustin



pgpexRcom6bJ0.pgp
Description: PGP signature


Re: Django on Debian Sarge?

2006-07-03 Thread Dustin Laurence
On Mon, Jul 03, 2006 at 07:54:44AM -0700, Rudolph wrote:

> I've got Django running on Sarge and de default mod_python package. No
> problem at all.

Perfect, that's what I was hoping someone would say.  What about putting
a note at

http://www.djangoproject.com/documentation/install/

that the previous note about Sarge's mod_python not being sufficient is
wrong?  Presumably it should come from someone who knows first-hand.

Dustin


pgp4q3VN7qY9L.pgp
Description: PGP signature


Filter by sum of filtered related objects?

2019-01-03 Thread Dustin Wyatt
Given the following models:


class Transaction(models.Model):
  amount = models.IntegerField()
  date = models.DateField()
  terms = models.ForeignKey('Terms')


class Terms(models.Model):
  name = models.CharField(max_length=100)
  timezone = models.CharField(max_length=50)


I need to annotate Terms with the sum of the related Transaction.amount's 
where the Transaction.date is between two dates and what those two dates 
are varies by Terms.timezone.

Possible?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/02257cdb-55a5-4ae9-bc2d-3b3fef0ef91f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.