Last active
April 22, 2018 18:22
-
-
Save bencleary/f6ba3f78d74d735b92d31357086498dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from .models import * | |
class CustomerAdmin(admin.ModelAdmin): | |
list_display = ['first_name', 'last_name', 'email', 'welcome_email_sent'] | |
list_display_links = ['first_name', 'last_name'] | |
admin.site.register(Customer, CustomerAdmin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
class CrmAppConfig(AppConfig): | |
name = 'crm_app' | |
def ready(self): | |
import crm_app.signals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default_app_config = 'crm_app.apps.CrmAppConfig' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Customer(models.Model): | |
first_name = models.CharField(max_length=100) | |
last_name = models.CharField(max_length=100) | |
email = models.EmailField(max_length=255) | |
welcome_email_sent = models.DateTimeField(blank=True, null=True) | |
created_at = models.DateTimeField(auto_now=True) | |
def full_name(self): | |
return f'{self.first_name} {self.last_name}' | |
class Meta: | |
db_table = "myawesomeapp_crm_customer" | |
verbose_name = "Customer" | |
verbose_name_plural = "Customers" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models.signals import post_save | |
from django.dispatch import receiver | |
from .models import * | |
@receiver(post_save, sender=Customer) | |
def send_welcome_email(sender, instance, created, *args, **kwargs): | |
if created: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment