SHARE
TWEET

Untitled

a guest Apr 27th, 2018 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class User(AbstractUser):
  2.  
  3.     mgid_login = models.CharField(max_length=160)
  4.     mgid_password = models.CharField(max_length=160)
  5.     mgid_token = models.CharField(max_length=160, null=True, blank=True)
  6.     mgid_idauth = models.CharField(max_length=160, null=True, blank=True)
  7.  
  8.     def __str__(self):
  9.         return self.username
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. class ModelForBlocking(models.Model):
  18.     bind = models.ForeignKey(User, on_delete=models.CASCADE, related_name='extended')
  19.     campaign_id = models.CharField(max_length=20, verbose_name='id рекламной компании', null=True, blank=True)
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. views.py
  27.  
  28. def api(request):
  29.     html = 'mgid_api.html'
  30.     form = TrulyForm(request.POST or None)
  31.     if form.is_valid():
  32.         form.save()
  33.         return HttpResponse('saved')
  34.     context = {
  35.         'form' : form,
  36.     }
  37.     return render(request, html, context)
  38.  
  39.  
  40. def list_of_conditions(request):
  41.     html = 'list_of_conditions.html'
  42.     user = request.user
  43.     user_query = User.objects.get(username=user)
  44.     extended = user_query.extended.all()
  45.     context = {
  46.         'condition':user_query,
  47.         'extended' : extended,
  48.     }
  49.     return render(request, html, context)
  50.  
  51.  
  52. forms.py
  53.  
  54.  
  55.  
  56.  
  57. class TrulyForm(ModelForm):
  58.  
  59.     class Meta:
  60.         model = ModelForBlocking
  61.  
  62.         fields = ['bind',
  63.                 'campaign_id',
  64.                 ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top