Commit fcc3c100 authored by Tang, Alexander's avatar Tang, Alexander
Browse files

Readme angepasst.

parent bab58aab
......@@ -94,7 +94,7 @@ Open the link and check, if the page opens up and shows s
**Note!** If you see a message, telling you to perform commands, something went wrong, as the
start page content could not be found. Try to redo the steps above, please.
# Intern oft verwendete Befehle
### Django Befehle
#### Neues Module (App)
` startapp *appname*`
......@@ -109,118 +109,3 @@ start page content could not be found. Try to redo the steps above, please.
` migrate`
Achtung: Wenigstens einmal auf alles, sonst gehts nicht.
#### Admin-Nutzer
` createsuperuser` |(changepassword)
#### Django-Klassen -> Datenbankmodel
in unserem Projekt vielleicht so etwas wie
class Blog(models.Model)
title = models.CharField(max_length=80) #maximal 80 Zeichen
image = models.ImageField(upload_to='...') #Wenn Bilder -> pillow ext laden
#### Dann Model in registrieren
# Register your models here.
from .models import Blog
#### -> Medienordner setzen
MEDIA_URL = '/media/' # kann natuerlich auch anders benannt werden
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')` # speichert Medien im Ordner 'media ab'
#### Statische Bilder anzeigen lassen
from django.conf.urls.static import static
from django.conf import settings
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
#### Prozess um weitere Seiten einzubinden
**1. Setting up URL** <br> add path and import views <br>
**2. Setting up View (eigentlich der Controller)** <br>
create new function in, e.g. def home(request): <br>
**3. Return a template (eigentlich die View)** <br>
create directories in project folder templates/...<br>
create html file <br>
#### Datenbank-Daten (Objekte) in Seite einbinden
from .models import Blog
def home(request):
blogObjects = Blog.objects().all # grabs all objects from the DB table 'Blog'
return render(request, '<Website e.g. <App folder>/home.html', {'blogobjects':blogobjects})
--> damit bekommt man ein QuerySet zurückgegeben
**2. home.html**
{% for blogobject in blogobjects %}
{{ blogobject}}
{% endfor %}
#### CKEditor Befehle
**1. Installation**
pip install django-ckeditor
**2. Vorbereitende Maßnahmen (schon durchgeführt und nicht nochmal nötig)**
Für CKEditor ohne Uploader
-Add ckeditor to your INSTALLED_APPS setting.
-Run the collectstatic management command:
``` collectstatic
This will copy static CKEditor required media resources into the directory given by the STATIC_ROOT setting.
See Django’s documentation on managing static files for more info.
Zusätzlich für CKEditor mit Uploader
-Add ckeditor_uploader to your INSTALLED_APPS setting.
-Add a CKEDITOR_UPLOAD_PATH setting to the project’s file. This setting specifies a relative path to
your CKEditor media upload directory. CKEditor uses Django’s storage API. By default, Django uses the file system
storage backend (it will use your MEDIA_ROOT and MEDIA_URL) and if you don’t use a different backend you have to
have write permissions for the CKEDITOR_UPLOAD_PATH path within MEDIA_ROOT, i.e.:
When using default file system storage, images will be uploaded to “uploads” folder in your
MEDIA_ROOT and urls will be created against MEDIA_URL (/media/uploads/image.jpg).
**3. Benutzung**
The quickest way to add rich text editing capabilities to your models is to use the included RichTextField model
field type. A CKEditor widget is rendered as the form field but in all other regards the field behaves as the
standard Django TextField. For example:
from django.db import models
from ckeditor.fields import RichTextField
class Post(models.Model):
content = RichTextField()
For file upload support use RichTextUploadingField from ckeditor_uploader.fields.
**4. Doc**
Mehr unter:
\ No newline at end of file
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