maybe something like this...
class Employee(models.Model):
# your employee model fields here, no FKs to Contact or
Assignment models
...
class EmployeeAssignment(models.Model):
active = models.BooleanField() # I added this
employee = models.ForeignKey(Employee)
...
class
See if this tag won't work for you:
class ObjectAttribNode(template.Node):
def __init__(self, obj, attr):
self.obj = obj
self.attr = attr
def render(self, context):
print self.attr
try:
obj = resolve_variable(self.obj, context)
form = NewsForm(request.POST, somegroup=somegroup)
given your form __init__ definition, you are passing POST into the
spot for somegroup.
What I did to get around this was something like this:
class NewsBaseForm(BaseForm):
def __init__(self, *args, **kwargs):
nkwargs =
You can make a 'views' subfolder in your app folder, and make sure it
contains an __init__.py file (can be empty).
My personal opinion is that going overboard trying to make your python
file structure 'neater' will eventually bite you in the ass. It wasn't
too bad for views, but became import
from here:
http://64.233.169.104/search?q=cache:bswtnEOJ33QJ:douglasjarquin.com/blog/2007/07/13/unicode-django-and-textile/+textile+unicode=en=clnk=3=us=firefox-a
try textile.textile(str(self.source))
On Aug 5, 12:34 pm, Martin Gilday <[EMAIL PROTECTED]> wrote:
> I have added textile.py to my
A queryset is kind of like a list, you can slice it, access by index,
or iterate through it. I'm not quite sure what you are trying to do,
but to access the individual user objects you have to fetch them from
the queryset somehow:
users = User.objects.all()
by index:
print users[0].user
print
how about surrounding the statement with a try and work the leap year
to regular year case with the exception?
On Aug 3, 10:16 am, Bram - Smartelectronix <[EMAIL PROTECTED]>
wrote:
> Jonathan Buchanan wrote:
>
> >
>
> >http://toys.jacobian.org/presentations/2007/oscon/tutorial/
>
> > Slide 14,
context_dict.update(button1_helper())
Opps, forgot to actually call button1_helper. Sorry, need sleep :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to
> thanks doug, this is what I did, but I am not comfortable with it.
> those two button do different things, and if they're under one method
> on the views it could be ugly, what if I have 4 or 5 submit buttons?
Keep in mind there is nothing keeping one view from calling another.
def
As far as I know a form submits to a single url via the action=?
specifier. That's just the way an html form works. Each submit
button that is part of the form is going to post to the action url in
the form. You can override with javascript, but that doesn't make
much sense unless you're doing
God, 0/2, just do what John proposed, I am not thinking straight right
now, what I would give for an edit capability on my emails, I'll spend
all of tonight removing my foot from my mouth.
On Aug 2, 10:49 pm, Lucky B <[EMAIL PROTECTED]> wrote:
> Ok, I've thought about it some more, an
the
middle-man model. I am pretty sure that's the only way to do it, but I
could be wrong.
On Aug 2, 10:29 pm, Lucky B <[EMAIL PROTECTED]> wrote:
> ack, I missed a few things, the ingredient-quantity measure. not sure
> how to do that. ignore my previous message.
>
> On Aug 2, 10:27 p
ack, I missed a few things, the ingredient-quantity measure. not sure
how to do that. ignore my previous message.
On Aug 2, 10:27 pm, Lucky B <[EMAIL PROTECTED]> wrote:
> You're missing just:
> ingredients = models.ManyToManyField(Ingredient)
>
> In your recipe model.
>
&
You're missing just:
ingredients = models.ManyToManyField(Ingredient)
In your recipe model.
If you want a pretty interface in admin (if you're not using newforms-
admin) then:
ingredients = models.ManyToManyField('Ingredient',
filter_interface=models.HORIZONTAL)
On Aug 2, 10:13 pm, "Shane
create different URLs (and thus different views) for the different
buttons and then redirect to wherever you want to go.
On Aug 2, 10:13 pm, james_027 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> How do I handle this situation wherein I want different submit button
> to call different method on the
If I gather correctly you want to see every ModelA that's bound to a
particular ModelB b?
ModelA.objects.filter(modelBs=b)
That gives you what you want.
On Aug 2, 7:20 pm, Benjamin Goldenberg <[EMAIL PROTECTED]> wrote:
> Hi everyone,
> I asked about this earlier today on IRC and
null=True only affects the database representation, you need to set
blank=True. The reason you can do it in the command line is that you
can bypass admin's validators through the command line.
On Aug 2, 11:08 am, Ramashish Baranwal <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I have a model that has a
I think you should be using form_for_instance on the dvd instance
instead of the generic form contructor.
http://www.djangoproject.com/documentation/newforms/#form-for-instance
On Aug 2, 11:14 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote:
> No ideas anyone? :-/
You could try Eclipse BIRT for a WYSIWYG interface. But otherwise you
can create a view however you want to report your data doing whatever
manipulation you wanted. I don't see what else you would need other
than to create a view.
On Aug 2, 5:17 am, Mir Nazim <[EMAIL PROTECTED]> wrote:
> Anybody
You can create a custom tag, I've never done it myself, but it's in
the docs:
http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags
I am sure you can get more help if you need it, but this should get
you started.
On Aug 2, 12:51 am, Greg <[EMAIL PROTECTED]>
You should be doing
>>> p = Profile.objects.get(id=1)#or .get(1) or one of the many other
>>> posibilities
filter returns a list of the results, in the case of id=# it probably
returns only one, but it's still a list of one member.
So in your case it would work if you did this:
>>>p=
Everything can be changed. Look under auto_id in the newforms docs on
djangoproject.com. The default does it exactly the way you seem to
be, prepending 'id_' to the field name. If you want to set a class,
you need to change the attrs dict on the field's widget.
All a newforms field really
You could also make your own render_to_response() function that
renders and caches the generic part of the page, and then passes that
in as a context for your base layout with the non-cacheable stuff like
the username. Or make some of the generic stuff tags that cache
themselves using the lower
> So my question is am I missing something or I was just expecting too
> much from the newforms?
I had similar problems initially, and after hundreds of forms built I
still get annoyed every time I have to build a newforms form. On the
other hand, I can't really think of a better way to do it
Garg, hit enter too fast.
Class MyForm(forms.Form):
username = forms.CharField(max_length=12)
def clean_username(self):
username = self.clean_data['username']
if username == 'bob':
raise ValidationError("Bob is not allowed here")
return username
If
newforms does that, but it's up to you do take care of the details by
either subclassing one of the existing fields like this snippet shows:
http://www.djangosnippets.org/snippets/115/
Or by making a specially named method on the form definition like
this:
Class MyForm(forms.Form)
username
Using threadlocals and a custom template loader would probably work,
just put your loader first in settings.py.
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
Just pass them in as context variables, either the whole thing or just
the parts you need. This is kind of a snippet from my current project
that might show what I mean. I say kind of because I use a handler
object that wraps request and a few other things instead of request
directly, but the
Maybe you could do something like this?
filterargs = {}
filterargs[fieldname] = some value
# or for other types of filtering
filterargs["%s__istartswith" % fieldname] = somevalue
mdl.objects.filter(**filterargs)
You might also want to take a look at the function get_model()
from
Don't use a ChoiceField, but do use the select widget.
class TF(forms.Form):
blah=forms.IntegerField(widget=forms.Select(choices=((1,'one'),
(2,'two'))), initial = 2)
post = {'blah': 42}
form = TF(post)
form should validate. It would be up to you to make sure that the
Integer value is
I don't know how others have approached it, but I have a 'settings'
file with defaults defined in one place and reference those values via
imports in the form file and model file. For values specific for the
app, I stick them in the models file.
models.py
-
POST_DEFAULTS =
You could also throw an exception, if you have debug on it'll have
everything including the post data.
On Jul 22, 11:34 pm, Doug B <[EMAIL PROTECTED]> wrote:
> Assuming you just want to debug and are using the dev server you can
> just do "print request.POST" and it w
Assuming you just want to debug and are using the dev server you can
just do "print request.POST" and it will show up on the dev server
console. The results aren't all that pretty, but usable.
--~--~-~--~~~---~--~~
You received this message because you are
admin != user
Atleast that's my view. As tempting as the pretty admin interface
might be, I think you would be better off rolling your own form and
view for end users. Then you have complete control. Using the
form_for_* functions you could have the whole thing done in a few
minutes.
fetch
Are you sure the request is actually being made, and not ignored by
the browser? If you do GETs to the same url with the same parameters
(your boolean I assume) the browser will simply ignore the request. I
ran into that trying to do some ajax stuff, and ended up appending a
timestamp number as
If you are using the helper functions like form_for_model, form.save()
should return the saved object. The helper functions build the save
method for you based on the model definition. If you are doing custom
forms, it's up to you to make the form.save() method to handle the
form->model
I have an event manager that is a bit like a database driven
pydispatch combined with a general logging/monitoring app.
Embarassingly enough I wrote it before learning about pydispatch and
signals. So much for not reinventing the wheel. It keeps track of
various events, calls registered
I've been looking around the limited signals documentation and the
code hoping to find a signal that basically says 'django is done
importing models ready to receive requests', but haven't found it
yet. The closest I've found is connecting a receiver to
request_started, and then removing that
Thanks to Malcolm, this was resolved. The problem was because I was
trying to use a model before all models had fully been loaded.
Unfortunately it was due to my own mistake rather than anything that
would help with ticket 1796, but I'm grateful he stuck around to help
figure it out anyway.
I've got a problem I can't figure out, and from the silence in IRC I'm
either doing something really stupid or it's as strange as I think it
is. I'd appreciate any assistance.
For a nice highlighted version try: http://dpaste.com/11163/
"""
I'm sorry this is so long. The nutshell version
is
Your proposed solution is exactly what I did. I think the official
term is a 'mixin class'. It's worked out really well so far.In my
case the mixin class looks for the Event class defined in the model
for various settings. In your case they might contain a mapping
between your mixin model
If you put the call to your _users() function in the form __init__() I
think it will be what you are looking for. initi s called
automatically whenever an instance is created.
class MemoForm(forms.Form):
-snip-
def __init__(self,*args,**kwarg)
If you put the call to your _users() function in the form __init__() I
think it will be what you are looking for. initi s called
automatically whenever an instance is created.
class MemoForm(forms.Form):
-snip-
def __init__(self,*args,**kwarg)
If you put the call to your _users() function in the form __init__() I
think it will be what you are looking for. initi s called
automatically whenever an instance is created.
class MemoForm(forms.Form):
-snip-
def __init__(self,*args,**kwarg)
The dev server operates much differently than an actual production
server. The production server will only evaluate module code once
when the module is initially loaded. It doesn't automatically scan
for file changes and load files as necessary like the dev server
does. If you want file
My suggestion would be to NOT implement it! I took a similar approach
when I was trying to learn python/django, wasted a bit of time, and
almost never use the monstrosity I created. I'd have been better off
just doing it the django way and/or waiting for newforms to be
completed (which may
You can't limit choice like that. The choices specified there are
evaluated only when the model is first evaluated (module load time).
What you need to do is limit the options displayed to the user via
form choices assigned in your view.
So you might do something like this (I'm half asleep, but
You can still create a Manipulator object to validate your data.
Thanks, and I may be clueless here, but it seems as if manipulators
don't work within the iterator context. If I am using an interator
to iterate over records that I want to modify and then update using save(),
how do I add in a
I've been toying around with Django, and I'm trying to figure out the
proper way to validate backend data going into the database that
doesn't come through a form. In this particular case, the data is
coming in off an XML feed and being inserted or updated into a Django
model.
Can someone point
301 - 349 of 349 matches
Mail list logo