Re: Using multiple form in Class Base View (CBV)

2015-04-09 Thread Dan Gentry
To modify the generic CBVs to handle two forms would mean changes in many 
of the base classes and mixins, including ProcessFormView, FormMixin, and 
BaseFormView.  It would make more sense to start with the View base class 
and roll your own methods.  If this is a one-off, I would probably keep it 
as a function based view. Not worth the work if you won't be reusing the 
code.

-- 
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/3f062e0e-ccd7-4001-95dc-b40da2240c8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Fixing a poorly written Django website (no unit tests)

2015-03-04 Thread Dan Gentry
No need to test the Django provided logic, but I like to write a few tests 
for each view that check the permissions, urls, updates, etc.  More of a 
functional test than a unit test.  I find that when these tests fail it is 
usually something changed somewhere else in the app.  For example, a change 
to a model that alters validation of an update.

In the case of your ecommerce code, complete tests can make your process of 
testing much faster compared to manual debugging work, plus they will test 
all areas of the code the same way every time.  Less chance for omission or 
error.  Confidence in the code goes up.

On Wednesday, March 4, 2015 at 7:03:14 AM UTC-5, Some Developer wrote:
>
> Hi, 
>
> I've been working on a Django website for about 2 months on and off and 
> am nearing the end of development work where I can start thinking about 
> making it look pretty and the after that deploy to production. 
>
> I've been doing lots of manual testing and I'm sure that the website 
> works correctly but due to the need to get the website in production 
> ASAP and my lack of unit testing experience with Django (I'm still not 
> entirely sure what the point of unit testing a 2 or 3 line Django view 
> is when you can clearly see if it is correct or not) I've neglected 
> automated testing. 
>
> While I'm still going to go ahead and launch the site in production as 
> soon as it is deployed I want to go back and add in all the unit tests 
> that are missing. How would you tackle this problem? 
>
> Most of the code is pretty simple but there are ecommerce elements that 
> I have tested extensively by running my code through the Python 
> debugger. These must always work. 
>
> I'm a bit ashamed that it has got this far but I'm mainly a C developer 
> and unit testing isn't pushed quite so hard there (even though it should 
> be). 
>
> Any help appreciated. 
>

-- 
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/bcfa95ac-8116-427d-bad0-25dc535161b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ListView and Deleteview

2015-02-02 Thread Dan Gentry
This is a bit of a stumper!

I don't see any big glaring issues.  A couple of housekeeping things:  Is 
there data in the table? Are you certain that you are using the correct 
template?

-- 
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/b84e3f59-d0da-40c4-a942-81f43861a6f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Class-Based CreateView and UpdateView with multiple inline formsets

2015-01-10 Thread Dan Gentry
I would suggest that in the UpdateView you should set the object to the 
master record being updated rather than to none for both get() and post().  


On Saturday, January 10, 2015 at 8:08:47 AM UTC-5, Ranjith Kumar wrote:
>
> Hello all,
> I have been trying to do Django class-based CreateView and UpdateView with 
> multiple inline formsets
>
> CreateView works fine but UpdateView is not working properly, If anyone 
> tried UpdateView with multiple inline formsets, please point me right 
> approach.
>
> *models.py*
> from django.db import models
>
> class Recipe(models.Model):
> title = models.CharField(max_length=255)
> description = models.TextField()
>
> class Ingredient(models.Model):
> recipe = models.ForeignKey(Recipe)
> description = models.CharField(max_length=255)
>
> class Instruction(models.Model):
> recipe = models.ForeignKey(Recipe)
> number = models.PositiveSmallIntegerField()
> description = models.TextField()
>
> *forms.py*
> from django.forms import ModelForm
> from django.forms.models import inlineformset_factory
> from .models import Recipe, Ingredient, Instruction
>
> class RecipeForm(ModelForm):
> class Meta:
> model = Recipe
>
> IngredientFormSet = inlineformset_factory(Recipe, Ingredient, extra=0)
> InstructionFormSet = inlineformset_factory(Recipe, Instruction, extra=0)
>
> *views.py*
> from django.http import HttpResponseRedirect
> from django.views.generic.edit import CreateView, UpdateView
> from django.shortcuts import get_object_or_404
>
> from .forms import IngredientFormSet, InstructionFormSet, RecipeForm
> from .models import Recipe
>
> class RecipeCreateView(CreateView):
> template_name = 'recipe_add.html'
> model = Recipe
> form_class = RecipeForm
> success_url = '/account/dashboard/'
>
> def get(self, request, *args, **kwargs):
> self.object = None
> form_class = self.get_form_class()
> form = self.get_form(form_class)
> ingredient_form = IngredientFormSet()
> instruction_form = InstructionFormSet()
> return self.render_to_response(
> self.get_context_data(form=form,
>   ingredient_form=ingredient_form,
>   instruction_form=instruction_form))
>
> def post(self, request, *args, **kwargs):
> self.object = None
> form_class = self.get_form_class()
> form = self.get_form(form_class)
> ingredient_form = IngredientFormSet(self.request.POST)
> instruction_form = InstructionFormSet(self.request.POST)
> if (form.is_valid() and ingredient_form.is_valid() and
> instruction_form.is_valid()):
> return self.form_valid(form, ingredient_form, instruction_form)
> else:
> return self.form_invalid(form, ingredient_form, 
> instruction_form)
>
> def form_valid(self, form, ingredient_form, instruction_form):
> self.object = form.save()
> ingredient_form.instance = self.object
> ingredient_form.save()
> instruction_form.instance = self.object
> instruction_form.save()
> return HttpResponseRedirect(self.get_success_url())
>
> def form_invalid(self, form, ingredient_form, instruction_form):
> return self.render_to_response(
> self.get_context_data(form=form,
>   ingredient_form=ingredient_form,
>   instruction_form=instruction_form))
>
> class RecipeUpdateView(UpdateView):
> template_name = 'recipe_add.html'
> model = Recipe
> form_class = RecipeForm
>
> def get_success_url(self):
> self.success_url = '/account/dashboard/'
> return self.success_url
>
> def get_context_data(self, **kwargs):
> context = super(RecipeUpdateView, self).get_context_data(**kwargs)
> if self.request.POST:
> context['form'] = RecipeForm(self.request.POST, 
> instance=self.object)
> context['ingredient_form'] = 
> IngredientFormSet(self.request.POST, instance=self.object)
> context['instruction_form'] = 
> InstructionFormSet(self.request.POST, instance=self.object)
> else:
> context['form'] = RecipeForm(instance=self.object)
> context['ingredient_form'] = 
> IngredientFormSet(instance=self.object)
> context['instruction_form'] = 
> InstructionFormSet(instance=self.object)
> return context
>
> def post(self, request, *args, **kwargs):
> self.object = None
> form_class = self.get_form_class()
> form = self.get_form(form_class)
> ingredient_form = IngredientFormSet(self.request.POST)
> instruction_form = InstructionFormSet(self.request.POST)
> if (form.is_valid() and ingredient_form.is_valid() and
> instruction_form.is_valid()):
> return self.form_valid(form, ingredient_form, instruction_form)
> 

Re: CBV with inline formset

2014-12-15 Thread Dan Gentry
I created a couple of mixins for a project that might help you.  See this 
gist: https://gist.github.com/dashdrum/03858d79ddfd9bba44d6

Pretty easy to use.  Here's an example Create view:

class RegistrationView(FormsetCreateMixin,CreateView):
template_name = 'registration/registration_form.html'
model = RegistrationMaster
form_class = RegistrationForm
detail_form_class = RegDetailFormSet


The mixin creates a new class variable: detail_form_class.  Set this in the 
view class declaration to point to your formset.  

I haven't tested this beyond the one project, so please tread carefully.  I 
hope this can at least get you moving in the right direction.



-- 
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/e4ddc6d2-b38d-4308-a424-949ebeb39996%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: modelformst save

2014-12-11 Thread Dan Gentry
While your form_invalid method is looking for reference_form as a 
parameter, the post method by default passes the form from 
get_form(form_class).  I would recommend overriding post to pass both form 
and reference form to form_invalid and form_valid.

Best of luck, Dan

-- 
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/46be40e0-584d-4486-b56f-a0c703fc677f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: UpdateView, ModelForm - form not redirecting problem

2014-06-01 Thread Dan Gentry
What does it do instead?


>

-- 
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/d58e49fa-a6f4-45e0-bf25-eedd5ebd0df9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Importing Existing Oracle Databases

2014-05-18 Thread Dan Gentry
I would suggest the managed option in the Meta class of the model.  Setting 
this to false will stop Django from trying to create the table, and it will 
instead expect it to already be available.  Also, the db_table option can 
be used if the name of your model is different than the existing table 
name.  See this page for details:

https://docs.djangoproject.com/en/dev/ref/models/options/

On Friday, May 16, 2014 4:24:03 PM UTC-4, G Z wrote:
>
> Hello,
>
> I've been looking online how to build a model in models.py of an existing 
> outside database. We developed and application in python, and I need to 
> import its data from an oracle database. However I tried this before by 
> establishing the fields in models.py to what the database says and running 
> syncdb but django still trys to create the database instead of using the 
> existing one if I remember right. What would be the best way to go about 
> doing what it is I want to do.
>

-- 
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/9dd87b6b-5fc2-4d1e-8bcd-698cce4d5bb1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How would you do this cleanly in Django (remembering the states of check boxes in multiple pages)

2014-05-09 Thread Dan Gentry
I would setup a data structure keyed off the session ID (or maybe a logged 
in user ID) that stored the transaction in progress for the user.  As the 
user went through the pages this data would be used to display what has 
already been selected and be updated for each screen.

I suppose that one could keep all of the information in the session data 
area as well.

-- 
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/08b54051-0a6a-421d-b9c4-2d629965247d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dreamhost for Django hosting.

2014-03-09 Thread Dan Gentry
I've had good luck hosting an app with a Dreamhost shared hosting account. 
 I even wrote a post about it a couple of years ago. (Maybe I should update 
it for 2014)

http://dashdrum.com/blog/2011/08/django-on-dreamhost/



On Saturday, March 8, 2014 11:53:54 PM UTC-5, Chen Xu wrote:
>
> I am trying to host my Django website on Dreamhost, I am wondering if 
> Dreamhost provides a virtual linux box that can allow you to ssh in?
>
>
>
> Thanks
>
>
> -- 
> ⚡ Chen Xu ⚡ 
>

-- 
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/c0fc29b5-8044-4081-b578-34d9d025d756%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: installing django trunk

2014-03-08 Thread Dan Gentry
Malik, in order to install within your virtualenv, you should activate it 
first  /bin/activate .  Then run the pip install command. 
 Cheers!

-- 
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/5d8b2639-fb63-4a35-8d6f-c54283bfd34e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: saving to two models from one class view

2014-01-14 Thread Dan Gentry
With a formset, like your application form, the template could look like 
one of these examples:


{{ formset.management_form }}

{% for form in formset %}
{{ form }}
{% endfor %}




{{ formset }}


(found on 
https://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-a-formset-in-views-and-templates
)

I'm not sure if this will do everything you want, but will get you past the 
current error.

-- 
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/cb43caf3-781f-4d41-9b4b-0fba73148b91%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What is the best way to have multiple admin users with there own models?

2013-09-06 Thread Dan Gentry
I would write views for the client to access their tables rather than using 
the built-in admin.  Your situation is not really what the admin was 
designed to do.  

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: verify before make changes?

2013-09-01 Thread Dan Gentry
Seems to me your call to get_object_or_404() would effectively check for 
the object's existence.  
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I really about to give up Django

2013-08-30 Thread Dan Gentry

Just my opinion, but I see no reason to use English names in models.  Use 
whatever you wish.  English speaking programmers have been using cryptic 
variable names for decades.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Script to move django 1.4.3 to 1.5.1

2013-08-30 Thread Dan Gentry
I've been using Django since v1.0, and when each major version is released, 
I run through the release notes to see what I need to change.  Russell is 
correct that most things will work from one version to the next, but I like 
to keep as up to date as possible to minimize my risk of hitting a 
deprecated feature.  Once I build a checklist, I can go through it for each 
app I support.  Doesn't take too long, and I feel I gain a better 
understanding of the new features this way.


>  

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: OperationalError: unable to open database file

2013-08-30 Thread Dan Gentry
When using sqlite3, one has to provide a full path to the database file. 
 For my projects I use something like this on my development machines (for 
a database file named 'db'):

import os 
PROJECT_DIR = os.path.dirname(__file__) 

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', 
'NAME': os.path.join(PROJECT_DIR, 'db'),
}
}


On Monday, July 22, 2013 1:48:43 PM UTC-4, Stian Sjøli wrote:
>
> i get this error while going throught the tutorial from the django 
> website. I am a mac user, and have modified my settings-file to use sqlite3 
> and the name variable to say "./mysite". Any suggestions why I get this 
> error?
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Iterating over fields in Formset

2013-08-11 Thread Dan Gentry
What is the purpose of checking test.id for a value of 3 or 6?

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Testing with legacy data

2013-08-08 Thread Dan Gentry
I'm not a fan of testing with actual data, except maybe as a final run to make 
sure no existing data breaks something or for stress testing with large amounts 
of data. Your legacy DB will not cover all of the possible cases that need to 
be tested in your code. 

Instead, write quality unit tests and functional tests that try all scenarios 
using factory boy or a similar data generator.  

My 2¢

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: more testing questions

2013-07-09 Thread Dan Gentry
1) I've been using Factory Boy to create test data rather than fixtures. 
 It is so much easier to ensure that I know exactly what data is available 
for a given test.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Class Based CreateView with foreign key question

2013-06-13 Thread Dan Gentry
I use the same pattern in my application, and it works just fine.


def dispatch(self, *args, **kwargs):

self.tc = get_object_or_404(TrainingClass, pk=kwargs.get('class_id', 
None))

return super(TrainingScheduleCreateView, self).dispatch(*args, 
**kwargs)  


def form_valid(self, form):

form.instance.training_class = self.tc

return super(TrainingScheduleCreateView,self).form_valid(form)


-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Handling delete and ability to support undo

2013-05-15 Thread Dan Gentry
A couple of thoughts:

Override the delete() method in your model to set the flag to True rather 
than delete the record.
Write a manager that filters out the 'deleted' records.  Use it for every 
query, except those used to retrieve or undo.

On Monday, May 13, 2013 3:07:16 PM UTC-4, Subodh Nijsure wrote:
>
> Hi, 
>
> I have requirement where users should be able to 'delete' the data 
> from database. 
>
> But at the same time we want to provide undo features. So what that 
> essentially means is keeping column 'is_deleted'  for every table and 
> when uses delete the data set value to 1. 
>
> And when users want to retrive some old records that were deleted show 
> them all the data regardless of value of is_deleted column. 
>
> Is there better way to provide this functionality when using django as 
> your CMS? 
>
> -Subodh 
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Multi-tenant database model with new user model?

2013-05-01 Thread Dan Gentry
Something I'm looking forward to learning as well.  My app uses the older 
user_profile approach.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Adding context data to a TemplateView?

2013-04-04 Thread Dan Gentry
Roy, I agree with Fallen that a subclass of TemplateView is required here. 
 I have used this technique often.  Dan

class MyTemplateView(TemplateView):
template_name = 'my_template.html'

def get_context_data(self, **kwargs):
context = super(MyTemplateView, self).get_context_data(**kwargs)
context['custom_variable'] = u'my special data'
return context

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django throws ImproperlyConfigured error when loading URLconf on startup

2013-03-24 Thread Dan Gentry
Andrei, I once received this error when the problem was actually in another 
python module being imported - in my case views.py.  Hope this helps, Dan

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5 CBV - DeleteView - CustomQuery

2013-03-24 Thread Dan Gentry
Agree with Tom that ccbv is a great resource for help with CBVs.  In fact, 
I used it to help me with this comment.

I would probably override the delete() method in DeleteView to do what you 
want to do.  The original justs deletes the record and redirects to the 
supplied URL:


   1. def delete(self, request, *args, **kwargs): 
   2. """ 
   3. Calls the delete() method on the fetched object and then 
   4. redirects to the success URL. 
   5. """ 
   6. self.object = self.get_object() 
   7. self.object.delete() 
   8. return HttpResponseRedirect(self.get_success_url())
   
   One could easily replace line 7 with your custom code:
   
   now = datetime.datetime.utcnow().replace(tzinfo=utc)
   self,object.date_deleted = now.strftime("%Y-%m-%d %H:%M:%S")
   self.object.save()
   
   Which would update the date as needed.
   
   Also, I would include the date check in the get_object() method:
   
   def get_object(self,queryset=None)
   obj = super(MyDeleteView,self).get_object(queryset)
   if obj.date_deleted is not None:
   raise Http404
   return obj
   
   Not tested, but will probably work :)
   

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: My Data dont be updated with my forms

2013-03-16 Thread Dan Gentry
Rafael,

This is a bit of a wild guess, but I'm wondering if your form isn't 
validating.  Since your template doesn't seem to be displaying any errors, 
you wouldn't know it.  

Also, since the Url column is marked as unique, but you are excluding it 
from the form, it may be the field throwing the error.

Just to check, add {{form.errors}} to your template and give it a try.

Best of luck,

Dan



-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django & Oracle connection problem

2013-01-25 Thread Dan Gentry
You've probably already tried the simple things:


   - Confirm that the server name and port are correct.
   - Ensure that firewall/routing rules will allow the connection.
   - Try a simple connection on the same box with sqlplus.
   

Walking through this list has helped me a number of times.


On Thursday, January 24, 2013 5:27:22 PM UTC-5, Dylan Klomparens wrote:
>
> I have a Django program that is connecting to an Oracle database. In my 
> settings.py file I have this configuration:
>
> DATABASES = {
>   'default': {
> 'ENGINE': 'django.db.backends.oracle',
> 'NAME': 'xe',
> 'USER': 'MY_USER_NAME',
> 'PASSWORD': 'abcdefghijklmnopqrstuvwxyz',
> 'HOST': 'db_server.example.com',
> 'PORT': '1234',
>   }}
>
> I received a strange error when attempting to load the website:
>
> ORA-28547: connection to server failed, probable Oracle Net admin error
>
> After further investigation, I sniffed the TCP traffic between the 
> webserver and the database server. I discovered this text in the network 
> communication, which I reformatted for this post:
>
> (DESCRIPTION=
> (ADDRESS=
> (PROTOCOL=TCP)
> (HOST=1.2.3.4)
> (PORT=1234)
> )
> (CONNECT_DATA=
> (SID=xe)
> (CID=
> (PROGRAM=httpd@webserver_hostname)
> (HOST=webserver_hostname)
> (USER=apache)
> )
> ))
>
> So my question is: why is Django attempting to connect to the Oracle 
> database with different credentials than the ones I specified? Notably, it 
> is attempting to use user 'apache' instead of 'MY_USER_NAME'. The database 
> host IP, port, and SID are correct and what I specified. It just appears to 
> be the user name that is different.
>
> (As a side note, I suppose the password is transmitted separately in a 
> later portion of the log in process?)
>

-- 
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.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How many developers have moved to class-based views?

2012-11-12 Thread Dan Gentry
It took me a few months to warm up to using class based views, and it was 
the pending decommissioning of the generic function based views that first 
caused me to take a look.  Now, I have converted all but the most 
complicated views to the class format (why change what works?).  Any new 
work I do is in CBV unless there is a compelling reason not to.

I agree with the remark from Kurtis that DRY is a great motivator to use 
CBVs.  Inspired by braces, I have begun to write my own mixins to minimize 
code copying.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/GqUJkhF50HQJ.
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: tutorial first step. -ImportError: No module named django.core-

2012-11-09 Thread Dan Gentry
Quick note: when using virutalenv on Windows, one runs the activate script 
to use the environment.  \Scripts\activate.bat

Same function as the source command in Linux.

Dan Gentry


>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Msx_DI0lDi8J.
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: Reverse of admin:jsi18n

2012-11-08 Thread Dan Gentry
Correction:

My URL tag does not include the quotes.  Should be:

{% url admin:jsi18n %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ifbpxbJtw_wJ.
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.



Reverse of admin:jsi18n

2012-11-08 Thread Dan Gentry
Using Django 1.3, I'm declaring a javascript file in the Media class of a 
ModelForm.  For the jsi18n javascript catalog, the examples show the path 
hard coded:

js = ('/admin/jsi18n/')

However, I want to make this a little more portable by replacing the path 
with a reverse() call.  I tried this:

js = (reverse('admin:jsi18n'))

which failed when the form was imported.  However, I can use the same 
argument in a URL call in the template:

{% url 'admin:jsi18n' %}

Any advice on how I can use reverse() in the Media class?  I haven't found 
anything helpful in my searches.

Thanks,

Dan Gentry

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WUsQvc_QxKAJ.
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 testing strategy

2012-10-05 Thread Dan Gentry
I've been using factory-boy as of late, and have found it to be a great way 
to setup each test exactly as I need it.  Fixtures aren't bad either, but 
working with a large amount of data can make it difficult to predict the 
proper output for a test, and changes to this data to accommodate a new 
test situation could affect others. 

You could setup a group of test records in the setup method of a test class 
to be used for several tests.

Keep your tests focused, and you'll find you won't need a huge batch of 
data to get good coverage.


>
>
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ixLvFEgiF00J.
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: save() got an unexpected keyword argument 'force_insert'

2012-09-25 Thread Dan Gentry
To address the original question, I saw a similar error when overriding the 
save() function of a model.  The solution was to include *args and **kwargs 
in the function definition:

def save(self,*args, **kwargs):
# your custom code here #
super(MyModel, self).save(*args, **kwargs)


>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vYCgvZ74BEQJ.
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: Alternatives to CBVs (class based views)

2012-09-13 Thread Dan Gentry
It would be helpful to see some more complex examples with these classes. 
 One thing I like about the CBVs is that they include all of the necessary 
code for common functions.  I have used them extensively (once I figured 
them out).

On Wednesday, September 12, 2012 12:59:12 PM UTC-4, Cal Leeming [Simplicity 
Media Ltd] wrote:
>
> Hi all,
>
> There is a lot of debate on whether there is a real future for the Django 
> CBVs (class based views). Personally, I find them tedious, and just wanted 
> a way to keep my views clean.
>
> So, here is a really minimalistic way of having class based views, without 
> the fuss.
>
> http://djangosnippets.org/snippets/2814/
>
> This is a fork from:
>
> http://stackoverflow.com/questions/742/class-views-in-django 
> http://djangosnippets.org/snippets/2041/
>
> My thanks to eallik for his initial post on stackoverflow for this.
>
> Personally I think Django's CBVs should offer a really minimalistic base 
> like this, as well as the existing CBV stuff already in the core - so as to 
> not force people into needing to learn an entirely new way of doing things, 
> but at the same time allowing them to reap some of the benefits of using 
> callable classes as views.
>
> Any thoughts?
>
> Cal
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/tCY5GSuWfOcJ.
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: complicated permissions

2012-09-10 Thread Dan Gentry

>
> Complicated indeed!
>

I once worked on a similar project that tackled the first 2 requirements as 
part of a multi-tenant application, storing both the userID and company ID 
for each detail record (content).  Plus, the user profile was extended to 
tie a User record to one or more companies.  

For your third requirement, sharing between companies, I would imagine a 
many-to-many relationship on a per record basis that recorded any sharing 
that was setup.

All of this permission stuff would have to be checked in your views - a 
mixin would be appropriate with class-based views.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/bBUBWd7lEGMJ.
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: Issue Deploying Django

2012-08-03 Thread Dan Gentry
Agreed that virtualenv will allow you to install python packages - however 
not any linux/unix packages.  I have no problems using Django on Dreamhost. 
 http://dashdrum.com/blog/2011/08/django-on-dreamhost/

On Thursday, August 2, 2012 10:34:35 PM UTC-4, trevorj wrote:
>
> You are trying to install packages system-wide when you don't have 
> credentials to do so.
>
> You can install everything you need without cluttering the system itself.
>
> For instance, use a virtualenv and set your PREFIX.
>
> Either way, happy hacking!
> On Aug 1, 2012 8:32 PM, "JJ Zolper"  wrote:
>
>> I'm trying to install GEOS and on my bluehost account under my django_src 
>> folder and what happened in the image happened.
>>
>> it said cannot create directory permission denied so i tired sudo make 
>> install after what I had just done ( "make" ).
>>
>> and then it said whats in the second image.
>>
>> When I tried to run:
>>
>> ./manage.py runfcgi [options]
>>
>> I got an error about GEOS so that's why I was doing that.
>>
>> Thanks for the help.
>>
>> JJ
>>
>> On Wednesday, August 1, 2012 1:03:21 PM UTC-4, JJ Zolper wrote:
>>>
>>> Thanks so much for the reply!
>>>
>>> I had a feeling I would need it but I just like to be sure before I act.
>>>
>>> Another thing. On Ubuntu there were additional packages I had to 
>>> install. I believe one was called "psycopg2-python-dev" or something like 
>>> that.
>>>
>>> If I install psycopg2-python at:
>>>
>>> http://www.initd.org/psycopg/ 
>>>
>>> Are there any additional packges that I might need?
>>>
>>> I apologize for not being able to remember the additional ones I added 
>>> before on Ubuntu but I'm at work and couldn't find in my installation 
>>> history what they might have been or in my django google group discussions.
>>>
>>> I feel like one was called "libpq-dev" actually.
>>>
>>> Thanks for the help.
>>>
>>> JJ
>>>
>>> On Wednesday, August 1, 2012 2:07:54 AM UTC-4, lawgon wrote:

 On Tue, 2012-07-31 at 20:52 -0700, JJ Zolper wrote: 
 > Do I need to go through and install the python like adapters is that 
 > what it's complaining about? I don't think this has to do with my 
 > Django code on the server it's just a file missing right? 

 you need to install pycopg - and it is nothing to do with your code 
 -- 
 regards 
 Kenneth Gonsalves 

  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/0Jx03fySUVUJ.
>> 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.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/9V4D-bMpS28J.
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: form.save() fails silently - how to debug?

2012-07-27 Thread Dan Gentry
I too am a little confused by the clean() method and the data_set field. 
 It seems that the data_set would contain a copy of the ID value for a 
change operation, and be None for an add.  What purpose does that serve?

Perhaps comment the clean() method just to see if the other fields can be 
saved.

Also, I concur with Karl's suggestion to use results.save()

Good luck!

On Friday, July 27, 2012 9:46:01 AM UTC-4, Derek wrote:
>
> Thanks Karen
>
> I am not quite sure what you mean by "Model save() would indicate an 
> error" - I am making a call to the form.save(), which in turn, I assume, 
> should result in the data being saved to the model (although nothing gets 
> saved in my case)?  No error is being raised that I can see.  
>
> I have not used pdb before; I will need to look into how that works and 
> how might help me.
>
> On Friday, 27 July 2012 14:00:37 UTC+2, Karen Tracey wrote:
>>
>> On Fri, Jul 27, 2012 at 3:25 AM, Derek  wrote:
>>
>>> The clean() method basically stores the non-model field data in the 
>>> model's dictionary field.  If this method was faulty, then it would also 
>>> cause problems in the test code.  As I said, when I print the data to 
>>> console it looks OK.  I am still trying to find how and where the save() 
>>> method indicates errors...?
>>
>>
>> Model save() would indicate an error by raising an exception, see:
>>
>> https://github.com/django/django/blob/master/django/db/models/base.py#L444
>>
>> I would attack the problem you are seeing by tracing through what's 
>> actually happening using pdb.
>>
>> Karen
>> -- 
>> http://tracey.org/kmt/
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/owgvY5LVe1QJ.
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: I can not install Django on Windows7

2012-07-18 Thread Dan Gentry
Do you have the proper level of security on the machine to install software?

On Wednesday, July 18, 2012 8:50:48 AM UTC-4, Владислав Иванов wrote:
>
> when I run the installation of Django python setup.py install - comes at 
> the end of an error that can not be put Django in C: \ Python27 \ Lib \ 
> site-packages
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vAB2AZlnAvQJ.
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: Catching Oracle Errors

2012-07-11 Thread Dan Gentry
Thanks Ian.  I'll see what I can do.


>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/EYbdNNR4bS8J.
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.



Catching Oracle Errors

2012-07-10 Thread Dan Gentry


My Django app runs on an Oracle database.

A few times a year, the database is unavailable because of a scheduled 
process or unplanned downtime. However, I can't see how to catch the error 
and give a useful message back to the requester. Instead, a 500 error is 
triggered, and I get an email (or hundreds) showing the exception. One 
example is:

  File 
"/opt/UDO/env/events/lib/python2.6/site-packages/django/db/backends/oracle/base.py",
 line 447, in _cursor
self.connection = Database.connect(conn_string, **conn_params)

DatabaseError: ORA-01035: ORACLE only available to users with RESTRICTED 
SESSION privilege

I see a similar error with a different ORA number when the DB is down.

Because the exception is thrown deep within the Django libraries, and can 
be triggered by any of my views or the built in admin views, I don't know 
where any exception trapping code would go.

Any suggestions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/DED1N0VNlGwJ.
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: Why using Generic Views?

2012-04-04 Thread Dan Gentry
I use generic views - either function or class based - for the common
functionality in my apps.  As Serge mentioned, a list works pretty
much the same in every application, so I just provide a few parameters
to a generic view.  More complicated forms still require custom code.

On Apr 3, 1:07 am, abisson  wrote:
> Good evening,
>
> I just finished the Django 1.4 Tutorial, and I really don't understand
> the point of Generic Views in Django? As far as I can see, we wrote
> more code than before, and what other example would make the Generic
> Views better than normal views?
>
> Thanks for the clarifications!

-- 
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: where do you host your django app and how to you deploy it?!

2012-04-04 Thread Dan Gentry
Dreamhost shared account

http://dashdrum.com/blog/2011/08/django-on-dreamhost/

-- 
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: auth groups puzzle

2012-02-04 Thread Dan Gentry
I've solved this problem in an app, but not with the built-in
permissions system.  Instead, I created a DB structure that links
users to companies and stores the r/w status for each.

On Feb 3, 12:58 am, Mike Dewhirst  wrote:
> I want to use the built-in auth_groups permissions system in a
> many-to-many sense but can't quite figure it out for my use case. Any
> help will be appreciated.
>
> The use case is: users have different types of access (r/o, r/w or
> admin) to different companies. Any single user can have r/o access to
> company-1, r/w access to company-2 and admin access to company-3 and so
> on. Any company can have relationships with many users each of whom will
> have one of the r/o, r/w or admin group permissions.
>
> So there has to be a many-to-many relationship between user and company
> and the group needs to be specified in that relationship table rather
> than in the auth_user_groups table - where it currently sits.
>
> How do I invoke a different set of permissions depending on the name of
> the group established in the user-company relationship table when a user
> is accessing that company's data?
>
> A side question is how do I remove the displayed Groups in the Django
> Admin auth/user display?
>
> Thanks
>
> Mike

-- 
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: failing django install on dreamhost

2012-01-29 Thread Dan Gentry
I'm going to guess that maybe there is a syntax in one of the lines
preceding this one.  Could you share the entire DATABASE session of
your settings file?

FYI, I have written a more up to date procedure for running Django on
Dreamhost - built on the great posts by Jeff Croft and others.
http://dashdrum.com/blog/2011/08/django-on-dreamhost/

On Jan 16, 12:19 pm, ebhakt  wrote:
> I have tried to install django on dreamhost using many ways :
>
>    1. I have tried the official django install script from dreamhost
>    2. tried to follow instructions as per
>    http://jeffcroft.com/blog/2006/may/11/django-dreamhost/
>
> But in all the cases it fails at the syncdb step
>
> I tried the steps mentioned in jeff's blog with an older version of django
> even (v1.2.1)
>
> but nothing seem to work !!
>
> Here is the message that i get doing django-admin.py syncdb
>
> 
>
> Traceback (most recent call last):
>   File "/usr/bin/django-admin.py", line 5, in 
>     management.execute_from_command_line()
>   File
> "/home/shell_user/django/django_src/django/core/management/__init__.py",
> line 429, in execute_from_command_line
>     utility.execute()
>   File
> "/home/shell_user/django/django_src/django/core/management/__init__.py",
> line 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File
> "/home/shell_user/django/django_src/django/core/management/__init__.py",
> line 252, in fetch_command
>     app_name = get_commands()[subcommand]
>   File
> "/home/shell_user/django/django_src/django/core/management/__init__.py",
> line 101, in get_commands
>     apps = settings.INSTALLED_APPS
>   File "/home/shell_user/django/django_src/django/utils/functional.py",
> line 276, in __getattr__
>     self._setup()
>   File "/home/shell_user/django/django_src/django/conf/__init__.py", line
> 40, in _setup
>     self._wrapped = Settings(settings_module)
>   File "/home/shell_user/django/django_src/django/conf/__init__.py", line
> 73, in __init__
>     mod = importlib.import_module(self.SETTINGS_MODULE)
>   File "/home/shell_user/django/django_src/django/utils/importlib.py", line
> 35, in import_module
>     __import__(name)
>   File "/home/shell_user/django/django_projects/WebBuilder/settings.py",
> line 16
>     'NAME': 'oncloud_database',                      # Or path to database
> file if using sqlite3.
>          ^
> SyntaxError: invalid syntax
>
> 
>
> Please comment !!
>
> Any help is always welcome
>
> Thanks
>
> --
> Bhaskar Tiwari
> Freelancer Developer and Active Directory Specialist
> Previously with Directory Services, Microsoft
> Cell Phone: Home Town : +91 9808437438 (preferred) , Delhi: +91 9971697075
> 
>  All we have to decide is what to do with the time that has been given to us
>
> Personal:
> ===http://ebhakt.info/
> ===
>
> Professional:
> ===http://www.ebhakt.com/http://fytclub.net/http://crackzhack.net/
> ===

-- 
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: Help with new version of django

2012-01-29 Thread Dan Gentry
I agree with Aaron.  I upgraded 5 apps from v1.0.4 to 1.3 earlier this
year, and it was pretty easy after reviewing the release notes.
Moving to class based views (to replace generic views) was not
required for 1.3, but I had fun and learned quite a bit.

On Jan 28, 7:35 pm, Aaron Cannon 
wrote:
> I suspect he means the latest stable version, in which it really is
> 1.3.1.  To my knowledge 1.4.1 does not yet exist.
>
> As for the original question, I would suggest familiarizing yourself
> with the what's new documents for Django 1.2 and 1.3, and then tuning
> your code accordingly.  Depending on what your application does, it
> may be quite painless.
>
> Alternatively, if you have good test coverage, you might just upgrade
> your Django version, test, and fix what's broken.
>
> Obviously, the first option is probably the better, but regardless, it
> will be quite difficult for anyone to give you specific advice based
> on the amount of information you provided.
>
> Aaron
>
> On 1/28/12, kenneth gonsalves  wrote:
>
>
>
>
>
>
>
> > On Wed, 2012-01-25 at 17:25 -0800, itua ijagbone wrote:
> >> Hello, please i need help as to how to update my project to the
> >> lastest version of django 1.3.1. i have been using 1.1.1 to develop
> >> the project. Please how do i go about it, making my project conform to
> >> 1.3.1
>
> > latest is 1.4.1
> > --
> > regards
> > Kenneth Gonsalves
>
> > --
> > 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.

-- 
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: Constraints on a one-to-many relationship and related problems

2011-12-28 Thread Dan Gentry
Just looking at the models, I'd like to make a couple of suggestions.

Instead of using a Foreign Key relationship in Customer to indicate
the billing address,  I would include a flag called 'billing_address'
in the Address table that would be set to True for the customer
selected address.

An override of save() in the Address model is then used to enforce the
'only one billing address' rule.

def save(self):
''' This will turn off the billing address flag for all other
addresses for this customer if the new record is selected '''
if self.billing_address:
old_billing_address =
Address.objects.filter(customer=self.customer).filter(billing_flag=
True)
for s in old_billing_address:
s.billing_flag = False
s.save()
super(Address, self).save()

Hope this helps,

Dan

On Dec 28, 6:02 am, Bart Nagel  wrote:
> I'm new to Django. I'm finding it very impressive so far but have hit
> a cluster of problems. I'm using the SVN version.
>
> Sorry for the length of this, I'm just trying to explain as fully as I
> can what I'm trying to do, what I have and what's going wrong.
>
> The relevant parts of my model, in the simplest terms, look like this.
>
>     from django.db import models
>
>     class Address(models.Model):
>         customer = models.ForeignKey("Customer")
>         street = models.CharField(max_length=128)
>         city = models.CharField(max_length=128)
>
>         def __unicode__(self):
>             return "%s, %s" % (self.street, self.city)
>
>     class Customer(models.Model):
>         last_name = models.CharField(blank=True, max_length=64)
>         first_name = models.CharField(blank=True, max_length=64)
>         billing_address = models.ForeignKey("Address", related_name="+")
>
>         def __unicode__(self):
>             return "%s %s" % (self.first_name, self.last_name)
>
> So customers can have many addresses, and one of those addresses is
> pointed to by the customer as being the billing address.
>
> I then have the Customer admin page set up so that Address entries are
> edited inline on the same form.
>
> 1. The billing address should be required, but obviously when it's a
>    new Customer there won't be any addresses on file, so there will be
>    no choices on the billing address dropdown.
>
>    So I need a way to accept a blank selection for billing address,
>    maybe have it labelled as "use first address given below", and then
>    just complain if no addresses are given below.
>
>    Later when there needs to be something to stop the billing address
>    from being deleted.
>
> 2. Related to the previous, there needs to be a constraint so there
>    must be at least one Address for each customer.
>
> 3. When editing an existing customer, only that customer's addresses
>    should be shown in the dropdown for billing address.
>
> Here's what I've tried...
>
> I set the billing address field to be optional for now.
>
> Problem 3 seemed easiest so I decided to tackle that first, and made a
> bunch of customers and addresses so I could test with the database
> somewhat populated.
>
> I found the ForeignKey.limit_choices_to in the documentation but since
> there's no "self" when I'm setting up the database fields I've no idea
> how I'd tell it to limit the options to something like
> self.addresses_set.all(), let alone have that updated as addresses are
> added, removed, edited in the inline form below.
>
> I first posted this problem on Stacko Overflow
> (http://stackoverflow.com/questions/8637912/) and a suggestion was to
> use a ModelChoiceField. I had a look at the documentation and it
> wasn't obvious what the difference is between that an ForeignKey, plus
> it looks like I'd have exactly the same problem as above.
>
> So I'm totally stuck on that one.
>
> Next I had a go at the other two problems. It seemed to me (bearing in
> mind I'm a newbie here) it'd be best to add that logic to the
> Customer.clean() method -- I could check the number of addresses which
> had been entered there and raise an Exception if it was zero. At the
> same time I could set the billing address, if not already set, to the
> first address given. All sounds simple enough, but apparently not.
>
> In the Customer.clean() method, I can't seem to get at what was posted
> as addresses. In there, self.address_set.all().count() is zero. I
> don't really see why -- I can get at the other data which was posted
> to the form as an object, why not the child objects which are being
> posted too?
>
> Perhaps just too early. Following a suggestion in the same Stack
> Overflow thread mentioned above, I figured out how to set up a
> listeners for the pre_save and post_save signals and inspected the
> count of addresses at those points. It's still zero in both cases.
> Even after the save. That was very confusing but from what I've found
> while Googling it's something to do with the database transaction
> having not been finished yet. I

Re: Redirect from get_queryset() in a class view?

2011-12-12 Thread Dan Gentry
I faced a similar situation where I had to check for valid input data
used to build the query in get_queryset().  My solution was to use a
decorator around the dispatch() function, but I think it could also be
used within that function.  I chose dispatch() because it acts like a
traditional view function - takes a request and outputs a response.
My code is a little specific to my situation, but it may help. Here is
it:

First, the decorator:

def require_institution():
"""
Decorator to check for a valid institution id in the session
variables
and return institution object in kwargs
"""
def decorator(func):
def inner(request, *args, **kwargs):
## If there is no inst_id set in the session, transfer to
institution select
## page for a chance to select one
try:
institution =
Institution.objects.get(pk=request.session.get('inst_id',None))
kwargs['institution'] = institution
except Institution.DoesNotExist:
path = urlquote(request.get_full_path())
tup = reverse('select_inst'), REDIRECT_FIELD_NAME,
path
return HttpResponseRedirect('%s?%s=%s' % tup)
return func(request, *args, **kwargs)
return wraps(func, assigned=available_attrs(func))(inner)
return decorator

And then the class:

class ListViewInstCheck(ListView):
model = Event
paginate_by = DEFAULT_PAGINATION

@method_decorator(require_institution())
def dispatch(self, request, *args, **kwargs):
return super(ListViewInstCheck, self).dispatch(request, *args,
**kwargs)

def get_queryset(self):
queryset = super(ListViewInstCheck,self).get_queryset()
return queryset.filter(institution=self.kwargs['institution'])

Hope this helps.

Dan


On Dec 10, 1:51 pm, Eli Criffield  wrote:
> So in a class based view inheriting generic.ListView I want to redirect on
> a condition, The logical place to do it is get_queryset, but you can't go
> returning a HttpResponseRedirect from a method that should return a query
> set. The django.shortcuts.redirect() just kinda does that for you so that
> doesn't work either. I can raise a  Http404 from inside get_queryset, but
> not something like raise Redirect('url/').
>
> I saw one answer to the problem where you put the condition
> in render_to_response but that'll gets called after get_queryset. I guess
> the other option is to put the condition in get and check there and return
> redirect. But that seems hacky.
>
> I'm just wonder whats the best way to do this.
>
> Eli Criffield

-- 
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: converting from function based views to class based views

2011-12-12 Thread Dan Gentry
I can't test this, but the code below may do what you want.  (I
learned this stuff from Reinout's blog posts)

# urls.py

(r'^tags/(?P[a-zA-Z0-9_.-]+)/$',
djangoblog.tag_views.TagDetailListView.as_view())

# views.py

from django.views.generic import ListView

class TagDetailListView(ListView):
template = 'tags/detail.html'

def get_queryset(self):
unslug = self.kwargs.get('slug',None).replace('-',' ')
tag = Tag.objects.get(name=unslug)
return TaggedItem.objects.get_by_model(Entry, tag)

def get_context(self, **kwargs):
context = super(TagDetailListView, 
self).get_context_data(**kwargs)
context['tag'] = self.kwargs.get('slug',None)
return context

On Dec 10, 3:40 pm, Jake Richter  wrote:
> Hi group,
>
> I'm working through this 
> tutorialhttp://www.webmonkey.com/2010/02/Use_URL_Patterns_and_Views_in_Django/
>
> It's written for Django 1.0 and I'm using 1.3 which has changed to
> class based views. I'm having a hard time converting from function
> based to class based. Can anyone offer help on how to change the
> following to class based views?
>
> #urls.py
>
> urlpatterns = patterns('',
>               url(r'^admin/', include(admin.site.urls)),
>         (r'^blog/', include('djangoblog.blog.urls')),
>         (r'^tags/(?P[a-zA-Z0-9_.-]+)/$', 
> 'djangoblog.tag_views.tag_detail'),
> )
>
> #blog/urls.py
> from django.conf.urls.defaults import *
> from djangoblog.blog.models import Entry
> from tagging.views import tagged_object_list
>
> info_dict = {
>         'queryset': Entry.objects.filter(status=1),
>         'date_field': 'pub_date',
>
> }
>
> urlpatterns = patterns('django.views.generic.date_based',
>         
> (r'(?Pd{4})/(?P[a-z]{3})/(?Pw{1,2})/(?P[-w]+)/$',
> 'object_detail', dict(info_dict,
> slug_field='slug',template_name='blog/detail.html')),
>         
> (r'^(?Pd{4})/(?P[a-z]{3})/(?Pw{1,2})/(?P[-w]+)/$',
> 'object_detail', dict(info_dict, template_name='blog/list.html')),
>         
> (r'^(?Pd{4})/(?P[a-z]{3})/(?Pw{1,2})/$','archive_day',dic 
> t(info_dict,template_name='blog/list.html')),
>         (r'^(?Pd{4})/(?P[a-z]{3})/$','archive_month',
> dict(info_dict, template_name='blog/list.html')),
>         (r'^(?Pd{4})/$','archive_year', dict(info_dict,
> template_name='blog/list.html')),
>         (r'^$','archive_index', dict(info_dict, 
> template_name='blog/list.html')),
> )
>
> # views.py
> from django.views.generic.list_detail import object_detail
> from tagging.models import Tag,TaggedItem
> from blog.models import Entry
>
> def tag_detail(request, slug):
>         unslug = slug.replace('-', ' ')
>         tag = Tag.objects.get(name=unslug)
>         qs = TaggedItem.objects.get_by_model(Entry, tag)
>         return object_list(request, queryset=qs, extra_context={'tag':slug},
> template_name='tags/detail.html')
>
> Thanks!
> - Jake

-- 
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: Getting into professional django development

2011-10-18 Thread Dan Gentry
With all due respect to Mr. Gonsalves, I do not care to work with the
Django trunk unless I'm just playing around with something.  My goal
is always to produce a production quality application.  Even the more
stable than average Django trunk cannot provide the consistency needed
to deliver an app to a customer.  Plus, I don't need the extra work of
basing my code on a moving target.  When trunk becomes v1.4, I will
convert my applications and upgrade.

I know - I'm a dinosaur.

Best of luck to all!

On Oct 18, 3:10 am, kenneth gonsalves  wrote:
> On Tue, 2011-10-18 at 12:36 +0530, kenneth gonsalves wrote:
> > On Mon, 2011-10-17 at 23:45 -0700, Kevin wrote:
> > > Currently I have been focusing on the following:
>
> > > * Django 1.2
>
> > 1.3 belongs to the stone age - since you are learning, it would be a
> > good idea to work with the current svn trunk, updating every week or
> > so.
> > --
>
> s/1.2/1.3/
> --
> regards
> Kenneth Gonsalves

-- 
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: TemplateView compatible with permission_required decorator?

2011-10-05 Thread Dan Gentry
Instead, you should decorate the dispatch method in the class-based
view.  See the docs here:

https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-the-class



On Oct 5, 10:27 am, Victor Hooi  wrote:
> Hi,
>
> I'm attempting to use one of the new class-based TemplateView with the
> permission_required decorator:
>
> @permission_required('foo.count_peas')
> class Pea(TemplateView):
>     template_name = "pea.html"
>
> However, when I do that, I get an error:
>
> Exception Type: AttributeError at /someurl/
> Exception Value: 'function' object has no attribute 'as_view'
>
> If I comment out the permission_required decorator, the view seems to work
> fine.
>
> Are the new class-based views compatible with the permission_required
> decorator?
>
> Or is there something I need to do to make them work together.
>
> Cheers,
> Victor

-- 
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: Alternative to Decorators for Class-Based View

2011-10-05 Thread Dan Gentry
In the docs there a paragraph or two about this.  Basically, one must
decorate the dispatch method instead.  See this link for the details.

https://docs.djangoproject.com/en/dev/topics/class-based-views/#decorating-the-class

Good luck!

On Oct 5, 11:42 am, Kurtis  wrote:
> Hey,
>
> What's the best way to go about doing things for class-based views
> such as requiring logins? In the function-based views it was easy to
> use decorators.
>
> Should I just replace the functionality that I would previously have
> put into decorators into abstract classes that I extend? If so, can
> someone throw me a simple example?
>
> Not only do I want to have some views require a user to be logged in,
> but I'd like to have other pages require a user to have an active paid
> membership, and so forth ... If there's a better approach to this, let
> me know.
>
> Thanks in advanced!

-- 
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 Development environment

2011-08-25 Thread Dan Gentry
Ubuntu, Eclipse with PyDev, virtualenv, pip, django debug toolbar,
Chrome, and lots of hot chocolate :)

On Aug 22, 6:07 pm, Stephen Jackson 
wrote:
> I am new to the world of Django. I would like to hear from other django
> developers describe their dev environment (tools, os, editors, etc.).

-- 
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: filtering drop downs according to logged in user

2011-04-21 Thread Dan Gentry
I have set the choices list in the view:

choices =
SomeModel.objects.filter(user=request.user).values_list('id','label')

Then, after the form is instantiated, modify the choices attribute of
the ChoiceField:

form = SomeOtherModelForm()
form.fields['model_dropdown'].choices = choices

Works in a similar fashion with a ModelChoiceField and the queryset
attribute.

On Apr 21, 10:10 am, "Szabo, Patrick \(LNG-VIE\)"
 wrote:
> Hi,
>
> I want to filter the dropdownlists that are automatically used to select
> a foreign-key in forms (in my views).
>
> Normally that could easily be done with "class Meta" in the Modelform.
>
> Thing is i want to filter by an attribute of the current
> userspecificly the groups that the user is assigned to.
>
> So how do i do that ?!
>
> Can i acces request.user in the models somehow ?!
>
> Kind regards
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Patrick Szabo
>  XSLT Developer
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: +43 (1) 534 52 - 1573
> Fax: +43 (1) 534 52 - 146

-- 
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: Formset and Choices with Objects

2011-04-21 Thread Dan Gentry
I should have included that my desire is to access these objects in
the template.

On Apr 21, 11:22 am, Dan Gentry  wrote:
> I'm trying to use a formset to display a variable number of detail
> rows on a form.  It's what they were created for, right?
>
> However, in order to display more detail in each row, I'd like to have
> access to the object behind it - to reference columns not displayed,
> follow foreign key relationships, etc., but I can't see how to do it.
> Any advice?
>
> On the same form, I'd like a similar functionality for the choices in
> a series of radio buttons.  The choices attribute only accepts a list
> of two values - index and label.  The design calls for several pieces
> of data (date, time, location) and the radio button in a tabular
> format.  Any thoughts here?
>
> Thanks for pondering my questions.
>
> Dan Gentry

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



Formset and Choices with Objects

2011-04-21 Thread Dan Gentry
I'm trying to use a formset to display a variable number of detail
rows on a form.  It's what they were created for, right?

However, in order to display more detail in each row, I'd like to have
access to the object behind it - to reference columns not displayed,
follow foreign key relationships, etc., but I can't see how to do it.
Any advice?

On the same form, I'd like a similar functionality for the choices in
a series of radio buttons.  The choices attribute only accepts a list
of two values - index and label.  The design calls for several pieces
of data (date, time, location) and the radio button in a tabular
format.  Any thoughts here?

Thanks for pondering my questions.

Dan Gentry

-- 
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: Best Practice for Raw SQL

2011-04-14 Thread Dan Gentry
Thanks.  I'll give raw() a try.

On Apr 11, 11:51 am, Jacob Kaplan-Moss  wrote:
> On Mon, Apr 11, 2011 at 7:53 AM, Dan Gentry  wrote:
> > Where I run into trouble is that the query returns data in columns,
> > but not objects. That means that I can’t reference an object attribute
> > using dot notation in my templates or views. Instead, I have to
> > include each attribute that will be needed as a query column. This
> > will limit what I or someone else can do in templates later without a
> > mod to the query.
>
> You're looking for the `raw()` method:http://django.me/raw. It takes
> a raw SQL query and yields models for you.
>
> 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.



Best Practice for Raw SQL

2011-04-11 Thread Dan Gentry
My application includes some existing tables from another, non-Django
application. One of them does not have an atomic primary key, and I’m
not in a position to change that. Therefore, I’m using one raw SQL to
access the data.
Where I run into trouble is that the query returns data in columns,
but not objects. That means that I can’t reference an object attribute
using dot notation in my templates or views. Instead, I have to
include each attribute that will be needed as a query column. This
will limit what I or someone else can do in templates later without a
mod to the query.

In an earlier application with a similar situation, I took the results
from the query and built a dictionary of objects. Clumsy, hard-coded,
and likely slow, but it did give me what I needed.

I’ve looked around the web, but haven’t found any practices to follow,
so I hope members of the group can offer some help.

Have you tackled this dilemma in the past? Or maybe read where someone
else has discussed a possible solution? (I’ll also take wild guesses).
Please leave a comment below.

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-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 identifier to distinguish an instance

2011-04-07 Thread Dan Gentry
When faced with a similar problem (I wanted to mark one of the 'B'
records as the primary of the group), I extended the save function of
the 'B' model to ensure that none of the other records were marked as
such.

def save(self):
if self.primary:
other_primaries =
B_Model.objects.filter(A_object=self.A_object).filter(primary= True)
for b in other_primaries:
b.primary = False
b.save()
super(B_Model, self).save()

One could also search for other primary records in the forms logic for
validation purposes.

On Apr 6, 6:13 pm, Tony  wrote:
> so I have two models, A and B.  B has a foreignkey relationship in it
> from A (To be clear because I know I dont explain it that well, one A
> has many Bs).  for each group of Bs each A is connected with, I want
> there to be a way to mark one of the Bs as unique from the rest of
> them.  I added in an extra field called unique_identifier that is a
> booleanfield. The problem is I dont know the best way to go about
> making sure there is only one B instance marked True for the
> unique_identifier field for each set of Bs.  What would be a good way
> to ensure there is one and only one instance marked True?

-- 
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: When do we stop using Django admin?

2011-03-11 Thread Dan Gentry
I tend to use the Admin for internal tasks - ones that would be
performed by a application or system administrator.  These are people
that understand the data structure and know things like the effects of
a cascaded delete.

For users, even a customer 'admin' person, I would write my own views
that will handle additional conditions rather than asking that user to
make the decision.

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



Migrating Groups of Permissions

2010-10-07 Thread Dan Gentry
As I deploy my application into production, I haven't found a good way
to migrate the groups of permissions I have defined and tested in
development.  In fact, due to my poor typing and reviewing, I missed
one in production and caused a small amount of concern with the users
until I figured it out.

It seems that I can't just dump and load the data from the test DB,
since the permissions may not have the same ID.  Any hints from the
community on how I can automate this to reduce the chance for error?

-- 
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: View Decorator

2010-08-05 Thread Dan Gentry
Steve, thanks for the guidance.  I'm heading in the right direction
with a better understanding of the concept, but still stymied by the
urls error.  Not seeing the connection between adding a decorator and
having trouble with urls.py.  I'll get there.  Dan

On Aug 4, 11:31 am, Steve Holden  wrote:
> On 8/4/2010 10:52 AM, Dan Gentry wrote:
>
>
>
>
>
> > When I attempt to use the decorator logic, the view becomes this:
>
> > views.py
> > @institution_required
> > def list_type(request):
>
> >     inst_id=request.session.get('inst_id',None)
>
> >     queryset = RecordType.objects.filter(institution=inst_id)
> >     return object_list(request, queryset, paginate_by = 12)
>
> > I don't make any changes to urls.py, but the error is
> > "TemplateSyntaxError at /index
> > Caught ImproperlyConfigured while rendering: The included urlconf
> > person.urls doesn't have any patterns in it"
> > However, when I take out the decorator, all of the urls work as
> > expected.
>
> > urls.py does import * from views.py
>
> Your decorator takes two arguments - its signature is
>
>   institution_required(fn, redirect_field_name=REDIRECT_FIELD_NAME)
>
> But the decorator mechanism only allows you to specify one argument (the
> decorated function). There is no way to specify anything OTHER than the
> default value for the redirect_field_name argument ...
>
> Therefore if you want to use decorators for this application you will
> have to write something more complex still: a function that takes a
> single redirect_field_name argument and /returns a decorator/ that can
> be applied to views. Then you would call it as
>
> @institution_required("Some_field_name")
> def list_type(request):
>   ...
>
> Your call to institution_required should return a decorator. That takes
> the decorated function as its single argument and returns the decorated
> function. This is getting a little complex for a beginner.
>
> regards
>  Steve
> --
> I'm no expert.
> "ex" == "has-been"; "spurt" == "drip under pressure"
> "expert" == "has-been drip under pressure".

-- 
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: View Decorator

2010-08-04 Thread Dan Gentry
Forgot to paste in the urls.

urls.py
from django.conf.urls.defaults import *
from django.views.generic.simple import redirect_to
from views import *


urlpatterns = patterns('person',

url(r'^create_type/$',create_type,name='type_create'),
url(r'^view_type/(?P\d+)/$',view_type,name='type_view'),
url(r'^update_type/(?P\d+)/$',update_type,name='type_update'),
url(r'^list_type/$',list_type,name='type_list'),
url(r'^delete_type/(?P\d+)/$',delete_type,name='type_delete'),

url(r'^index',index,name='person_index'),
url(r'^$', redirect_to, {'url': 'index'}),

)

-- 
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: View Decorator

2010-08-04 Thread Dan Gentry
When I attempt to use the decorator logic, the view becomes this:

views.py
@institution_required
def list_type(request):

inst_id=request.session.get('inst_id',None)

queryset = RecordType.objects.filter(institution=inst_id)
return object_list(request, queryset, paginate_by = 12)

I don't make any changes to urls.py, but the error is
"TemplateSyntaxError at /index
Caught ImproperlyConfigured while rendering: The included urlconf
person.urls doesn't have any patterns in it"
However, when I take out the decorator, all of the urls work as
expected.

urls.py does import * from views.py

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



View Decorator

2010-08-04 Thread Dan Gentry
I'm trying to move some code from a view to a decorator to use with
many views.  This is the view:

views.py:
def list_type(request):

inst_id=request.session.get('inst_id',None)

## move to decorator
if not inst_id:
path = urlquote(request.get_full_path())
tup = reverse('select_inst'), REDIRECT_FIELD_NAME, path
return HttpResponseRedirect('%s?%s=%s' % tup)
##

queryset = RecordType.objects.filter(institution=inst_id)
return object_list(request, queryset, paginate_by = 12)

I've moved the middle bit of code to a decorator I wrote (basically
copying user_passes_test), but when I use it I get the strange error
that my urls.py file contains no patterns.

decorators.py:
def institution_required(fn, redirect_field_name=REDIRECT_FIELD_NAME):

inst_url = reverse('select_inst')  ##  URL to select institution

def _wrapped_view(request, *args, **kwargs):
if not request.session.get('inst_id',None):
path = urlquote(request.get_full_path())
tup = inst_url, redirect_field_name, path
return HttpResponseRedirect('%s?%s=%s' % tup)
return fn(request, *args, **kwargs)
return _wrapped_view



Would anyone like to school me on the correct way to write a view
decorator?  Thanks in advance.

-- 
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: Chase Paymentech

2010-06-20 Thread Dan Gentry
Storing credit card numbers (and other info) isn't the only concern of
the PCI standards. If your form collects a number an passes it on to
the processor, you could also be vulnerable.

On Jun 18, 2:09 pm, surtyaar  wrote:
> Hi Bobby,
>
> You might be interested in a django clone of the sample shopping cart
> chase paymentech provided (http://store.e-xact.com/).
>
> You can get the code and setup instructions here 
> :http://github.com/gitaaron/E-xact-django-clone
>
> Rgds/
> Aaron
>
> On Apr 20, 10:34 am, Bobby Roberts  wrote:
>
>
>
> > Hey Bill -
>
> > It is my understanding that as long as you do not store credit card
> > information on your servers, PCI compliance is not an issue.  Chase,
> > Authorize.net, Paypal, ilovechecks.com etc all have API gateways to
> > handle the transactions via https protocol which satisfies the
> > industry financial standards.  I'm just wondering if anyone has infact
> > worked with the Chase API before
>
> > On Apr 20, 10:17 am, Bill Freeman  wrote:
>
> > > Beware!  There are a number of security vulnerabilities you can have when
> > > handling credit card numbers.  There is something called PCI (Payment Card
> > > Industry, if I'm not mistaken) compliance, the intent of which is to
> > > try to avoid
> > > some of the big credit card number stealing hacks that have been in the 
> > > news
> > > in recent years.
>
> > > For most sites it is better to deal with someone like Authorize.net:  
> > > These
> > > services let you point your "checkout" link at them, either with a back 
> > > channel
> > > identified by order number (which you add to the url) to pick up the 
> > > total, and
> > > perhaps the item list, or a way to provide that in the get or post
> > > with a suitable
> > > signature.  They host a page that you get to style, so you can have,
> > > for example,
> > > your color scheme and logo.  They accept the credit card information, do 
> > > the
> > > dance with the payment processor (such as Chase Paymentech), and, if
> > > payment is successful, send you a packet, email, or provide a webservice
> > > where you can check, so that you know to "ship".  These services do all 
> > > the
> > > PCI compliance diligence.  You are safe because the credit card 
> > > information
> > > never touches your website.
>
> > > On Mon, Apr 19, 2010 at 10:17 AM, Bobby Roberts  
> > > wrote:
> > > > Has anyone out there integrated a payment module in django over to
> > > > Chase Paymentech to process credit cards?  I'm looking for sample code.
>
> > > > --
> > > > 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 
> > > > athttp://groups.google.com/group/django-users?hl=en.
>
> > > --
> > > 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 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > 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 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
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 app svn management

2010-04-30 Thread Dan Gentry
I have my DEV server pointing to the svn repository, and I can try out
changes there.  The web server admins take care of moving the
application to production.

On Apr 29, 4:25 pm, Dexter  wrote:
> This was not really a feature request or how its really setup.
> But I wanted to know how the community thinks of this kind of development
> setup.
>
> I'm looking forward to your responses.
>
> Grtz, Dexter
>
>
>
>
>
> On Thu, Apr 29, 2010 at 4:10 PM, Dexter  wrote:
> > Hi there,
>
> > I was wondering if there is a solution to manage a django deployment with
> > svn like revision tool.
> > What I would like to have my main django deployment to be a trunk like
> > folder.
> > When I want to test something, or make a new app, I want to make a branch
> > oid. which should be visible under some sort of url structure (ie.
> >www.example.org/svn/branchname/normal_folder_structure)
>
> > I wouldn't know if this is the best way to develop app's, but I guess it
> > would be nice to commit something when it's solid, and not having to
> > compromise the general site preformance/stability.
>
> > What do you think of this?
>
> > Grtz, Dexter
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

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



Multiple CAS Servers

2010-02-23 Thread Dan Gentry
In the early stages of writing an app that will serve two
constituencies, each with their own CAS service.  (I work at a
university, and we serve both staff/students and alumni.)  The idea is
to attempt authentication with the first CAS server, and try the other
if the first is unsuccessful.

I've been using the wonderful django-cas package with a single server,
and I imagine I'll have to expand it in some way to handle the 2nd.

Anyone have any experience in this area, or thoughts to share?

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