尝试在Heroku上部署并获取服务器500错误

时间:2016-04-02 06:36:19

标签: django heroku web-deployment

尝试将我的应用部署到heroku但是我收到500服务器错误。一切都在当地工作得很好。我有调试设置为False我跑

heroku run python manage.py migrate

我做了

git add .
git commit -am ' ready to deploy'
git push heroku master

并且没有任何工作

当我运行heroku日志时,我得到以下

(veins)apples-MacBook-Pro:zoe ray$ heroku logs
    2016-04-02T06:01:42.740469+00:00 app[web.1]:     cursor.execute(sql, params)
    2016-04-02T06:01:42.740470+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/db/backends/utils.py", line 79, in execute
    2016-04-02T06:01:42.740471+00:00 app[web.1]:     return super(CursorDebugWrapper, self).execute(sql, params)
    2016-04-02T06:01:42.740471+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    2016-04-02T06:01:42.740472+00:00 app[web.1]:     return self.cursor.execute(sql, params)
    2016-04-02T06:01:42.740473+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/db/utils.py", line 95, in __exit__
    2016-04-02T06:01:42.740473+00:00 app[web.1]:     six.reraise(dj_exc_type, dj_exc_value, traceback)
    2016-04-02T06:01:42.740474+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    2016-04-02T06:01:42.740474+00:00 app[web.1]:     raise value.with_traceback(tb)
    2016-04-02T06:01:42.740475+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    2016-04-02T06:01:42.740475+00:00 app[web.1]:     return self.cursor.execute(sql, params)
    2016-04-02T06:01:42.740476+00:00 app[web.1]: django.db.utils.ProgrammingError: relation "blog_post" does not exist
    2016-04-02T06:01:42.740477+00:00 app[web.1]: LINE 1: ...blog_post"."video", "blog_post"."video_path" FROM "blog_post...
    2016-04-02T06:01:42.740477+00:00 app[web.1]:                                                              ^
    2016-04-02T06:01:42.740481+00:00 app[web.1]: 
    2016-04-02T06:01:42.946479+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brushlands-92656.herokuapp.com request_id=f3c1fae5-6cc4-4550-b6c2-eb1a0e2bee56 fwd="67.86.108.92" dyno=web.1 connect=0ms service=398ms status=500 bytes=124376
    2016-04-02T06:07:31.152260+00:00 heroku[slug-compiler]: Slug compilation started
    2016-04-02T06:07:31.152265+00:00 heroku[slug-compiler]: Slug compilation finished
    2016-04-02T06:07:30.975815+00:00 heroku[api]: Deploy 722c474 by darraysk@gmail.com
    2016-04-02T06:07:30.975815+00:00 heroku[api]: Release v10 created by darraysk@gmail.com
    2016-04-02T06:07:31.126625+00:00 heroku[web.1]: Restarting
    2016-04-02T06:07:31.127170+00:00 heroku[web.1]: State changed from up to starting
    2016-04-02T06:07:36.620656+00:00 heroku[web.1]: Stopping all processes with SIGTERM
    2016-04-02T06:07:37.634475+00:00 heroku[web.1]: Starting process with command `gunicorn zoe.wsgi --log-file -`
    2016-04-02T06:07:38.159253+00:00 app[web.1]: [2016-04-02 06:07:38 +0000] [3] [INFO] Handling signal: term
    2016-04-02T06:07:40.023938+00:00 app[web.1]: [2016-04-02 06:07:40 +0000] [3] [INFO] Starting gunicorn 19.4.5
    2016-04-02T06:07:40.024557+00:00 app[web.1]: [2016-04-02 06:07:40 +0000] [3] [INFO] Listening at: http://0.0.0.0:39370 (3)
    2016-04-02T06:07:40.024671+00:00 app[web.1]: [2016-04-02 06:07:40 +0000] [3] [INFO] Using worker: sync
    2016-04-02T06:07:40.027892+00:00 app[web.1]: [2016-04-02 06:07:40 +0000] [7] [INFO] Booting worker with pid: 7
    2016-04-02T06:07:40.042782+00:00 app[web.1]: [2016-04-02 06:07:40 +0000] [8] [INFO] Booting worker with pid: 8
    2016-04-02T06:07:41.334511+00:00 heroku[web.1]: State changed from starting to up
    2016-04-02T06:07:44.708412+00:00 app[web.1]: [2016-04-02 02:07:44 -0400] [8] [INFO] Worker exiting (pid: 8)
    2016-04-02T06:07:44.707345+00:00 app[web.1]: [2016-04-02 02:07:44 -0400] [7] [INFO] Worker exiting (pid: 7)
    2016-04-02T06:07:44.998762+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brushlands-92656.herokuapp.com request_id=4a801b6e-a744-4ba9-9110-ac975c94209c fwd="67.86.108.92" dyno=web.1 connect=0ms service=341ms status=500 bytes=239
    2016-04-02T06:07:45.110398+00:00 app[web.1]: [2016-04-02 06:07:45 +0000] [3] [INFO] Shutting down: Master
    2016-04-02T06:07:46.168820+00:00 heroku[web.1]: Process exited with status 0
    2016-04-02T06:10:35.425027+00:00 heroku[api]: Starting process with command `python manage.py migrate` by darraysk@gmail.com
    2016-04-02T06:10:42.040062+00:00 heroku[run.2415]: Awaiting client
    2016-04-02T06:10:42.061407+00:00 heroku[run.2415]: Starting process with command `python manage.py migrate`
    2016-04-02T06:10:42.279921+00:00 heroku[run.2415]: State changed from starting to up
    2016-04-02T06:10:46.387084+00:00 heroku[run.2415]: Process exited with status 0
    2016-04-02T06:10:46.416848+00:00 heroku[run.2415]: State changed from up to complete
    2016-04-02T06:10:57.595523+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brushlands-92656.herokuapp.com request_id=826f1c8a-aa38-4f0f-8bc8-4f1c5a4ecdbc fwd="67.86.108.92" dyno=web.1 connect=0ms service=62ms status=500 bytes=239
    2016-04-02T06:11:02.831354+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brushlands-92656.herokuapp.com request_id=98dc2e1f-d3d4-4f5b-83ea-41fed4173d93 fwd="67.86.108.92" dyno=web.1 connect=0ms service=57ms status=500 bytes=239
    2016-04-02T06:14:09.380829+00:00 heroku[api]: Deploy 612dac6 by raysk@gmail.com
    2016-04-02T06:14:09.380829+00:00 heroku[api]: Release v11 created by raysk@gmail.com
    2016-04-02T06:14:09.539964+00:00 heroku[slug-compiler]: Slug compilation started
    2016-04-02T06:14:09.539969+00:00 heroku[slug-compiler]: Slug compilation finished
    2016-04-02T06:14:09.751419+00:00 heroku[web.1]: State changed from up to starting
    2016-04-02T06:14:09.748910+00:00 heroku[web.1]: Restarting
    2016-04-02T06:14:12.589888+00:00 heroku[web.1]: Stopping all processes with SIGTERM
    2016-04-02T06:14:13.369470+00:00 app[web.1]: [2016-04-02 06:14:13 +0000] [3] [INFO] Handling signal: term
    2016-04-02T06:14:14.302512+00:00 app[web.1]: [2016-04-02 02:14:14 -0400] [7] [INFO] Worker exiting (pid: 7)
    2016-04-02T06:14:14.340173+00:00 app[web.1]: [2016-04-02 02:14:14 -0400] [8] [INFO] Worker exiting (pid: 8)
    2016-04-02T06:14:14.583043+00:00 app[web.1]: [2016-04-02 06:14:14 +0000] [3] [INFO] Shutting down: Master
    2016-04-02T06:14:15.409910+00:00 heroku[web.1]: Process exited with status 0
    2016-04-02T06:14:15.746975+00:00 heroku[web.1]: Starting process with command `gunicorn zoe.wsgi --log-file -`
    2016-04-02T06:14:18.296264+00:00 app[web.1]: [2016-04-02 06:14:18 +0000] [3] [INFO] Starting gunicorn 19.4.5
    2016-04-02T06:14:18.297558+00:00 app[web.1]: [2016-04-02 06:14:18 +0000] [3] [INFO] Listening at: http://0.0.0.0:5053 (3)
    2016-04-02T06:14:18.297718+00:00 app[web.1]: [2016-04-02 06:14:18 +0000] [3] [INFO] Using worker: sync
    2016-04-02T06:14:18.303157+00:00 app[web.1]: [2016-04-02 06:14:18 +0000] [7] [INFO] Booting worker with pid: 7
    2016-04-02T06:14:18.337725+00:00 app[web.1]: [2016-04-02 06:14:18 +0000] [8] [INFO] Booting worker with pid: 8
    2016-04-02T06:14:19.451560+00:00 heroku[web.1]: State changed from starting to up
    2016-04-02T06:14:21.933300+00:00 app[web.1]: Internal Server Error: /
    2016-04-02T06:14:21.933312+00:00 app[web.1]: Traceback (most recent call last):
    2016-04-02T06:14:21.933313+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/handlers/base.py", line 149, in get_response
    2016-04-02T06:14:21.933314+00:00 app[web.1]:     response = self.process_exception_by_middleware(e, request)
    2016-04-02T06:14:21.933315+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/core/handlers/base.py", line 147, in get_response
    2016-04-02T06:14:21.933316+00:00 app[web.1]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
    2016-04-02T06:14:21.933317+00:00 app[web.1]:   File "/app/blog/views.py", line 21, in post_list
    2016-04-02T06:14:21.933344+00:00 app[web.1]:     latest_article = Post.published.latest('created')
    2016-04-02T06:14:21.933345+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/manager.py", line 122, in manager_method
    2016-04-02T06:14:21.933346+00:00 app[web.1]:     return getattr(self.get_queryset(), name)(*args, **kwargs)
    2016-04-02T06:14:21.933347+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/query.py", line 544, in latest
    2016-04-02T06:14:21.933348+00:00 app[web.1]:     return self._earliest_or_latest(field_name=field_name, direction="-")
    2016-04-02T06:14:21.933349+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/query.py", line 538, in _earliest_or_latest
    2016-04-02T06:14:21.933349+00:00 app[web.1]:     return obj.get()
    2016-04-02T06:14:21.933350+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.5/site-packages/django/db/models/query.py", line 387, in get
    2016-04-02T06:14:21.933351+00:00 app[web.1]:     self.model._meta.object_name
    2016-04-02T06:14:21.933446+00:00 app[web.1]: blog.models.DoesNotExist: Post matching query does not exist.
    2016-04-02T06:14:22.079558+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brushlands-92656.herokuapp.com request_id=dcfa294d-0e95-42b2-89ea-f3fb0079ffaf fwd="67.86.108.92" dyno=web.1 connect=1ms service=720ms status=500 bytes=74281
    2016-04-02T06:25:36.260686+00:00 heroku[api]: Deploy 17dd9d2 by raysk@gmail.com
    2016-04-02T06:25:36.260686+00:00 heroku[api]: Release v12 created by raysk@gmail.com
    2016-04-02T06:25:36.435629+00:00 heroku[slug-compiler]: Slug compilation started
    2016-04-02T06:25:36.435638+00:00 heroku[slug-compiler]: Slug compilation finished
    2016-04-02T06:25:36.374326+00:00 heroku[web.1]: Restarting
    2016-04-02T06:25:36.375144+00:00 heroku[web.1]: State changed from up to starting
    2016-04-02T06:25:41.211458+00:00 heroku[web.1]: Stopping all processes with SIGTERM
    2016-04-02T06:25:42.383832+00:00 app[web.1]: [2016-04-02 06:25:42 +0000] [3] [INFO] Handling signal: term
    2016-04-02T06:25:44.015508+00:00 heroku[web.1]: Starting process with command `gunicorn zoe.wsgi --log-file -`
    2016-04-02T06:25:47.892982+00:00 app[web.1]: [2016-04-02 06:25:47 +0000] [3] [INFO] Starting gunicorn 19.4.5
    2016-04-02T06:25:47.893186+00:00 app[web.1]: [2016-04-02 06:25:47 +0000] [3] [INFO] Listening at: http://0.0.0.0:17481 (3)
    2016-04-02T06:25:47.893308+00:00 app[web.1]: [2016-04-02 06:25:47 +0000] [3] [INFO] Using worker: sync
    2016-04-02T06:25:47.905428+00:00 app[web.1]: [2016-04-02 06:25:47 +0000] [7] [INFO] Booting worker with pid: 7
    2016-04-02T06:25:47.932437+00:00 app[web.1]: [2016-04-02 06:25:47 +0000] [8] [INFO] Booting worker with pid: 8
    2016-04-02T06:25:48.665213+00:00 heroku[web.1]: State changed from starting to up
    2016-04-02T06:25:56.840201+00:00 app[web.1]: [2016-04-02 02:25:56 -0400] [8] [INFO] Worker exiting (pid: 8)
    2016-04-02T06:25:56.845143+00:00 app[web.1]: [2016-04-02 02:25:56 -0400] [7] [INFO] Worker exiting (pid: 7)
    2016-04-02T06:25:57.944293+00:00 app[web.1]: [2016-04-02 06:25:57 +0000] [3] [INFO] Shutting down: Master
    2016-04-02T06:25:59.048324+00:00 heroku[web.1]: Process exited with status 0
    2016-04-02T06:26:29.718005+00:00 heroku[router]: at=info method=GET path="/" host=obscure-brushlands-92656.herokuapp.com request_id=60816714-1381-435c-b5f1-4b1274ca4905 fwd="67.86.108.92" dyno=web.1 connect=1ms service=690ms status=500 bytes=239

似乎是我的问题?欢迎所有指导

修改

下面是我的views.py

from django.shortcuts import render, get_object_or_404, HttpResponseRedirect, Http404, redirect
    from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
    from .forms import ContactForm, SubmitForm, FeedForm
    from django.core.mail import send_mail
    from django.conf import settings
    from taggit.models import Tag
    from django.db.models import Count
    from haystack.query import SearchQuerySet
    from django.contrib import messages

    from .forms import PostForm
    from .models import Post, Article, Feed

    import feedparser
    import datetime


    def post_list(request, tag_slug=None):
        object_list = Post.published.all().order_by('-id')
        articles = Article.objects.all()[:8]
        latest_article = Post.published.latest('created')

        tag = None
        if tag_slug:
            tag = get_object_or_404(Tag, slug=tag_slug)
            object_list = object_list.filter(tags__in=[tag])
        paginator = Paginator(object_list, 7) # 3 posts in each page
        page = request.GET.get('page')
        try:
            posts = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer deliver the first page
            posts = paginator.page(1)
        except EmptyPage:
            # If page is out of range deliver last page of results
            posts = paginator.page(paginator.num_pages)
        template = 'blog/post/list.html'
        title = 'main'
        context = {
            'page': page,
            'posts': posts,
            'tag': tag,
            'title': title,
            'articles': articles,
            'latest': latest_article
        }
        return render(request, template, context)


    def post_detail(request, slug=None):
        post = get_object_or_404(Post, slug=slug)

        # List of similar posts
        post_tags_ids = post.tags.values_list('id', flat=True)
        similar_posts = Post.published.filter(tags__in=post_tags_ids)\
            .exclude(id=post.id)
        similar_posts = similar_posts.annotate(same_tags=Count('tags'))\
            .order_by('-same_tags', '-publish')[:4]

        template = 'blog/post/detail.html'
        context = {
            "post": post,
            'similar_posts': similar_posts
        }
        return render(request, template, context)


    def post_create(request):
        if not request.user.is_staff or not request.user.is_superuser:
            raise Http404
        form = PostForm(request.POST or None, request.FILES or None)
        if form.is_valid():
            instance = form.save(commit=True) # changed from form.save(commit=False)
            instance.save()
            messages.success(request, "Created !!")
            return HttpResponseRedirect(instance.get_absolute_url())
        template = "blog/post/post_form.html"
        context = {
            "form": form
        }
        return render(request, template, context)


    def post_update(request, slug=None):
        if not request.user.is_staff or not request.user.is_superuser:
            raise Http404
        instance = get_object_or_404(Post, slug=slug)
        form = PostForm(request.POST or None, request.FILES or None, instance=instance)
        if form.is_valid():
            instance = form.save(commit=True)
            instance.user = request.user
            instance.save()
            messages.success(request, "Saved !!")
            return HttpResponseRedirect(instance.get_absolute_url())
        template = "blog/post/post_form.html"
        context = {
            "instance": instance,
            "name": instance.title,
            "form": form,
        }
        return render(request, template, context)


    def post_delete(request, id):
        if not request.user.is_staff or not request.user.is_superuser:
            raise Http404
        instance = get_object_or_404(Post, id=id)
        instance.delete()
        messages.success(request, "Deleted !!")
        return redirect('blog:post_list')


    def contact(request):
        form = ContactForm()

        if request.method == 'POST':
            # Form was submitted
            form = ContactForm(request.POST or None)
            if form.is_valid():

                form_email_from = form.cleaned_data.get("email_from")
                form_message = form.cleaned_data.get("message")
                form_full_name = form.cleaned_data.get("full_name")
                # print(email, email_from, message)

                hispanic_mail = 'hispanicheight@gmail.com'
                subject = 'Site contact form'
                contact_message = settings.EMAIL_HOST_USER
                from_email = settings.EMAIL_HOST_USER
                to_email = hispanic_mail
                contact_message = "{}: {} via {}".format(form_full_name, form_message, form_email_from)
                send_mail(subject,
                          contact_message,
                          from_email,
                          [to_email],
                          fail_silently=False)

        template = 'blog/post/contact.html'
        context = {
            'form': form,
        }
        return render(request, template, context)


    def video_submission(request):
        form = SubmitForm()

        if request.method == 'POST':
            # Form was submitted
            form = SubmitForm(request.POST or None)
            if form.is_valid():
                video_title = form.cleaned_data.get("title")
                form_message = form.cleaned_data.get("video_description")
                form_email_from = form.cleaned_data.get("email")
                form_video_url = form.cleaned_data.get("video_url")

                # print(email, email_from, message)

                hispanic_mail = 'hispanicheight@gmail.com'
                subject = 'Video url submission'
                contact_message = settings.EMAIL_HOST_USER
                from_email = settings.EMAIL_HOST_USER
                to_email = hispanic_mail
                contact_message = "{}: {} from email: {}  video url {}".format(
                    video_title,
                    form_message,
                    form_email_from,
                    form_video_url
                )

                send_mail(subject,
                          contact_message,
                          from_email,
                          [to_email],
                          fail_silently=False)
                messages.success(request, "Your submission has been sent")

        template = 'blog/post/video_submission.html'
        context = {
            'form': form,
        }
        return render(request, template, context)


    def post_search(request):

        form = request.GET.get('q')
        results = SearchQuerySet().models(Post).filter(content=form)

        # count total results
        total_results = results.count()
        template = 'blog/post/search.html',
        context = {
            'form': form,
            'results': results,
            'total_results': total_results

        }
        return render(request, template, context)


    def privacy(request):
        template = "blog/lo_nav/privacy.html"
        context = {
        }
        return render(request, template, context)


    def terms(request):
        template = "blog/lo_nav/terms.html"
        context = {
        }
        return render(request, template, context)


    def dmca(request):
        template = "blog/lo_nav/dmca.html"
        context = {
        }
        return render(request, template, context)


    def articles_list(request):
        articles = Article.objects.all()

        template = 'news/feed_articles.html'
        context = {
            "articles": articles
        }
        return render(request, template, context)


    def article_delete(request, id):
        if not request.user.is_staff or not request.user.is_superuser:
            raise Http404
        instance = get_object_or_404(Article, id=id)
        instance.delete()
        messages.success(request, "Deleted !!")
        return redirect('blog:feed_articles')


    def feed_list(request):

        feeds = Feed.objects.all()
        template = 'news/feed_list.html'
        context = {
            "feeds": feeds,


        }
        return render(request, template, context)


    def feed_delete(request, id):
        if not request.user.is_staff or not request.user.is_superuser:
            raise Http404
        instance = get_object_or_404(Feed, id=id)
        instance.delete()
        messages.success(request, "Deleted !!")
        return redirect('blog:feed_list')


    def new_feed(request):
        if request.method == "POST":
            form = FeedForm(request.POST)
            if form.is_valid():
                feed = form.save(commit=False)

                existing_feed = Feed.objects.filter(url=feed.url)
                # if a feed exists it wont make a duplicate
                if len(existing_feed) == 0:
                    feedData = feedparser.parse(feed.url)

                    # set some fields
                    feed.title = feedData.feed.title
                    feed.save()

                    for entry in feedData.entries:
                        article = Article()
                        article.title = entry.title
                        article.url = entry.link
                        article.description = entry.description

                        d = datetime.datetime(*(entry.published_parsed[0:6]))
                        date_string = d.strftime('%Y-%m-%d %H:%M:%S')

                        article.publication_date = date_string
                        article.feed = feed
                        article.save()

                return redirect('blog:feed_list')
        else:
            form = FeedForm()
        template = 'news/new_feed.html'
        context = {
            "form": form
        }
        return render(request, template, context)

my models.py

from django.db import models
    from django.core.urlresolvers import reverse
    from taggit.managers import TaggableManager

    # added for slug creation
    from django.db.models.signals import pre_save
    from django.utils.text import slugify

    from django.utils import timezone
    from django.contrib.auth.models import User


    class PublishedManager(models.Manager):
        def get_queryset(self):
            return super(PublishedManager,
                self).get_queryset().filter(status='published')


    # relative to media_cdn i.e. media_cdn/20/car.jpg
    def upload_location(instance, filename):
        return "{}/{}".format(instance.id, filename)


    class Post(models.Model):

        STATUS_CHOICES = (
           ('draft', 'Draft'),
           ('published', 'Published'),
        )
        title = models.CharField(max_length=250)
        slug = models.SlugField(max_length=250,
                                unique_for_date='publish')
        image = models.ImageField(upload_to=upload_location,
                                  null=True,
                                  blank=True,
                                  height_field='height_field',
                                  width_field='width_field')
        height_field = models.IntegerField(default=0)
        width_field = models.IntegerField(default=0)
        author = models.ForeignKey(User,
                                   related_name='blog_posts')
        body = models.TextField()
        publish = models.DateTimeField(default=timezone.now)
        created = models.DateTimeField(auto_now_add=True)
        updated = models.DateTimeField(auto_now=True)
        status = models.CharField(max_length=10,
                                  choices=STATUS_CHOICES,
                                  default='draft')
        video = models.BooleanField(default=False)
        video_path = models.CharField(max_length=320,
                                      null=True,
                                      blank=True,)

        class Meta:
            ordering = ('-publish',)

        def __str__(self):
            return self.title

        def get_absolute_url(self):
            return reverse('blog:post_detail', kwargs={"slug": self.slug})


        objects = models.Manager() # The default manager.
        published = PublishedManager() # Our custom manager.
        tags = TaggableManager()


    def create_slug(instance, new_slug=None):
        slug = slugify(instance.title)
        if new_slug is not None:
            slug = new_slug
        qs = Post.objects.filter(slug=slug).order_by("-id")
        exists = qs.exists()
        if exists:
            new_slug = "%s-%s" % (slug, qs.first().id)
            return create_slug(instance, new_slug=new_slug)
        return slug


    def pre_save_post_receiver(sender, instance, *args, **kwargs):
        if not instance.slug:
            instance.slug = create_slug(instance)


    pre_save.connect(pre_save_post_receiver, sender=Post)

    class Feed(models.Model):
        title = models.CharField(max_length=200)
        url = models.URLField()
        is_active = models.BooleanField(default=False)

        def __str__(self):
            return self.title
        # newest first

        class Meta:
            ordering = ["-id"]


    class Article(models.Model):
        feed = models.ForeignKey(Feed)
        title = models.CharField(max_length=200)
        url = models.URLField()
        description = models.TextField()
        publication_date = models.DateTimeField()

        def __str__(self):
            return self.title
        # newest first

        class Meta:
            ordering = ["-id"]
似乎我的数据库甚至没有被创建。我看到另一个帖子有类似问题,但他跑了

python manage.py syncdb -all

我应该跑步吗

python manage.py migrate -all?

我已经迁移了,我还没有尝试过。我刚看到它,我现在在学校,这就是为什么我还没试过呢

0 个答案:

没有答案