You can always check out the free online Django book at:
http://www.djangobook.com/
There is the 1.0 version (outdated) and a free web-preview of the 2nd
edition available.
In addition to books, the documentation for Django is pretty fantastic
to learn from for a beginner. This is located at:
h
This may not be helpful but here is how I usually go about processing
model forms:
class Partner(models.Model):
# this is your model, DB fields go in here
# This is your model form
class PartnerForm(forms.ModelForm):
class Meta:
model = Partner
# This is the view that displays a ne
What do you mean by having the ID "in" the form? I don't quite
understand what you are trying to do.
On Jul 21, 4:15 pm, mettwoch wrote:
> Ok, I come back to what I wrote before. If the partner already exists
> it has an id (primary-key or whatever). If it doesn't exist it has no
> id. I'd just
Oh I gotcha now.
Django model forms by default do not represent auto fields (ID's)
because it wouldn't make much sense for a user to be able to edit the
PK in a form. Having said that, I do understand why you need to be
able to see the PK.
I shown in my example, I personally prefer to represent
That shouldn't be a problem, after all templates are just strings as
are textfields.
If you have a model with your textfield in it as so:
class MyModel(models.Model):
template = models.TextField()
and you have a view which renders the template defined in the next
field
def my_view(request)
The stuff in the brackets are the optional arguments passed to the
"register" view.
You can read the documentation about the view at:
http://bitbucket.org/ubernostrum/django-registration/src/b360801eae96/docs/views.txt
Alternatively you can check out the code as well.
Cheers,
Dan
--~--~--
Take a peek at the Django forms documentation, specifically the
ModelChoiceField and ModelMultipleChoiceField, the docs are at:
http://docs.djangoproject.com/en/dev/ref/forms/fields/
These fields allow you to specify a queryset to populate your form
select fields, this queryset can be the list of
Looks just like you have an error in your programming, the name of
your view is "Dpatas", then you attempt to later call
"Dpatas.objects.filter()" as if Dpatas was a model. The _CheckLogin is
coming from your use of the @login_required decorator I would imagine.
Hopefully that helps,
Dan
On Jul
Assuming that you set_sub_date() function just sets the publish date
to when the item was created and easy way to do this is in the model
class PressRelease(models.Model):
pub_date = models.DateField(auto_now_add=True)
That will just set the pub_date to the current date when it is added
to t
what error are you getting?
On Aug 1, 4:41 pm, cprsystems wrote:
> I'm trying to write a simple html page using Django that passes one
> variable via a submit button and text line and prints it out to
> another hmtl document. I'm having trouble getting it to work. Could
> someone explain what I'
Have you checked out:
http://code.google.com/p/django-threadedcomments/
I think it is still being updated for 1.1, but it should still work
with 1.1. I haven't used it, just know of it's existence.
Cheers,
Dan
On Aug 7, 11:44 am, Alessandro Ronchi
wrote:
> I must add threaded comments to my
I just wanted to give a shout out as well to webfaction. I used to use
my own virtual private server for hosting django stuff, but to cut
costs i switched to a webfaction account and it is pretty fantastic.
Super easy to set up, if you decide to go that way just drop me and
email and i'd be happy
http://docs.djangoproject.com/en/dev/topics/auth/#limiting-access-to-generic-views
hope this helps. Basically you write your own view which calls the
generic view after you have done your authentication.
On Apr 16, 11:25 am, Col Wilson
wrote:
> I'm using generic views to render my pages
> (djan
virtualenv can be used with mod_wsgi, we are doing so on our
production servers.
see http://code.google.com/p/modwsgi/wiki/VirtualEnvironments for more
information
Cheers,
Dan
On May 3, 8:26 am, Stodge wrote:
> I am aware of virtualenv, but can it be used with mod_wsgi. Time to do
> some readi
project.com/en/1.2/ref/contrib/admin/#modeladmin-methods)
Hope this helps!
Dan Harris
dih0...@gmail.com
On Jun 8, 10:04 am, onorua wrote:
> I have
>
> class User(models.Model):
> Switch = models.ForeignKey(Switch, related_name='SwitchUsers')
> Port = models.Fore
You need to have a 500.html and a 404.html defined when DEBUG=False.
See: http://code.djangoproject.com/ticket/3335
Hope this helps!
Dan Harris
dih0...@gmail.com
On Jun 8, 2:56 pm, adrian wrote:
> tracked the problem more down...
>
> the problem appeared when using own handler404/h
ModelAdmin. You of course don't have to use
JQuery, but it is included by default in the admin and is quite
popular.
Dan Harris
dih0...@gmail.com
On Jun 8, 3:17 pm, onorua wrote:
> Hello, thank you for your reply!
> That's really what I've looked for, some way to prepop
ve "might" work.
And obviously if you have like 5 child classes, this gets ugly very
quickly.
Dan Harris
dih0...@gmail.com
On Jun 8, 3:27 pm, John M wrote:
> Hmm, that doesn't really get me what I want, it just caches the
> related child objects in one SQL query.
>
> Wh
are
you reading? If they are the official Django tutorials that is most
likely a bug in the documentation.
The documentation on the deprecation of newforms in favor of form is
in the Django 1.0 release notes at:
http://docs.djangoproject.com/en/dev/releases/1.0/
Cheers,
Dan Harris
dih0...@gmail.c
rks just fine for me. Flipflop the comments to toggle ascending
vs descending.
Hope this helps,
Dan Harris
dih0...@gmail.com
On Jun 5, 9:16 pm, rahul jain wrote:
> Hi Django,
>
> I tried lots of different ways to get my ids listed in ascending order
> (1 - x). But it always disp
e than 1 match found")
candidates[0].incumbent = True
candidates[0].save()
Something like that might work for you assuming that the models and
stuff are similar. Also, this code is just off the top of my head, so
who knows if it will actually work :)
Cheers,
Dan Harris
dih0...@gmail.com
Sounds about right, glad it's working for you!
Dan Harris
dih0...@gmail.com
On Jun 10, 12:41 pm, onorua wrote:
> I did following:
> add Media JS for User model (jquery and my own script follows), with
> FireBug get the names of HTML id of the elemets I want to process.
> Then
'float'
You can convert the decimal returned by the form into a float, or
convert the floats into decimals and do your math. Converting to
decimal is probably more precise.
Hope this helps,
Dan Harris
dih0...@gmail.com
On Jun 10, 3:22 pm, Waleria wrote:
> Hello..
>
> I
a foreign keys with a depth of two.
Hope this helps,
Dan Harris
dih0...@gmail.com
On Jun 10, 3:19 pm, Michael Hrivnak wrote:
> If I use select_related() on a queryset and specify some attribute names, will
> it follow those relationships as far as possible, or does that imply
> &q
r
like:
{% for r in res %}
{{ r.name }} - {{ r.name__count}}
{% endfor %}
however there may be duplicated {{ r.name }}
Dan Harris
dih0...@gmail.com
On Jun 10, 5:24 pm, SlafS wrote:
> Thanks.
>
> I've already tried that but this isn't quite what i'm looking for. As
>
n a list of the form:
[{'name__count': 2, 'name': u''}, {'name__count': 1, 'name':
u'bbb'}]
Hope this helps!
Dan Harris
dih0...@gmail.com
On Jun 10, 5:01 pm, SlafS wrote:
> Hi there!
> I have a question. If i have a model w
at is how I read the docs, it may not be correct :)
Cheers,
Dan Harris
dih0...@gmail.com
On Jun 10, 4:54 pm, Michael Hrivnak wrote:
> I read that myself. I asked the question because it goes on to state that you
> can specify down-stream models like this:
>
> query.select_related(person__
readability thing, you might want to split that giant line of
code into a few separate calculations, but that's just an idea!
Cheers,
Dan Harris
dih0...@gmail.com
On Jun 10, 3:33 pm, Dan Harris wrote:
> The error looks like you are attempting to multiply a decimal by a
> float
first-view
part of the documentation for more.
Cheers,
Dan Harris
dih0...@gmail.com
On Jun 10, 6:30 pm, albert kao wrote:
> I try the "Writing your first Django app tutorial, part 3" (http://
> docs.djangoproject.com/en/dev/intro/tutorial03/#intro-tutorial03) with
> Django-1
els.py file only. If you make a models directory, you have to
import all models you want Django to recognize into your __init__.py
file within the models directory.
Hopefully this makes sense, if not I can try to be more clear.
Dan Harris
dih0...@gmail.com
On Jun 10, 4:46 pm, rahul jain wro
Looks like you haven't created any polls yet, at least not one with an
ID of 5. Go into the admin section described in part 2 of the tutorial
and make a few polls. Once you've create some you should see polls of
IDs 1,2,3 etc show up and the URLs should start to work.
Dan Harris
dih0...
That looks ok from a code readability point of view, however you will
still need to cast the form values to float or cast the float values
(i.e. pow(2,2) and pow(2*math.pi*v,2) to Decimals otherwise will you
will get an UnsupportedOperation exception.
Dan Harris
dih0...@gmail.com
On Jun 11, 6:58
uses
with the "db_table" meta option. Please refer to the docs at:
http://docs.djangoproject.com/en/1.2/ref/models/options/#model-meta-options
for more information.
Cheers,
Dan Harris
dih0...@gmail.com
On Jun 11, 1:06 pm, creecode wrote:
> Hello all,
>
> I have a model named FOO
hence the space.
See: http://docs.djangoproject.com/en/1.2/ref/models/options/#verbose-name
for more details.
Cheers,
Dan Harris
dih0...@gmail.com
On Jun 11, 2:38 pm, creecode wrote:
> Hello Dan,
>
> Thanks for the info. verbose_name does take care of the display
> problem and I m
s:
# "show me all objects that are the last meeting before 3 or start
betweeen 3pm and 5pm"
MyModel.objects.filter(latest_meeting | after_3_and_before_5)
Not sure if this is what you're looking for or if it's even right :)
Dan Harris
dih0...@gmail.com
On Jun 11, 4:28 pm, Ces
This article might help you out: http://djangoadvent.com/1.2/object-permissions/
Cheers,
Dan Harris
dih0...@gmail.com
On Jun 11, 11:46 pm, Wiiboy wrote:
> Hi guys,
> I don't know whether the built-in permissions system would be
> appropriate here, but I want to control access to
order_by_here') # replace
with your ordering method
return db_field.formfield(**kwargs)
return super(MyModelAdmin, self).formfield_for_foreignkey(db_field,
request, **kwargs)
Hope this helps,
Dan Harris
dih0...@gmail.com
On Jun 13, 8:53 am, backdoc wrote:
> This only impacts th
alling the super class delete. This way when the cascades
go through it doesn't have links to next or previous chapters and not
everything is deleted.
Hope this helps,
Dan Harris
dih0...@gmail.com
On Jun 15, 12:11 pm, Tim Arnold wrote:
> Hi,
> I have a model for a Book that contains Ch
looking for.
Cheers,
Dan Harris
dih0...@gmail.com
On Jun 22, 10:59 am, Venkatraman S wrote:
> On Tue, Jun 22, 2010 at 8:06 PM, M Rotch wrote:
> > I'm setting up a website with multiple subdomains, and one thing I
> > notice right away (and is expected) is that each subdomain has
orm from a model, blank=True inside the models
is transformed into required=False for the form.
class MyModelForm(forms.ModelForm):
class Meta:
model = MyModel
Hope this helps!
Dan Harris
dih0...@gmail.com
On Jun 22, 4:11 pm, Jonathan Hayward
wrote:
> What is the preferred way t
40 matches
Mail list logo