0

I have an app running and I made a huge mistake, I've deleted a user from the admin site of my Django app before deleting it's UserProfile.

Now, when I try to see the UserProfiles from the admin site, I keep getting an error, for what I've seen it's a record not found exception.

I've got this problem because I cannot use any backup as the latest one is half a month old and all my users will get really mad if they loose all data.

So, how can I do it so I can enter in the UserProfile (It would be best if using the admin site) to delete the UserProfile?

Thanks

Sascuash
  • 3,661
  • 10
  • 46
  • 65
  • You could try go directly to the delete URL : `mysite.com/admin/myapp/userprofile/1/delete/` obviously replacing `myapp` with whereever your `UserProfile` app is and `1` with the correct ID. You will most likely get the same error so you will have to go onto the command line if so – Timmy O'Mahony Jun 13 '13 at 21:02

1 Answers1

0

Try doing it from the shell!

You need some way to find that UserProfile, do you have an ID of the user or maybe of the UserProfile itself?

python manage.py shell
>>> from your_app_thing.models import UserProfile
>>> user_profile = UserProfile.objects.get(id=<user profile id>)
>>> user_profile.remove()

Alternatively, you could add UserProfile to the admin panel?

from django.contrib import admin

from .models import UserProfile

admin.site.register(UserProfile)
Eric Carmichael
  • 560
  • 4
  • 15
  • unfortunately I don't have the ID of the user, the UserProfile is added to the admin site, and that's where I'm having the problem, I cannot enter there as I get the error (It's like it cannot load the page) – Sascuash Jun 18 '13 at 15:18