Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2012-01-27 Thread alej0
self.object is None because you the workflow is def form_valid(self, form): self.object = form.save(commit=False) self.object.user = self.request.user self.object.save() super(CreateCampaignView, self).form_valid(form) # that does the redirect actually it's not necesary to neme i

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2012-01-13 Thread Juergen Schackmann
you made my day, working exactly like expected. :-) thanks a lot -- 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/-/RUSugDsY9K0J. To post to this group, send

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2012-01-12 Thread Alasdair Nicol
On 11/01/12 20:54, Juergen Schackmann wrote: if is use this code, as proposed by russ: def form_valid(self, form): self.object.user = ... (something meaningful.. e.g., self.request.user) return super(CreateCampaignView, self).form_valid(form) i get the error 'NoneType' obje

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2012-01-12 Thread Juergen Schackmann
I am trying to do the same as described in previous example: I have a model with a foreign key field to User and in the view I want to populate the the field from request.user. And when doing it exactly the way as Russ proposed, I get the described error. -- You received this message because

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2012-01-12 Thread Andres Reyes
What are you triying to achieve? 2012/1/12 Juergen Schackmann : > can really no one help? i am really stuck here at the moment > > -- > 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.goog

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2012-01-12 Thread Juergen Schackmann
can really no one help? i am really stuck here at the moment -- 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/-/RYLQqxJE7HYJ. To post to this group, send email

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2012-01-11 Thread Juergen Schackmann
if is use this code, as proposed by russ: def form_valid(self, form): self.object.user = ... (something meaningful.. e.g., self.request.user) return super(CreateCampaignView, self).form_valid(form) i get the error 'NoneType' object has no attribute 'user'. and actually, by lo

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-18 Thread br
While this doesn't contribute an answer to your question, I must say that name "class-based generic views" is a bit misleading . . . implying that these class-based views are for doing things you want to do that follow a strictly set pattern out of the box (i.e, listviews, detailviews, create views

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-16 Thread Paul Walsh
Hi Russ, Wow - your response is *exactly* what I needed - thanks a great deal :) As you mention in there, *because* CreateView gets me so far without the Form class (it builds me a form based on the model I declare), I was exactly looking to do other "ModelForm" stuff at the CreateView level.

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Venkatraman S
The below email contents can go into the django wiki? Explained in a lucid manner. Actually, it would be awesome, if someone from this group can volunteer to extract useful text explanations from this ML and put in the wiki. I would have done it, but i lost my password, and i dont see a 'forgot pa

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Russell Keith-Magee
On Fri, Jul 15, 2011 at 5:18 PM, Paul Walsh wrote: > I am pretty new to Django - new enough to be developing my first Django app > on 1.3. So, I am basing all my work on class-based generic views, and have > never used the older generic view functions. > A problem I have is the lack of examples an

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Andre Terra
On Fri, Jul 15, 2011 at 7:37 AM, Kenneth Gonsalves wrote: > > caveat - I have never used generic views, class based or otherwise, but > I was under the impression that if one wants customised forms or views, > generic is not the way to go. > > These views are classes and they exist precisely so th

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Andre Terra
Paul, Your form logic will go on your Form (or ModelForm) definition, not on the view. As the docs [1] say, CreateView is a combination of ModelFormMixin and ProcessFormView. Please read the docs on those two mixins to understand what methods your CampaignCreate class can override, but do move the

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Michał Sawicz
Dnia 2011-07-15, pią o godzinie 16:07 +0530, Kenneth Gonsalves pisze: > caveat - I have never used generic views, class based or otherwise, > but > I was under the impression that if one wants customised forms or > views, > generic is not the way to go. Why not? The model edit views use the Model

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Venkatraman S
Class based views reduce the amount of code written, but i am yet to get a grasp of it(need more experimentation). Somehow, i prefer plain 'old' way of methods in views.py which respond to different urls - it gives me better control and is easily to maintain. -V -- You received this message beca

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Kenneth Gonsalves
On Fri, 2011-07-15 at 02:18 -0700, Paul Walsh wrote: > I am pretty new to Django - new enough to be developing my first > Django app > on 1.3. So, I am basing all my work on class-based generic views, and > have > never used the older generic view functions. caveat - I have never used generic v

Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Paul Walsh
I am pretty new to Django - new enough to be developing my first Django app on 1.3. So, I am basing all my work on class-based generic views, and have never used the older generic view functions. A problem I have is the lack of examples and documentation on the new class-based generic views. M