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
2
votes
1 answer

Message framework: no module messages

I am following this tutorial: http://docs.djangoproject.com/en/dev/ref/contrib/messages/ but I get this error: Error: No module named messages . And in django/contrib folder effectively there isn't a messages app. How can I get work message…
xRobot
  • 25,579
  • 69
  • 184
  • 304
2
votes
1 answer

Django IntegrityError 1452

I had an application that was working nicely using a User class that I had defined. After working on this for a few weeks, I realized I needed user authentication, and decided to use django's User class instead (I didn't really understand how this…
Daniel Rosenthal
  • 1,386
  • 4
  • 15
  • 32
2
votes
4 answers

Referencing django.contrib.auth.login in Django templates

I am new to Django and am having difficulty with using django.contrib.auth.login. My urls.py: from django.conf.urls import patterns, include, url from myapp import views from django.contrib import auth urlpatterns = patterns('', url(r'^$',…
jazzblue
  • 2,411
  • 4
  • 38
  • 63
1
vote
0 answers

Can I use the current logged in user in models.py?

What I have: The default django User model with an attached Profile model that, amongst others, contains a ForeignKey to an Office model. So every user in my application is tied to a specific office. And in each office there are several…
Martin K
  • 33
  • 4
1
vote
1 answer

Django authenticate user does not work after logging in

I'm trying to create a custom session-based login in Django using a custom user model and a custom login template. For some reasons it worked at first but now the authenticate method from django.contrib.auth is not authenticating user. When it did…
1
vote
1 answer

How can I a Djanog auth user on the command line and not have to manually enter the password?

I'm using Django 3.2 and the auth module. I would like to create a super user on the command line (for eventual inclusion in a docker script). When I try this $ python manage.py createsuperuser --username=joe --email=joe@example.com I'm prompted…
Dave
  • 15,639
  • 133
  • 442
  • 830
1
vote
2 answers

How do I use the Django rest framework to prolong a JWT session token?

I'm using Django 3.2 with the django.auth.contrib app and djangorestframework-jwt==1.11.0. How do I prolong/reissue a new session token upon receiving a request for an authenticated resource and validating the user can access that resource? I use…
Dave
  • 15,639
  • 133
  • 442
  • 830
1
vote
2 answers

Manager for a user profile to create and delete both user and the profile

I have a model called Personnel which I'm using as the profile model for the User model. Moderators on my site can create and their own accounts but all the profile fields should be filled in. Here's my model class Personnel(models.Model): """ …
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
1
vote
1 answer

How to have PyCharm suggest code completion for Django

I have the following code: from django.test import TestCase from django.contrib.auth import get_user_model class ModelTests(TestCase) def test_newUserEmailNormalized(self): email = "test@TEST.COM" user =…
Peter
  • 119
  • 12
1
vote
1 answer

Django upgrade from 1.8 to 1.9 is breaking on model import in init

I have run into the same problem that @JohnnyQ has commented on here. My __init__.py is referring to multiple imports that in-turn are referring to models and these are required. The code works perfectly fine with django 1.8.x but breaks when Django…
1
vote
0 answers

How to use django on two databases

I have a legacy Django project with a legacy database. That project uses django.contrib.auth.User as the user model. Now I need to write a new Django project and that app has to get access to the legacy database. The problem is that my new Django…
Marc
  • 3,386
  • 8
  • 44
  • 68
1
vote
0 answers

Django Pydocs / reading the Django Documentation

Since the Django online documentation only provides code examples, and doesn't really provide a simple module / class reference, I'm trying to read the pydocs locally but keep running into this problem. pydoc django error message: I'm running the…
maitland
  • 21
  • 3
1
vote
2 answers

Extending login function from django.contrib.auth.views (Django project)

BACKGROUND: I'm using the versatile django-brake for rate limiting in my Django app. I now need to configure it to limit brute force login attempts in my app too. The way to do that is to decorate the login view with the decorator…
Hassan Baig
  • 15,055
  • 27
  • 102
  • 205
1
vote
1 answer

Password reset in Django-registration can't find site.domain

My password_reset_email.html in django-registration looks like this: {% blocktrans %} To reset your password, please click the following link: {% endblocktrans %}

H C
  • 1,138
  • 4
  • 21
  • 39
1
vote
1 answer

How to get Django Cache Machine to work on django.contrib.auth.models.User?

I'm using Django Cache Machine to cache my Django ORM objects. It's a great piece of software. It has immensely reduced the database accesses for nearly all my models -- and it is simple to use. However, one model is still not being cached:…
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272