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.shortcuts import render | |
from django.http import JsonResponse | |
from django.views.generic import FormView | |
from .forms import * | |
# Create your views here. | |
class HomeView(FormView): | |
form_class = UploadForm |
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 Customer | |
from import_export import resources | |
from import_export.admin import ImportExportModelAdmin | |
# Register your models here. | |
class CustomerResource(resources.ModelResource): | |
class Meta: | |
model = Customer |
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 | |
import barcode # additional imports | |
from barcode.writer import ImageWriter | |
from io import BytesIO | |
from django.core.files import File | |
# Create your models here. | |
class Customer(models.Model): | |
name = models.CharField(max_length=50) | |
barcode = models.ImageField(upload_to='barcodes/', blank=True) |
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 | |
# Create your models here. | |
class Customer(models.Model): | |
name = models.CharField(max_length=50) | |
barcode = models.ImageField(upload_to='barcodes/', blank=True) | |
def __str__(self): | |
return self.name | |
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 import forms | |
from .models import Customer, Request | |
class CreateRequestForm(forms.ModelForm): | |
customer = forms.CharField() | |
def clean(self): # update | |
data = self.cleaned_data.pop('customer') | |
customer, created = Customer.objects.get_or_create(name=data) | |
self.cleaned_data.update({'customer': customer}) |
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 import forms | |
from .models import Customer, Request | |
class CreateRequestForm(forms.ModelForm): | |
customer = forms.CharField() # update | |
class Meta: | |
model = Request | |
fields = '__all__' |
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.shortcuts import render | |
from django.views.generic import CreateView | |
from .forms import CreateRequestForm | |
from .models import Request, Customer | |
# Create your views here. | |
class CreateRequestView(CreateView): | |
form_class = CreateRequestForm | |
model = Request |
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 import forms | |
from .models import Customer, Request | |
class CreateRequestForm(forms.ModelForm): | |
class Meta: | |
model = Request | |
fields = '__all__' |
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 | |
# Create your models here. | |
class Customer(models.Model): | |
name = models.CharField(max_length=100) | |
def __str__(self): | |
return self.name | |
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.shortcuts import get_object_or_404 | |
from django.shortcuts import render | |
from .models import MyUser, Location, Article, MatriculeNo | |
def home(request): | |
# c = {} | |
# c.update(csrf(request)) | |
template = loader.get_template('home.html') | |
context = RequestContext(request, { | |
# c, |