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
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
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
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
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
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
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
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
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.
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
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
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
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
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
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
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
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
17 matches
Mail list logo