Indeed! I have actually used the admin site to do it before I posted this 
it's just something I didn't know was by design. After numerous searches I 
came here but I may have been asking the wrong questions in google :). 

The shell would be good if I have quite a few I need to delete. Thankfully 
I had only one entry.

Thanks for help, Jason.

On Saturday, 23 June 2018 14:46:44 UTC+1, Jason wrote:
>
> well, nothing stopping you from doing the same in the django shell and 
> doing `Group.objects.get(pk = some_pk).delete`.  that would be an 
> alternative for going straight to the db.
>
> I can see some issues with this coming up, especially if you're doing 
> deletes with django's raw sql capability.  But that should never happen, 
> you should do a select then iterate and delete.
>
> On Saturday, June 23, 2018 at 9:28:15 AM UTC-4, James Bellaby wrote:
>>
>> OK. So it's by design.
>>
>> So during development I can't go straight to the database and delete a 
>> "Group" quickly due to an error I made. I'd have to set up tests to deal 
>> with it at an application level.
>>
>> No probs though. I'm just happy I know it can't be done and not that it's 
>> a bug I'd have to wait for.
>>
>> Thanks for the answers :)
>>
>> On Saturday, 23 June 2018 14:16:33 UTC+1, Melvyn Sopacua wrote:
>>>
>>> On zaterdag 23 juni 2018 14:40:30 CEST Jason wrote: 
>>> > Not quite.  If you run python manage.py sqlmigrate <appname> 
>>> > <migration_name>, you can see the SQL generated for that migration. 
>>> > 
>>> > 
>>> https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-sqlmigr
>>>  
>>> > ate 
>>> > 
>>> > Because Django emulates Cascade, its done outside of the db, and 
>>> therefore 
>>> > shouldn't be a db-level constraint. 
>>>
>>> The case for and against can be made pretty much with the same argument: 
>>> - for: if a row is deleted outside of Django, so by direct database 
>>> manipulation, then the relations become inconsistent, so having database 
>>> reflect models prevents this. 
>>> - against: if a row is deleted outside of Django, so by direct database 
>>> manipulation, then signals are not processed and objects are deleted 
>>> regardless. The consequences of this are unpredictable and application 
>>> specific. 
>>>
>>> Django chose to not align model relations with database representation. 
>>> Knowing this means you have to handle things through Django exclusively 
>>> where 
>>> it matters. 
>>>
>>> -- 
>>> Melvyn Sopacua 
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/00e2d392-99d5-43a6-b6f7-65f348b2185c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to