السلام عليكم
انا الان صممت قالب ب ال html و ال css لكن اريد ان اعرف مثلا اذا حبيت ان اضيف صفحة جديدة اتوماتيكيا مثل زر اضافة موضوع في المنتديات مثلا كيف يمكنني عمل ذلك وشكرا ؟
السلام عليكم
انا الان صممت قالب ب ال html و ال css لكن اريد ان اعرف مثلا اذا حبيت ان اضيف صفحة جديدة اتوماتيكيا مثل زر اضافة موضوع في المنتديات مثلا كيف يمكنني عمل ذلك وشكرا ؟
هل تستعمل اطار عمل معين في مشروعك ؟
مش فاهم قصدك ب اطار عمل :)
يعني Framework مثل جانغو
انا بستخدم django :)
ok
فهمت ياريت شرح وكمان ياريت معلومات عن كيفية عمل ايضا زر انشاء موضوع جديد مثلا ؟
شكرا لك خد وقتك اخي :)
class Article(models.Model): title = models.CharField(max_length = 200) content = models.CharField(max_length = 200)
from app.models import Article
from django.shortcuts import render_to_response, RequestContext
def articles(request):
articles = Article.objects.all()
return render_to_response('articles.html', locals(), context_instance = RequestContext(request))
ما قمنا بعمله حتى هذه النقطة هو استدعاء جميع المقالات واظهارها دفعة واحدة في ملف articles.html
from app.models import Article
from django.shortcuts import render_to_response, RequestContext
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
def articles(request):
articles_list = Article.objects.all()
paginator = Paginator(articles_list, 3) # Show 3 articles per page
page = request.GET.get('page')
try:
articles = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
articles = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
articles = paginator.page(paginator.num_pages)
return render_to_response('articles.html', locals(), context_instance = RequestContext(request))
{% for article in articles %}
{# Each "article" is an article model object. #}
{{ article.title|upper }}<br />
<hr/>
{{ article.content }}
...
{% endfor %}
<div class="pagination">
<span class="step-links">
{% if articles.has_previous %}
<a href="?page={{ articles.previous_page_number }}">previous</a>
{% endif %}
<span class="current">
Page {{ articles.number }} of {{ articles.paginator.num_pages }}.
</span>
{% if articles.has_next %}
<a href="?page={{ articles.next_page_number }}">next</a>
{% endif %}
</span>
</div>وفي الاخير انصحك بالتعمق اكثر في الدروس الاصلية حتى تكسب خبرة اكثر
بالتوفيق