I'm working on my first Django project and employing django-registration and django-profiles. The former worked beautifully with nary an issue. The second has been a bit more problematic.
After many hours, specific user profiles can finally be viewed, which is terrific, along with a list of all profiles.
The two issues I'm encountering: django-profiles will not automatically create a new profile when a new user is created. Once a user is created in the admin, a profile should be created. That isn't occurring.
In addition, the profiles/edit_profile form results in this error:
"TemplateSyntaxError at /profiles/edit/ Caught NoReverseMatch while rendering: Reverse for 'edit_profile' with arguments '(,)' and keyword arguments '{}' not found."
I've searched for answers to these issues to no avail.
This is the model for the profile in my app file:
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
first_name = models.CharField(max_length=25)
last_name = models.CharField(max_length=35)
email = models.EmailField()
birth_date = models.DateField(blank=True, null=True)
city = models.CharField(max_length=25)
state = models.CharField(max_length=20)
zip_code = models.CharField(max_length=10)
def __unicode__(self):
return " %s" % (self.user)
def get_absolute_url(self):
return ('profiles_profile_detail', (), { 'username': self.user.username })
get_absolute_url = models.permalink(get_absolute_url)
This is my form:
class ProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
This is the template:
{% extends 'base.html' %}
{% block page_title %}Edit Profile{% endblock %}
{% block headline %}Edit Stentorian Profile{% endblock %}
{% block content %}
<form action="{% url edit_profile user %}" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
{% endblock %}
Interested in learning what errors I made and how to fix these. (I realize the user object carries first and last name, but there appears no other way to insert these into the profile other than with their own specific fields).
Any insight appreciated.
Edit: It seems to have worked out thanks to The Missing Manual. Unfortunately, /profiles/edit now bounces to /profiles/create. Not sure of this issue.