
221 B.R. 769 (1998)
In re Salvatore W. DiSALVO, aka, S.W. DiSalvo, Bill DiSalvo, Debtor.
Jody DiSALVO, Appellant,
v.
Salvatore W. DiSALVO, Appellee.
BAP Nos. CC-96-1660-PTJ, CC-96-1943, Bankruptcy No. LA 95-23292 TD, Adversary No. 95-02837.
United States Bankruptcy Appellate Panel of the Ninth Circuit.
Argued and Submitted October 22, 1997.
Decided May 15, 1998.
*770 *771 C. Casey White, Tilem & White, Glendale, CA, for Jody DiSalvo.
Steven Karlton Kop, Weiss, Scolney, Spees, Danker & Kop, Los Angeles, CA, for Salvatore W. DiSalvo.
Before PERRIS,[1] JONES and TCHAIKOVSKY,[2] Bankruptcy Judges.

OPINION
PERRIS, Bankruptcy Judge.
Plaintiff appeals the bankruptcy court's judgment in a dischargeability action under 11 U.S.C. § 523(a)(15) extinguishing a debt incurred in a dissolution judgment, and its order awarding attorney fees. We REVERSE the extinguishment of the debt and REMAND for reconsideration of attorney fees.

FACTS
Appellant Jody DiSalvo ("plaintiff") and debtor-appellee Salvatore DiSalvo ("debtor") were divorced before debtor filed bankruptcy. As relevant to this appeal, the Judgment of Dissolution of Marriage provided that debtor was to pay plaintiff $100,000 as an equalizing judgment, to be evidenced by a promissory note and secured by a deed of trust on debtor's residence. It also provided for an award of attorney fees to the prevailing party if either party was required to commence an action to enforce the provisions of the judgment. Debtor executed the note and trust deed.[3]
*772 Debtor did not pay the $100,000. Plaintiff began proceedings to execute on the judgment, including obtaining a writ of execution in which she sought to levy on debtor's assets, filing an application to compel debtor to appear at a judgment debtor's examination, obtaining an earnings withholding order seeking to garnish debtor's wages, levying on debtor's bank account, and seeking to obtain appointment of a receiver to take possession of stock in debtor's insurance agency. Through those actions plaintiff collected $83.
After debtor filed bankruptcy, plaintiff filed an adversary proceeding, seeking a determination that certain obligations arising out of the dissolution judgment, including the $100,000 equalizing judgment, are nondischargeable. After trial, the bankruptcy court found that debtor's obligation with respect to the equalizing judgment is dischargeable under section 523(a)(15).[4] It also found that plaintiff had violated California's one-action rule, California Code of Civil Procedure 726(a). As a sanction for the violation the court extinguished the security and the $100,000 debt. Debtor requested attorney fees, which the bankruptcy court granted.

ISSUES
1. Did the bankruptcy court err in extinguishing the debt as a sanction for violation of the one-action rule?
2. Did the bankruptcy court err in awarding attorney fees to debtor?

STANDARD OF REVIEW
The Panel reviews the bankruptcy court's conclusions of law de novo. In re Pecan Groves of Arizona, 951 F.2d 242, 244 (9th Cir.1991). The Panel independently reviews the bankruptcy court's interpretation of state law. In re Park at Dash Point, L.P., 985 F.2d 1008, 1010 (9th Cir.1993); In re Sunnymead Shopping Center Co., 178 B.R. 809, 814 (9th Cir. BAP 1995). The bankruptcy court's choice of remedies is reviewed for an abuse of discretion. In re Goldberg, 168 B.R. 382, 384 (9th Cir. BAP 1994); Sunnymead Shopping Center Co., 178 B.R. at 814.
The Panel reviews a bankruptcy court's award of attorney fees for an abuse of discretion. In re Riverside-Linden Inv. Co., 945 F.2d 320, 322 (9th Cir.1991). A bankruptcy court necessarily abuses its discretion if it bases its ruling on an erroneous view of the law or a clearly erroneous assessment of the evidence. Cooter & Gell v. Hartmarx Corp., 496 U.S. 384, 405, 110 S.Ct. 2447, 110 L.Ed.2d 359 (1990). The court also abuses its discretion if the Panel has a definite and firm conviction that the court committed a clear error of judgment in the conclusion it reached after weighing all of the relevant factors. In re Travel Headquarters, Inc., 140 B.R. 260, 261 (9th Cir. BAP 1992).

DISCUSSION
1. Did the bankruptcy court err in ordering that the debt be extinguished as a sanction for plaintiff's violation of the one-action rule?
California Code of Civil Procedure § 726[5] provides, in part:
"(a) There can be but one form of action for the recovery of any debt or the enforcement of any right secured by mortgage upon real property or an estate for years therein, which action shall be in accordance with the provisions of this chapter."
Although the section refers only to mortgages, it also applies to deeds of trust. Ghirardo v. Antonioli, 14 Cal.4th 39, 50, 924 P.2d *773 996, 57 Cal.Rptr.2d 687 (1996). Under this rule, referred to as the one-action rule, a creditor whose debt is secured by a mortgage or deed of trust on real property must proceed against the security before seeking a personal judgment against the debtor. Walker v. Community Bank, 10 Cal.3d 729, 733, 518 P.2d 329, 111 Cal.Rptr. 897 (1974).
A. Application of section 726(a).
Plaintiff argues that section 726(a) does not apply to her actions to enforce the dissolution judgment for three reasons. First, plaintiff asserts that the rule does not apply to the enforcement of a judgment.[6] That argument is not supported by the plain language of the statute. Section 726(a) provides that it applies to "the recovery of any debt or the enforcement of any right secured by mortgage upon real property. . . ." (Emphasis supplied.) An award in a judgment is a "right" that in this case was secured by the trust deed.[7] Therefore, section 726(a) applies to enforcement of that right.[8]
Next, plaintiff argues that the one-action rule does not apply because the security is worthless. See Cohen v. Marshall, 197 Cal. 117, 123, 239 P. 1050 (1925); Ghirardo v. Antonioli, 14 Cal.4th at 48, 57 Cal.Rptr.2d 687, 924 P.2d 996. Foreclosure is not required where the debt had not been secured originally or where, if the debt was originally secured, the security later became valueless through no fault of the debtor. Giandeini v. Ramirez, 11 Cal.App.2d 469, 471, 54 P.2d 91 (1936); Pacific Valley Bank v. Schwenke, 189 Cal.App.3d 134, 140, 234 Cal.Rptr. 298, rev. denied (1987); 3 Witkin, Summary of California Law, "Security Transactions in Real Property" § 117 (9th ed.1987). There was evidence in this case that the security was without value at the time the trust deed was executed. However, a creditor is presumed to know what she is doing when she takes the security. See Giandeini, 11 Cal.App.2d at 473, 54 P.2d 91. A creditor does not have the right to accept worthless security and then waive it, thereby converting the obligation into a personal one that the debtor did not assume. Id. at 472-73, 54 P.2d 91. Where, as in this case, the mortgage on its face purports to be a security for the debt, a foreclosure and sale is the proper mode for determining whether the security is, in fact, valueless. Security-First National Bank of Los Angeles v. Chapman, 31 Cal.App.2d 182, 194, 87 P.2d 724 (1939).
Finally, plaintiff argues that debtor waived the one-action rule by not raising it in response to plaintiff's various collection actions. Even if debtor waived the affirmative defense that was available in those collection actions, waiver of the affirmative defense does not constitute a waiver of the right to seek sanctions for violation of the rule. O'Neil v. General Security Corp., 4 Cal. App.4th 587, 598 n. 6, 5 Cal.Rptr.2d 712 (1992).
B. Imposition of sanctions under the one-action rule.
Section 726(a)
"is susceptible of a dual application  it may be interposed by the debtor as an affirmative defense or it may become operative as a sanction. If the debtor successfully raises the section as an affirmative defense, the creditor will be forced to exhaust the security before he may obtain a money judgment against the debtor for any deficiency. If the debtor does not *774 raise the section as an affirmative defense, he may still invoke it as a sanction against the creditor on the basis that the latter by not foreclosing on the security in the action brought to enforce the debt, has made an election of remedies and waived the security."
Walker, 10 Cal.3d at 734, 111 Cal.Rptr. 897, 518 P.2d 329 (citations omitted); Security Pacific National Bank v. Wozab, 51 Cal.3d 991, 997, 800 P.2d 557, 275 Cal.Rptr. 201 (1990).
Ordinarily, the one-action rule issue arises in one of two contexts. First, the debtor may raise it as an affirmative defense to the secured creditor's action on the debt. Second, if the debtor does not raise it as an affirmative defense to an action on the debt, the debtor may assert the rule as a means of imposing a sanction for violation of the one-action rule.
In this case, the issue was raised in defense to a dischargeability action brought by plaintiff. Plaintiff sought a determination that debtor's $100,000 debt to her is nondischargeable. Debtor defended by arguing not that plaintiff must first pursue the security before she can seek to collect the debt from him personally, but argued instead that, by plaintiff's prepetition collection actions, she elected her remedy and is subject to sanctions.
This is an appropriate situation for the imposition of a sanction for violation of section 726(a). The bankruptcy court did not err in concluding that it should impose a sanction.
C. Appropriate sanction for violation of the one-action rule.
The issue remains whether the sanction imposed, loss of both the security and the debt, was appropriate. We conclude that it was not.[9]
When a secured party brings a personal action on a debt without first foreclosing on the security, the debtor can raise the one-action rule as a defense and thereby require the creditor to pursue the security first. Walker, 10 Cal.3d at 734, 111 Cal.Rptr. 897, 518 P.2d 329. If the debtor does not do that, he or she waives the right to require the creditor to look first to the security for the debt. See Wozab, 51 Cal.3d at 1004-05, 275 Cal.Rptr. 201, 800 P.2d 557. If the debtor chooses not to raise the defense and allows the creditor to proceed against the debtor personally, the creditor is said to have elected her remedy and cannot thereafter foreclose her security. Id. If the creditor attempts to foreclose, the debtor can insist on the sanction of loss of the security; the debt, however, is not affected. Id. at 1004, 275 Cal.Rptr. 201, 800 P.2d 557.
Debtor relies on dicta in Bank of America v. Daily, 152 Cal.App.3d 767, 772, 199 Cal. Rptr. 557 (1984), which said that a creditor who fails to follow the one-action rule waives the security and waives the unpaid balance of the debt. The California Supreme Court recognized that language as "clearly dictum," and rejected such an extreme rule. Wozab, 51 Cal.3d at 1003, 275 Cal.Rptr. 201, 800 P.2d 557.
There is one instance in which loss of the underlying debt is imposed as the sanction for violation of the one-action rule. In Pacific Valley Bank v. Schwenke, the Court of Appeal held that section 726(a) was a bar to a creditor's action on a promissory note. The creditor had voluntarily released the security without the debtor's knowledge or consent. The court held that the creditor's unilateral action divesting himself of the security constituted a waiver of his right to proceed on the note. 189 Cal.App.3d at 140-41, 234 Cal.Rptr. 298.
In this case, the bankruptcy court found that plaintiff "intended to abandon the Deed of Trust." Whatever her intent, plaintiff did not in fact abandon the security, and was therefore entitled to look to the security for payment of the debt. By pursuing debtor personally, however, she elected her remedy and has waived the security. There is no authority for the proposition that she also waived the right to collect the debt.
This result is consistent with the purposes of section 726(a), which are to prevent multiplicity of actions and to allow the *775 debtor to force the creditor to look to the security as the primary fund for the payment of the debt. Walker, 10 Cal.3d at 735, 111 Cal.Rptr. 897, 518 P.2d 329. Debtor had the opportunity to raise the one-action rule as a defense to plaintiff's prepetition actions to collect the debt from him personally. He did not do that, choosing to forgo his right to require plaintiff to exhaust the security first. Plaintiff, by having pursued debtor personally, has elected her remedy and cannot now bring a second action to foreclose the security. Thus, there will not be multiple actions to collect this debt, one from debtor personally and one from the security.
As in Wozab, extinguishing the debt would be so severe as to be punitive and would result in a windfall to debtor. The bankruptcy court correctly pointed out that debtor's actions in attempting to collect the $100,000 debt resulted in her collection of only $83.
The bankruptcy court also considered that plaintiff's actions forced debtor to file bankruptcy to avoid appointment of a receiver, which would have adversely affected debtor's business. Nonetheless, the operation of section 726 is largely within the control of the debtor. Wozab, 51 Cal.3d at 1004, 275 Cal. Rptr. 201, 800 P.2d 557. If debtor had wanted to stop plaintiff's actions earlier and force her to pursue the security first, he had the opportunity to raise the one-action rule in response to those actions. He did not do that until plaintiff brought this dischargeability action.
Finally, the bankruptcy court can provide sufficient protection from actions of plaintiff that threaten debtor's business without requiring her to forfeit both her security and the debt. The bankruptcy court's sanction of extinguishing the debt was an abuse of discretion.
2. Did the bankruptcy court err in awarding attorney fees?
A party is entitled to attorney fees only if provided by statute or contract. In re Sparkman, 703 F.2d 1097, 1099 (9th Cir.1983). There is no general right to attorney fees under the Bankruptcy Code. In re Baroff, 105 F.3d 439, 441 (9th Cir.1997). Nor is there any specific provision allowing for attorney fees in a dischargeability action under the facts of this case.[10] Therefore, there is no right to attorney fees for litigating the dischargeability issue. In re Hashemi, 104 F.3d 1122, 1126-27 (9th Cir.), cert. denied ___ U.S. ___, 117 S.Ct. 1824, 137 L.Ed.2d 1031 (1997).
A prevailing party in a bankruptcy proceeding may, however, be entitled to attorney fees under applicable state law "if state law governs the substantive issues raised in the proceedings." Baroff, 105 F.3d at 441. Because California law governs the enforceability of the debt, debtor is entitled to fees for the costs of litigating that issue if state law so provides. Hashemi, 104 F.3d at 1127.[11]
In light of our reversal of the sanction for violation of the one-action rule, the case must be remanded for the bankruptcy court to reconsider whether there is a right to attorney fees under state law[12] and, if so, whether debtor is the prevailing party on the *776 state law issue. If it determines that debtor is entitled to fees, it must determine whether debtor incurred any segregable fees in prosecuting the action regarding enforcement of the debt, and if so, the amount of any such fees. Hashemi, 104 F.3d at 1127.[13]

CONCLUSION
The trial court erred in extinguishing the debt that was secured by the trust deed. Therefore, the court's order extinguishing the debt is REVERSED. The case is REMANDED for reconsideration of whether debtor is entitled to attorney fees and, if so, for a determination of what fees are attributable to the issue of enforcement of the debt.
NOTES
[1]  Hon. Elizabeth L. Perris, Bankruptcy Judge for the District of Oregon, sitting by designation.
[2]  Hon. Leslie J. Tchaikovsky, Bankruptcy Judge for the Northern District of California, sitting by designation.
[3]  In fact, debtor executed the promissory note five months before the judgment of dissolution was entered. We cannot tell when the trust deed was executed, because there is no copy of the pertinent trust deed in the record on appeal. The record contains more than one copy of a trust deed, but it is not the trust deed at issue here. The copy in the record at Vol. I Appellant's Excerpts of Record at p. 183 and Vol. II Appellant's Excerpts of Record at p. 405 shows a beneficiary named David Barr, a debt amount of $24,000, a recording date of November 7, 1990 and a recording number XX-XXXXXXX. The parties stipulated in the pretrial order that the pertinent trust deed did exist (Vol. II Appellant's Excerpts of Record at p. 7  parties stipulated that debtor executed a trust deed in accordance with the dissolution judgment and that plaintiff recorded the trust deed). In addition, the trial court found that debtor delivered to plaintiff in 1990 a deed of trust to secure debtor's obligations, which was recorded with a recording number XX-XXXXXXX. Neither party challenges that finding on appeal.

The recording number of the trust deed that is in the record is XX-XXXXXXX; the recording number of the trust deed cited by the trial court is XX-XXXXXXX. It thus appears that the trust deed pertinent to this case was the next trust deed recorded after the trust deed that is in the record, which was recorded more than a month after the dissolution judgment was entered.
[4]  This ruling is not challenged in this appeal. Accordingly, the debt may be treated as any other unsecured debt in a plan of reorganization.
[5]  All references in this opinion to section 726(a) are to Cal.Code Civ. Pro. 726(a).
[6]  Debtor asserts that plaintiff was enforcing the promissory note, not the judgment. Debtor is incorrect. The note was executed pursuant to the settlement agreement, which was entered into months before the dissolution judgment was entered. Any debt arising from the settlement agreement was merged into the judgment. Hough v. Hough, 26 Cal.2d 605, 160 P.2d 15 (1945). The $100,000 note merely evidenced the $100,000 award that was to be, and in fact was, included in the dissolution judgment. Once the judgment was entered, debtor's obligation to pay the $100,000 arose from the judgment, not from the note. The note became redundant of the judgment after the judgment was entered. Therefore, the right to payment in this case arises from the judgment, not from the note.
[7]  Neither party challenges the validity of the trust deed.
[8]  This is consistent with Rettner v. Shepherd, 231 Cal.App.3d 943, 950, 282 Cal.Rptr. 687, rev. denied (1991), which applied section 726(a) to enforcement of a note and trust deed that were taken in satisfaction of a judgment.
[9]  Plaintiff appeals only the loss of the debt; she does not challenge the loss of the security.
[10]  11 U.S.C. § 523(d) provides for an award of attorney fees to a debtor in a dischargeability action under certain circumstances. Those circumstances do not exist in this case.
[11]  Plaintiff argues that debtor did not properly plead his claim to attorney fees under Fed. R. Bankr.P. 7008(b), which requires that a request for attorney fees be "pleaded as a claim in a complaint, cross-claim, third-party complaint, answer, or reply as may be appropriate." Even assuming that debtor's request for fees in the prayer of his answer was not sufficient, see, e.g., In re Odom, 113 B.R. 623 (Bankr.C.D.Cal.1990); Matter of DeMaio, 158 B.R. 890, 892 (Bankr. D.Conn.1993), we assume that the bankruptcy court treated the pleadings as amended to properly plead the attorney fees. Fed. R. Bankr.P. 7015; Fed.R.Civ.P. 15(b). See In re Tilbury, 74 B.R. 73, 76 n. 1 (9th Cir.BAP1987), aff'd 851 F.2d 361 (9th Cir.1988). The bankruptcy court considered plaintiff's objection that the fees were not properly pled, and nonetheless awarded fees. Because there was no prejudice to plaintiff from any pleading defect, the bankruptcy court did not err in considering the fees issue on the merits.
[12]  As we explained earlier in the opinion, plaintiff sought to enforce the judgment, not to collect on the promissory note. Therefore the attorney fee provision in the promissory note has no relevance to a determination of debtor's right to attorney fees. There is, however, an attorney fee provision in the judgment that may be pertinent.
[13]  Plaintiff did not cross-appeal to request attorney fees if she is determined to be the prevailing party.
