Questions tagged [django-contrib]

django-contrib is a django package with a variety of extra, optional tools that solve common Web-development problems

django-contrib is a django package with a variety of extra, optional tools that solve common Web-development problems.

85 questions
73
votes
7 answers

request.user returns a SimpleLazyObject, how do I "wake" it?

I have the following method: def _attempt(actor): if actor.__class__ != User: raise TypeError Which is called from a view: self.object.attempt(self.request.user) As you can see, the _attempt method expects actor to be type…
Himerzi
  • 899
  • 1
  • 8
  • 16
10
votes
4 answers

Does Django ship with the authentication templates for use with the django.contrib.auth module?

I found some under the tests directory but I'm not sure if they are the right ones. By authentication templates I mean login.htm, password_reset.htm, etc. Some of the templates can be found at:…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
10
votes
4 answers

Django: Why create a OneToOne to UserProfile instead of subclassing auth.User?

Note: If you are tempted to 'answer' this question by telling me that you don't like django.contrib.auth, please move on. That will not be helpful. I am well aware of the range and strength of opinions on this matter. Now, the question: The…
9
votes
1 answer

Unable to create an integration test for Django's reset password flow

I'm trying to implement an integration test for the password reset flow, but I'm stuck at the "password_reset_confirm" view. I already tested the flow manually, and it works fine. Unfortunately, the Django unit test client seems unable to follow…
9
votes
2 answers

contrib.staticfiles and Django admin media

I just switched from 1.2 to trunk (r15175 at this writing) to play with contrib.staticfiles, and now when using the local devserver all my admin media returns a 404. The static media (as managed by the new contrib app) all work as expected, but I'd…
saturdayplace
  • 8,370
  • 8
  • 35
  • 39
8
votes
2 answers

Django: Is "collectstatic" supposed to collect media files as well?

I dont know if I am confusing the purpose of collectstatic. Here's my settings module: # BASE_DIR is the location of my django project folder STATIC_URL = '/this.static/' STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),…
7
votes
2 answers

django comments: how to prevent form errors from redirecting the user to the preview page?

Currently, django.contrib.comments sends the user to the preview page if there is any error on the form. I am using comments in the context of a blog and I would much rather that the user stayed on the page they were on if something went wrong with…
Teebes
  • 2,056
  • 2
  • 14
  • 11
6
votes
3 answers

When storing phone numbers in Django, should I store them as an raw digits or use django.contrib.localflavor?

The title may have been confusing, but please let me explain: Currently when I am storing phone number with raw digits like 5554441234. Then in my template I was going to "format" the number into something like 555-444-1234. I realized in Django's…
hobbes3
  • 28,078
  • 24
  • 87
  • 116
6
votes
1 answer

Django - get_current_site(request) just grabs example.com

My django project is working with a third-party forum. The activation_email is being send through get_current_site(request). The password rest is done by a django built called password_reset from django.contrib.auth.views import. For another app I…
pillow_willow
  • 99
  • 3
  • 11
6
votes
2 answers

Testing only project in Django

When I try to run python manage.py test in my Django (1.4) project, I get the error: ERROR: test_site_profile_not_available…
5
votes
1 answer

Postal Code model field shows up as State list in Admin

Not sure, but I think this may be a bug? Here is my model: class Property(models.Model): Name = models.CharField(max_length=40) Description = models.TextField(default="Description Not Available") Address = models.CharField(max_length=60,…
Kerry Hatcher
  • 601
  • 6
  • 17
5
votes
3 answers

django: failing tests from django.contrib.auth

When I run my django test I get following errors, that are outside of my test suite: ====================================================================== ERROR: test_known_user…
gruszczy
  • 40,948
  • 31
  • 128
  • 181
4
votes
3 answers

Django - Read the current's user authentication backend class

I am using a custom authentication backend with Django, to automatically create and login users from a legacy system. My Backend class is this: from django.contrib.auth.backends import ModelBackend from django.contrib.auth.models import User from…
4
votes
1 answer

Spurious failures in django.contrib.messages.tests when running manage.py test

I've recently added authentication (via django.contrib.auth of course) to my application, along with appropriate "signin"/"signup" links to my base.html. The problem comes when I run manage.py tests, and I get 4 failures, all from…
4
votes
1 answer

Intermittent ImportError with Django package

I have the following import line in a Django 1.4 project running in Python 2.7.6: from django.contrib.gis.utils import GeoIP This line works just fine 100% of the time in production and in development, but this line fails with an ImportError in…
ryanmrubin
  • 728
  • 4
  • 11
1
2 3 4 5 6