Commit bcac9f60 authored by Silje Odland's avatar Silje Odland
Browse files

removes knitter-model, fixes user registration

parent b1b9220f
......@@ -11,7 +11,7 @@
<div class="form-group" style="margin-left:10%; margin-top:50px">
<p><i>Litt om meg:</i></p>
<p> {{ knitter.about }} </p>
<p>Her skal info</p>
</div>
</div>
......
......@@ -2,20 +2,19 @@
{% load static %}
{% block body %}
<div class="content-section">
<form method="POST">
<div style="border-radius: 20px ;margin-top: 80px;width: 60%; margin-left: 20%; background-color: white; height: 450px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
<form method="POST" action="{% url 'register' %}">
{% csrf_token %}
<fieldset="form-group>
<div style="margin-left: 4%; margin-top: 10px; margin-right: 4% " >
<fieldset class = "form-group">
<legend class="border-bottom mb-4">Join Today</legend>
{{ form.as_p }}
</fieldset>
<div class="form-group">
<button class="btn btn-outline-info" type="submit">Sign Up</button>
</div>
</div>
</form>
<div class="border-top pt-3">
<small class="text-muted">
Allready have an account? <a class="ml-2" href="#">Sign In</a>
</small>
</div>
</div>
......
# Generated by Django 3.0.3 on 2020-02-24 19:11
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('feed', '0002_post_publisher'),
]
operations = [
migrations.RemoveField(
model_name='post',
name='publisher',
),
]
from django.db import models
from ..users.models import Knitter
# Create your models here.
......@@ -8,5 +7,4 @@ from ..users.models import Knitter
class Post(models.Model):
text = models.TextField(null=True, blank=True,max_length=4000)
image = models.ImageField(null=False)
publisher = models.ForeignKey(Knitter, null=True, on_delete=models.CASCADE)
from django.shortcuts import render
from ..feed.models import Post
from ..users.models import Knitter
from django.contrib.auth.models import User
# Create your views here.
def index(request):
......@@ -11,5 +11,5 @@ def startpage(request):
return render(request, "startpage.html", {'posts':posts})
def myprofile(request,pk):
knitter = Knitter.objects.filter(pk=pk).first()
knitter = User.objects.filter(pk=pk).first()
return render(request, "myprofile.html",{'knitter':knitter})
\ No newline at end of file
from django.contrib import admin
from .models import Knitter
# Register your models here.
admin.site.register(Knitter)
\ No newline at end of file
# Generated by Django 3.0.3 on 2020-02-24 19:11
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0002_knitter_profilepicture'),
]
operations = [
migrations.DeleteModel(
name='Knitter',
),
]
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class Knitter(AbstractUser):
about = models.CharField(max_length=300, null=True, blank=True)
profilepicture = models.ImageField(null= True)
......@@ -8,7 +8,8 @@ def register(request):
if form.is_valid():
username = form.cleaned_data.get('username')
messages.success(request, f'Account created for {username}!')
#return redirect('startpage/')
form.save()
return redirect('startpage/')
else:
form = UserCreationForm()
return render(request, 'register.html', {'form': form})
\ No newline at end of file
......@@ -130,5 +130,4 @@ STATICFILES_DIRS = [
MEDIA_ROOT = 'uploads/'
MEDIA_URL = '/uploads/'
AUTH_USER_MODEL = 'users.Knitter'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment