Hello guys
    I'm using spyder it contain python 3.6 so how I can I install django
Please help me

On Tue 24 Jul, 2018 6:46 pm John Son, <[email protected]> wrote:

> *models.py*
> class Post(models.Model):
>     title = models.CharField(max_length=200)
>     body = models.TextField()
>     user = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True,
> null=True)
>     date = models.DateField(default=datetime.now, blank=True)
>     text_author = models.CharField(max_length=200, null=True, blank=True)
>
> *forms.py*
> class PostForm(forms.ModelForm):
>     class Meta:
>         model = Post
>         fields = ("title", "body", "user", "text_author")
> *views.py*
> def create_Post(request):
>     form = PostForm(request.POST or None)
>     if form.is_valid():
>         instance = form.save(commit=False)
>         instance.save()
>         return HttpResponseRedirect (instance.get_absolute_url())
>     context = {
>         "form": form,
>     }
>     return render(request, 'blog/create.html', context)
>
> *As shown in attached image, the user has to select themselves from list
> of users before they can submit their post.(which doesn't make sense). I
> want the form to know which user is writing the form(assuming they are
> logged in) so the user doesn't have to identify themselves before they
> submit their post. I'm guessing I need to edit my models.py but I have no
> idea. Please Help.*
>
> *Thank you.*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/75d197ab-503c-4aed-83ce-210831fb1502%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/75d197ab-503c-4aed-83ce-210831fb1502%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMeUrx9%2BsCevo0HbBzivV-U7YLa7suCqvcxUmH8kyDFaMisqhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to