django-twitter-tag è un tag template Django per visualizzare tweets recenti dell'utente.
È possibile limitare il numero di tweets, filtrare risposte e retweet. Dal momento che l'applicazione espone python-twitter modello di stato al contesto template, è possibile anche accedere a tutti gli attributi o metodi Tweet per le vostre esigenze. Non è necessario analizzare tweets per rendere URL, hashtag o Twitter username cliccabile, è stato fatto per voi già. Basta usare html attrubute di Twitter (vedi esempio sotto).
Installazione
Si consiglia di installare è pip:
Pip installare django-twitter-tag
Uso
& Nbsp; Aggiungi twitter_tag al INSTALLED_APPS in settings.py:
& Nbsp; INSTALLED_APPS = (...
& Nbsp; 'twitter_tag',
& Nbsp; ...
& Nbsp;)
& Nbsp; tag Load nel modello come questo:
& Nbsp; {% del carico twitter_tag%}
& Nbsp; Get dell'utente (futurecolors in esempio) più recenti tweets e memorizzarli in tweets variabili:
& Nbsp; {% get_tweets per "futurecolors" come tweets%}
& Nbsp; Ora avete un elenco di tweets nel contesto del modello, che si può iterare in questo modo:
& Nbsp;
- {{tweet.html}}
& Nbsp; {% per Twitter in tweets%}
& Nbsp;
& Nbsp; {% endfor%}
& Nbsp;
Esempi
È possibile specificare il numero di tweets per ottenere:
{% get_tweets per "futurecolors" come tweets escludono "risposte" limite del 10%}
Per filtrare le risposte Tweet (che iniziano con @ char):
{% get_tweets per "futurecolors" come tweets escludono "risposte" limite del 10%}
Per ignorare retweets nativo:
{% get_tweets per "futurecolors" come tweets escludono "retweet"%}
Extra
Tweet di proprietà
get_tweets tiene un elenco di oggetti di stato, che represet tweet unico utente. Secondo API python-twitter, ogni stato ha le seguenti caratteristiche, consumata in modelli:
status.created_at
status.created_at_in_seconds
status.favorited
status.in_reply_to_screen_name
status.in_reply_to_user_id
status.in_reply_to_status_id
status.truncated
status.source
status.id
status.text
status.location
status.relative_created_at
status.user
status.urls
status.user_mentions
status.hashtags
Di Tweet html
Tweet ha anche la proprietà Status.html supplementare, che contiene Tweet, formattato per output HTML con tutti i link necessari.
La gestione delle eccezioni
Se DEBUG == true eccezioni API di Twitter come 'Over capacita' sono sollevate e propagate, altrimenti the're tacere
Requisiti :.
- Python
- Django
I commenti non trovato