You should exclude the password field in your overridden model form.
If you want to have a password added at the time of user registration
then you can add an additional charfield to the form (make sure to use
the "password" widget). You should probably add two such fields so you
can compare them t
Any validation which has to do with multiple fields should be done in
the clean() override, not within the individual field validator.
You can't rely on cleaned_data existing before that point.
http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-o
Yes, the password stored will only ever be the hash type, hash salt,
and hash. You should never store it in plain text.
If you're interested you can look at the actual model. You might be
interested in these functions: set_password(), get_hexdigest(), and
check_password().
These make it clear what
It doesn't seem like converting your data into fixtures will provide
any advantage. If it's pipe-delimited, then just write a Python script
imports the CSV module (which can handle other delimiters) and your
model(s).
Use it to read the data and convert it to dictionaries, then create
instances of
I think you just may be missing a call to get_profile() in this view.
You can just do that and do a try block with an except block for
DoesNotExist. That will let you know the situation you're in, whether
the profile already existed or not.
Also, unless I'm misreading something you're trying to pa
It depends on whether it can contain whitespace or must contain
whitespace, and whether that whitespace may appear anywhere in the
string or only in a certain location, or after (or before) some other
matched pattern.
Examples:
[\w\s]+ will match "word" and/or whitespace, mixed.
\w+[\w\s]+ will
You can use Python's unittest module to test any Python code (including Django
code).
What is it about Django's test client or TestCase class that is a problem for
you?
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this gr
Django is a Python module like any other. You won't be able to install it on
shared hosting because you won't have permissions to the package directory. You
can easily get around this by using virtualenv.
Here are the basics you'll need:
download virtualenv
extract the tarball
do not try to i
One easy solution for this is to override the __init__() of your model
and save the values of the properties you care about in a dictionary
within your instance, such as self.orig_values.
Then, override the save() and compare the values of your model to
self.orig_values to see if they've changed.
Did you do any database migrations, or just add the new field?
Just adding the new field to the model doesn't undo the groundwork laid by your
original syncdb, which has set up the other field as the primary key in the
database itself. Although your Django model is the way you want it, your
da
There are always ways. You could subclass models.Model and add the behavior, if
you read enough to understand how Django's models work.
However, since you're only going create a model once (except migrations later),
is it really going to save that much work?
If you want to do it a quick & dirty
Of course. You can dynamically add to self.fields in the __init__ of your form
instance.
Shawn
--
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,
Just FYI, the videos from DjangoCon 2010 are already up on blip.tv.
The Python AV team was awesome.
Here's that talk:
http://blip.tv/file/4112452/
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to djan
It's probably your PYTHONPATH.
Check the result of:
echo $PYTHONPATH
I'm guessing that your apps directory is not in the path. If not, you can add
it to your path.
export PYTHONPATH=yourdirectory:$PYTHONPATH
--
You received this message because you are subscribed to the Google Groups
"Djan
Try writing both values to the screen or standard out.
It's always possible that one of them isn't being populated.
--
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 unsubscr
Oh, and you don't have a space between those two variables, so it could be that
they're running together and appear to be a single one.
--
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...@googlegrou
I recommend "The Definitive Guide to Django," without reservation.
See my review for more details:
http://www.amazon.com/review/R2ET5WRO205C9I/ref=cm_cr_rdp_perm
Ignore anyone who says it's outdated. Some people are thrown into fits of
despair when a book's cover has a title that's 0.1 less th
On Sep 24, 2010, at 6:53 AM, Franklin Einspruch wrote:
> I recommend against Beginning Django E-Commerce in favor of The
> Definitive Guide. The project described in the former has you chasing
> down so many details that it's hard to get a sense of the big picture.
> As a second book it's more in
Context processors will do this for you.
http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors
--
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.
We need more information. Preferably the full traceback.
In short, something is trying to add a date object to a unicode text
object. Possibly the date as a date object and the time as a unicode
string. How did you convert the original data to JSON?
--
You received this message because you are s
If you're updating a database created by Django, I recommend that your import
script import your Django models and update them with the data. Otherwise you
run the risk of running SQL that breaks your Django app (or worse, causes it to
run with corrupted data and no errors).
I'd do something wi
If you're asking for functionality like this: http://www.changedetection.com/
Or are you looking for something to embed in your own code to know when
something has happened on your own site?
If the former, you can probably do it by scheduling a urlopen and saving its
hash, comparing it each tim
I did a quick Google search and didn't find anything that was obviously solving
this problem. I did see companies that sell this service, and probably with
good reason.
Due to dynamic content such as ads, data from RSS feeds, and simply
auto-generated content from server-side code, it seems tha
I live on the east coast, but the past two DjangoCons have caused me to fall in
love with Portland. It would be a treat for me to get to go there again in
2011.
In fact, if it's in Portland next year I plan to make a family vacation of it.
So, that's my vote, for whatever it's worth. Hope to
This sounds like more of a Python question than a Django question
Have a look at Python's 'random' module and Django's 'send_mail' shortcut.
Shawn
--
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.
Do you see anything at all like this if you run your app from your development
box?
You can always use the Python debugger to trace for your code and look for
bottlenecks.
(Awesome tutorial) http://www.doughellmann.com/PyMOTW/pdb/index.html
Also, put in logging and add log.debug statements in
http://djangocon.blip.tv/file/3322277/
--
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.
I ran into an interesting forms issue today which I came up with a solution
for. Now I'm wondering if there's a better way.
Situation:
I have a forms.Form with several fields in it, including a ChoiceField. The
values in this ChoiceField are dependent on what the user has access to. Many
users
Actually, I spoke too soon on this one. My original solution doesn't work
because the hidden input on the form doesn't have a value, so the form won't
validate.
I fixed this by just adding display: none to the widget attrs in the __init__
instead of changing the widget to a HiddenInput. Now the
On Sep 29, 2010, at 5:08 PM, aa56280 wrote:
> Can't you specify the value using the initial argument?
> http://docs.djangoproject.com/en/dev/ref/forms/fields/#initial
>
>
I did that originally, but it doesn't show up when the HiddenInput renders.
That's why I stopped changing the widget.
Sh
You can just add another keyword argument to your constructor.
If you override the __init__ of your form then just pop that item
off before passing it on to the __init__ in super() and nobody gets hurt.
;o)
Shawn
On Sep 29, 2010, at 6:03 PM, Oivvio Polite wrote:
> I'm creating new users+pr
>
> Hmm.. I can't think of any caveats off the top of my head. Did you try that?
> The only thing that smells a little like trouble to me is setting a
> default manager.
If you create a custom manager, then add it to each model as "objects," then
it'll be the default (and only) manager and any c
For what it's worth, I use the get_or_create with the 'default' keyword to do
this:
for record in reader:
new_values = {
'product_code': slugify(record['Product Code']),
'msrp': record['Suggested Retail'],
#etc...
}
product, was_created = Product.obje
You can use BeautifulSoup to parse the page. That will result in a
BeautifulSoup object from which you can get the text of any element.
Simple example:
soup = BeautifulSoup.BeautifulSoup(html_string)
#find a div with class 'header3' containing the text 'Locations'
locati
Check out South:
http://south.aeracode.org/
--
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
','.join(your_list)
--
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, v
On Oct 4, 2010, at 9:27 AM, ashwin morey wrote:
> Hi,
>
> I am using django development server and not apache. But the print str is not
> working.
> I tried changing str to s, but no luck.
>
> thanks
I think you would benefit greatly from doing a Python tutorial.
http://docs.python.org/tuto
1. http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together
2. If you're using a foreign key to a User instance then duplicate names aren't
a problem.
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group
Why not just use a ModelForm?
You can override the form's clean() or add a clean_url() method. You'll be able
to use self.instance to get the model instance of the model form, and from that
you can get the previously-used URLs.
Shawn
--
You received this message because you are subscribed t
I think your model should have a foreign key to User, and the user field in
your model should be set by the time you're doing this validation. That makes
more sense and is also a lot easier to do.
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users
The answer is in the error:
ManyToManyFields are
not supported in unique_together.
Instead, you can put custom validation in your form's save(), your ModelForm,
or (in Django 1.2) in your model validation.
--
You received this message because you are subscribed to the Google Groups
"Django
Is there anything specific you're concerned about?
Almost everything is applicable to the latest version. If you're not using
trunk, then just being familiar with the 1.2 release notes will be enough to
let you know if what you're reading is deprecated. Most Django books out there
haven't ben
I have Webfaction. I found a file named /etc/redhat-release which states that
my server is running CentOS release 5.5 (Final).
I hope that helps. Look for a file in /etc beginning with 'lsb' (for Linux
Standard Base') or 'redhat.'
Shawn
--
You received this message because you are subscribed
I searched the list online and haven't seen any recent discussions about this,
so I figured I'd check in. Last I heard, Orbited was the way to go, but it
seems that both it and django-orbited haven't seen any development in quite a
while. The developer of Orbited is working on something called H
What are you trying to accomplish? If you set blank = True and null = True then
they'll be null in the database after the migration and if left blank by the
user.
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, se
If you do a Google search for "Django legacy database" you'll get all the info
you need. It's a fairly common topic and it's all been discussed before.
If you have any specific questions once you decide whether to migrate, use
Django's inspectdb, or sync multiple databases then please ask for de
If the field isn't a required field, I don't think South would complain about
no default being set.
What type of field is it? What version of Django, and what version of South?
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to
It seems that the command you're running is not on your PYTHONPATH. You may
have to enter the full path to django-admin.
Shawn
--
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.
One way would be to use the dumpdata command to export everything, change your
settings to point to the new database, then loaddata to restore.
There may be a better way, but this way allows you to dump to a
database-agnostic backup so it seems like it would suit your needs.
Shawn
--
You rece
On Oct 13, 2010, at 1:58 PM, Brian Bouterse wrote:
> I have found cron to be a poor solution for this although it is tempting
> since it is so easy and will get you started right away. What I observe
> happens is, basically someone puts the cron job in crontab, and then a lot of
> time passes
On Oct 13, 2010, at 4:11 PM, ringemup wrote:
>
>> It's surprisingly easy to get set up with nothing more than the
>> tutorial/into for django-celery. If anyone has problems with it I'd be happy
>> to try to assist.
>
> Thanks, I might take you up on that.
>
>> Although getting everything wor
On Oct 13, 2010, at 5:07 PM, ringemup wrote:
> Thank you for taking the time to explain that, Shawn -- it makes
> everything a LOT clearer.
>
> If you could spare the time, I'm curious about a couple of aspects of
> the architecture:
>
> - What is the purpose of having a separate broker and dae
On Oct 13, 2010, at 5:25 PM, Javier Guerra Giraldez wrote:
> On Wed, Oct 13, 2010 at 3:43 PM, Shawn Milochik wrote:
>> C. The Celery daemon polls the broker regularly, looking for tasks.
>
> i hope this isn't polling, but a signal initiated by the broker.
>
> --
Check out your model's _meta.get_all_related_objects().
Explore that through the interactive interpreter and you'll find
everything you need.
Shawn
--
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.
One possibility is to add a post-delete signal which listens for
instances of news items and uses the content type to clean up comments
with that content type and primary key.
I'm pretty sure this isn't considered a bug, but I couldn't address
the issue of whether it was a planned part of the desi
Your post model should have a foreign key to user, perhaps named "creator" or
"owner."
Then ensure that the edit and delete views in your application can only modify
or delete posts where the owner is request.user.
Shawn
--
You received this message because you are subscribed to the Google G
Given a tuple/list of primary keys named ordered_ids and a queryset named
records:
results = [records.get(pk = x) for x in ordered_ids]
This is a naive example, as it assumes that ordered_ids will never have IDs
which don't exist in the queryset, but it gives a simple way to do what you're
ask
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
This'll do the trick. ;o)
Shawn
--
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
And like magic, it's there!
http://docs.djangoproject.com/en/dev/topics/serialization/#natural-keys
--
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 gro
On Sun, Oct 24, 2010 at 6:26 AM, Michael Scull wrote:
> Hi,
> I'm having trouble installing django and connecting to irc.
>
> --
> Mit freundlichen Grüßen / Best Regards,
> Michael D Scull
>
If you want help, please look up the exact error output you're getting
in the "Search this Group" box here
Try going into the shell with 'manage.py shell,' import the User
model, and attempt to delete that user. See what happens and give us
the traceback if it fails and you still don't know why.
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
Try this instead:
http://djangosnippets.org/snippets/1478/
Or you could do it manually in your model:
1. Add field _value_json to your model.
2. Add functions (get_value, set_value) which do the simplejson work.
3. Add a property named 'value' with get_value and set_value as its
getter and sette
The errors are given a standard 'error' class. You can just add CSS to
modify it to your tastes.
Shawn
--
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
I'm using Django 1.1.
I have a forms.Form that has fields in it, and I'm dynamically
creating custom fields, each with a name beginning with 'custom_.'
In my template I'm already displaying the non-custom fields. I need to
be able to show just the custom fields.
How do I iterate through only the
>From the traceback it seems that your hypothesis about the Python
version may be correct. I don't know what versions of Python South
tests with.
However, I'm in the same situation you are (Cent OS), and I get along
wonderfully with virtualenv. I'm using Python 2.7 and everything's
grand. If you n
A short note about your primary concern:
You can simply change the shebang line of your manage.py script to
point to the 'python' in your virtualenv. The same goes for a .wsgi
file. There's nothing particularly magical about "activating" a
virtualenv in an interactive terminal session.
Shawn
--
Context processors, or a custom template tag, as described in James Bennett's
book, "Practical Django Projects."
--
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
http://docs.djangoproject.com/en/dev/howto/custom-model-fields/
--
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+unsub
I don't think you need to change the value, but rather add
localization so add proper formatting.
http://docs.djangoproject.com/en/dev/topics/i18n/localization/#format-localization
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this
Add a clean() method to your ModelForm, and raise a forms.ValidationError if
self.instance.whatever.all().count() == 0.
Shawn
--
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.
Don't use Django's connection; just use psycopg2 directly.
--
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.
Instead of the domain try 0.0.0.0 or your public IP address.
python manage.py runserver 0.0.0.0:8000
or
python manage.py runserver 82.165.105.204:8000 #this is just a sample
IP address for Host Monster
Shawn
--
You received this message because you are subscribed to the Google Groups
"Djang
If you're using Internet Explorer you have to add the http:// to the
URL. If you're not, I apologize for suggesting you might be using the
Big Blue E. ;o)
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email
The queryset returns zero or more instances of your model. So if
there's only one result, you can just get the first item in the
queryset by its index.
For example:
some_queryset = YourModel.objects.filter(**kwargs)
if some_queryset.count() == 1:
x = some_queryset[0]
#x is now an instanc
2010/11/10 Łukasz Rekucki :
> On 10 November 2010 21:55, Shawn Milochik wrote:
>> The queryset returns zero or more instances of your model. So if
>> there's only one result, you can just get the first item in the
>> queryset by its index.
>>
>
Łukasz,
Good and valid points. Thanks.
Shawn
--
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...@googlegrou
On Wed, Nov 10, 2010 at 4:42 PM, Brian wrote:
> Dan, Thanks for the reply.
>
> I just can not get it to work. Works just fine in same or any
> directory under the dir that the .py file is in.
>
> I played with TEMPLATE_DIRS setting without any luck, tested to the
> root dir and still does not work
On Wed, Nov 10, 2010 at 5:16 PM, octopusgrabbus
wrote:
> Thank you. This worked well.
> However, I'm left with this value
>
>
> How do I get that into a comparable form?
>
It sounds like you're getting the __unicode__() representation of your
model. If you want the data in the actual fields you'
On Wed, Nov 10, 2010 at 4:35 AM, derek wrote:
> I have not really understood when and why they are needed; I would be
> interested to see an alternative also because it might improve my
> understanding.
>
I've never used them before, and always avoided looking into them
because I thought they wer
On Fri, Nov 12, 2010 at 3:12 PM, Lindsay Hunt wrote:
> I'm really a novice with using Django. Can you help me understand where I
> can find the settings.py ?
You really need to at least do the tutorial. If you have questions
this basic, then if someone answers them you'll probably get stuck
imm
Sure: djangogigs.com is a good resource.
Shawn
--
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...@googlegro
The recommended way to do this is to actually use Python's logging
module. If you're using trunk or 1.3 beta then you can configure it
right in settings.py.
If you really want to view print statements, use the development
server (in your development environment) and you'll see them.
Also, dependi
Another solution is to use context processors (they're in the docs).
--
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+
It's definitely possible. I've seen that myself before.
Shawn
--
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+unsub
On Sun, Nov 14, 2010 at 1:23 PM, John Fabiani wrote:
> On Sunday, November 14, 2010 09:19:01 am Shawn Milochik wrote:
>> It's definitely possible. I've seen that myself before.
>>
>> Shawn
>
> While in this runserver mode is my database password exposed?
>
The version of Python isn't related to this. The problem is that the
django script you are calling isn't on your system's PATH.
If a program is on your PATH, such as the 'ls' command, you can just
type 'ls' and it will run. If you type 'which ls' you will see where
the program lives. You can also
You'll need to use AJAX for this, or refresh the entire page.
Be aware that you'll have to have all the states/provinces as
'choices' in the ChoiceField in the form, otherwise the form won't
validate.
As for examples, just do a quick Google search. The easiest way (in my
opinion) is to use jQuery
What version of Django are you using?
Also, you can create a customized Connection() for each piece of mail you send:
http://docs.djangoproject.com/en/dev/topics/email/
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this grou
On Tue, Nov 16, 2010 at 10:39 AM, diegue...@gmail.com
wrote:
> I'm using django 1.2 but i dont know how connections works exactly, i wish
> use only one backend, SMTP, but how i tell the connection, the new user for
> authentication for smtp?
>
Read the fine Django docs at the link I attached. Yo
On Tue, Nov 16, 2010 at 7:40 PM, Alex s wrote:
> Hi,
>
> I am planning to limit the number of users logged online in my application.
>
> How can I do it?
>
> Thanks
> Alex
There is no "logged in" state for a user. You will have to store user
IDs and the last time a request came in for that user,
On Tue, Nov 16, 2010 at 9:08 AM, derek wrote:
> " you'll have to have all the states/provinces as 'choices' in the
> ChoiceField in the form, otherwise the form won't validate."
>
> Yup, this is a "real" gotcha. IMO, its not really true filtering if
> you take this approach, as the initial form w
When you put an app into INSTALLED_APPS, it looks on your PYTHONPATH.
If you make an app intended to be pluggable, your users should be
installing your application with pip or something, and your app code
will exist on the PYTHONPATH, not in a subfolder of their Django
project.
If you want to dev
I installed the django-selenium-test-runner package and have finally
have almost everything working. Everything happens up through the
launch of the browser, but when it tries to hit the 127.0.0.1 there's
no connection. It appears that there's no test server running. I
obviously can't run it manual
What does the "action" parameter of your HTML form contain? I'm
guessing it's a relative URL.
If you want it to go to the same place, you can make the action blank
("") and it will submit to the same page.
Shawn
--
You received this message because you are subscribed to the Google Groups
"Djan
When you run dumpdata you can specify apps or models within an app to
export. That will allow you to avoid bringing Django's scaffolding
into your fixtures.
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email
This works for me. Are you certain the code you think is being executed is
where it's "freezing"?
Try some logging statements. How are you running your tests -- are you just
using the standard test runner?
On Nov 22, 2010, at 9:04, Murray wrote:
> pdb dosn't seem to work inside my unit tests,
On Dec 24, 2009, at 2:51 PM, Aristotle Miternan wrote:
> Hello all,
>
>I'm fairly new to Django and I noticed a curious behavior of
> forms. I noticed that there is no simple way to test a form for a form
> not being filled at all. I think it might be a semi-common use case
> that you might
Django-south is the best solution right now. Django-evolution is no longer
developed, as the author thinks South is the current best solution.
http://south.aeracode.org/
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this gr
Try this:
request.META['HTTP_HOST']
If not, check the docs for the request object:
http://docs.djangoproject.com/en/dev/ref/request-response/#httprequest-objects
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, se
Michael,
I think what Karen was referring to was this:
http://catb.org/~esr/faqs/smart-questions.html
It's not how much or how little you know. It's how you ask the question. There
are a lot of people on this list who will willing answer the most elementary
question, if the request is made in a
201 - 300 of 1241 matches
Mail list logo