Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Draft

class praw.models.Draft(reddit: praw.Reddit, id: Optional[str] = None, _data: Dict[str, Any] = None)

  A class that represents a Reddit submission draft.

  Typical Attributes

  Note

  This table describes attributes that typically belong to objects of this class. PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, PRAW makes no effort to document any new/removed/changed attributes, other than to instruct you on how to discover what is available. As a result, this table of attributes may not be complete. See Determine Available Attributes of an Object for detailed information.

  If you would like to add an attribute to this table, feel free to open a pull request.

  Attribute | Description
  --- | ---
  `link_flair_template_id` | The link flair’s ID.
  `link_flair_text` | The link flair’s text content, or `None` if not flaired.
  `modified` | Time the submission draft was modified, represented in Unix Time.
  `original_content` | Whether the submission draft will be set as original content.
  `selftext` | The submission draft’s selftext. `None` if a link submission draft.
  `spoiler` | Whether the submission will be marked as a spoiler.
  `subreddit` | Provides an instance of `Subreddit` or `UserSubreddit` (if set).
  `title` | The title of the submission draft.
  `url` | The URL the submission draft links to.

  __init__(reddit: praw.Reddit, id: Optional[str] = None, _data: Dict[str, Any] = None)

    Initialize a `Draft` instance.

  delete()

    Delete the `Draft`.

    Example usage:

        draft = reddit.drafts("124862bc-e1e9-11eb-aa4f-e68667a77cbb")
        draft.delete()

  classmethod parse(data: Dict[str, Any], reddit: praw.Reddit) → Any

    Return an instance of `cls` from `data`.

    Parameters:

      - data – The structured data.

      - reddit – An instance of `Reddit`.

  submit(*, flair_id: Optional[str] = None, flair_text: Optional[str] = None, nsfw: Optional[bool] = None, selftext: Optional[str] = None, spoiler: Optional[bool] = None, subreddit: Optional[Union[str, praw.models.Subreddit, praw.models.UserSubreddit]] = None, title: Optional[str] = None, url: Optional[str] = None, **submit_kwargs) → praw.models.Submission

    Submit a draft.

    Parameters:

      - flair_id – The flair template to select (default: `None`).

      - flair_text – If the template’s `flair_text_editable` value is `True`, this value will set a custom text (default: `None`). `flair_id` is required when `flair_text` is provided.

      - nsfw – Whether or not the submission should be marked NSFW (default: `None`).

      - selftext – The Markdown formatted content for a `text` submission. Use an empty string, `""`, to make a title-only submission (default: `None`).

      - spoiler – Whether or not the submission should be marked as a spoiler (default: `None`).

      - subreddit – The subreddit to submit the draft to. This accepts a subreddit display name, `Subreddit` object, or `UserSubreddit` object.

      - title – The title of the submission (default: `None`).

      - url – The URL for a `link` submission (default: `None`).

    Returns:

      A `Submission` object for the newly created submission.

    Note

    Parameters set here will override their respective `Draft` attributes.

    Additional keyword arguments are passed to the `Subreddit.submit()` method.

    For example, to submit a draft as is:

        draft = reddit.drafts("5f87d55c-e4fb-11eb-8965-6aeb41b0880e")
        submission = draft.submit()

    For example, to submit a draft but use a different title than what is set:

        draft = reddit.drafts("5f87d55c-e4fb-11eb-8965-6aeb41b0880e")
        submission = draft.submit(title="New Title")

    See also

    - `submit()` to submit url posts and selftexts

    - `submit_gallery()`. to submit more than one image in the same post

    - `submit_image()` to submit images

    - `submit_poll()` to submit polls

    - `submit_video()` to submit videos and videogifs

  update(*, flair_id: Optional[str] = None, flair_text: Optional[str] = None, is_public_link: Optional[bool] = None, nsfw: Optional[bool] = None, original_content: Optional[bool] = None, selftext: Optional[str] = None, send_replies: Optional[bool] = None, spoiler: Optional[bool] = None, subreddit: Optional[Union[str, praw.models.Subreddit, praw.models.UserSubreddit]] = None, title: Optional[str] = None, url: Optional[str] = None, **draft_kwargs)

    Update the `Draft`.

    Note

    Only provided values will be updated.

    Parameters:

      - flair_id – The flair template to select.

      - flair_text – If the template’s `flair_text_editable` value is `True`, this value will set a custom text. `flair_id` is required when `flair_text` is provided.

      - is_public_link – Whether to enable public viewing of the draft before it is submitted.

      - nsfw – Whether the draft should be marked NSFW.

      - original_content – Whether the submission should be marked as original content.

      - selftext – The Markdown formatted content for a text submission draft. Use `None` to make a title-only submission draft. `selftext` can not be provided if `url` is provided.

      - send_replies – When `True`, messages will be sent to the submission author when comments are made to the submission.

      - spoiler – Whether the submission should be marked as a spoiler.

      - subreddit – The subreddit to create the draft for. This accepts a subreddit display name, `Subreddit` object, or `UserSubreddit` object.

      - title – The title of the draft.

      - url – The URL for a `link` submission draft. `url` can not be provided if `selftext` is provided.

    Additional keyword arguments can be provided to handle new parameters as Reddit introduces them.

    For example, to update the title of a draft do:

        draft = reddit.drafts("5f87d55c-e4fb-11eb-8965-6aeb41b0880e")
        draft.update(title="New title")